Saturday, January 2, 2016

Summarize of what I accomplished between mid-2014 to end-2015.

January 2nd, 2016! --- Happy New Year!

In my last post, I wrote a couple of ideas I was having in mind... Since then, I made some progress!

Music Synthesizer

I started to explore about VST and as I work on a concept, I realize that the best way to give flexibility for sound creation is by giving the user access to a computer language. One of the synth which already exist is 4klang by Alcatraz.

When I realize that, I cancel the creation of a VST as I though as a programmer, there is not much advantage to spend time creating an interface to program what I could already write in C. I am still interested to explore sound & music...

Video Game Clock - Next Gen!

In beginning of 2015, I though to enhance the video game clock project! I explore the power consumption using hardware interrupt and saw that I could greatly reduce it. I also modify my boot-loader to support USB instead of CD-ROM. In order to debug my USB boot loader, I made a small memory explorer which could fit in the boot loader sector. I then started to code a tool to convert NES (Nintendo Entertainment System) background to a packed data set and display a scrolling background. Here, is the demo using Castlevania (NES)...

Custom USB bootloader hexviewer + "Castlevania" scroller in asm386.

On my laptop (not on this one in the video), the performance of the CPU is so terrible that the CPU can barely draw the background in one frame. I realize that some CPU need some custom instructions in order to run at a decent speed. I was estimating that the CPU on my laptop is running by default to 20-33 MHz. Worst, moving the mouse is causing a lot's of CPU cycles being lost and the scrolling started to move very choppy.

I started to read about custom instructions on x86 CPUs and realize the nightmare it would become. Writing specific code for each CPU to manage their performance. Also, I realize that newest technologies has no support in BIOS calls. Meaning that there is no easy way to get WIFI for example!

Demos, physics!

It's been a couple of years that I has been asked to participate into a text-mode demo competition. The challenge seem simple, doing a real-time animation & music using the text-mode of early PC (16 colors, msdos charset). I decided to jump in for this year competition and just do something simple.

One of the interesting feature in this project was to code a fluid simulation. As I like playing with math, it was fairly easy to write the rules in order to get the water particle moving. I first planned to have also a temperature factor and get the environment deteriorate if they are expose to a high contrast between cold & hot. However, with 1 CPU computing 10 000 particles and using my crappy laptop... I realize that I have to get things simple.

One of the most critic I got from people... "hey, stop making your life hard and you could use this library or tool for that"! But, I like to start writing equations on a piece of white paper and get things done. The Internet is still useful, but I use it for some reference. However the pleasure is to get visualize in my mind the equation written and see that the simulation on screen is even more accurate & wonderful than what I thought!

That's all for now...

Tuesday, May 13, 2014

Super Doriath - Cancelled. Why?

It's been a while I did not post. What is happening? There has been no activity since several months!

 Well, that's usually not a good sign...

Last year, on December 31, I was talking with one of my friend about this project. He was enthusiast and supportive but concerns about the legal aspect. After all, I did not succeed to get in touch with the authors of the original game! The few emails I sent to websites related to that game remains unanswered after nearly a year.

He suggests… Instead of working on porting a game, I should do my own game.

It is one possible solution... but doing a port or a sequel of an existing game should help to boost the popularity and have more people to enjoy/talk about it.

But, my friend told me (again) his bad experience in the past regarding copyright. That without a written agreement I could put myself at risk to get a legal letter at any time. So, after we discuss this topic, I decided... yes, I should do my own adventure game from scratch.

And then, I was busy on other stuff…
But that delay gives me time to think about it...
  • What should I do? 
  • What I really want to do?

I got some ideas (10) over the years, some which I prefer over others, but not a definitive decision yet.

"Something" Thinking...
Artificial Intelligence

