Showing posts with label Amiga. Show all posts
Showing posts with label Amiga. Show all posts

18/09/2018

Setting the record straight on AMOS

I feel I have an apology to make.

One of my first posts, and the one people most seem to appreciate, is the one in which I absolutely slated AMOS for the Amiga as a programming language. I went to some lengths on the matter of how poorly I found AMOS to be constructed, how its organization was lackluster, and pointed to the inconsistency of its design and various choices made. Those were the things that frustrated me back when I was a weedy little sprog desperate to code games on the Amiga.

Which is all well and good, but that's not everything that is important about a language. A language isn't just its syntax or its implementation. The most important part of a language is the intangibles. The community. The accessibility. The culture.

AMOS had that. And what's more... it still does. In my post I made mention of François Lionet, the man who wrote AMOS. I paid him what was at best a backhanded compliment, in saying he was an able programmer. Not only did I undersell things (the man wrote a language that touched almost all of the Amiga's hardware, and in a fast but systems-friendly way), but I did the man himself a tremendous disservice.

AMOS had its share of flaws, yes. But if the alternative was not to push it out the door, aspiring Amiga coders would have had a much higher bar to clear.

And perhaps that was why my reaction to it was so negative. As the youngest boy in a well-to-do academic household, I grew up internalizing elitism and my supposedly fated intellectual superiority. AMOS was supposed to teach me how to attain full control over the machine, and yet learning its basics brought me no closer to understanding Assembler or C. I think my lingering resentment toward AMOS may be a reflection of my own reaction to a perceived failing, and the need to reframe AMOS as a condescending play-toy.

If that's true, I'd say it's high time I grew out of it. I now believe that François Lionet was entirely correct on several key points.

  • The Amiga community needed a REPL-capable language that was powerful, reasonably fast, and tailored to the machine. AMOS was that.
  • The playing field needed to be leveled. The Amiga base was largely split into gamers and power users, with few of the latter having the patience to educate the former. But coding should not just be the province of an enlightened priesthood. The Amiga, after all, always held the potential to be all things to all people. For all its flaws, AMOS democratized coding. That is a badge of honor.
  • AMOS is often good enough. It's not weak simply for not being Assembler, and you can pull off some pretty impressive things in AMOS if you know how. That fact is often overlooked, but no less true for all that, because the worth of a program isn't in its presentation. If you have a game that is shit in 16 colors and increase the colors to 256, then what you have now is slightly more colorful shit. What makes a good program? Solid concepts. Great art. Attention to detail. Clever use of algorithms. If your idea is good enough, it should be viable on the Amstrad.
  • Documentation is key. Most Amiga programmers wrote their own instructions, which tended to be confusing, omit key information, and generally required you to live inside the author's skull. Worse for me as a teen was that nobody seemed to acknowledge this, which left me with the impression of constantly missing something important. In AMOS, François Lionet produced a manual that actually made a degree of sense. While it still managed to confuse me in places (mainly in mixing AMOS-specific concepts with general Amiga ones), the manual was very readable, explained most concepts in a way that didn't confuse the reader, and was sensibly laid out.
  • It was inspiring. Where other communities were opaque and grudging, AMOS wanted to welcome you. Back then, I wanted coding to be a secret club, so I scoffed at the lack of gatekeeping. Even then, though, Lionet's honest celebration of aspiring coders shone through, and it was a great motivator. It's a pity I didn't fully appreciate that back then, but I treasure it all the more today. We need a more enthusiastic approach to computer programming and content creation, and AMOS had that in spades.

These factors are, I think, enough to excuse a litany of sins. It was enough to make me join the Amos group on Facebook, where François Lionet himself is a regular poster. AMOS may never be my holy grail, but I've taken to using it when I want to quickly slap some graphics on the screen or construct a table of precomputed values. Explorative development is quite quick, and less likely to crash the machine than Assembler or even C. I still would have preferred a system that didn't reinvent graphics handling or sandbox the system, but the existing AMOS is a flawed but solid product. François Lionet could have left it at that when he left Europress. He's working on Friend OS, and that could easily be his legacy. It would certainly be enough for most people.

Not for François Lionet, though.

François Lionet, it turns out, is more of a visionary than I gave him credit for. He's also a far greater person. Why? Well, aside from unfailing courtesy and unstinting helpfulness on his own Facebook group (which he does not, I must add, treat as his own private fiefdom even though he easily could), and disregarding his work and advocacy for the Amiga-like Friend OS, his sheer enthusiasm and investment in doing right by his fans should be an inspiration for all of us.

