Coding

Coding is fun. Apart from my projects at work, I've had several projects going (more or less) at home as well. Here are some examples of what I've done:

Tail

(C++) Tail is a program that I wrote one day because I needed it at work. Ideal for monitoring Apache weblogs in realtime, for example! First I made the Java version. Then I ported that version to C++ using JLib, my C++ class library. The C++ version has since been edited somewhat.

My tail version is freeware, and if you find a bug, I'll try to fix it for you. Instructions are available via the command line. (Note that IIS logs do not work with tail. If you open them in Winhex, you'll understand why.)

Downloads

Win32 Binary || Partial C++ Source || Partial C++ Source (2012 Refactored Edition)


JLib

(C++) JLib is a C++ class library inspired by the libraries and concepts of Java, C#, and Qt. It is designed to be a high performance, portable, lightweight and intuitive toolbox for realizing desktop and embedded projects. With all the basic necessities; such as timers, Unicode, collections, iterators, signals and slots, shared pointer, IO, type traits, foreach, implicit sharing, and GUI components, you'll quickly be writing fast and maintainable code.

JLib is currently implemented on Win32, but the API does not expose the underlying platform. So there's no need to learn archaic data types or function protocols.

There is no dependency on Boost, MFC, STL - or even the C++ standard library. Differences in standard C library implementations are handled by a thin compatibility layer. Only a small subset of the Win32 API is used on Windows. Platform specific code for Mutex, Thread, Timer, Socket, and so on, resides in one file; inside the JPlatform namespace. Thus, porting efforts will be minimal. The entire library compiles without warnings - and all tests pass - on both MSVC6 and GCC 4.4.

Feature highlights
  • Core
    • String (UTF-16, with implicit sharing) and StringView.
    • Text codecs: ISO 8859-1, Windows 1252, UTF-8, UTF-16.
    • Array<T>, List<T>, Set<T>, Hash<TKey, TValue> - all with implicit sharing. Built-in sorting. STL-compatible iterators.
    • Object class with support for parent-child hierarchies and type info.

  • Language augmentation
    • IntFP<n>.
    • Variant, with support for custom types.
    • SharedPointer<T>, ScopedPointer<T>.
    • foreach keyword, so you can do cool stuff like foreach(const FileInfo & info, FileInfo("my_directory")).
    • synchronized (Object/Mutex * lock) { code }, exactly like in Java :-)
    • Signals and slots based on pbhogan/Signals, which includes the FastDelegates framework developed by Don Clugston.
    • instanceOf without enabling rtti or using a moc.
    • Type traits (is_const, is_pointer, is_array, etc), adapted from the VC6 port of the Loki library.

  • Multithreading support
    • Thread/Runnable multithreading concept.
    • Mutex, ScopedMutexLocker.

  • Utility classes
    • DateTime, TimeSpan, Math, Base64.
    • Random (adapted from Mersenne Twister).
    • System::currentTimeMillis, System::arraycopy.
    • Memory block manager template simplifies usage of placement new for performance critical code.

  • IO
    • Console::out.println.
    • FileInfo, including iterating and recursing directories.
    • File, RandomAccessFile.
    • InputStream, ByteArrayInputStream, DataInputStream, FHandleInputStream, FileInputStream.
    • OutputStream, ByteArrayOutputStream, DataOutputStream, FHandleOutputStream, FileOutputStream.
    • Reader, InputStreamReader, StringReader, Writer, OutputStreamWriter, StringWriter, PrintWriter.
    • Socket, ServerSocket, URL, HttpConnection, with streams.
    • CRC32 and MD5 hashing, with streams.

  • Compression (stream based)
    • RLE.
    • Huffman, Delta (work in progress).

  • Parsing
    • Command-line parser.
    • Generic lexical analyzer (very fast!).
    • CSVFile, ConfigFile (Windows ini-files and Java property files).
    • HTML parser written from scratch (Supports entities, comments, attributes, nesting recovery, etc.).

  • GUI
    • GraphicsItem, Painter, Font, Pixmap, Color, Brush, Pen, LinearGradient, PointF, RectF, SizeF.
    • GraphicsItems support mouse / key / focus events, paint function, visibility, opacity, stacking order, and clipping at the item level.
    • Widget, Clickable, Button, Label, LineEdit, Image, ProgressBar.
    • Software rendering of lines and circles, rectangles, polygons, gradients, pixmaps and bitmap fonts - all with alpha-blending, opacity, and additional Painter level clipping.
    • Offscreen painting into Pixmaps.
    • Image loading (png, jpeg, gif, bmp, psd, tga, hdr, pic) uses the compact library stb_image.c developed by Sean Barrett et. al.

  • Animation
    • Timer.
    • LinearInterpolator<T>, EasingCurve.
    • PropertyDelegate<T>, AnimatableProperty<T>, PropertyAnimation<T>.

      Example code: item->posProperty.animateTo(PointF(10, 10));

Lots of unit tests.

Example binary size on Windows XP (release builds): 400k

The current library is a solid foundation for adding new features. I plan to include the FreeType font rendering library, provided it does not add megabytes to the executable. Windows and Amiga bitmap font loading is on the way.


Spider

(Java) Spider is a configurable and multithreaded web spider that can gather file/image/email URLs from an entire website. It incorporates an HTML parser written from scratch, and has a very clean and modular design.

Feature highlights
  • Easy configuration.
  • Collect URLs of whatever file extensions you like.
  • Optional document cache for lightening fast re-runs (if Java's URLConnection decides to freeze, and it does).
  • Fast, reusable HTML parser written from scratch.
  • Unlimited number of threads to maximize network throughput.

Cycle Exact Amiga Emulator Prototype

(C, C++) This was the masters thesis (450 pages) for my Civil Engineering degree. It is the working, proof-of-concept prototype of a cycle exact emulator of the Commodore Amiga 500. The emulator is coded in C, with some auxillary classes in C++ for easier implementation. I focused mainly on a modular design, cycle-exact modelling and emulation, and highly speed-optimized code.

The prototype is currently in the state of a working emulator skeleton. All modules, such as CPU, Blitter, Copper, sound, sprites, disk, RAM, ROM, Chip-RAM, and so on, can read and write from/to memory as dictated by the bus arbitrator module. For example, the CPU (pre)fetches the opcode, fetches any additional words, takes variable time to compute the result, then writes the result back (if any). The Blitter module implements the interleaved and pipelined bus behaviour found in the real Amiga. At all times, any module wanting to take the bus must obey the priority rules set out by the arbitrator and the current DMA register settings.

What really took me by surprise when I studied the log output, was how efficient the Amiga uses it's precious 3,54 MHz bus cycles. No wonder it became so popular back in the late 80's.

Next for this project is to replace the mockup CPU opcodes with real opcodes. All bus interaction for every possible instruction bus pattern and operand size is already in place. My estimate is that it will take another two months of full-time work for this emulator to boot into Workbench and games.

Feature highlights
  • Cycle exact emulation core.
  • Low level chipset register emulation ensures maximum application compatibility.
  • Chip RAM, Fast RAM, ROM emulation with separate bus arbitration for Fast RAM and ROM, and Chip RAM.
  • The design allows for reproduction of all kinds of tricks used by the Amiga programmer: Sprite multiplexing, direct writes to the sound registers, mid scanline resolution changes, and so on.
  • All hardware modules of the Amiga currently interact with each other running test operations, but produce no output.
  • Models based on experiments on a real Amiga where documentation did not suffice.

© 2003-2016 CvK. All rights reserved - use at your own risk.
Last modified on 5th of January, 2016