Ultimate Amiga
Network Boards => Extensions Forum => AMOS Factory => Extensions Programming => Topic started by: Lonewolf10 on November 23, 2009, 05:55:57 PM
-
Hi,
Since some of you have requsted it, I have cobbled together a basic guide for the layout of the AMOS Pro extensions. Below is the basic layout explained, followed by the ASM code of a shortened version of my own in-development extension.
AMOS Pro Extension - Basic Layout
==========================
(NB: Any macros, or variables set up at the start of an extension will NOT offset Start)
1) Start: Addresses for each section (22 bytes: 4 longwords + 1 word)
2) C_Off: Offsets for all the commands AND the error & no error routines. (?? bytes: (no of
commands * 2 bytes)+ 4 bytes
3) C_Tk: Token code (command syntax) always ends with a word with a value of 0
(length varies)
4) C_Lib: Default/Cold Boot code + ASM code for each command + ASM code for error and no error
routines. (length varies)
5) C_Title: Extension name, which is used in About Loaded Extensions. (length varies)
6) C_End: End of extension marked by a word with the value of 0 (2 bytes)
AMOS Pro Extension - Example ASM Code
=====================================
Version MACRO
dc.b "v0.22 (August 2008)"
ENDM
IncDir "Amiga-HD:HD1-DEV_KIT/Assembler/AMOS_Exts_Sources/AMOSPro_includes/"
Include "|amos_includes.S" ;important!
; Extension number (24), or (x-1)=x
ExtNb equ 24-1
; Now all the colours
RED equ $F00
GREEN equ $F0
BLUE equ $F
BLACK equ $0
WHITE equ $FFF
;ExtAdr: rs.l 26*4 ;not required if "|amos_includes.S" is used
Start dc.l C_Tk-C_Off
dc.l C_Lib-C_Tk
dc.l C_Title-C_Lib
dc.l C_End-C_Title
dc.w 0
C_Off
dc.w (L1-L0)/2,(L2-L1)/2,(L3-L2)/2,(L4-L3)/2 ; first 4 commands
dc.w (L5-L4)/2,(L6-L5)/2,(L7-L6)/2,(L8-L7)/2 ; last 2 commands + error & no error
; routines
; Do not forget the LAST label!!!
; The next two lines need to be unchanged...
C_Tk: dc.w 1,0
dc.b $80,-1
; Now the real tokens...
dc.w -1,L_RED
dc.b "re","d"+$80,"0",-1
dc.w -1,L_GREEN
dc.b "gree","n"+$80,"0",-1
dc.w -1,L_BLUE
dc.b "blu","e"+$80,"0",-1
dc.w -1,L_BLACK
dc.b "blac","k"+$80,"0",-1
dc.w -1,L_WHITE
dc.b "whit","e"+$80,"0",-1
dc.w 0
**********************************************************************
* COLD START
C_Lib
L0
lea MB(pc),a3
movem.l a3,ExtAdr+ExtNb*16(a5) ;store address of datazone (MB)
moveq #ExtNb,d0 ;important (Extension loaded/running ok)
rts
even
MB ;Datazone for the extension follows
BEZIER dc.b "Bezier ",0
even
DATASTORE
rs.l 16 ;reserve 64 bytes (16 longwords)
NAME1 dc.b "Extension24.Lib",0
**********************************************************************
* Leave first label for future expansion!
L1
******* RED
L_RED equ 2
L2 move.l #RED,d3
moveq #0,d2
rts
even
******* GREEN
L_GREEN equ 3
L3 move.l #GREEN,d3
moveq #0,d2
rts
even
******* BLUE
L_BLUE equ 4
L4 move.l #BLUE,d3
moveq #0,d2
rts
even
******* WHITE
L_WHITE equ 5
L5 move.l #WHITE,d3
moveq #0,d2
rts
even
******* "With messages" routine.
L_Custom equ 6
L6 lea ErrMess(pc),a0
moveq #0,d1 ;Can be trapped
moveq #ExtNb,d2 ;Extension number
move #0,d3 ;Important (display error message on?)
Rjmp L_ErrorExt ;Jump to routine... (requires "AMOS_includes.S")
rts
even
ErrMess dc.b "Error Message 0",0 ;Msg 0
dc.b "Error Message 1",0 ; 1
dc.b "Error Message 2",0 ; 2
dc.b "Invalid value",0 ; 3
dc.b "Illegal memory type",0 ; 4
dc.b "Bezier bank not reserved",0 ; 5
dc.b "Value less than 0",0 ; 6
dc.b "Value greater than string length",0 ; 7
dc.b "Out of memory",0 ; 8
dc.b "Message number too high",0 ; 9
dc.b "Message number too low",0 ;10
******* "No errors" routine
L7 moveq #0,d1
moveq #ExtNb,d2
moveq #-1,d3 ;Important (display error message off?)
Rjmp L_ErrorExt ;Jump to routine... (requires "AMOS_includes.S")
rts
even
L8 ; required to de-limit "No errors routine".
********************************************************************
*
C_Title
dc.b " ADB Extension24 "
; dc.b "123456789012345678901234567890123456789012345678901234567890"
Version
dc.b " by Andrew D. Burton ",0,"$VER: "
Version
dc.b 0
even
C_End
dc.w 0
even
Regards,
Lonewolf10
-
... and here's information about extensions for AMOS 1.3 (and earlier?). Again, the ASM sourcecode has had chunks removed to make it easier to get the gist of the layout.
AMOS 1.3 Extension - Basic Layout
==========================
(NB: Any macros, or variables set up at start of extension will NOT offset the Default/Cold Start code)
1) Default/Cold Start code
2) Custom: Custom error routine
3) ASM code for commands
4) Tk: Token syntax, finished off with by a word with a value of 0
5) MusWel: Welcome text
6) MusErr: Error messages used by Custom:, finished off by a longword with a value of 0
AMOS - The Creator Extension (1.3) - Example ASM Code
=====================================================
(Source: MUSIC.S from AMOS1_23.ZIP)
Include "Equ.s"
Translate equ -30
******************************************************************
* ** * * **** **** *** ** **** *** ***
* * * ** ** * * * * * * * * * *
* **** * ** * * * **** **** **** **** * *
* * * * * * * * * * * * * * *
* * * * * **** **** **** * * **** *** ***
******************************************************************
*
* AMOS MUSICAL ROUTINES
*
* Version 1.3
* By Francois Lionet
* AMOS (c) Mandarin / Jawx 1990
*
* This source code is public domain
*
* Last change 21/01/1991
*
******************************************************************
******* COLD START
* This must be at the beginning of your program!
* It is called just after loading...
movem.l a4-a6,-(sp)
lea MusInt(pc),a1 * Interrupt routine
move.l a1,VBLRout(a5) * Branch
lea MusAdr(pc),a1
move.l a0,(a1) * Store address of BRANCH TABLE
lea MB(pc),a3 * Base of music parameters
lea BkCheck(pc),a0 * Address of CHECK MUSIC BANK
move.l a0,d2
lea AdMB(pc),a1
move.l a3,(a1)
* 50/60 herz?
move.l #3546895,MusClock-MB(a3)
move.w #100,TempoBase-MB(a3)
EcCall NTSC * Is system NTSC?
tst.w d1
beq.s ItsPAL
move.w #120,TempoBase-MB(a3)
move.l #3579545,MusClock-MB(a3)
* Go on!
ItsPAL lea Tk(pc),a0 * Address of TOKEN TABLE
lea MusWel(pc),a1 * Address of WELCOME MESSAGE
lea MusDef(pc),a2 * Address of SCREEN RESET
lea MusEnd(pc),a3 * Address of QUIT
moveq #0,d1 * Returns NUMBER OF EXTENSION
movem.l (sp)+,a4-a6
moveq #0,d0 * NO ERRORS
rts
******* SCREEN RESET
MusDef:
lea MB(pc),a3
* Init narrator
bsr NarInit
* Init musique
bsr RazWave * Reset waves
move.l Buffer(a5),a0 * Draw square wave
move.l a0,a1
moveq #127,d0
MuDf1 move.b #-127,128(a0)
move.b #127,(a0)+
dbra d0,MuDf1
moveq #0,d1 * 0-> Noise
bsr NeWave
moveq #1,d1 * 1-> Square wave
bsr NeWave
move.w #LNoise/2-1,d2 * Draw first noise
move.w BSeed-MB(a3),d1
move.l WaveBase-MB(a3),a0
lea WaveDeb(a0),a0
MuDf2 add.w Circuits+6,d1
mulu #$3171,d1
lsr.l #8,d1
move.w d1,(a0)+
dbra d2,MuDf2
move.w d1,BSeed-MB(a3)
moveq #56,d0 * Default settings
moveq #%1111,d1
bsr Vol
bsr MVol
move.w #5,SamBank-MB(a3) * Sample bank=5
moveq #0,d0 * Sam loop off
moveq #-1,d1
bsr SL0
bsr MuInit
rts
******* Call normal error messages
OOMem moveq #24,d0 * Out of mem
bra.s IError
IFonc: moveq #23,d0 * Function call
IError: move.l MusAdr(pc),a0 * No need to care about SP!
jmp 4(a0)
******* Call customized error messages
WNDef moveq #0,d0
bra.s Custom
SNDef moveq #1,d0
bra.s Custom
BNSam moveq #2,d0
bra.s Custom
STSho moveq #3,d0
bra.s Custom
W0Res moveq #4,d0
bra.s Custom
MnRes moveq #5,d0
bra.s Custom
MNDef moveq #6,d0
Custom: moveq #0,d1 * Error can be trapped
lea MusErr(pc),a0 * Your list
move.l MusAdr(pc),a1
jmp 8(a1)
IBug: move.l MusAdr(pc),a0
jmp (a0)
******************************************************************
* MUSIC
******* MUSIC OFF-> Stops all musics
IMuSOff movem.l a0-a3/d0-d1,-(sp)
lea MB(pc),a3
clr.l MuBase-MB(a3)
clr.w MuNumber-MB(a3)
bsr MOff
movem.l (sp)+,a0-a3/d0-d1
rts
******* VOICE ON/OFF Voices
IVoice move.l (a3)+,d0
and.w #$000F,d0
move.l a3,-(sp)
lea MB(pc),a3
bsr VOnOf
movem.l (sp)+,a3
rts
***********************************************************
* =VU METRE(v)
FVu move.l (a3)+,d0
cmp.l #4,d0
bcc IFonc
lea MB(pc),a0
moveq #0,d3
move.b 0(a0,d0.w),d3
clr.b 0(a0,d0.w)
moveq #0,d2
rts
***********************************************************
* =MU BASE
FMB lea MB(pc),a0
move.l a0,d3
moveq #0,d2
rts
***********************************************************
* MUSIC TOKEN TABLE
* The next two lines NEED to be there...
Tk: dc.w 1,0
dc.b $80,-1
dc.w 1,FMB-Tk
dc.b "mubas","e"+$80,"0",-1
dc.w 1,FVu-Tk
dc.b "vumete","r"+$80,"00",-1
dc.w IVoice-Tk,1
dc.b "voic","e"+$80,"I0",-1
dc.w IMusOff-Tk,1
dc.b "music of","f"+$80,"I",-1
* You MUST finish the table by a ZERO
dc.w 0
*************** Welcome message
* 27 Y,position is like locate ,position...
MusWel: dc.b 27,"Y8Music player V 1.3",0
*************** ERROR MESSAGES
MusErr: dc.b "Wave not defined",0 *0
dc.b "Sample not defined",0 *1
dc.b "Sample bank not found",0 *2
dc.b "256 characters for a wave",0 *3
dc.b "Wave 0 and 1 are reserved",0 *4
dc.b "Music bank not found",0 *5
dc.b "Music not defined",0 *6
dc.b "Can't open narrator",0 *7
*************** That's it!
dc.l 0
I hope this will be useful to someone... that's 4 hours I won't get back!!
Regards,
Lonewolf10
-
Thanks Lonewolf10!
Maybe Sidewinder and I can put together our own CPU-blitting routines. I've already got a CPU-based Paste Bob substitute written as a shared library in AmigaE.
-
... and to complete the set, I found the attached file whilst debugging my own extension. It contains a few basic pointers from Francois himself, plus a little information on why the extension format was changed.
Regards,
Lonewolf10