Pl2 LINEA.DOC

From Atari Wiki
Revision as of 20:23, 17 December 2023 by Olivier.jan (talk | contribs)
Jump to navigation Jump to search


--------------------
CHAPTER NR°8:

THE LINEAS

--------------------

*** INTRODUCTION ***
--------------------

- LineAs are graphical functions, they are very simple
  but have the advantage of being really very fast.
  (Much more than the VDI...)

  LineAs are commands of the 'BLITTER', i.e., it is the HARDWARE
  (Some PHYSICAL components of the computer and the routines that
  are executed by the PROCESSOR himself.) that execute these func-
  tions and not the SOFTWARE (The SOFTWARE part of your computer:
  ROM, programs...).
  If your ST is equipped with the BLITTER of course... (The MEGA 2ST and the
  MEGA 4ST are equipped.)
  
  NB: There is a SOFTWARE version of the BLITTER that is available in the public
  --- domain in the form of a desktop accessory...
  
  These functions are very fast since not coming from the SOFTWARE, the
  routines do not need to be interpreted by the PROCESSOR.

- To call the LineAs functions, you will have to provide the appro-
  priate parameters in the VDI TABLE and also in an INTERNAL TABLE
  specific to LineAs.
  Some registers will also be used.

  Indeed, the LineAs use the VDI's CONTROL, PTSIN, PTSOUT,
  INTIN, and INTOUT arrays.
  Registers d0, d1, d2, a0, a1, a2 will also be used, so you will have
  to be careful not to lose their content...
  Some parameters are also provided by the LineAs in return in
  d0, a0 or INTOUT (here again, be careful not to lose d0!)

  We have seen that the LineAs use an INTERNAL TABLE:

  It is in this table that the functions search for the parameters
  that we have deposited, the only problem is that the location of this
  internal table varies (hence its name).

  To find the location of this internal table, just
  call the function $A000 with:

  DC.W  $A000

  What a strange syntax isn't it??

  The explanation is very simple: During the ASSEMBLY step of your
  listing, the ASCII codes representing the instructions and their operands
  will be translated into BINARY because the 68000 only recognizes
  information coded in binary:
  Thus, a NOP will be translated by %100111001110001, a RTS by %0100111
  001110101 etc... and so for all instructions.
  If we translate these codes from binary to HEXADECIMAL, we obtain
  instructions coded in HEX:
  Thus, NOP will be written: $4E71
  and    RTS will be written: $4E75
  etc...

  However,
  --
  You can REPLACE, in an ASSEMBLER program, an instruction
  by its HEX CODE equivalent if it is declared as such in
  the TEXT segment, it would suffice to write:

  DC.W  $4E71 instead of a NOP  (or DC.B  $4E, $71)
  or
  DC.W  $4E75 instead of an RTS ... (or DC.B  $4E, $75)

  This remains valid for all the instructions of the 68000 (Even for
  labels).

  But,
  ----
  No 68000 instruction will be coded in HEX by a WORD of type:

  $A...  (or $F...)

  We have therefore filled this lack (we rather took advantage of it!) by coding
  the LineAs functions in $A...

  NB: There are also $F... routines but we will not use them
  -- because they are not compatible between the OLD ROM and NEW ROM versions
     of the ST.

  It will therefore suffice to write  DC.W  $A...  for the 68000 to decode this
  instruction by the LineA instruction of code $A...

  There are a total of 16 commands that are installed and that can
  be translated this way, these are the 16 LineAs routines:

  To call them simply DECLARE them in the TEXT segment:

 The LineAs:
-----------
$A000: Installs the internal table
$A001: Places 1 point on the screen
$A002: Sets the color of a screen point
$A003: Draws an arbitrary line
$A004: Draws a horizontal line
$A005: Draws a filled rectangle
$A006: Draws a filled polygon
$A007: ?
$A008: Allows text block transfer
$A009: Activates the mouse cursor
$A00A: Deactivates the mouse cursor
$A00B: Modifies the shape of the mouse cursor
$A00C: Erases a sprite
$A00D: Draws a sprite
$A00E: Copies a block of points
$A00F: Identical to VDI's CONTOUR FILL function (opcode=103)

