Tag: AmigaOS

  • 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.