You know guys, what prevents me from coming back to AMOS source code and change it, is that I fear it will take me a long time to setup a proper dev environment with UAE, with disc and everything, editor, graphcx editor, assembler... all the necessary tools to work...

Once I have that, I am sure that I can find how to compile again very quickly...

But, if someone does that, that is, make me such machine, and provides me with a zip file with everything installed and ready to run in one click, I can try! It will be really fun to dive again into 68000 code, I will feel 30 years younger! And if in AGA you only allow one screen, full size, and only 16 colors rainbows (the first ones) or something like that, then it is not much to do! I think I can do that in a week-end...

What do you think?

The group erupted into standing ovation. A bit of faffing about ensued regarding just how this thing would be accomplished. But in the end, this was the conclusion, from the mouth of the Lionet himself:

OK guys. You have really cool ideas, and it would be so stupid to leave them get forgotten in the depths of FB.

I will act as an administrator now on this side, sorry, but if YOU want a better version of AMOS, there is no choice.

1. I create a post with bugs

2. You post bugs there, it will come back up if it is active. But I am not making it sticky, this would be really depressing for me to see it fill up every time I connect

3. I create a 'suggestion' post, and this one will be sticky :) (possible Michael Ness?)

4. I will delete each and everyone of the posts with suggestions and bugs after this one. But carry on with conversations please!

BTW: I will not read them after... let me look... Colin Vella (sorry, not read), ' if possible, .... :P

Good to be the king! :D (I'm not, or if I am, a Viking king, not a French one with white powder acting as a lady. Don't come too close to me, I will slash your throat so that you can have fun in paradise :) )

This is what being a true gentleman looks like. So that is why I owe François Lionet an apology: instead of the whining and picking out perceived flaws in his work, I should have celebrated the soul of a man who, 30 years after a computer's demise, still makes good on his promises to its community.

One poster on FB responded to François' offer by simply saying, "you legend!"

Simple, but beyond dispute.

So thank you, François Lionet. Appreciated or underrated, a legend you remain.

05/09/2018

Converting C into Assembler on the Amiga

Introduction

This article is basically a cheat-sheet for converting C code into Amiga Assembler. The basic method is not my own. I found a page on it a year or so back, but unfortunately, I forgot to save the link. This is my rendition of the method, and any errors in thought or application should be considered mine.

Most coders, whether on the Amiga or not, are familiar with the C language. Not everyone knows how to work with Assembler, though, and the bar for learning it can be daunting.

For people already conversant with C who want to learn Assembler, there's a solution: translating it yourself, by hand, at speed. That sounds like a tall order, and complex C is indeed hard to translate. But C doesn’t have to be complex in order to be powerful. If it turns out a reduced subset of C code can help to not only dip our toes into Assembler but to write it quickly and accurately (and I aim to demonstrate that it can), then it should be an avenue worth pursuing.

Our goal, then, is to write our program in C, and then render that code into legal 68k Assembler. At first glance that would be intimidating. However, by adding just a few self-imposed constraints, we can restructure the C code into a form less concise but much easier to translate.

This is a deceptively powerful technique. After all, compiled C is just the computer doing its uninspired best to write Assembler in the first place. It just does it much faster than a human, though sometimes less efficiently (particularly on older systems, where memory and CPU speeds impose constraints on the fancy optimizations the compiler can pull). Still, manual translation remains a proven method of producing a working Assembler program in short order. The added benefit is the greater insight into one's own code offered by manual translation.

From C to A in three steps

The procedure itself is unambiguous. It takes a C listing, and the end result is a rough sketch of the final yet-to-be-optimized Assembler code. We will most likely require a few Amiga-specific additions to get something up on the screen, but the resulting binary will otherwise be fully functional.

  1. Write the routine in C. Determine its correctness.
  2. Restructure the routine in accordance with the following constraints:
    1. Calculations must be on the form of [value] = [value] [sign] [number or variable] (ex: "x = x + 2"), nothing more complex.
    2. Comparisons must be on the form of [number or value] [comparator] [number or variable] (ex: "x != 2"), nothing more complex.
    3. Remove complex branching constructs. Replace with goto or function call.
    4. Remove loop constructs. Replace with goto.
    5. The only allowed conditional is a single-line if statement followed by a goto.
    6. Remove references to variable length strings, arrays or lists. Use statically sized arrays.
    7. Replace primitive functions with calls to OS functions on the target platform when convenient (ie. typedef).
    8. Rename variable names to resemble register names, where appropriate.
    9. Test that the code’s output is unchanged (i.e. is still correct).
  3. Translate this modified code into rough Assembler form, add Amiga-specific code (libraries, interrupts, hardware access) and, again, verify correctness.

