22 March 2020, 14:56 | #1 |
Registered User
Join Date: Oct 2019
Location: Denmark
Posts: 5
|
Asm one. Horizontal demonstration
Need a example for a small copper amiga program that can demonstranter how to control the beam the horizontal way. For instance draw a rectangle in the middel of the screen... The vertical way seems more logical... Cant figur out the horizontal way
|
23 March 2020, 22:13 | #2 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Code:
include "graphics/gfxbase.i" include "custom.i" ; Program parameters BGCOLOR equ $aaa ; background color RCOLOR equ $844 ; rectangle color RVPOS equ 100 ; rectangle's vertical start position RHPOS equ 120 ; rectangle's horizontal start position RWIDTH equ 80 RHEIGHT equ 50 ; AmigaOS constants EXECBASE equ 4 ; exec LVOs CloseLibrary equ -414 OpenLibrary equ -552 ; graphics LVOs LoadView equ -222 WaitTOF equ -270 ; Copper macros CMOVE macro ; register,value dc.w \1,\2 endm CWAIT macro ; vpos,hpos dc.w ((\1)&$ff)<<8|(((\2)&$fe)|1) dc.w $fffe endm CEND macro dc.w $ffff,$fffe endm section code,code ;--------------------------------------------------------------------------- ; Program start from CLI. WB-start is not supported. ; take over system bsr init beq .2 ; execute main routine and wait for mouse button to exit bsr main .1: btst #6,$bfe001 bne .1 ; restore system .2: bsr exit moveq #0,d0 rts ;--------------------------------------------------------------------------- init: ; Save current state and take over the system. ; -> a6 = CUSTOM ; -> Z-flag indicates error move.l (EXECBASE).w,a6 ; open graphics.library lea GfxName(pc),a1 moveq #33,d0 jsr OpenLibrary(a6) move.l d0,_GfxBase beq .1 ; save currently active View and load a NULL-View move.l d0,a6 move.l gb_ActiView(a6),ActiView sub.l a1,a1 jsr LoadView(a6) jsr WaitTOF(a6) jsr WaitTOF(a6) ; disable all interrupts and DMA lea CUSTOM,a6 move.w #$8000,d1 move.w INTENAR(a6),d0 or.w d1,d0 move.w d0,Oldintena move.w DMACONR(a6),d0 or.w d1,d0 move.w d0,Olddmacon not.w d1 move.w d1,INTENA(a6) move.w d1,DMACON(a6) .1: rts GfxName: dc.b "graphics.library",0 even ;--------------------------------------------------------------------------- exit: ; Restore the system and the display to its previous state. move.l _GfxBase,d1 beq .1 ; init failed, nothing to restore ; reenable system DMA and interrupts lea CUSTOM,a5 move.w #$7fff,d0 move.w d0,INTENA(a5) move.w d0,DMACON(a5) move.w Olddmacon,DMACON(a5) move.w Oldintena,INTENA(a5) ; restore system View move.l d1,a6 move.l ActiView,a1 jsr LoadView(a6) move.l gb_copinit(a6),COP1LC(a5) ; close graphics.library move.l a6,a1 move.l (EXECBASE).w,a6 jsr CloseLibrary(a6) .1: rts ;--------------------------------------------------------------------------- main: ; Display a rectangle using the Copper. ; a6 = CUSTOM ; load copper list and enable Copper-DMA move.l #clist,COP1LC(a6) move.w #$8280,DMACON(a6) rts section copper,data_c clist: CMOVE COLOR00,BGCOLOR CUR_VP set RVPOS rept RHEIGHT CWAIT CUR_VP,RHPOS CMOVE COLOR00,RCOLOR CWAIT CUR_VP,RHPOS+RWIDTH CMOVE COLOR00,BGCOLOR CUR_VP set CUR_VP+1 endr CEND section bss,bss _GfxBase: ds.l 1 ActiView: ds.l 1 Oldintena: ds.l 1 Olddmacon: ds.l 1 I don't like addresses instead of symbols for hardware registers. It looks so messy. |
|
25 March 2020, 23:05 | #3 | |
Registered User
Join Date: Oct 2019
Location: Denmark
Posts: 5
|
Thanks... Did not Know about the macros...
Gave me something to think about Quote:
|
|
26 March 2020, 00:27 | #4 |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
I thought I was the only one with a CMOVE macro
|
26 March 2020, 09:29 | #5 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Obviously when you create a macro you are free to do it anyway you like, but is there a reason to deviate from standard motorola's order move #value,destination in CMOVE?
Just curious if it's a random thing or not... |
26 March 2020, 10:49 | #6 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
|
It's a copper instruction stored as word pairs in memory. It is not a 68000 instruction. The copper interprets the 2 words as "register" (1st word) and "data to write to that register" (2nd word)
|
26 March 2020, 11:44 | #7 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
Code:
; Copper macros CMOVE macro ; value, register dc.w \2,\1 endm |
|
26 March 2020, 13:04 | #8 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
|
|
26 March 2020, 14:03 | #9 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
Code:
move.w #0,$180 Code:
CMOVE 0,$180 |
|
26 March 2020, 14:49 | #10 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
|
|
26 March 2020, 15:00 | #11 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,408
|
I'd say the reason it's "register, value" is that this is how the Copper actually works.
See, it's not actually "register, value" from the perspective of the Copper. Rather, it's "instruction, value". Or perhaps better put it's more like "MOVE|register,value", "WAIT|condition,value", "SKIP|condition,value". Edit: the one thing that makes this a bit less clear is that the value for the MOVE instruction is actually 0, so you end up with just the register number as the instruction after the or. The macro's are just there to make things a bit easier and I'd argue it's best to stick with the way the Copper works as the Copper is it's own little processor and not a 68k (like DanScott pointed out) Last edited by roondar; 26 March 2020 at 15:25. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tool to convert asm to gnu asm (gas) | Asman | Coders. Asm / Hardware | 13 | 30 December 2020 11:57 |
EHB, HAM6 and HAM8 demonstration pictures? | TroyWilkins | Amiga scene | 95 | 22 November 2016 10:24 |
Demonstration and Interview with Jan Derogee | trackah123 | Amiga scene | 2 | 22 February 2009 13:19 |
First public demonstration of Dragon(Elbox) | ppill | News | 15 | 09 December 2006 23:29 |
Report from mA1-C/OS4 demonstration In Istanbul | Paul | News | 0 | 21 December 2004 11:37 |
|
|