Difference between revisions of "Commodore Amiga"
(→Getting something on screen) |
|||
Line 26: | Line 26: | ||
==== Getting something on screen ==== | ==== Getting something on screen ==== | ||
− | One of the shortest ways to get you started with getting anything on screen at all, is to initialize and use the intuition graphics library routines. These are relatively easy to setup and allow you to plot pixels, | + | One of the shortest ways to get you started with getting anything on screen at all, is to initialize and use the intuition graphics library routines. These are relatively easy to setup and allow you to plot pixels, circles, rects and even polygons. |
− | However, as can be expected these routines are | + | However, as can be expected these routines are extremely slow in execution. |
<syntaxhighlight lang=""> | <syntaxhighlight lang=""> | ||
Line 38: | Line 38: | ||
move.l $4.w,a6 ; execbase | move.l $4.w,a6 ; execbase | ||
move.l 156(a6),a6 ; graphics.library | move.l 156(a6),a6 ; graphics.library | ||
+ | |||
+ | ; clear screen | ||
+ | lea sc_RastPort(a5),a1 | ||
+ | jsr _LVOClearScreen(a6) | ||
frameloop: | frameloop: | ||
move.w #240-1,d7 ; y | move.w #240-1,d7 ; y | ||
yLoop: | yLoop: | ||
− | move.w # | + | move.w #640-1,d6 ; x |
xLoop: | xLoop: | ||
− | + | ; Set Pixel/Pen Color | |
− | ; | ||
move.b d6,d0 ; d0=x | move.b d6,d0 ; d0=x | ||
eor d7,d0 ; d0=x^y | eor d7,d0 ; d0=x^y | ||
− | lsr | + | lsr #3,d0 ; d0>>=4 |
− | and # | + | ;and #3,d0 ; d0&42 |
− | + | jsr _LVOSetAPen(a6) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | dbra d6,xLoop | + | ; Write Pixel |
+ | move d6,d0 | ||
+ | move d7,d1 | ||
+ | jsr _LVOWritePixel(a6) | ||
+ | dbra d6,xLoop | ||
dbra d7,yLoop | dbra d7,yLoop | ||
− | + | bra frameloop | |
− | bra frameloop | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 14:59, 28 March 2024
Contents
Commodore Amiga
The Commodore Amiga system consists of the M68k system with custom hardware for graphics and sound.
Setting up
- Assembler: VASM
- Emulator(s): Linux: fs-uae, Windows: WinUAE
Compile source to Amiga Kickstart1.x executable:
vasm -kick1hunks -Fhunkexe -o example -nosym
Amiga executable format
Here's an example where deadc0de is the only code data. 0000 03f2 marks the end of the block.
00000000: 0000 03f3 0000 0000 0000 0001 0000 0000
00000010: 0000 0000 0000 0001 0000 03e9 0000 0001
00000020: dead c0de 0000 03f2
Video display
The Amiga OCS uses an interleaved planar memory layout to represent its various paletted display modes.
Getting something on screen
One of the shortest ways to get you started with getting anything on screen at all, is to initialize and use the intuition graphics library routines. These are relatively easy to setup and allow you to plot pixels, circles, rects and even polygons. However, as can be expected these routines are extremely slow in execution.
incdir "include"
include "graphics/graphics_lib.i"
include "intuition/screens.i"
move.l $170(a2),a6 ; intuitionbase from globvec
move.l ib_ActiveScreen(a6),a5 ; a5 = activeScreen (640x240 on most systems)
move.l $4.w,a6 ; execbase
move.l 156(a6),a6 ; graphics.library
; clear screen
lea sc_RastPort(a5),a1
jsr _LVOClearScreen(a6)
frameloop:
move.w #240-1,d7 ; y
yLoop:
move.w #640-1,d6 ; x
xLoop:
; Set Pixel/Pen Color
move.b d6,d0 ; d0=x
eor d7,d0 ; d0=x^y
lsr #3,d0 ; d0>>=4
;and #3,d0 ; d0&42
jsr _LVOSetAPen(a6)
; Write Pixel
move d6,d0
move d7,d1
jsr _LVOWritePixel(a6)
dbra d6,xLoop
dbra d7,yLoop
bra frameloop
Planes
Every plane contains one bit of a pixel's colour index value. The bits of the binary representation of a colour index like %1010 (% Bit3,Bit2,Bit1,Bit0) will end up in 6 different planes (bits most significant to least significant aka left to right): Plane4 Plane3 Plane2 Plane1.
So basicly Plane1 contains all of the Bit0s of all pixels, Plane2 all Bit1s, Plane3 all Bit2s and Plane4 all Bit3s.
The first pixel on a plane is described by the leftmost (aka most significant) bit in a word, the second one by the second-leftmost etc. - just like this %0123456789abcdef with 0-f=pixels 1-16. %1000000000000000=$8000=pixel 1 in a plane word set. The 16th pixel will use the leftmost bit of the next word in this plane. etc.
Setting a palette
The Amiga OCS uses index values into a palette of colours. Palette format is a word per index with 3 nibbles for 4-bit RGB (e.g. $00f for blue). Here is some code that will help you setup an entire palette at once using the trap #14function
pea paldata(pc)
move.w #6,-(sp)
trap #14
; Palette data
paldata:
dc.w $000,$100,$200,$311,$422,$533,$644,$755
dc.w $575,$464,$353,$242,$131,$020,$010,$000
Alternatively you can set individual palette entries either by using a trap function or writing to the palette color address directly (starting at address $ffff8240).
Sound
To be added
Make some noise
So, here is a bit of sound code that outputs some sounds to the PCM output
To be added