Pl2 CORRIG 3.DOC
---------
EXERCISE CORRECTIONS
on LineAs
---------
1) Exercise nr° 1:
--------------
Here is the correction listing.
I think this exercise didn't cause you much trouble,
carefully look at this listing, it doesn't have any difficulty.
TEXT
INCLUDE "LINEQU.L" ;the EQUs
INCLUDE "INIT_TOS.L" ;Setblock
INCLUDE "MACROS.L" ;The macros
SETBLOCK ;Initialization
;We search for the address of the internal Table for the LineAs
DC.W $A000 ;return in a0 of the address
;of the internal table
;We drop the addresses of the VDI array tables in the internal table
move.l #CONTROL,ticontrol(a0)
move.l #INTIN,tiintin(a0)
move.l #PTSIN,tiptsin(a0)
move.l #INTOUT,tiintout(a0)
move.l #PTSOUT,tiptsout(a0)
PRINTLINE MOUSE ;text
WAIT ;waiting
lea INTIN,a6 ;address of INTIN in a6
move #0,6(a6) ;0 in intin+6 (mask color)
move #1,8(a6) ;1 in intin+8 (foreground color)
lea DATA,a5 ;address of 'DATA' in a5
move #31,d0 ;31 in d0
adda.l #10,a6 ;increment a6 by 10 units:
;a6 therefore points on intin+10
LOOP move (a5)+,(a6)+ ;we drop the data in
;the INTIN table pointed by
;a6
dbf d0,LOOP ;we loop 32 times for the
;32 data (16 words for the
;mask and 16 words for the
;foreground)
DC.W $A00B ;TRANSFORM MOUSE
move #0,intin ;counter=0
DC.W $A009 ;SHOW MOUSE
PRINTLINE MESSAGE ;text
WAIT ;waiting
TERM ;end
DATA
MOUSE DC.B 27,'E','I change the shape of the mouse cursor...'
DC.B ' mouse ...',0
MESSAGE DC.B 27,'E','Move the MOUSE please ...',7,0
DATA DC.W %0000001110000000 ;the 16 data (WORDS)
DC.W %0000011111000000 ;of the MASK
[...] (omission of repeated patterns)
DC.W %0000001110000000
DC.W %0000000000000000 ;the 16 data (WORDS)
DC.W %0000001110000000 ;of the FOREGROUND
[...] (omission of repeated patterns)
DC.W %0000000000000000
BSS
INCLUDE "TABLEAU.L" ;the VDI table
END
2) Exercise nr°2:
--------------
Again, no major difficulty...
It was just necessary to pay attention to using graphical coordinates
that correspond to the used resolution.
(OX)=640 from 0 to 339
(OY)=200 from 0 to 199 (MEDIUM resolution)
TEXT
INCLUDE "LINEQU.L" ;the EQUs
INCLUDE "INIT_TOS.L" ;Setblock
INCLUDE "MACROS.L" ;The macros
SETBLOCK ;initialization
DC.W $A000 ;we request the address of the T.I. and
movea.l a0,a5 ;we put it in a5 because a0 might
;be modified by our MACROS...
; We place the addresses of the VDI arrays
move.l #CONTROL,ticontrol(a0)
move.l #INTIN,tiintin(a0)
move.l #PTSIN,tiptsin(a0)
move.l #INTOUT,tiintout(a0)
move.l #PTSOUT,tiptsout(a0)
PRINTLINE FRAME ;text
WAIT ;waiting
DC.W $A00A ;HIDE MOUSE
CCONOUT #27 ;ESC
CCONOUT #'E' ;+ 'E' = clear the screen
move #1,_fg_bp_1(a5)
move #1,_fg_bp_2(a5) ;color=%11=3
move #0,_wrt_mode(a5) ;Write mode AND
move #1,_patmsk(a5) ;1+1=2 data for the PAT
move.l #LINE,_patptr(a5) ;in 'LINE' is
;the new PAT
move #%1111111111111111,_ln_mask(a5) ;solid LINE
move #0,d5 ;0 in d5
move #22,d6 ;22 in d6
LOOP move #0,_x1(a5) ;_x1=0
move d5,_y1(a5) ;_y1=d5
move #630,_x2(a5) ;_x2=630
move d5,_y1(a5) ;_y2=d5
add #9,d5 ;we add 9 to d5
DC.W $A004 ;and we draw the H-LINE
dbf d6,LOOP ;we repeat 23 times
move #0,d5 ;0 in d5
move #42,d6 ;42 in d6
LOOP move d5,_x1(a5) ;_x1=d5
move #0,_y1(a5) ;_y1=0
move d5,_x2(a5) ;_x2=d5
move #197,_y2(a5) ;_y2=197
add #15,d5 ;we add 15 to d5
DC.W $A003 ;and we draw the LINE
dbf d6,LOOP ;we repeat 43 times
WAIT ;waiting
TERM ;end
DATA
LINE DC.W %1111111111111111 ;the PAT (EVEN
DC.W %1111111111111111 ;number of WORDS)
FRAME DC.B 27,'E','I am going to draw a grid ...'
DC.B 13,10,'Functions LINE and H-LINE:',0
BSS
INCLUDE "TABLE.L" ;the VDI Table
END
3) Exercise nr°3:
--------------
Here is the listing of the program that draws a rectangle with a PAT
redefined after loading the previous grid program.
TEXT
INCLUDE "LINEQU.L" ;the EQUs
INCLUDE "INIT_TOS.L" ;Setblock
INCLUDE "MACROS.L" ;The MACROS
SETBLOCK ;initialization
PRINTLINE FRAME ;text
WAIT ;waiting
PEXEC NUL,ZERO,PRG,#0 ;we load the program whose
;name is in 'PRG' in mode
;0 and without parameters.
DC.W $A000 ;We look for the address of the T.I.
movea.l a0,a5 ;We save this address because it
;might be erased by one of our
;MACRO if it uses this
;register...
; We set the VDI table addresses in the T.I.
move.l #CONTROL,ticontrol(a0)
move.l #INTIN,tiintin(a0)
move.l #PTSIN,tiptsin(a0)
move.l #INTOUT,tiintout(a0)
move.l #PTSOUT,tiptsout(a0)
move #1,_fg_bp_1(a5)
move #0,_fg_bp_2(a5) ;Color=%01=1
move #0,_wrt_mode(a5) ;Write mode AND
move #7,_patmsk(a5) ;7+1=8 data for the PAT
move.l #FILL,_patptr(a5) ;The new PAT is in
;'FILL'
;coordinates of the rectangle
move #129,_x1(a5) ;_x1=129
move #24,_y1(a5) ;_y1=24
move #496,_x2(a5) ;_x2=496
move #183,_y2(a5) ;_y2=183
DC.W $A005 ;FILLED RECTANGLE
WAIT ;waiting
TERM ;end
DATA
FILL DC.W %0111111111111110 ;the PAT (EVEN number of
DC.W %0100000000000010 ;WORDS)
DC.W %0101000000001010
DC.W %0101111111111010
DC.W %0101000000001010
DC.W %0100000000000010
DC.W %0111111111111110
DC.W %0000000000000000
FRAME DC.B 27,'E','I am going to draw a square with $A005 '
DC.B 'after loading FRAME.PRG ',0
NUL DC.B 0 ;No environment and
ZERO DC.B 0 ;command line
PRG DC.B 'A:\FRAME.PRG',0 ;the NAME of the prg to load
BSS
INCLUDE "TABLE.L" ;the VDI Table
END
4) Exercise nr° 4:
---------------
Here is the listing of the program that displays the SPRITE.
It was necessary to use UNDRAW SPRITE each time
to be able to display the SPRITE at different coordinates.
It was also necessary to provide ALL the parameters that the DRAW
SPRITE and UNDRAW SPRITE routines need for a correct result.
I chose, for the shape of my SPRITE, an ATARI symbol and my
initials: L-P. (It's not very original, I admit...)
I also use the macro instruction VSYNC to synchronize our
graphic editions: the program is significantly slowed down but the
flickering of the SPRITE display disappears...
TEXT
INCLUDE "LINEQU.L" ;The EQUs
INCLUDE "INIT_TOS.L" ;Setblock
INCLUDE "MACROS.L" ;the MACROS
SETBLOCK ;initialization
DC.W $A000 ;T.I. address in a0 and
movea.l a0,a5 ;in a5 to avoid losing it
;if a MACRO uses the
;a0 register...
; We set the VDI Table addresses in the T.I.
move.l #CONTROL,ticontrol(a0)
move.l #INTIN,tiintin(a0)
move.l #PTSIN,tiptsin(a0)
move.l #INTOUT,tiintout(a0)
move.l #PTSOUT,tiptsout(a0)
PRINTLINE PIX ;text
WAIT ;waiting
DC.W $A00A ;HIDE MOUSE
CCONOUT #27 ;ESC
CCONOUT #'E' ;+'E' = clear the screen
move #0,_wrt_mode(a5) ;Write mode AND
move.l #BLOCK,a0 ;Address of the definition
;block of the SPRITE in a0
move.l #SAVE,a2 ;Address of the Backup Buffer
;in a2 (128 bytes for medium
;resolution)
; The SPRITE first goes from left to right (X coordinate in d0
and Y coordinate in d1)
move #10,X ;1 WORD=10 in 'X'
BBB add #1,X ;Add 1 in 'X'
move X,d0 ;Put the WORD of 'X' in d0
move #100,d1 ;Put 100 in d1
move.l #BLOCK,a0 ;The block address in a0
cmpi #620,d0 ;Is d0=620?
beq TWO ;if YES, go to 'TWO'
move.l #SAVE,a2 ;Otherwise put the address of the Backup
;buffer of the sprite in a2
DC.W $A00C ;and UNDRAW SPRITE
move.l #BLOCK,a0 ;The block address in a0
move.l #SAVE,a2 ;The buffer address in a2
DC.W $A00D ;and DRAW SPRITE
VSYNC ;Synchronize
jmp BBB ;and repeat in 'BBB'
; Then the SPRITE returns from right to left.
TWO sub #1,X ;subtract 1 in 'X'
move X,d0 ;put the word of 'X' in d0
move #100,d1 ;put 100 in d1
move.l #BLOCK,a0 ;The block address in a0
cmpi #10,d0 ;Is d0=10?
beq END ;If YES, then go to 'END'
move.l #SAVE,a2 ;Otherwise address of the buffer in a2
DC.W $A00C ;and UNDRAW SPRITE
move.l #BLOCK,a0 ;The block address in a0
move.l #SAVE,a2 ;The buffer address in a2
DC.W $A00D ;and DRAW SPRITE
VSYNC ;Synchronize
jmp TWO ;and repeat in 'TWO'
END WAIT ;waiting
TERM ;end
DATA
;The definition block of the SPRITE:
BLOCK DC.W 0 ;X of the hot point
DC.W 0 ;Y of the hot point
DC.W 0 ;VDI Format
DC.W 0 ;Mask Color
DC.W 1 ;Foreground Color
DC.W 0 ;no mask
DC.W %0000000000000000 ;1st line of the 1st plan
DC.W 0 ;no mask
DC.W %0000110110110000 ;2nd line of the 1st plan
DC.W 0 ;no mask
DC.W %0000110110110000
DC.W 0
DC.W %0000110110110000
DC.W 0
DC.W %0001100110011000
DC.W 0
DC.W %0011000110001100
DC.W 0
DC.W %0011000110001100
DC.W 0
DC.W %0110000110000110
DC.W 0
DC.W %0110000110000110
DC.W 0
DC.W %0000000000000000
DC.W 0
DC.W %0011000001111100
DC.W 0
DC.W %0011000001101100
DC.W 0
DC.W %0011000001111000
DC.W 0
DC.W %0011000001100000
DC.W 0
DC.W %0011111001100000
DC.W 0 ;no MASK
DC.W %0000000000000000 ;16th line of the 1st plan
PIX DC.B 27,'E','I am going to move a SPRITE with '
DC.B '$A00D',0
BSS
X DS.W 1 ;reserve a WORD in 'X'
SAVE DS.B 128 ;the BUFFER for the SPRITE (MEDIUM
;resolution)
INCLUDE "TABLE.L" ;the VDI table
END
5) Exercise nr°5:
--------------
Here is the listing of the program displaying points of different
colors on the screen.
[...]
(The rest following the same logic of translation and code structure)
6) Exercise nr°6:
--------------
Here is the corrected program that displays diamonds without and then with CLIPPING...
[...]
(The rest following the same logic of translation and code structure)
------------------
That's it for the corrections of the exercises on LineAs...
The listings of these 6 programs as well as the executable programs
are of course on this disk in the files:
1) TRANSMOU.L & TRANSMOU.PRG
2) CADRE .L & CADRE .PRG
3) RECTANGL.L & RECTANGL.PRG
4) SPRITE .L & SPRITE .PRG
5) POINT .L & POINT .PRG
6) POLYGONE.L & POLYGONE.PRG
Laurent PIECHOCKI
8,Impasse Bellevue Continue in the file: INTERRUP.DOC
57980 TENTELING ------------
Back to ASM_Tutorial