But let's now focus on our $A000 function:

We have seen earlier that it initializes the INTERNAL TABLE in which we will place parameters. This TABLE contains 50 variables, some the size of a word and some the size of a long word. To obtain the address where the table begins, we use the function $A000:

DC.W  $A000

The function provides us with the address where the table is located in A0:

We can now access all the variables in this table using an INDIRECT addressing mode. However, since the variables do not all have the same size (word or long word), the (a0)+ and (a0) addressing modes will not be used...

We will use the d(a0) addressing mode to access the different parameters of the table:

So, MOVE.W 0(a0) will place the word=0 in the 1st parameter of the table,
MOVE.W 2(a0) will place the word=0 in the parameter at a0+2,
and so on...

Therefore, we need to know the values of the relative locations of the variables in the table. Since the d(a0) syntax is not very informative, we will define (with EQU) the relative locations of all these variables:

Here they are:
   
; Definition of EQUIVALENCES for the INTERNAL TABLE of LineAs

; Variable NAME = Relative Displacement

v_planes        EQU       0                ;number of planes
v_lin_wr        EQU       2                ;bytes per write line
ticontrol       EQU       4                ;address of T.I CONTROL
tiintin         EQU       8                ;address of T.I INTIN
tiptsin         EQU       12               ;address of T.I PTSIN
tiintout        EQU       16               ;address of T.I INTOUT
tiptsout        EQU       20               ;address of T.T PTSOUT
_fg_bp_1        EQU       24               ;bit 0 of color
_fg_bp_2        EQU       26               ;bit 1 of color
_fg_bp_3        EQU       28               ;bit 2 of color
_fg_bp_4        EQU       30               ;bit 3 of color
_lstlin         EQU       32               ;always =-1
_ln_mask        EQU       34               ;line shape for $A003
_wrt_mode       EQU       36               ;WRITE MODE
_x1             EQU       38               ;X coordinate of the first point
_y1             EQU       40               ;Y coordinate of the first point
_x2             EQU       42               ;X coordinate of the second point
_y2             EQU       44               ;Y coordinate of the second point
_patptr         EQU       46               ;fill address
_patmsk         EQU       50               ;fill number
_multifill      EQU       52               ;details later
_clip           EQU       54               ;clipping flag
_xmn_clip       EQU       56               ;leftmost X for clipping
_ymn_clip       EQU       58               ;highest Y for clipping
_xmx_clip       EQU       60               ;rightmost X for clipping
_ymx_clip       EQU       62               ;lowest Y for clipping
_xacc_dda       EQU       64               ;points to $8000 for TXTBLT  
_dda_inc        EQU       66               ;enlargement factor=$FFFF
_t_sclsts       EQU       68               ;=0                   
_mono_status    EQU       70               ;TEXT EFFECTS type
_sourcex        EQU       72               ;character number in SET  
_sourcey        EQU       74               ;=0  
_destx          EQU       76               ;X coordinate of TEXT
_desty          EQU       78               ;Y coordinate of TEXT  
_delx           EQU       80               ;character width  
_dely           EQU       82               ;character height
_fbase          EQU       84               ;SET address  
_fwidth         EQU       88               ;SET X
_style          EQU       90               ;FLAG for TEXT EFFECTS  
_litemark       EQU       92               ;shading mask  
_skewmask       EQU       94               ;TEXT inclination mask
_weight         EQU       96               ;number of enlargement bits  
_r_off          EQU       98               ;offset for TEXT italic 
_l_off          EQU       100              ;left (Left) offset 
_scale          EQU       102              ;enlargement flag (1/0)       
_chup           EQU       104              ;TEXT rotation angle  
_txt_fg         EQU      

Back to ASM_Tutorial