How the method is used

To illustrate the method, we could try a simple example. Project Euler is a website that offers a series of problems in roughly ascending difficulty. Most of these problems are constructed in such a way as to make a brute-force solution computationally expensive.

I generally try to avoid spoilers. However, the very first Project Euler exercise should be considered reasonably easy for any CS student to solve in a handful of minutes. The Sieve of Eratosthenes provides a fairly good, conceptually simple solution. Better still, it yields a short enough listing to be manageable for us to translate. Note that will not translate the printout part of the routine, as it would just be a distraction.

Running this program yields a sum of 233168, which in hex is 0x38ed0. This is our expected result.

Next is to prepare the C listing for translation. Applying our list gives us the following modified C listing:

This is already pretty close to what we want, but we're still not there. We need to put registers in place of variables:

Except for the Printf() function, this is practically Assembler at this point. The instructions are now ready to be translated. The result:

Assembling the program results in a minor error, easily fixed by changing the addq instruction in the third loop to add.w.

As noted, the program should result in a value of 0x38ED0 in register d0. When we assemble the corrected listing and run it, it yields exactly that: ergo, the program works. The only bug we encountered stemmed from my attempt to optimize instruction size, which was not part of the method. Had I stuck to the script, the first attempt would have assembled and given the correct response.

Two things bear mention about our C implementation. When I wrote this, I declared three iterators (scoped to each for loop). Doing so is good high-level practice, but runs contrary to the Assembler ethos of porous scope. When preparing for translation, consider deliberately compromising scoped constructs or even declaring variables as global.

Regardless, the results speak for themselves. Judging by the above demonstration, the idea is sound.

14/06/2018

Incremental Tutorials #1: The Bootable Program

I grew up with my dad’s Amiga 2000. It was a brilliant machine that I desperately wanted to understand. The path was daunting, with countless steps and milestones along the way.

Although I did learn a lot, there were some I didn't manage. I kept circling back to one particular goal. The bootable disk. This was something the PC couldn't manage, and that for me somehow encapsulated what it meant to use the Amiga.

It's exactly what the name suggests. You place a floppy in the diskdrive, it loads, and then the game starts. I wanted to make such a disk. It was magic to me, the province of mighty game coders, and I was a kid dreaming the dreams of Icarus. I never did succeed, not back then. But as it turns out, it’s never too late to start.

Programs on the Amiga usually came in one of two categories. Either the program was meant to be used under Workbench (generally, that meant it was a utility), or it was designed to boot from floppy and would immediately kill the system in order to maximize those resources for running the program (this was usually the case for games). We will probably go into how to do that as a later refinement, but it all starts with this first lesson, which is booting from floppy.

Well, turns out it's not a difficult process. To that end, I’m making this our first incremental tutorial. It has but one, simple goal: to let you create a bootable disk containing a typical game or utility for the Amiga 2000.

This tutorial will be simple and rough. It will not be optimized in any significant way. The idea is to master the basic technique first, before we return and refine what we have into something smaller and punchier.

First iteration: the floppy that boots

Overview

This will be the first tutorial. The intended end result is a disk that will boot into an already existing program. This requires

  • adding a boot-block to the disk,
  • adding a program for us to boot, and
  • writing a suitable start-up sequence.

This is a reasonably straightforward task. I will stress that I'm assuming you use an emulated machine, as logistical issues of running on real hardware (like transferring ADFs to floppies, etc) won't be part of this tutorial.

Step One - adding a boot-block

All bootable disks start with a blank floppy. If you're using physical media, that's any old floppy disk you have lying around whose contents don't matter to you. If using an emulator, create a disk image such as an ADF file (UAE has a button for this).

Now, the next thing you do is boot your Workbench system disk (version doesn't matter). Once WB finishes loading, open a CLI window, and start typing.

format drive df0: name Lesson1_1

What follows is a prompt to format the disk, so pop out the Workbench disk. Insert the empty disk (making sure it's not write-protected), and hit return. Formatting will, unsurprisingly, wipe the disk, erasing all its data and leaving it blank. Next, we want to ensure the disk boots when you insert it into Df0: on startup. After the drive's settled, type:

install df0:

You'll be asked to swap the disks, but the program itself takes no appreciable time to run. That's basically it; you now have a disk that autoboots. Go ahead and try it by pressing CTRL+Amiga+Amiga. Once you're done, boot back into Workbench.

Step Two - adding a program

The idea here is to start a piece of code that doesn't need running under Workbench. My rationale for that is the fact that bootable disks often avoided using things they didn't need. In other words, we don't want to tie ourselves to having a running Workbench process. Following this stripped-down ethos, we want a dead simply program, one that doesn't use extra libs or indeed more than one executable. It seems pleasingly symmetric to use Pong for this, so we will: this PD version of Pong by Claudio Buraglio from 1991 satisfies all the conditions.

If you're running an emulated Amiga, transferring the binary is just a matter of loading the ADF like any disk. A real Amiga makes it a bit harder: I would recommend the PCMCIA to Compact Flash solution, a Gotek drive, or (if you're feeling old-school) a null-modem cable. Transferring it to a real machine can be nontrivial, but, again, beyond the scope of this tutorial.

Next, copy the Pong file to the disk.

Step Three - adding the startup-sequence

The final step is eminently simple. Create a folder named "s" on the Lesson1_1 disk. Whenever a disk boots, AmigaDOS checks the folder named "s" to see if it contains a file called "startup-sequence". As it's empty at present, we need to create that file.

Open a new CLI window. Type the following (assuming the disk is in df0:):

ed df0:s/startup-sequence

This should create a startup-sequence file. Type

Pong

, then an asterisk, then confirm by pressing Y. This will save the new startup-sequence.

Congratulations: you have an autobootable disk.

Conclusion

We now have a disk that will autoboot and run an existing program. It's still a systems-friendly program, and can be run under Workbench. The common OS startup routines are still in place. But we can boot.

If you're anything like me, you may be underwhelmed at this point. "What? It's that easy?"

On the one hand... yes, yes it is. On the other, though, 'easy' was really the point of this exercise. Every journey has to begin by one single step.

13/06/2018

Incremental Tutorials

This blog has lain silent for a while. I’ve been busy with real life, because real life must take precedence when you have work and children to consider. The main reason, though, was that I just couldn’t decide on how to finish the tutorial. The bar for learning graphics programming seemed just too high (because of course, I’d resolved not to resort to AMOS, which would have made it trivial). No book I read on the subject seemed to truly have what I needed, or to fit my setup, or be low-level enough for what I had in mind.

So there I sat, wondering why I couldn’t make headway. I felt stupid. I questioned if I was even smart enough to begin to understand the subject, let alone write about it authoritatively.

Eventually, I realized that the problem wasn’t intelligence or understanding, but that the underlying logic behind my tutorials was lacking. So I decided to change my approach. My original format was that of the typical tutorial: “this is what you want to do, here’s how you set things up, these are the steps you must take, and you’re done.” When written well, that gives you a good solution for achieving the goal at hand.

On reflection, I wanted something different. The standard tutorial is sequential. I don’t really want that: what I really want to do is to describe a creative process, and that process (at least for me) is not sequential but iterative.

Enter the incremental tutorial. Each tutorial consists of a number of self-contained posts. For each post, we add or modify one piece of functionality, while producing a valid product that does something. That means that each tutorial will have few steps, be of manageable simplicity, and that there will always be a checkpoint close at hand to retreat to, should anything go wrong.

I think this is a promising concept. It remains to be seen whether it's enough to take it all the way.

14/06/2017

The worst language in the world

Preface

I wrote a popular answer on Quora. It involved an Amiga based language, and it occurred to me that it could be a good fit for the blog. And here we are.

Just remember though: while the post itself is jocular, the horror behind it is genuine. If you should decide to embark on this journey for yourself, gentle reader, be mindful of my warning. Heed the words of Signor Dante Alligheri.

Lasciate ogni speranza, voi che in Amos entrate

The Worst Language in the World

There are some really awful languages out there. I’m not counting the ones that are bad by design. Nobody’s seriously developing in Malbolge or INTERCAL or if they are, they’re presumably making some kind of masochistic point.

No, we’re talking real programming languages. Programming languages fit to purpose. Languages to make your life easier.

Programming semantics exist to shoulder cognitive burdens. They let us dispense with trivial code so that we don’t have to recreate old solutions. That way, we can focus on higher level code, the solutions and algorithms that really matter. Otherwise, we might as well all write in Assembler and be done with it.

In short, we leverage the power of programming languages to dispense with makework. When at their best, when coding a solution looks difficult and arduous, good programming languages are your best friend.

This is AMOS Professional, a BASIC variant for the Amiga personal computer.

It is not your friend.

Oh, it wants to be. It’ll always be there when you call. But somehow, that’s part of the problem.

This is your friend AMOS. Whenever it tells you about this great idea it just came up with? That’s how you know you should start running.

A brief history lesson

AMOS began on the Atari ST, in the form of the popular STOS BASIC. It was created by François Lionet and Constantin Sotiropoulos, then of Mandarin Software. Both were able programmers, with both vision and the ability to make that vision a reality: the noble goal of opening up the ST’s full multimedia capabilities to the user-base.

On release in 1988, STOS immediately grew popular, although not without earning its share of criticism. Two years later, the Amiga version (named AMOS) was released. You now no longer had to mind line numbers, and with the Amiga support you could now program the custom chips in various ways, with functions to manipulate the blitter, the copper, and various peripherals. It was more powerful, more polished, and more accessible than STOS. In fact, it was capable enough to allow you to write commercial grade software, or even games, for the Amiga.

In short, AMOS stands as a testament to the parable of the road to hell being paved with good intentions.

None of those things sound bad. What’s the problem?

The first issue is that of the runtime. AMOS is a black box. On paper, you need no knowledge of the innards of AMOS to produce a set number of impressive effects.

Notice I didn’t say “any number” effects? No, AMOS has a set bag of tricks which it thinks you should be allowed to employ. If what you want to do lies beyond that, tough luck. It enforces this limitation by encapsulating your code in the AMOS interpreter. This means the runtime will always stand between you and the actual machine, and even when it pretends it’s allowing direct access (such as with AREG and DREG), that’s actually not what’s happening under the hood. Even when you use the AMOS compiler so that the program is no longer interpreted, AMOS will still enforce this artificial separation.

If you want to do something under AMOS, that’s only easy as long as the programmers planned for it: if they didn’t, the runtime makes greater control all but impossible.

This, of course, also applies to access to AmigaOS.

AmigaOS was a fairly revolutionary operating system back in its day. It was lightweight and flexible and had nifty features like preemptive multitasking. It seems obvious that if you want to create a universal programming language for such a machine, it should produce applications for the OS. Europress disagreed, in effect creating an entirely separate and parallel graphical interface for AMOS programs. This was slow, bloated and unwieldy, even when compiled; compilation also made certain functions such as setting copper control to manual crash the computer. Above all else, it meant AMOS programs would always be visually recognizable, and so carry the distinct graphical signature of failure.

Second problem is the language itself. It’s shit.

Hey, aren’t you being a bit harsh?

You tell me. AMOS was written in the late eighties. It’s not as if we didn’t by then know perfectly well what sound language design principles looked like.

These are the hallmarks of a well designed language:

  • Elegance. A sparse design with a small set of highly useful keywords that behave more or less similarly. Function arguments always follow the same order, naming conventions are kept consistent, and the syntax encourages doing the right thing.
  • Expressiveness. An expressive language lets you describe problems in terms of the problem domain. This allows you to simplify the problem through abstraction. It also allows you to exclude categories of error, ideally at compile time, because of its semantics.
  • Consistency and simplicity. The language behaves in well-defined ways that let you reason about it. The simpler a language is, and the less unexpected its behavior, the easier it is to master.
  • Extensibility. A good language allows you to add new functionality to it. Ideally, such extensions should be functionally indistinguishable from core components of the language.
  • Power metrics. By which we’re talking execution speed, memory requirements, etc.

AMOS is the ugliest language I’ve ever used. Everything has keywords, and those keywords have names that frequently make no sense. There’s tons of them. With no consistent naming scheme or parameter succession, you’re forced to commit all these things to memory.

A sane language would structure this somehow using namespaces or packaging. In Java, hardly a paragon of elegance, an instruction might be invoked using

System.Security.Cryptography.AsymmetricAlgorithm

That’s a bit verbose, but the idea is clear: you go in the direction of organizing the language as specifically as possible, so that the keywords don’t conflict.

AMOS… chooses the opposite direction.

Wait… what does that even mean?

It means that other than inside comments and text strings, all the text in the editor (yes, that most certainly includes variables) is matched against existing keywords, of which there are hundreds. And if they match, case insensitively of course, the variable name is broken apart by the ever-helpful editor.

Look. Suppose you have this line of code:

Rain_Water_Level = 12
print "The water level is " + Rain_Water_Level + "!"

Looks like legal syntax, right? Unfortunately, turns out the word “Rain” is a keyword, so the variable name will be broken up. And since this occurs even case insensitively, good luck trying to write things like RAIN_water_level. That reduces the set of variables you can use to write descriptive code to an alarming degree, quickly making most code impenetrable. And yes, of course Cos, Sin and Tan are reserved keywords.

You may also notice that the language is not typed. Nor is it consistent: it will silently convert values for the print statement, in an effort to be helpful. Just like back in the day when Internet Explorer allowed incorrect code to still produce a usable webpage, this sort of help will sooner or later backfire as the errors overflow and you’re left with a turgid mess.

Under IE, of course, you could still enforce strict rendering. In AMOS, you cannot. It will cheerfully give you a coil of rope and then help you tie the knot just so.

This is horrible.

Oh, I’m just getting started. You see, there were some things AMOS was too slow to actually do. It’s an interpreted language after all, and what you needed for moving objects on the screen was speeds on the Assembly level. So what do you think they did?

…they let you use Assembly, to really leverage the processor?

Hahahahano. Not really. They created a whole new metalanguage called AMAL (AMOS Animation language) which you then have to write within AMOS. AMAL code is fed into AMOS as a text string and precompiled into assembly, but with its own semantics, with its own way of assigning variables, its own evaluation order, its own object system, and its own set of control structures. So no, it’s entirely its own language.

So there’s actually one entire extra language built into in AMOS?

Of course not. Two separate languages? That would be ridiculous.

There are three. Well, five if you count the pseudo-Assembly and the copper list code (which as mentioned earlier, will crash the computer if you try to use it under the compiler).

The third language is called Interface. It’s an entirely separate body of semantics for building and displaying windows and widgets. As for why there’s a separate system for interface widgets, guess what? The existing commands were too slow, so, well… they made an extra language. Because there’s not as if the operating system already contains perfectly suitable and fast code for a GUI, right?

And if you’re thinking that this could be something like MFC or wx, i.e. a graphical GUI creator with fit-to-purpose semantics, let me disabuse you of that right away. No, it’s just the same functions with different names and syntax, the only difference apparently is implementation. It’s like you’re hacking PhP in the days before there was PhP!

Structured programming (o cruelest joke!)

BASIC is often maligned, but the language family itself doesn’t preclude good structure. You could do a lot with very little. Something like duck typing would allow the creation of objects that could sensibly group related data, which could then be sent as function arguments.

But this is AMOS, where there’s no such thing as an object or a function argument. There are only integers, floats, strings and arrays, and naturally, they’re all of static length (without using its dodgy OS calling facility, you simply cannot reasonably use malloc from AMOS). And since the language is dynamically typed and variables are automatically instantiated, and since scope is something that only happens in procedures (which are so cumbersome as to preclude easy use)…

Yes, you guessed it: if you try to create a variable named x, let’s just hope you haven’t previously declared another variable called x somewhere in the program and forgot about it, because if you did, you’re now assigning a new value to that original variable, trashing it. Look forward to weird bugs, especially from the plethora of goto-like constructions (such as “every x gosub HELLO”, which will recall fond memories of the joys of debugging race conditions in C).

But there are functions which take arbitrary length input, however, such as polygon functions. You might even be forgiven for thinking we’ve finally stumbled into something sensible and useful. Alas, no — the number of arguments in those functions are set at compile time. That is, you can’t simply define an array of coordinates and then push it into the polyline function — no, you have to type out all the specific coordinates (“Polygon x(0), y(0) to x(1), y(1) to x(2), y(2) …”). Look forward to hilarious keyboard slips and the resultant bug hunt.

What it means is essentially that, contrary to languages like C in which you can raise the abstraction level by carefully encapsulating resultant functionality in functions and libraries, doing the same in AMOS quickly becomes a chore. The easier, more immediately productive choice is always to write it as one big blob of data, possibly with a few subroutines sharing data with the main function. Which boils down to the fact that while longer C programs can go toward greater order, longer AMOS programs naturally trend toward chaos and situational homicide.

It’s ironic to me that after learning rudimentary 68K Assembly, I already consider it far more well-formed and expressive than AMOS was, and AMOS was supposed to be instructive and easy to use!

But surely, if it was popular and skillfully coded, it couldn’t have been all bad!

To the contrary, I argue the greatest sin of AMOS was its popularity and the fact that it worked. A hated language would never have convinced so many young coders to waste their time in the vain effort of trying to learn AMOS well enough to write a proper game. A poorly written language without snazzy graphical features would have immediately dispelled the myth of its speed and power.

Instead, the fact that you could do some fairly cool things out of the box in AMOS concealed the fact that there was a cutoff point after that. Because try as it might, AMOS simply wasn’t capable of harnessing the full speed and capabilities of the Amiga.

To heap insult onto injury, learning the full scope of AMOS Pro was a full-time job easily comparable to the time it’d take learning Assembly. Only difference is, the AMOS programmer would end his journey realizing it was all smoke and mirrors, with few transferable skills that would make sense in other coding languages.

In closing, I admire Francois Lionet and co. They did a tremendous job on a project that clearly meant a lot to them, and obviously, a lot of Amiga fans disagree with me and loved their product.

Even so, I personally think that if there was ever any specific BASIC dialect Dijkstra alluded to when he said, “[..] students that have had a prior exposure to BASIC [..] are mentally mutilated beyond hope of regeneration.”, then surely it must have been a prescient reference to the coming of AMOS.

15/11/2016

Amiga Emulation 101

Hey everyone! I mentioned I've been working on an Amiga article. Sadly I got sidetracked: I had to upgrade to Windows 10, and found myself thwarted when moving my existing Amiga setup from the Linux laptop. I could have worked out the culprit (smart money's on memory corruption on the USB stick) but troubleshooting bores me to tears. I decided to make a new installation instead, with all the usual programs necessary for coding on the Amiga. At which point I realized, hey, someone other than me might find this useful.

