Tag: AmigaOS

  • Loading pictures using DataTypes.

    As you might know, DataTypes on the Amiga is a universal system for managing files in different formats. This lets an application query the datatypes.library to load or save a file, while the OS takes care of converting the format. If a user installs new DataTypes on their computer, all existing programs using the DataTypes system will instantly work with the new format.

    Happy happy DataTypes.

    For a more in-depth explanation on how to use DataTypes in your application, I suggest checking out this link:

    https://wiki.amigaos.net/wiki/Datatypes_Library

    Since DataTypes are based on BOOPSI, a DataType object essentially is as a Gadget and can therefore be added to a Window. This isn’t the approach I’m aiming for in this article. Instead, I’ll demonstrate how to load an image from a file and populate a BitMap for further processing with graphics.library. The example below will open a window, load a .png file, and copy it to the window’s rastport for display. The result is a small program that’s similar to the MultiView utility, but much simpler.

    When using datatypes.library, it’s a good idea to test your code on different versions of AmigaOS. For example, ApolloOS will automatically handle high-color images, while AmigaOS 3.2 needs to be explicitly told to use newer modes. These small differences between AmigaOS variants can be tricky to anticipate without thorough testing.

    Support for high-color pictures was introduced in datatypes.library version 43, which means you’ll need AmigaOS 3.5 or later. You can refer to this table to see which versions of DataTypes are included in different AmigaOS releases.

    OSversion of datatype.library
    AmigaOS 3.0v39
    AmigaOS 3.1v40
    AmigaOS 3.5v43
    AmigaOS 3.9v44
    AmigaOS 3.2v47
    ApolloOSv45

    I’ll let the actual source code speak for itself. Here’s how to load pictures into a Bitmap using DataTypes in assembler.

    DataType Image viewer in assembler.

  • Example: Display message requester.

    		; What: Example on how to display a message using EasyRequestArgs in Intuiiton.
    		;
    		; Author: Tomas Jacobsen - bedroomcoders.com
    		; Date: January 2026
    		; Version: 1.0
    		
    
    		opt d+							; Include debug information in file
    		output	RAM:DisplayMessage				; Save program to RAM:
    
    		incdir	"include:"
    		include	"exec/exec_lib.i"
    		include	"intuition/intuition_lib.i"
    		include	"intuition/intuition.i"
    		
    
    		section my_code,code
    
    
    		;Initialization
    		;------------------------
    
    _Init		movea.l	4.w,a6					; ExecBase in a6
    				
    		moveq	#0,d0							; 0 = any version of intuition, 39 = at least OS 3.0
    		lea	_IntuitionName,a1
    		jsr	_LVOOpenLibrary(a6)
    		move.l	d0,_IntuitionBase
    		beq.s	.libraryError
    
    		movea.l	_IntuitionBase,a6
    		suba.l	a0,a0						; Set a0=0 - Display on default screen
    		lea	_EasyStruct,a1					; Pointer to structure in a1
    		move.l	#es_SIZEOF,es_StructSize(a1)		; Fill in size in structure
    		clr.l	es_Flags(a1)						; Set flags in structure to 0
    		move.l	#_Title,es_Title(a1)			; Write a pointer to title into strucure
    		move.l	#_Message,es_TextFormat(a1)		; Write a pointer to message into strucure
    		move.l	#_OKMsg,es_GadgetFormat(a1)
    		sub.l	a2,a2
    		sub.l	a3,a3
    		jsr	_LVOEasyRequestArgs(a6)
    	
    		movea.l	4.w,a6
    		movea.l	_IntuitionBase,a1
    		jsr	_LVOCloseLibrary(a6)
    
    .libraryError
    		moveq	#0,d0							; Return zero (no error) to the system
    		rts				
    
    
    			
    		section my_data,data
    
    _IntuitionName		dc.b	"intuition.library",0
    				even
    _Title			dc.b	"My message",0
    				even
    _Message			dc.b	"This is a message from my assembler code.",0
    				even
    _OKMsg			dc.b	"OK",0
    				even
    
    _EasyStruct			ds.b	es_SIZEOF				; EasyStruct for Requesters
    				even
    		
    _IntuitionBase		dc.l	0
    

  • Coding for AmigaOS.

    AmigaOS is your bridge to the hardware.

    An operating system serves as a bridge between the user and the computer’s hardware, while also providing routines and services that help applications run smoothly on the platform and take advantage of all the ready-made functionality the OS offers.

    AmigaOS is no different, providing a rich set of routines you can tap into for your code. This made it far ahead of its time, and it’s still seen as both efficient and welcoming to coders and users alike.

    Most routines are organized into libraries. For example, the intuition.library contains routines for managing windows and screens. If you need to open a file or read a directory in your code, the dos.library is the place to look. The graphics.library can help you draw a circle on the screen or animate an image by moving it around.

    For a full guide to the built-in libraries, take a look at the official autodocs here:

    https://developer.amigaos3.net/autodocs

    Let’s dive in and explore how to work with all this functionality using assembler. To use a library’s contents, you first need to open it, and when you’re finished, close it properly. The one exception is the exec.library, which is always open and ready to use. This is the library that lets us open any other library.

    movea.l 4.w,a6 ; At memory address 4 you will always find a pointer to ExecBase/SysBase

    With ExecBase loaded in a6, we can call any of Exec’s functions. A library base is essentially a table of available functions, with the base pointing to the last one. To call a function, we use a negative offset from the base. Confusing, I know. An example is in order.

    ; Find ExecBase and use Exec's OpenLibrary funtion to open Intuition.
    ; Store IntuitionBase in a variable for later using it's functions.
    
    _LVOOpenLibrary = -552
    _LVOCloseLibrary = -414
    
    Start:
    		movea.l	4.w,a6			; ExecBase in a6
    		lea	IntuitionName,a1	; Name of Intuition Library
    		moveq	#0,d0			; Any version of the library is OK
    		jsr	_LVOOpenLibrary(a6)	; Jump to Execbase - 552.
    		move.l	d0,IntuitionBase	; Store IntuitionBase in memory
    
    		; ... Lots of useful code ...
    
    		movea.l	4.w,a6
    		movea.l	IntuitionBase,a1	; Library to close
    		jsr	_LVOCloseLibrary(a6)	; Always clean up and close after us.
    
    		rts
    
    IntuitionBase:	dc.l	0
    IntuitionName:	dc.b	"intuition.library",0
    		even

    jsr _LVOOpenLibrary(a6) translates to jsr -552(a6), which means the CPU jumps to the address located 552 bytes before the address that a6 points to.

    In the developer tools, you’ll come across include files—definitions you can add to your code that let you use function names instead of numbers. We’ll explore this in more detail in a later article. In the upcoming articles, you’ll also see more examples of how to use OS functions. It might feel a bit confusing at first, but it will start to click as you get more examples of how they’re used.