Blitz:Blitz Mode

From Amiga Coding
Revision as of 16:40, 15 September 2015 by Daedalus (talk | contribs) (QAmiga Mode)
Jump to: navigation, search

The Amiga OS is a great operating system, but with the limited power available when the Amiga was released first it made sense to bypass the OS and use the hardware directly. This disabled multitasking and took over the machine, but allowed games to run faster and with more colours without worrying about other tasks needing access to resources.

Blitz Basic / AmiBlitz can use a special mode called "Blitz Mode" which suspends the OS like this and allows full, unrestricted access to the Amiga's features by using a special set of commands. Your program can swap in and out of Blitz mode at will, but bear in mind that any OS features that rely on other tasks, e.g. intuition, file access etc. will be unavailable in Blitz mode.

Generally, freezing the OS like this is considered antisocial on a multitasking OS, so please be sure you really need to use it. Also, bear in mind that it will only work on "real" Amigas with the custom chipsets since it uses the chips directly, so using Blitz mode automatically rules your program out of working on a next-gen Amiga system.

Switching Modes

To switch to Blitz mode, the keyword Blitz is simply used. When your program reaches this command, the OS is instantly suspended and the screen will go blank. Everything the system does from this point on must be done by accessing the chips directly.

To switch back to normal mode, use the keyword Amiga. This will restore the OS to normal running mode, and Intuition will redraw the screen as it was before Blitz mode was entered. Please remember however, that even though operation is resumed, if some task was unexpectedly interrupted when Blitz mode was activated, some unexpected behavior could result. For example, writing to a file on disk could result in a corrupted file, or even a corrupted partition. For this reason, always ensure nothing else is happening when using Blitz mode. There isn't a 100% safe way of doing this, so generally it's just an idea to not use Blitz mode at all if you want your software to be used in a multitasking environment, and if you must use Blitz mode, add a small delay before entering Blitz mode to allow any disk caches to be flushed: VWait 250 BLITZ This will pause for 5 seconds (on a PAL machine; 4 seconds on an NTSC Amiga) before entering Blitz mode.

QAmiga Mode

This is a special mode that is useful when your program mostly runs in Blitz mode. It switches the Amiga back to a limited Amiga mode, keeping the Blitz display and custom chip registers intact. This allows your program to use OS functions for accessing files without reverting to the standard OS display. The Blitz display can't be updated in this mode however, instead will appear frozen until your program returns to Blitz mode.

As with other mode switch commands, simply executing the command QAmiga will enter the QAmiga mode, and executing the Blitz command will return your program to Blitz mode where it left off.

Creating a Blitz Mode Display

Blitz Basic supports two separate systems for creating displays in Blitz mode: the Slice library and the Display library. The Slice library is inherited from older versions of Blitz Basic, and supports the capabilities of the OCS/ECS chipsets only. The Display Library was introduced in Blitz Basic 2 as a replacement for the Slice library that also includes more flexibility and support for the AGA chipset. If you only need to support OCS/ECS graphics then either library can be used, however to use AGA graphics you'll have to use the Display library. Note that you can only use one library or the other - commands from the Slice library won't work with a display built using the Display library for example.

The Slice Library

The Display Library