So, in short, here's how to set up an easy-to-use Amiga 1200 desktop environment on either Linux or Windows.


Setting up the A1200

Ah, the trusty Amiga 1200. In my opinion, the 1200 sits closest to the sweet spot of the Amiga experience: faster than the 500, reasonably inexpensive to purchase, with four times the chip memory, gobs of expansion options and of course the AGA graphics. Back then, it was as if someone had taken the 500 and improved it across the board.

Of course, in hindsight, it wasn't a perfect machine. Blitter fill rates, sound quality, number of hardware sprites and floppy drive capacity hadn't kept pace with the other improvements. The AGA architecture, while more capable in certain areas, lacked the elegant, Swiss-watch interconnectedness of the OCS and ECS machines. Mostly, the 1200 was too little and too late, debuting half a decade after the point of being able to replicate the revolution that the original Amiga 1000 had been.

Nevertheless, the 1200 remains the easiest way to achieve a reasonable desktop experience on a low-end Amiga. Therefore, while the A500 or A2000 may be a "purer" way of experiencing the Amiga, this is not what we'll do in this instance. Instead, we'll emulate an Amiga 1200.

This tutorial has the following prerequisites:

  • a modern desktop, preferably running Windows 7/8/10 or Linux,
  • an internet connection, and
  • a ROM file of the A1200's kickstart chip (see below),
  • a full set of Workbench 3.1 floppy disks (or images thereof), and
  • snacks (optional).

