Saturday, March 22, 2008

Code Shell

The first thing to do is write a code-shell, or skeleton. A framework that handles all the tedious setup and exit that can be reused and expanded upon for all future projects.

There's several ways to do this - you can save all the relevant bits and peices such as DMA, interrupts, copperlists ect. then shut everything off and do as you please. Most demos did this - and a lot of demos don't run very well across the board on all Amigas.

Another way is to set yourself up as a proper process, do all the system relevant setup, then set yourself at a very high priority and run your code - and do system friendly cleanup. This is a lot more work - especially if you no longer have all the Rom Kernel Manuals.

The latter is my approach.

A lucky find, all the RKM's in a nice web friendly format : right here

After an afternoon of pouring over exec libraries, process structures, trial - error, and slow going I decided to take a break, have a coffee, and do some stress relief Googling. Back in the day a good friend, Colin Bell - aka Ziggy (to my Siggy) helped me make the leap from demo-style hardware banging to system friendly, nearly C like assembly programming. One of the most gifted Amiga Assembly programmers I've ever met.

A quick Google found his article in the Amiga Text Mag; HowToCode7
(His is the article on reading C)
And voila - what do we find? Some startup code!
It's quite nice and fairly complete - some of the assembly options balked a little my other code - but getting the whole package from Aminet also yields a nice CIA timed mod player.

It's nice - it has some features I need - but it is around 11 years old. Its fine for someone writing a straight forward demo, but will need some reorganising, reformatting, and other bits to fit into my project.

Part of coding is putting your ego aside and accepting that somewhere someone has done it better than you - sometimes better than you can ever do. When that happens you should take what you can and study it in hopes of bettering your own skills.

My search brought me around to a usual haunt, Amiga.org - I did a quick forum search and came up with Piru's Startup - this guy has rewritten exec, he knows his stuff, and this was just what I wanted - more thorough than the former code and needing very little change (only changing some library call formatting to use Devpac 3 system macros - because I find them orderly and neat).

With the system takeover sorted, I did some quick copperlist and bitplane setups - made a chunk of memory for the test screen, a mouse click test and a wait for the vertical blank... and all ready to go!

We can setup and leave the system nice and cleanly - and have enough tests that it should work on all classic Amigas.

No comments: