flipCode - Tech File - Lionel Brits [an error occurred while processing this directive]
Lionel Brits
(aka Betelgeuse)
Click the name for some bio info

E-Mail: britsc@cadvision.com

   04/17/2000, My Not-So Tech File

Hello and howdy! I bring you another installment of my tragically popular tech file series. I’ve got a lot on my mind today, some of which you may or may not like to hear about. Anyway, read on and have fun.

Why BMP files are evil

In my last tech file I mentioned the inherent evilness of this Microsoft bitmap specification. A while ago I had to code a BMP loader for DOS/DJGPP. At the time I wasn’t aware of all the weird constraints imposed by the BMP format. I spent about two weeks combing through my code until finally remembering of the width-alignment rule (width must be even number). Data is also stored in BGR and not RGB. Finally, BMP files are written upside down but not in reverse (so the bottom scan-line is on top). I now use TGA and find it much easier to use.

Capital punishment and your so-called life

I have a tendency to analyze things to the point of absurdity, and this makes me almost impossible to argue with (unless you have a very good argument). What upsets me however, is when people say or do really stupid and then justify these things with even more senseless opinions. What’s worse, we allow these people to vote in our elections and make decisions that affect our lives.

Today my Social Studies teacher – whose name cannot be mentioned because of privacy acts in the constitution – made a rather irresponsible remark about capital punishment. In my ongoing attempt to isolate the self from the being, in philosophical terms, I’ve considered the morality of the death-sentence quite extensively, and I was well prepared to share my own opinion. She expressed her views on capital punishment as a viable alternative to imprisonment. I am very much against this policy and so I was eager to point out to her the very contradiction that lies within this misunderstood concept.

Capital punishment is not a punishment at all. Those sentenced to this form of termination feel very little physical pain or discomfort at all. The psychological affects of awaiting the sentence, on the other hand, may be seen as an appropriate punishment for the crime committed. The flaw in this justification is that punishment, by definition, is intended to change a person for the better by causing him/her to feel remorse. One does not feel remorse in death.

Others argue that capital punishment serves as a warning to potential perpetrators. No study has proven this conclusively. Some go as far as to say that by terminating the individual, money and time is saved by correctional institutions. Not only is this inhuman, but the expense of keeping a prisoner on death row for years is far greater than the savings.

Even worse are those who see capital punishment as a means by which revenge can be taken. These people can somehow obtain comfort and satisfaction by taking the life of another. How these people set themselves apart from the people they condemn is beyond my understanding.

The bottom line is that we, as a society, do not have the capacity to be making these life-or-death decisions for others. We have neither the intelligence nor the right to take away the human rights of others. Capital punishment should be abolished until such time as we do; hopefully never.

Back to reality – my compiler

Well, the assembler part of my compiler project is about 90to completion. I have however, decided to redo much of the code. I originally wrote my parser to read 1kb of definitions at a time. A temporary buffer is used to hold this data. Each time a definition is read, a copy of it is created and added to a list. What results is a slow and inefficient memory manager that does horrible things to the processors cache flow (since data is scattered all over the place). This weekend I will rewrite most of my parser so that it reads the entire file into contiguous memory and builds an index from that. This will eliminate the need for those costly calls to malloc.

My indexer will generate a 2 dimensional array for each character used in symbol names. For instance,

+-A - ...
+-B    "DB *" {%1}
+-W    "DW *" {%1}
This should be more efficient than strcmp-ing through an entire linked list.

What’s left of my parser can now handle C/C++ like macros such as

#define "MOV AX, *" { B8 %1 }
or multi-line definitions in the form of

#define "INT *"
    0xCD %1
The assembler phase will also handle macros like

#set "bits" "32"
When I have time I might write a tutorial (a column perhaps?) on parsing scripts. This should be especially useful for those creating ‘smarter’ games. I didn’t find much information on this subject when I started (apart from an old paper on how to code a Pascal compiler), so this should be useful. If you would like to see such a tutorial, please email me.

Fixed point math

A while ago I had an idea for creating a look-up table for division. I didn’t persue this too far since I had limited knowledge of fixed point math and how division took place. Now I am playing with this idea again. Maybe I can incorporate this into my new spiffy high-speed rasterizer ;-) I will hopefully have come up with a solution soon.


Well, you’ve made it this far. Visit #flipcode and complain about my writings, if you want.


May your camel spit nothing but dates!


  • 10/18/2000 - A Coder's Insanity
  • 04/17/2000 - My Not-So Tech File
  • 03/28/2000 - EggNBeans, How Do I Love Thee? Let Me Count The Ways
  • 03/19/2000 - Midgets, Calculus And Dirty Punks
  • 02/25/2000 - Strike Two!
  • 01/27/2000 - Introduction

  • This document may not be reproduced in any way without explicit permission from the author and flipCode. All Rights Reserved. Best viewed at a high resolution. The views expressed in this document are the views of the author and NOT neccesarily of anyone else associated with flipCode.

    [an error occurred while processing this directive]