The kick-rom (that is the kickstart file) is an image of the physical ROM chip that sits on the Amiga 1200 motherboard. The 1200 was originally released with version 3.0 of kickstart; the difference to 3.1 is fairly marginal and should not matter much for this tutorial. What does matter is that the emulation software we're going to use requires the kick-rom file to operate. Without that ROM file, the emulator will not run, and the ROM file is not free to distribute.

How to get a kick-rom file? Well, if you own a physical Amiga 1200 with access to Internet, you can download a program called GrabKick from Aminet. That will extract a file which you can then transfer to the PC.

The alternative is to buy the ROM from Cloanto, the current distributors. Their Amiga Forever package is a very good purchase; they offer various software and ROM packages as well as a complete easy to use Amiga environment at a very reasonable price. We're going to try a different approach to theirs for this tutorial, however, so if you buy their CD, don't bother installing the whole package.

FS-UAE

We're going to use an emulator, and when it comes to the Amiga, there's really only one: UAE. The acronym is commonly interpreted to mean Universal Amiga Emulator, but it originally stood for the Unusable Amiga Emulator, due to its inability to even boot. Further refinement provided the features theretofore missing. With the introduction of just-in-time compiling it got a hefty speed boost, and UAE today is fast enough to emulate Amigas with PowerPC accelerators and GPUs while still remaining cycle-exact.