I can write software about anything... or could I? When I think about something challenging, making a software that replicate the human brain even partially, it`s far from being trivial! 

But it is probably the most interesting topic in Computer Science. Not because of the cool gadgets that could become a reality but for what we could learn.

However, important discoveries in that field of science will lead to various applications. Among them, some will bring a significant negative impacts/dangers in our life. This will also bring new opportunities, but would the overall change will be positive? I doubt.

This idea will be research-oriented and not application-oriented. What would I learn? What would be my discoveries?

So far, from my experience in writing smart-application (flexible and adaptive, but not auto-learning & creative). I was dividing problems into few parts and give each one their own goal to achieve. 

For example, in a calibration software I wrote, the input data was creating a certain shape in 2D. Within that shape, 8 key points should be used by the firmware, which was his calibration values. 

I wanted to have a flexible software which will find the key points as soon as they get draw on screen, just like we (human) could do it.

To achieve this I divided the task into 4 steps: 

  • draw the input data on screen, 
  • find geometrical features that could potentially be a key point, 
  • evaluate key points and output possible solutions using 8 among them,
  • strict validation of the final result.

The last step was the only part of the software which was strictly program. This step was equivalent as a human inspector verifying the solution. 

Part #2 and #3 consisted of 'for-loops' not limited by the number of elements but they were limited by time! I wanted the system to take advantage of the time. As the time pass, the input data being draw on screen reveal more and more data. The user who draw something on screen can complete the input shape needed, but the system could start analyzing and finding key points even if the drawing is incomplete. 

This software end up to be robust and reliable. As long as the basic feature of the shape remains the same, the system can find the solution even if the drawing shape is distorted.

Although this system is not learning anything by himself. It is a good example of an adaptive system build from scratch using intuition. Also, it prove that limiting computation in quantum using time limit could increase the performance. 

In my application, random points on the drawing surface were selected with also a random size for the region to be evaluated. The key feature was ending edges, but the size of the region of interest would also determine what size that ending edge could be. Allowing to analyze various size of a same feature.

Back to the research I am interested to do. I have identified few aspects that would be part of an Artificial Intelligence System. They are: input & output, memory, mind, emotion and functions. Where functions are some basic functions that should allows the main structure to work. In order words, they are the foundation of the operation executed on information by the system. 

When I think about something, the part which is composing ideas and though will be the mind. Of course each component will interact with all others. And I think that's the tricky thing, as usually when you write a software, one function call others but rarely call back the caller. 

My hopes are modest as I know I may end up with more questions than answers.

But, I think that spending a considerable amount of time will result to at least more knowledge, and perhaps I will exchange with other people interested or who work in that field of research.

Quest for Tires (Coleco Vision)'s Theme
Video Game Clock
Video Game Clock - NextGen!

One short project I did in the past was a self-bootable clock on 386+, using graphics of "Quest for Tires" on Coleco Vision. Sources and binary can be found here:

I could decide to work on a newest version which will add power management (as the current version use 100% of the CPU), hard drive installation and boot-up via other media than CD-ROM. 
Also, I could add contents based on the date and time!

There are many themes that can be added. It could be like a Calendar, where you have some special stuff based on the holiday: New Year, Anniversary of first human in space (Yuri Gagarin)! 

Another idea, it could display fake news & events but based on news of the past up to today and try to predict what will happen in the future. Making the daily experience of looking & reading of such a display being like having a window through a parallel Universe! Over the years the content would become more and more distant to the reality, but will share some common stories (those from the past) with our world.

I think this idea has some commercial potential. It could be on “kickstarter”! I would like to know (you, readers)... what type of contents you would feel more enthusiast about?

Perhaps an editor for creating contents could also be developed.

A first version for smart phones and tablets might be the best to do before building a dedicated hardware clock! And maybe old tablets could be converted to a wall clock, which will reduce the e-trash and giving them a second life!

nanoKONTROL 2 - Korg
Music Synthesizer

I play piano. Well, I never took piano lesson and all I learned is by myself since the age of 4. At the beginning, I discover a few tricks in music which helped me to improve my skills. 

One of them was creating & repeating patterns. Another was to select fewer notes to play. After few days or weeks with my first piano, I discovered that playing with the black notes only could easily be melodious, but will make it sound like Chinese music! 

But, what I was most amaze about music is how it can trigger emotions? Why I could play notes and feel so depress? Strangely, I liked it. A tool to control my emotion! Strange, it's nothing we see, it's no words... But it does carry a meaning! 

As a kid, I though that it might depends of people or culture. Surprisingly, it is mostly universal, and even across species! There are preferences and variants, but the basic parameters (fast vs slow tempo = stressful vs calm) trigger in general the same change of emotions. Our preferences seem more related with other factors in our environment combine with when we hear certain type of songs. I might over simplify here, but you got the main idea.

Over the year, I wrote a few simple synthesizer and also few tools to generate samples. These were primitive but interesting enough. In early 2000, I re-create a sound sample of a guitar using an analysis of it's frequency. My idea was to create a sum of 'sum of sine' waves at different period scales. For each period scale, the amplitude get lower by a big factor, so after the 3rd or 4th period scale, it become negligible. The first order only produced a sound which sounded like a FM Synth. By adding the all the order of scales, the sound become more rich. Up to a point where it become hard to distinguish between the original sample and the one generated from the equation.

I though to first do a study with samples at different pitch and try to deduce a more generic equation. However, looking to the number of parameters involved and knowing that for each, I would get a complex equation, I knew this system could not run real-time on a Pentium III, 733 Mhz.

Then, later on I took a look on different articles about synthesizer published by Sound on Sound (Synth Secrets). I print out all the articles and wrote resume about them. The first few articles give details about the implementation, however it become less technical and more practical at the end.

The last things I did related with sounds was to develop on paper a new algorithm which could produce a wider variety of sounds. My hope was that this model I wrote could lead to a wider variety of sounds with only few input parameters. Considering the number of people who worked on that topic and the result which has been achieved, there is not too much chance I will get a breakthrough discovery. 

The mathematical structure of the equation I wrote down looked promising. Usually when there are symmetry and simplification that show up, it's a good sign. I was aiming to develop it to be an audio system part of the GP2X library I was working on. When I stopped to make demos for GP2X, this project become cancelled.

For my reference, there are 2 small executable which feature amazing sounds:

CandyTron (fr-030) by Farbrausch

Adding voice in a song in 2003! It may be hard to understand, but a full lyric is there and with more than one type of voice.

Uncovering Static by Fairlight & Alcatraz

I found that the sound quality feature one of the most amazing I hear within a 64kb intro.

There is a kind of beauty knowing that emotions can be trigger from small mathematics models. It also required a good amount of work to compose and develop it. 

I think, like arts, you can appreciate it even more when you are familiar with the work behind it.

1-Bit Processing Unit

When reading the specification for the chips used in the Coleco Vision, I though perhaps I can design my own microprocessor!

When I was student in the 1990, I took few courses to design electronic components. Because I was use to program on 6502 and 80386, assembling logic gates to perform operations was easy and fun. 

Even after years not doing anything in electronic, it does not take long to understand: bloc diagrams, timing charts or reading specifications. I get a clear idea of how, what and why it's like that. On Coleco, in a day, I could write down what possible tricks could be explore regarding the CPU-VPU (VPU: Video Processor Unit) communication to enable newest video mode & colors.

What if I would be making my own CPU? Since the beginning of the commercial CPU, we saw the number of bits increasing (8-bit, 16-bit, 32-bit, ...) which end up offering a wider range of instructions and better performance. However, you don't always need 32 or 64-bit word to compute your data. As an optimization, sometime I pack multiple data into a 32-bit word and unpack it after the operation. Sometime it's the would need more bits to keep the precision, even when using floating-points!

I think there might be a better approach to achieve greater performance. What if we will design the most tiny unit we could: a 1-bit processing (BitPU) unit linked to a tiny memory and interconnected to other BitPUs. Considering the number of transistors we can put on a die today, we will end up with thousands of BitPUs across the die. The performance for one single instruction would be slower, but the number of processing unit might be around 75,000 per die!

A software is not slow because the processor is slow to execute 1 instruction. But it's slow because of the number of instructions to perform. It's the loops size which are responsible for sky-rocketing the number of instructions to perform.

What happen today on a Quad-Core processor when you write a software (single-thread) to compute a blur filter on an image? For each output pixel of the image of size (W * H), N * N pixels will be read and each input pixel will be multiplied with a specific weight. The number of data to read, multiplication and addition will be equal to: W * H * N^2. On the die of the processor, a small portion of the die will be used. Leaving a big portion of the die unused! With an architecture of BitPUs, the compiler will be design to take advantage of the number of processors.


Let's suppose we want to blur a HD (1080p) image with a gauss filter of 5x5 pixels (W = 1920, H = 1080, N = 5).

The number of input pixels read and computed sequentially will be equal to:
W * H * N^2 = 1920 * 1080 * 5^2 = 51,840,000.

Let's assume we have 48,000 BitPUs per core and we have a quad-core. The total of BitPUs available will be: 192,000 BitPUs Then, the number of instruction executed sequentially by the population of BitPUs will be equal to 51,840,000 / 192,000 = 270!

Each BitPUs will have enough logic to allows arithmetic & logical operations, including branches.

However, this architecture is so radically different than the classic one and many possible issues need to be analyze: heat, memory transfer, complex operations (including floating points). The BitPUs is based on 8-bit processor which was fairly limited to what they could perform in hardware.

I think I should write a white paper about it - I never wrote a white paper before. In order to write a white paper, I would need to study it more and study similar articles. Regarding the development & marketing of this product, this would required a fairly amount of resources in money, labor, contacts...

With the amount of details I give here, it might be a smart and successful idea. But, at this stage it's only an idea, not yet proven and where the research and development required investment. If this idea turn out to be better than today's architecture, I do believe one day someone will think and give a try anyway. If someone read it and decide to use it and end up making money, good for him and good for everyone (to have access to a better architecture)!

Development tools
for Coleco Vision

While working on "Super Doriath", I was thinking if I would have more time I wish to create and use my own editor, compiler and emulator (all-in-one). 

Today's PC are quite powerful, enough to handle text editing while checking the syntax and modifying the binary output. In one word, no need to wait for compiling. One good example is the website: ShaderToy.

If I would write my own text editor & compiler, I might also be interested to get the emulator combined... this to see exactly what is happening. Imagine that you are about to write a piece of code which is fairly complex. You could decide to stop the running code at the beginning of the function you are about to write. Then let's say inside that function you have 3 blocks of code to write... 1st to pre-compute some stuff, 2nd to generate intermediate data and 3rd to draw something on screen. You could write the code for each part and verify that it working as expected by moving the pause position.

With the traditional tools, to get this thing, you will need to do this: to compile... start the emulator, put a break-point, start the code, wait until it reach the break-point then open the proper view to check the data. Repeat again and again at each time you do a change.

Another key feature I would like to have is to be able to store and reuse code. When using software, we end up producing some files or data. Over the years, I lose track of some code I wrote. What I do when I want to re-use a code, I will copy the latest version of a function without knowing how many copy of that functions I have copied in the past. 

I would like to be able to store a function in a gadget which will help me to re-use it. This gadget would manage variants of the same code and the editor should find the similar piece of code based on what I write. So, if I am writing for the n-time part of a code to open a binary file or to draw something on screen, I would like to have the code available and modified with the variable names I started to write.

Regarding the text editor, one feature I found very useful is to be able to have multiple carets (text cursors) which can write or delete text at different place simultaneously! It's available in notepad++ by using the mouse and ALT key. You can then select columns of text and add or remove stuff, without having to edit line by line! I wonder if that feature could be extended to be even more versatile? Sometime, there are multiple place in code that you need to add an instruction... like protecting a variable with a mutex.

By designing my own development tool, this could lead to many add-on! If a tool like that could turn out to be use by others, it may turn out that I would be working on that tool only while other will be developing their games, demos or utilities.

Macintosh Computer - System Disk (OS)
Operating System

After writing many stuff which could be part of core of an operating system, I think I could write my own operating system on a specific hardware. 

When the Amiga company hired Carl Sassenrath to write their operating system, they told him you can write any type of operating system. He decided to write a multi-tasking operating system! If you asked me what kind of operating system I would like to write... I would choose to go with a single tasking but with support of multi-task! Also, it will be more oriented for developers than users, but will be relatively simple.

GP2X is dead and most people are using cellphone and tablets... These devices are heavy dependent of networking services in order to work. I think the PC market will shrink over the years. People get more and more dependent of their computer as they could carry it with them. Once you can do everything on your portable device, why having a big box at home? I am also considering to have only laptops in the future.

So, on which platform I could write an OS? I think maybe Rasberry PI could be an interesting platform. But I have no idea how long the current hardware will last? Would it be replace by newly chips within the next 5 years? Would current users will also be upgrading to the newly hardware right away?

If I would wrote an operating system, it should be for a dedicated hardware. After all, there won't be a list of drivers to load. Ideally, only one type of hardware will be supported. The device will instantly boot. You turn ON the power switch, it's READY! Yup, just like the C64.

This limit the system to what it can perform on boot-up. But having the display, sound, input and storage device ready is what it need. Network could arrive a bit later, but considering it's usage today, network should be ready as soon as possible!

Also, one key feature could be to have a reset button that keep the memory intact! The Operating System could use the existing data to recover, if possible.

Commodore 128 - Programmer's Reference Guide
New Basic for C64/C128

Another idea, is to create a new basic for Commodore 64/128. My first computer was a Commodore 128 which was using Basic version 7.0. While on C64 you would need to use unfriendly peeks and pokes to memory, on C128 you could call graphics & sounds functions!

However, there is one aspect which was problematic, basic is super slow compare to assembly language. I don't blame the author of the Basic... which at that time could include Bill Gates. There are rumors that he did write some parts of the assembly language used to be shipped to Commodore. Maybe for the Commodore PET?

Writing code from scratch for a new version of ROM for those machine C64, C128... what benefit could we add? Assuming that backward compatibility could be put into a separate code available by toggling a switch or by pressing a key while turning the device on. Maybe this backward compatibility could be turned ON automatically when loading a file (having some bits on diskettes or tapes reserved to tell which ROM to use).

Commodore 64 remains a popular computer today. Well... relative to other obsolete computers! But, as far as I know... no one has ever try to write a new ROM for those machine? While on Commodore Amiga, different ROM version were produced. I did not check the technical details, but maybe Cartridge is more suitable than replacing the ROM?

Paint Shop Pro (v7.0)
Paint Software

The most popular paint software on PC is PhotoShop. There is a freeware which is similar: Gimp. Me, I am still using Jasc Paint Shop Pro v7 (PSP), released in 2000! Maybe I should try the Corel version X6, but I like the one I am use to.

I am not an artist but I use it to draw or to edit something from time to time. I also wrote some software to do some graphic stuff.

In the past, I wrote an editor for drawing vector shapes over a video footage ( If I would write my own paint program, I will treat pictures and video as the same entity. Also, I will allow vectors and bitmap to coexist (this is already the case with PSP).

In my opinion, this idea should start with something small and be combines with another project which will benefit of its development.

As it's been a while I did not try newest version of graphic software, I should look and see what they have change. But, last that I tried, video, bitmap and vector graphics was still handle in at least three different software.

Simulation in Blender 3D -
Intro 64Kb based on physics

In the past, I did a few demos on GP2X (a portable entertainment player), our group: Québarium. I remember how long it took to do our first one. We were often talking about making something, I was showing them some parts, but never felt we were ready to release something soon. It took a fast demo compo (a crappy production, in my opinion), followed by few good comments to jump in for more!

Our last release "Chalcogens" was our first cooperation with 2 other demo groups: DESiRE and TRSI. During those years, I was the team leader, coder and main graphician 
(I don’t think I deserve the title of graphic artist) for Québarium. We produced 6 demos (which is 2 times more what I did in the early 1990)! Our last release was pretty hard for me as I got sick (food poisoning) and after a week being back to normal… I comeback one night with a flooding in my condo. At least, the flooding did not started in my unit.

In this adventure, I pushed myself and others to get the release on the deadline despite all these bad luck! I still think it was the right decision, as otherwise it would have moves the release date to more than 6 months! I have to mention that we started the project 2 months before the deadline. So, by adding 6 months, we will be on break for a long time and we will be tempted to add and change more and more things.

When I think about making a new demo, I think about 2 options… a PC intro or a text mode demo for TMDC. For a text mode demo, I have no specific idea but it will probably be more for fun & experimenting rather than to compete for a first place.

For a PC intro (probably 64kb), my idea is about building 3D models with cube (like lego) and playing with physic.

There are so many amazing 4 and 64 kb intros on PC that I won’t even try to compete against them. But implementing a physic simulator can be quite fun (although a bit frustrating when things goes wrong). The equations to compute physic are fairly simple, the hard part is to manage collisions of several objects. Imagine, you can compute the position of every objects up to when a collision happen. Then, the speed vector will change based on the state of objects involved in the collision. That change of movement could end up with more and more collisions, making the system to slow down exponentially. There are many tricks to help making a physic system run in real-time. But those tricks cost more development time.

Ideally, the animation should be funny and make the audience laugh! For me when you can get the crowd react, that’s our biggest reward! Even if sometime we look at each other and wonder… why they are laughing now?

Here is our fast demo produce in 8 hours (the theme was: potato).
Our best moment, when someone shout at the end... making us feel that, the audience did like it and would have to get more!

Coleco Vision screen
Video Game (Coleco Vision)

I could also just continue on making a video game on Coleco Vision? Within the same genre (adventure game/maze) or not of Doriath.

When I first started on converting Doriath from C64 to Coleco Vision... it was to answer one simple question: Could this game have been made in 32 Kb ROM and 1 Kb RAM? I was interested by the challenge to reduce the data size.

As I was working on it, it become an ambitious project which I was trying to squeeze more and more content into 32 Kb. This was fun but it could turn out to be a very long process where every single detail could become a quest of optimization!

Before releasing demos for Québarium, we were thinking & trying to create games for iPod touch/iPhone/iPad and Xbox360. One of the neat thing I put in place was a way to get a list of game ideas among our group. It was a simple document shared among us where a game idea should be summarize in one or two sentences only. The text was written in order to make the game appealing and was similar to description you could find back to game boxes. Then, a note from 1 to 10 was given by each member of the group.

I was also looking to speed up the development process of making a game (from the idea, to the prototype to the actual game). The first step was to maintain a list of ideas. Then I though, someone in the team will pick one idea among the list, sketch some details (his vision) and will then act like the team leader/producer for that game. The type of game I was envision would be similar to what was made on Coleco Vision or Atari 2600. It has to be simple but fun. The focus being to be quick to produce. How quick? I though, for our group of 3 people, the whole process should take a week-end! Less than 20 hours (4 hours on Friday, 8 hours for Saturday and Sunday)! It could be faster than that, but I was aiming for a receipt where we can easily create any kind of game (with the limitation of the system/tool) within that time frame.

The logic of the game will be limited, and the number of level will be from 3 to 10. The tool would have been custom and all sorts of limitation will be present to reduce the number of choices. The ROM of the game would be a custom binary format which could be added to an engine compiled for a given platform, reducing the amount of work needed to port the game. Once your game work and compile for one hardware, it will do the same for another hardware. Differences like input controls would have been integrated in the software emulator, not in the game.

My goal was: if we can build a game the quality of the early '80s in 2 days, we could more likely end-up with a couple of productions which will have it's own signature. Our time will be spend more on trying & learning marketing strategies in order to be successful to get revenue.

In term of games, I did a remake of Clu Clu Land on C64 using a game editor "Game Construction Kit" in the 80's. And Othello (for 2 players) on a TI-81 calculator in the early 90's. In 2008-2009, I wrote a couple of game prototype for Xbox 360 using 3D graphics enter manually in the text editor.

I still have a Coleco Vision which I borrow from a friend and a SD cartridge for it. I feel that I should do at least one game on this hardware! Maybe aiming for a smaller idea?

In Conclusion,

I am not sure after which project I will like to work on but I hope to spend again few hours per week on some personal projects. Why? Well, doing something by yourself where the objectives are from yourself is good for the self-esteem.

Like anything in life, it's a question of balance. Also, it's better to have short term objective. But, there are some type of projects which required more time than other. In my list, all of them take a fair amount of time. None of them can be done in one week-end, they are some which might be made in few months, other might take several years (considering my free time for hobbies).

I excluded here other area of activities which are not related with computer science...

I welcome you to write down your comments...

and as always, thanks for reading!

Tuesday, December 10, 2013

Super Doriath on ColecoVision, Mockup v2. (VI)

I am proud to present an updated graphical version of the game, this time based on: Graphic Mode II. It is still a mock-up and I started to figure out how the tiles will be placed in memory.

Graphic Mode II allows 2 colors per line within a character. While Graphic Mode I (previous version) was based on 2 colors per character.

SuperDoriath, mockup v2.

The inconvenient of using this graphic mode is in term of resources. It take more memory in the cartridge, in the video RAM and also more CPU to create tile-animation (especially because for a given tile to appear anywhere on screen, it need to be copy at 3 different location).

But... it does look way better!

I also expect more sprites-flickering, but I think the additional color for the player worth it.

You may also notice the name become... "Super Doriath". I don't want to just port the game to Coleco Vision, but I want to make it a better game... stay tunes!

And as always, thanks for reading!

Thursday, September 5, 2013

Doriath on ColecoVision, The Tools. (V)

When I first started to see if Doriath could be made on Coleco Vision, I got no idea what are the tools available. After asking on forums, a lot's of people give me some help by telling me where to look for documentation, tools and hardware.

In this article, I want to describe the tools I will be using, my though about it and what I consider to be useful. You does not have to write your software in assembly language, but in my case the choice is clear... assembly language only!

Why? I wanted to get in control of the code and data, explore some limitation of the hardware and I knew that I want to produce the game only on ColecoVision platform. So, no need to port the game and by doing so I can learn more about the machine and its limitation.

Then, the question is... which compiler I will use to produce a binary (.ROM) from the source code I will write (text file)?
I have been suggest to use tniASM for pure assembly language. It's a command line utility, easy to use which can indicate errors by specifying line number where the syntax error occur.

The compiler does not seem to offer much feature. I would have like to see a Map and Listing file, which could help to know the length of functions and data.

I was considering to write my own compiler. In the past, I wrote a compiler for assembly language for some Commodore 64 personal projects. It was a compiler that was producing a disk image, rather than a file!

You may wonder, why someone today will be writing his own compiler if one already exist? In fact, you may be doing so when you see that you can add features or use new concepts. Back to my C64 compiler, I wanted to have an easy way to manage data on a full diskette and not be limited to one file. By writing my own compiler, I could provide keywords that will tell where to place data on disk and eventually automate some disk access without using other utilities.

Basically, by writing your own compiler, you can bring feature that will save you time or give you information to improve what you try to achieve.

Some compilers come with an IDE (Integrated Development Environment) which offer a text editor and debugger. With tniASM, you need to use your favorite text editor and Emulator/Debugger.

Notepad++ is a free and small software which can be run easily and support many features for text editing that we can find in a complex IDE like the Microsoft Visual Studio (text editor).

It support many computer languages and will identify keywords and types by changing colors or style which make them easier to read. It also support the ALT + click and drag mouse feature, which allow to edit columns of text. That feature is very convenient when editing array of data.

Did I think to write my own text editor? In a way yes... when I see that I will be in a text editor, compiling in a command line. Then, getting an error on line # x in file y. Hum... I though there is room for so much improvement that it's seem an interesting project.

I was thinking to have a real-time compiler combine with a text editor. Something which does not need to click... compile, but does self-modify as you type your source. New features like being able to modify code while keeping copy of other versions, allowing the programmer to see if his changes does reduce the number of bytes or clock cycles. Or, to be able to click on the header of a function and tell, add this to a library of functions for reference or re-usability in a newer project. We can even push it further by selecting a bunch of functions set in a library and be able to generate a computer language out of it.

When you are the one writing the software, you can imagine pretty much what you want! You know that the more features you add, the more work hours you will need. As a programmer, I can do barely any kind of software and routines. If it involve so many hours, why not programming something which write software by it's own? I got some serious though about this problem over the years of what limit what a person can write as a program. How we overcome problems which at first we don't know how to solve? Hum, as you can see ideas of big projects are coming out faster than I could make them. I choose to pick up this game & blog writing first. Was it a good idea? ;-P

Back to the tools... In order to execute and debug my game, I will be using an emulator: BlueMSX. It does contain a debugger which allow to enable breakpoints, step through the execution and so on. I don't think it offer a feature to measure clock ticks between 2 points. The only way I can think about profiling stuff is to loop a routine N times and calculate the number of NMI interrupts. Having a precision of 1/60 seconds is not too bad but it could be definitively better, I would say... 16.7 times better!

When I was thinking about having my own compiler combine with a text editor, I was also thinking about emulating the chips. But then, that mean having to support all hardware components, doing reverse engineering on the hardware and so on. In short... a project for the next 3-5 years considering a 4-6 hours of free time per week and not doing any other projects. So, for now, I will focus on the game itself and learn the tools that other did.

Even if testing in an emulator could be good enough, as I am interested to know the details how it work. I got to test some stuff on the real hardware. People are selling their Coleco Vision mostly on eBay.

I am not interested to have one forever but will prefer to have one for testing until the end of the project. I don't like to pile up stuff and prefer to keep things which I use. I could resume my way of consuming goods on saying that I tend to be fast on giving my things and slow on acquiring new stuff. I like organize place and easy to clean. I regret so much when I purchase something which I don't use. So, when it's time to buy I would ask myself many times, do I really need this?

Lucky I am, my best friend is quite the opposite and agree to provide me a Coleco Vision. I promise him the game in return of the rent! Is it a good deal? Well, I guess we will find out only at the end of the project.

On the other hand, I purchase an Atarimax Ultimate SD cartridge. Having the hardware is one thing, being able to put my software in is another thing! There was two options, this cartridge or an EEPROM and an EEPROM programmer. It is more easy and fast to write a file on SD card than it is to write on an EEPROM.

So far, I have receive it and started to experiment how the video chip is working. On my first day, I achieve a stable CPU-VDP (Z80 and TMS99x8) communication for every frame and display 48 sprites on screen (where the limit is known to be 32). On my second day, I tested the text mode by switching the color and char patterns at specific place on screen. I also create a new video mode based on the multicolor mode. But instead of a resolution of 64x48, the new one is 64x192.

You can get my source code, binary and screenshot here:


If you would like to burn an EPROM, there is one available with a PCB for 12$. From the pictures I saw, I think you need to buy a socket if you want to easily remove, reburn and place back the chip. When I will complete the project, I think to go with someone that could distribute the game rather than doing it myself. Being a producer and distributor could be a cool thing to do but that will involve more spending in money and time. With one game only, and the small market potential, I think it make more sense to go with a distributor.

Website for the EPROM cartridge:

An EPROM programmer is necessary in order to program your chips. Eprom programmers like the one from Batronix can program a variety of chips. I don't know the voltage required to write, but I guess the speed being not too fast, maybe a MSP430 combined with enough memory to hold 32 Kb could do the job. A MSP430 (16-bits microcontroller) devkit from TI cost 4.30$ US! That's just a guess, but if someone could come with a programmer around 25$, that will make this solution more affordable.

You can find the this EPROM programmer at

I was talking above about chips emulations. In fact, when analyzing the limit of the hardware, being able to measure things make a big difference between hypothesis and facts. Being able for example to probe the video signal to see the timing of HSYNC and VSYNC via analogue probes and be able to measure data transfers on bus via digital probes could be useful. I saw that Rigol seem to have an interesting product for that type of measurements. However, I did not investigate more about it and there might be other brands which are better.

If I would be thinking to build a new hardware design, then for sure this tool will be required. But, for software development so much can be done without it.

The model DS1102D is a 100 Mhz mixed signal, available for 840$ + Taxes + Shipping at

And as always, thanks for reading!

Thursday, August 22, 2013

Doriath on ColecoVision, Mockup. (IV)

In my previous article, I manage to re-size screens according to the Coleco Vision specification. However, each tile or character shown was the original tile from the Commodore 64. On the Commodore 64, tiles can be either 8 x 8 pixels using 2 colors or 4 x 8 pixels (larger pixel size) using 4 colors among the 16 colors available.

The game on Coleco Vision will be using Graphic Mode I. This graphic mode allows up to 256 tiles. Each tile is 8 x 8 pixels and is limited to a 2 colors pattern among the 15 colors available. The 2 colors of the tiles are specified for each 8 consecutive tiles among the 256, which give a total of 32 entries ( 256 tiles in total / 8 tiles ).

The screen during the game is divided into 2 parts: information (upper part) and action (lower part). In order to keep the same number of lines for the action part, the information is limited to 4 lines (instead of 5). The 5th line in the original game is use to display the content of the chest box for few seconds when the player open one. This information can be display on line 4 for few seconds and switch back to display the position of the player. The information section (shown above) will need 4 sprites to enhance the icons.

I decided to add the scroll fragment and I am not sure if the wisdom display in the original game is relevant. From my understanding the wisdom give an idea about the completion of the game. But, amulets and scroll fragments seem a better indicator. In case I need to add wisdom, I plan to add the percentage above the scroll fragment number (similar to what I did for the Stamina Potion & Stamina).

The keypad on the Coleco Vision controller will be use to activate items:

  1. Stamina Potion
  2. Portcullis Key
  3. Trapdoor Key
  4. Fungata Potion
  5. Cloronar Potion
  6. Scroll Fragment
  #. Option Screen (To Be Define...)

A plastic with the proper graphic would be design once these options are confirm.

In order to validate the look of the game, I decided to work on the tiles and use the original sprites (but with the Coleco Vision colors).

I have redraw the larges tiles using the restriction mentioned above. I try to maintain the original look and feel while doing some small improvement.

I took 7 screenshots of the original games which has different characteristics.

This screen offer a mix of different color elements. A mix of cave & brick tiles and include various elements like: fire, ladder, rope, portcullis and a drop of water. I decided to keep the ladder near the brown color, but use 2 greens for the rope.

This screen is to verify how it look when most of the elements are red. The brown on Coleco Vision being mostly red. 

This screen is to verify the yellow use for the cave patterns versus the King's enemy.

This screen is to verify how the mushroom will look like (enhanced with 1 sprite).

This screen is to verify how the purple used for Mingos's enemies look like next to the red used for the bricks.

This screen is to verify how the cave pattern look like. I work mostly on these tiles trying different patterns of pixels and colors. I was thinking to enhance it with some tiles of dark yellow and white colors, but the look on one screen make me think that the spread of white mark may look like a bug.

This screen is to see how the water look like.

It may not be final, but so far I am quite please with this look. In order to keep record of each tile (character), I created a template where I add the tiles the game need.

The first two columns are reserved for my own usage (the Coleco Vision palette and the colors I pick for the 8 tiles on this line).

I add a red layer over the tiles which are needed to display the information above the action screen. A green layer is over the tiles which will cause collision detection between sprites and background.

The charset will be at least use in 2 copies in the Video RAM. One where all tiles will be copied, and the 2nd one where the last 8 lines will be missing. These 8 lines give a total of 64 tiles reserved to display a Draconis or Krakoli.

Some characters will be updated to produce an animation: 1 tile for fire torch,  9 tiles for water and 16 tiles for water spray. Since these animation are running below refresh rate, these animated background objects will be schedule to happen at different frame. This will reduce the amount of work that need to be done to render a single frame.

Please leave your comments below. ^_^

And as always, Thanks for reading...