Skip to content

System Takeover

Disable AmigaOS interrupts and DMA to take full control of the hardware. Required for bare-metal game programming.

Taught in Game 1, Unit 1 systeminitializationdmainterrupts

Overview

To program the Amiga’s custom chips directly, you must first disable AmigaOS. This means turning off all interrupts and DMA channels, then selectively enabling only what your program needs. Without this, the OS will interfere with your hardware access.

Code

; =============================================================================
; SYSTEM TAKEOVER - AMIGA
; Disable OS and take control of hardware
; Taught: Game 1 (Signal), Unit 1
; CPU: ~50 cycles | Memory: ~30 bytes
; =============================================================================

CUSTOM      equ $dff000

; Register offsets from CUSTOM base
DMACON      equ $096            ; DMA control
DMACONR     equ $002            ; DMA control read
INTENA      equ $09a            ; Interrupt enable
INTENAR     equ $01c            ; Interrupt enable read
INTREQ      equ $09c            ; Interrupt request

            section code,code_c

start:
            lea     CUSTOM,a5           ; Custom chip base in A5

            ; === Save system state (for clean exit) ===
            move.w  DMACONR(a5),d0
            or.w    #$8000,d0           ; Set bit 15 for later restore
            move.w  d0,saved_dmacon

            move.w  INTENAR(a5),d0
            or.w    #$8000,d0
            move.w  d0,saved_intena

            ; === Disable everything ===
            move.w  #$7fff,INTENA(a5)   ; Disable all interrupts
            move.w  #$7fff,INTREQ(a5)   ; Clear pending interrupts
            move.w  #$7fff,DMACON(a5)   ; Disable all DMA

            ; === Your game setup here ===
            ; Install copper list, set up sprites, etc.

            ; === Enable only what you need ===
            move.w  #$83a0,DMACON(a5)   ; Master + Copper + Sprites + Bitplanes

            ; ... game code ...

            ; === Restore system before exit ===
            move.w  #$7fff,DMACON(a5)
            move.w  #$7fff,INTENA(a5)
            move.w  saved_dmacon,DMACON(a5)
            move.w  saved_intena,INTENA(a5)

            rts

saved_dmacon:   dc.w    0
saved_intena:   dc.w    0

Trade-offs

AspectCost
CPU~50 cycles
Memory~30 bytes + 4 bytes for saved state
LimitationMust restore before returning to OS

When to use: Every Amiga game or demo that accesses hardware directly.

When to avoid: Programs that want to coexist with the OS (use system-friendly methods instead).

How DMACON/INTENA Work

These registers use a SET/CLEAR mechanism controlled by bit 15:

  • Bit 15 = 0: CLEAR the specified bits (disable)
  • Bit 15 = 1: SET the specified bits (enable)
move.w  #$7fff,DMACON(a5)   ; Clear bits 0-14 (disable all)
move.w  #$83a0,DMACON(a5)   ; Set bits 5,7,8,9,15 (enable selected)

DMACON Bit Reference

BitNamePurpose
15SET/CLR1=set bits, 0=clear bits
9DMAENMaster DMA enable
8BPLENBitplane DMA
7COPENCopper DMA
6BLTENBlitter DMA
5SPRENSprite DMA
4DSKENDisk DMA
3-0AUDxENAudio channels 0-3

Common DMACON Values

ValueEnables
$83a0Master + Copper + Sprites + Bitplanes
$8380Master + Copper + Bitplanes (no sprites)
$83e0Master + Copper + Sprites + Bitplanes + Blitter
$87e0All above + Audio

Patterns: VBlank Game Loop, Copper List Basics

Vault: Commodore Amiga