UAE comes in different flavors, one of which is called FS-UAE. The FS part is the GUI built on top of UAE, and for my money it's a far more uncluttered and usable experience than WinUAE. As a bonus, it is available for major Linux flavors as well as Windows, and behaves identically between platforms. Download FS-UAE and install it according to these instructions (with the current version, you no longer need to edit the config files).

The first thing you need to do is to import the kickstarts. By clicking the top left icon, you will see a menu. Here, you either select Import Kickstarts... (if you extracted a free-standing kick-rom file) or Amiga Forever Import... if using Amiga Forever. Next, under Amiga Model, select A1200 and the appropriate ROM configuration (either 3.0 or 3.1/020 will do fine). Under Joystick & Mouse Port, select No Host Device for the joystick -- this will allow you to use the arrow keys when coding. Finally, register and save this as your configuration (left-hand list box).

Next, in the tab list, click on the tab icon that looks like a black chip. This takes you to the Kickstart ROM tab. Here, select Custom and choose your kick-rom file. You may also tick "Zorro II Fast RAM" - select the largest amount. Save configuration.

Now, click on the floppy icon in the tab list. This allows you to uncheck (and thus activate) all four potential floppy drives, which we will do for the sake of convenience. More important is the Media Swap List; FS-UAE requires you to add all floppies you can use beforehand. Click the plus sign, then select all the Workbench 3.x disks.

