Pl2 CORRIG 3.DOC: Difference between revisions

From Atari Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 101: Line 101:
 
--------------
 
--------------
 
Again, no major difficulty...
 
Again, no major difficulty...
Just needed to be careful to use graphical coordinates that match the used resolution.
+
It was just necessary to pay attention to using graphical coordinates
  +
that correspond to the used resolution.
   
 
(OX)=640 from 0 to 339
 
(OX)=640 from 0 to 339
Line 113: Line 114:
 
INCLUDE "MACROS.L" ;The macros
 
INCLUDE "MACROS.L" ;The macros
   
[...]
+
SETBLOCK ;initialization
  +
(Rest following the same logic of translation and code structure)
 
  +
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:
 
3) Exercise nr°3:
 
--------------
 
--------------
Here is the listing of the program that draws a rectangle with a PAT
+
Here is the listing of the program that draws a rectangle with a PAT
redefined after having loaded the previous grid program.
+
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
(The rest following the same logic of translation and code structure)
+
;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...
   
 
4) Exercise nr° 4:
 
4) Exercise nr° 4:

Revision as of 15:52, 17 December 2023


                         ---------

                   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...

4) Exercise nr° 4:
   ---------------

               [...]
               (The rest following the same logic of translation and code structure)


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