Monday, June 18, 2018

Week 4 -- Show me the World

Week 4 -- Show me the World
(Here is supposed to be a video of the map)

Overview

  • Map rendering
  • Improving dialog handling

Unfortunately the map rendering kept breaking so there’s no video of it right now. While there are improvements in other areas like the dialog handling, the map renderer blocked me for most of the week.
Below I describe the structure of the MAZE.CMP file that stores static background tiles and how it is used.

Details

struct Map { // MAZE.CMP
	byte tileIndex[128][20]
	byte subTileIndex[146][64]
	byte bitmap[1832][32]
}

Compared to sprites from animation files (discussed in Week 2) the static background is composed of tiles from MAZE.CMP. Those tiles in turn are made of subtiles of 8x8 to save space by assembling the bigger tiles of the smaller ones. So the tileIndex are offsets into subTileIndex that again are offsets to the 8x8 pixel data in bitmap.

On every frame an indexMap is generated of the currently visible subtiles. The reason is not only for caching but for clipping tiles (that’s what kAnimationShadow* are for) and general tile manipulation depending on game state.
34x18 tiles are shown at a time on screen. There will be overdraw as the viewport is only 256x128 but it doesn’t matter as the video buffer is 320x200 and it is clipped off by the frame border in the end. Currently my implementation draws the frame border first for “clearing” the screen as it was convenient to just blit the fullscreen image without the need for transparency.

Next Week

The most urgent feature right now is renderering the map. Not only does it help to visually convey the progress better but other features like player movement, rendering of NPCs, Objects, animation of static objects like torches, collision, … depend on it. Besides that, the definitions for the all objects, … will need to be ported over as well.

Monday, June 11, 2018

Week 3 -- Game intro running

Week 3 -- Game intro running

Overview

  • Text rendering
  • Basic Dialog implementation for intro
  • Logic abstraction

The porting process is tougher than I had anticipated. I described my problems with the animations in Week 2 and continued with correctly positioning sprites in the dialog. Fortunately I [found my mistake](link to Renderer::drawSprite pos calc) and dialogs not only for the intro, but in general will be solved soon.

Details

The logic differentiates between different states like showing a dialog, the game, a cutscene, and so on. This helps the logic to know when to update what so that for example you are not slain while still picking up items from a chest. link
The characters for text rendering are stored in general2.anm that use the ASCII value as an offset to access the sprite in the animation (link to Dialog::update default case). The dialog strings contain information directly for fadein/out, what type of dialog it should be (Yes/No, Ok, multipage, immediate) and so on.
In general the implementation is quite simple. The engine iterates over every char one after another and either executes the ‘meta char’ (e.g. ‘|’ for fade in text) or renders the sprite for the character. When the null terminator is reached and no further string is to be loaded, the dialog rendering terminates and depending on if the dialog expects user input (password, yes/no, ok) the logic either waits on a keypress before switching back to its ‘game state’ and continues where the player left off.

Next Week

Judging from my current speed, I hope to get our hero making its first steps in the first level and ironing out the remaining dialog bugs.

Sunday, June 3, 2018

Week 2 -- Animation

Week 2 -- Animation

I picked the animations above randomly but I just realized how they depict the development process so far.
Coffee fueled nights, excruciating pain bursting my skull (most of the time because of dumb mistakes I miss for hours), but you must press on! ;)

Overview

  • .anm file support 1
  • Mapping animations 1 2
  • Render support for animations

Details

All sprites are stored in .anm files, divided intro multiple sprite chunks that either form an animation or just an accumulation of sprites like inventory icons or characters.
There is no meta information that would help identify what frames form an animation in cases where several animations are stored in one sprite chunk (blood splatter effects for example). So i manually mapped them what can be quite error prone, especially as some animations are not used in the game and seem to differ from version to version.
The DOS/Genesis/NES version have a battle scene compared to other versions where the fighting happens on the map. Some of the sprites are still available but the animations seem to be incomplete.

struct AnmFile {
	struct AnimationHeader {
		u16 offsetToSpriteOffsets
		u16 numFrames
		u16 centerX
		u16 centerY
	} [numOfAnimationsInFile]
	
	u16 offsetToSprites[header.numFrames]	
	
	struct Sprite {
		byte x
		byte y
		byte width
		byte height
		byte remap
		byte widthPerLine[sprite.height]
		byte pixelPosOffset[sprite.height]
		byte pixelData[] // one nibble per pixel
	} []
}

Next Week

Until the end of this week, I will implement the game intro what will encompass extending the game logic and dialog implementation.

Sunday, May 20, 2018

Week 1 -- MIDI files and basic plumbing


The first week is already over and brought up some quite interesting problems. Here is a short list of what has been done.
  • Decoding EALIB files (1)
  • Converting audio files (1,2)
  • Rendering .BM (fullscreen) images (1)

 

 

Implementation

The game's assets are LZSS encoded in two libraries, imm1.lib and imm2.lib.
The header starts with a 5 byte long signature "EALIB" and an uint16LE of the number of files encoded. The following table consists of 18 byte entries per file and a list terminator (flag x00) as its last entry.


Fullscreen image files like the title screen and the screen frame are stored linearly so that each nibble that represents one of the 16 possible colors just need to be written in its own byte.



Music files are stored as .BIN and consist of a custom header as colorfully shown above, followed by MIDI data. The header appears to be similar to Ski or Die but there are still questions open. This shows my best guess at what it could be + lots of googling




It is worth mentioning that the first MIDI event is missing its delta time, that I append as I convert the header to a type-0 MIDI header. (code)
Audio effects have not been implemented yet. Unfortunately they are generated directly by calling into the sound driver that stills need to be reverse engineered.


Next Week

Although the audio is not yet done, I will leave it for now and implement handling of .ANM files and sprite rendering next.

Tuesday, May 1, 2018

Introducing -- The Immortal


Feels good to be back :)

I was one of the lucky four students to participate in GSoC under ScummVM.
For a more thourough introduction of myself see my post from last year.
Over the course of this summer I will be porting The Immortal, a dungeon crawling adventure with difficult puzzles and cruel battles waiting within.

So far I have written the extractor and decoder for the library files of the DOS version, what will be the base for this port.
You can follow the progress by either keeping an eye on this blog or my working branch