So far, we've set up a fairly standardized Amiga 1200 with some extra peripherals. However, there's one thing missing that we really need: a hard disk. Click the main menu (top left tab icon). From the menu, select HDF Creator... and create a non-partitioned HD file which you call System (a size of 60 MB should be enough). This creates a file that acts as a hard drive. Select the Hard Drives tab, and pick the file you just created.

Now, start FS-UAE with the Workbench disk in you primary floppy drive. Boot it up. You'll see your hard drive as an unformatted non-Dos disk. Click on it, select Format from the menu, using FFS (Fast File System) with no trash can. Format. Now, load the Install disk into DF1:, and Locale and Extras in the other two. Double-click on the Install disk, then on the Install Workbench icon. In the installer, select intermediate level, and when it comes to installation directory, select your System hard drive (for some stupid reason, the default is DF0:!). Installation should prompt you for disks as they are needed. Once you're done, Workbench 3.x will have been installed.

Configuring Workbench

The first thing you need to do is close down the Amiga. We need some way to get files onto the machine, and the easiest way is for you to mount a second hard drive under the hard drives tab. Instead of mounting a hard file, you can mount a Windows or Linux directory. I usually find it simplest just to mount the Downloads folder. Now you can freely move files between your main computer and onto the Amiga. Workbench will treat it as if it's a regular hard drive (as long as you select "show hidden files" from the menu).

Workbench is pretty well set up for serious work right off the bat, but there are a few things it lacks. Its greatest Achilles' Heel is arguably the lack of a decent command line interface. While the default CLI is leagues beyond MS-DOS, that's really damning with faint praise. To fix this, we're going to download KingCON (also known as Newshell) off of Aminet. KingCON is unfortunately packed in lha format. You can either use a free utility like 7-zip to open it up on the PC, or download Lha from Aminet. If you do the latter, move Lha.run to RAM:, execute the file there, then copy the archiver (called lha_68020) to the System:C/ folder. The other files are unnecessary.

Next, move KingCON_1.3 to RAM: and unpack it there. Execute the installer, and follow the instructions (basically, you enter the cli, type "ed s:user-startup", change KRAW and KCON to RAW and CON, and add the unmount CON: / unmount RAW: commands as it directs).

Slightly complicated? Perhaps. On balance, I think the new CLI (which lets you use the TAB key to autocomplete or choose files from inside a file requester) is easily worth the small hassle of installation.

Back up the hard-file; we're almost done.

Making it pretty (optional)

Workbench does look a bit drab. Nothing that can't be fixed, however -- all you need is to download Magic User Interface and MagicWB. Copy them to RAM: as usual, and then install.

Conclusion

You should now have an Amiga WB environment up and running. I've tried to keep my tutorial as general as possible, so I've avoided actual programming environments, DirOpus, graphics editors like DPaint, et cetera. There's a ton of useful software to that effect, and I'll mention others when needed.

This has been a primer on how to painlessly set up an emulated Amiga environment. I hope you liked it and will, as always, be grateful for feedback.