[comp.sys.atari.st] My Line-A Support

jimomura@lsuc.on.ca (Jim Omura) (11/10/90)

     Thanks to all who helped me with the Line-A stuff.  Since
I've finished all that I intend to do for now, I'm declaring it
Public Domain.  Those of you who are more proficient than me,
please don't laugh too hard -- the hospitals don't need more
hernia patients. :-)

#!/bin/sh
# This is a shell archive (shar 3.11)
# made 11/10/1990 14:09 UTC by jimomura@lsuc.on.ca
# Source directory /scr/jimomura/tempdir
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   1126 -rw-r--r-- Readme
#   4895 -rw-r--r-- grtest.c
#   1256 -rw-r--r-- line_a.h
#   5113 -rw-r--r-- line_a.s
#
touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
if [ -s /tmp/s3_touch$$ ]
then
	TOUCH=can
else
	TOUCH=cannot
fi
rm -f /tmp/s3_touch$$
# ============= Readme ==============
echo "x - extracting Readme (Text)"
sed 's/^X//' << 'SHAR_EOF' > Readme &&
X1990/11/10
X
X     I have finished working up the Line_A support as far as I
Xneed it for the time being.  As such, I have no intention to
Ximpliment any more.  In saying this, I should note that I don't
Xreally have enough information onhand to finish all the possible
Xfunctions anyway, though I have enough to do a fair bit more than
XI have.
X
X     This file set includes the following:
X
X1.  'line_a.h' is the header file I'm currently using.  It is based
X    on information from "Atari ST Internals" (Data Becker).
X
X2.  'line_a.s' is the actual assembly source code for Sozobon C
X    version 1.2.  NOTE that the individual functions can be separated.
XThe transition marker lines are in the following format:
X
X; *** End of functionname ***
X
XIf you search for the 3 asterisks you'll find the transition markers
Xand just have to "cut out" what you need.
X
X3.  'grtest.c' is a crude test program I used to test the functions.
X    There is some imbedded documentation in the file.
X
X     All the files in this set are PUBLIC DOMAIN.
X
XCheers! -- Jim O.
X
X'jimomura@lsuc'
XJim Omura, 2A King George's Drive, Toronto, Ontario, Can., M6M 2G8
SHAR_EOF
chmod 0644 Readme || echo "restore of Readme fails"
if [ $TOUCH = can ]
then
    touch -am 1110090990 Readme
fi
set `wc -c Readme`;Wc_c=$1
if test "$Wc_c" != "1126"
then echo original size 1126, current size $Wc_c;fi
# ============= grtest.c ==============
echo "x - extracting grtest.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > grtest.c &&
X/* GrTest.C */
X
X/* Test A-Line Graphics Routines */
X
X#include <stdio.h>
X#include "line_a.h"
X
Xshort vplanes;
Xshort vlinwr;
X
Xshort *cntrl;
Xshort *intin;
Xshort *ptsin;
Xshort *intout;
Xshort *ptsout;
X
X/* The following for 'foregrnd()' if used: */
Xshort plane1;
Xshort plane2;
Xshort plane3; /* My correction -- Jim O. */
Xshort plane4; /* My correction -- Jim O. */
X
X/* The following for 'fgrnd() if used: */
Xshort colour; /* This is NOT a true A Line var. -- Jim O. */
X
X/* short lstlin; Not Used */
X
Xshort lnmask;
Xshort wrtmod; /* My correction -- Jim O. */
Xshort x1;
Xshort y1;
Xshort x2;
Xshort y2;
Xshort *patptr; /* "long" Pointer to "short" array */
Xshort patmsk;
Xshort multifill;
Xshort clip;
Xshort xmnclip;
Xshort ymnclip;
Xshort xmxclip;
Xshort ymxclip;
Xshort xaccdda;
Xshort ddainc;
Xshort tsclsts;
Xshort monostatus;
Xshort sourcex;
Xshort sourcey;
Xshort destx;
Xshort desty;
Xshort delx;
Xshort dely;
Xlong  fbase;
Xlong  fwidth;
Xshort style;
Xshort litemask;
Xshort skewmask;
Xshort weight;
Xshort roff;
Xshort loff;
Xshort scale;
Xshort chup;
Xshort textfg;
Xlong  scrtchp;
Xshort scrpt2;
Xshort textbg;
Xshort copytran;
X
Xshort fillpat[] = { 0xffff,0xffff };
X
Xmain()
X{
X    extern LINE_A *algtbase();
X    char          buffer[10];
X    short         fast; /* Switch for MCShow() */
X    LINE_A        *stpntr;
X
X    stpntr = algtbase(); /* Get A-Line Data Struct Base */
X
X#ifdef DOCUMENTATION
X#include "line_a.h"
XLINE_A *algtbase();
X
XReturns pointer to A-Line Structure
X#endif
X
X    printf("A-Line Data at %1ld\n",stpntr);
X
X/* Line Function Test: */
X
X#ifdef DOCUMENTATION
Xinclude <line_a.h>
Xvoid fgrnd(stpntr,colour);
XLINE_A *stpntr;
Xint    colour;
X
XSets the foreground colour to "colour".
X
XALTERNATIVE CALL:
Xvoid foregrnd(stpntr,plane1,plane2,plane3,plane4);
Xint    plane1, plane2, plane3, plane4;
X/* The lowest bit in a colour register corresponds to plane1 */
X
X     There might be some advantage for using this
Xlatter call where 1 plane is specifically being changed
Xoften.  The call has been tested and works.
X
X#endif
X
X    colour = 1;
X
X    fgrnd(stpntr,colour);  /* Set Foreground Colour */
X
X    wrtmod = 0;
X    lnmask = -1;
X
X    setlmsk(stpntr,wrtmod,lnmask);
X
X    x1 = 39;
X    y1 = 39;
X    x2 = 55;
X    y2 = 55;
X
X    line(stpntr,x1,y1,x2,y2);
X
X/* Get Pixel Function test: */
X
X    colour = getpxl(stpntr,x1,y1);
X
X    printf("Colour %1d\n",colour);
X
X/* Horizontal Line Function Test: */
X
X    patptr = fillpat;
X    patmsk = 1;
X
X    setfmsk(stpntr,wrtmod,patptr,patmsk);
X
X#ifdef DOCUMENTATION
Xinclude <line_a.h>
Xvoid setfmsk(stpntr,wrtmod,patptr,patmsk);
XLINE_A *stpntr;
Xshort wrtmod;
Xshort *patptr; /* The pointer itself is 'long' */
Xshort patmsk; /* Number of mask words -1 */
X     If a mask is needed, 'patmsk' is the number of bit pattern
Xwords less 1.  Therefore "0" means 1 word, "1" means 2 words, etc.
X'Patptr' points to the array.
X#endif
X
X    x1 = 60;
X    y1 = 60;
X    x2 = 72;
X
X    hline(stpntr,x1,y1,x2);
X
X/* Filled Box Function Test: */
X
X    clip = 0;
X    xmnclip = 0; /* Dummy values, unused */
X    ymnclip = 0;
X    xmxclip = 0;
X    ymxclip = 0;
X
X    setclip(stpntr,clip,xmnclip,ymnclip,xmxclip,ymxclip);
X
X#ifdef DOCUMENTATION
Xinclude <line_a.h>
Xvoid setclip(stpntr,clip,xmnclip,ymnclip,xmxclip,ymxclip);
XLINE_A *stpntr;
Xshort clip; /* Clip mode flag */
Xshort xmnclip; /* Upper Left X */
Xshort ymnclip; /* Upper Left Y */
Xshort xmxclip; /* Lower Right X */
Xshort,ymxclip; /* Lower Right Y */
X
X#endif DOCUMENTATION
X
X    x1 = 3;
X    y1 = 27;
X    x2 = 7;
X    y2 = 31;
X
X    fbox(stpntr,x1,y1,x2,y2);
X
X#ifdef DOCUMENTATION
Xinclude <line_a.h>
Xvoid fbox(stpntr,x1,y1,x2,y2);
XLINE_A *stpntr; /* Pointer to Line-A variable structure */
Xshort x1,y1;   /* Coordinates of upper left corner */
Xshort x2,y2;   /* Coordinates of lower right corner */
X
XShort Explanation:
X     Makes a FILLED BOX.
X
XAffected by:
X foregrnd() /* sets new drawing color */
X setfmsk() /* sets Fill mask */
X setclip() /* sets clip */
X
X#endif DOCUMENTATION
X
X/* Test Mouse Cursor Show and Hide */
X
X#ifdef DOCUMENTATION
X
Xvoid mchide()
X
XHide Mouse Cursor
X
XCalls to MCHide() are counted by the OS for MCShow().
X
X#endif DOCUMENTATION
X
X#ifdef DOCUMENTATION
X
X#include "line_a.h"
X
Xvoid mcshow(spntr,fast)
XLINE_A *spntr;
Xshort fast;
X
XShow Mouse Cursor
X If 'fast' = 0 then the mchide() count is bypassed
X If 'fast' != 0 then mchide() count is active and
X mouse will not be shown until "show" calls > "hide"
X
X#endif DOCUMENTATION
X
X    printf ("0 = Fast Show, 1 = Show, 2 = Hide, 3 = Quit\n");
X    fast = 0;
X    for(;;)
X    {
X        fgets(buffer,10,stdin);
X        switch( atoi(buffer))
X        {
X        case 0:
X            mcshow(stpntr,0);
X            continue;
X        case 1:
X            mcshow(stpntr,1);
X            continue;
X        case 2:
X            mchide();
X            continue;
X        default:
X            break;
X        }   /* Endswitch */
X
X        break; /* Exit Loop */
X
X    }   /* Endloop */
X
X}   /* End of main() */
X
X/* End of grtest.c */
SHAR_EOF
chmod 0644 grtest.c || echo "restore of grtest.c fails"
if [ $TOUCH = can ]
then
    touch -am 1110085790 grtest.c
fi
set `wc -c grtest.c`;Wc_c=$1
if test "$Wc_c" != "4895"
then echo original size 4895, current size $Wc_c;fi
# ============= line_a.h ==============
echo "x - extracting line_a.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > line_a.h &&
X/* Line_A.h */
X
X/* By Jim Omura */
X
Xtypedef struct /* According to info in  "Atari ST Internals" */
X{
X    short v_planes,
X          v_lin_wr;
X    short *CNTRL, /* Note that Pointers to 'short' are 'long' */
X          *INTIN,
X          *PTSIN,
X          *INTOUT,
X          *PTSOUT;
X    short _FG_BP_1,
X          _FG_BP_2,
X          _FG_BP_3, /* My correction -- Jim O. */
X          _FG_BP_4,
X          _LSTLIN,
X          _LN_MASK,
X          _WRT_MOD, /* My correction -- Jim O. */
X          _X1,
X          _Y1,
X          _X2,
X          _Y2;
X    short *_patptr; /* "long" pointer to "short" array */
X    short _patmsk,
X          _multifill,
X          _CLIP,
X          _XMN_CLIP,
X          _YMN_CLIP,
X          _XMX_CLIP,
X          _YMX_CLIP,
X          _XACC_DDA,
X          _DDA_INC,
X          _T_SCLSTS,
X          _MONO_STATUS,
X          _SOURCEX,
X          _SOURCEY,
X          _DESTX,
X          _DESTY,
X          _DELX,
X          _DELY;
X    long  _FBASE,
X          _FWIDTH;
X    short _STYLE,
X          _LITEMASK,
X          _SKEWMASK,
X          _WEIGHT,
X          _R_OFF,
X          _L_OFF,
X          _SCALE,
X          _CHUP,
X          _TEXT_FG;
X    long  _scrtchp;
X    short _scrpt2,
X          _TEXT_BG,
X          _COPYTRAN;
X} LINE_A;
X
X/* End of Line_A.h */
SHAR_EOF
chmod 0644 line_a.h || echo "restore of line_a.h fails"
if [ $TOUCH = can ]
then
    touch -am 1110085190 line_a.h
fi
set `wc -c line_a.h`;Wc_c=$1
if test "$Wc_c" != "1256"
then echo original size 1256, current size $Wc_c;fi
# ============= line_a.s ==============
echo "x - extracting line_a.s (Text)"
sed 's/^X//' << 'SHAR_EOF' > line_a.s &&
X	.text
X	.globl	_algtbase
X_algtbase:
X; int algtbase()
X; Get Pointer to A-Line Data Structure
X; Sozobon C Line-A Support By Jim Omura
X	link	a6,#-0
X;
X        .dc.w	$a000		; A-Line pseudo-instruction
X; Return value is already in D0
X	unlk	a6
X	rts
X;
X	.data
X; *** End of algtbase ***
X	.text
X	.globl	_fbox
X_fbox:
X; void fbox(spntr,x1,y1,x2,y2)
X; LINE_A *spntr;
X; int x1,y1,x2,y2;
X; Filled Box
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_x1
X;var	2	14	_y1
X;var	2	16	_x2
X;var	2	18	_y2
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	move.w	12(a6),38(a0)
X	move.w	14(a6),40(a0)
X	move.w	16(a6),42(a0)
X	move.w	18(a6),44(a0)
X;
X	.dc.w	$a005		; Pseudo Instruction
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of fbox ***
X	.text
X	.globl	_fgrnd
X_fgrnd:
X; void fgrnd(spntr,colour)
X; LINE_A spntr;
X; int    colour;
X; Set Foreground Colour
X; Sozobon C Line-A Support Function by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_colour
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	lea	24(a0),a0	; A0 points at Plane 1
X	move.w	12(a6),d1	; D1 = Colour Reg.
X	moveq	#3,d2		; D2 = Loop Counter
X;
XDISTLP:				; Start Loop "Distribute Bits"
X; *** Hugh Redelmeier's version:
X	clr.w	(a0)
X	lsr.w	#1,d1
X; NOTE: Last Bit shifted out sets CCR Carry and eXtend Flags
X	roxl.w	(a0)+		;   Store remainder in Bit Plane & incr.
X;
XNEXT:
X	dbra	d2,DISTLP	; End of Loop
X;
X	unlk	a6
X	rts
X	.data
X; *** End of fgrnd ***
X	.text
X	.globl	_getpxl
X_getpxl:
X; int getpxl(spntr,x,y);
X; LINE_A *spntr;
X; int x,y;
X;
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_x
X;var	2	14	_y
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	lea	12(a0),a0	; A0 points at PTSIN
X	movea.l	(a0),a0		; A0 = PTSIN
X;
X	move.w	12(a6),(a0)+	; Store X
X	move.w	14(a6),(a0)	; Store Y
X	.dc.w	$a002		; Pseudo Instruction returns colour in D0
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of getpxl ***
X	.text
X	.globl	_hline
X_hline:
X; void hline(spntr,x1,y1,x2)
X; LINE_A *spntr;
X; int x1, y1; /* Start Point */
X; int x2;     /* End point */
X;
X; Horizontal Line
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_x1
X;var	2	14	_y1
X;var	2	16	_x2
X;
X	link a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	move.w	12(a6),38(a0)
X	move.w	14(a6),40(a0)
X	move.w	16(a6),42(a0)
X;
X	.dc.w	$a004		; Pseudo Instruction
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of hline ***
X	.text
X	.globl	_line
X_line:
X; void line(spntr,x1,y1,x2,y2);
X; LINE_A *spntr;
X; int x1,y1; /* Start Point */
X; int x2,y2; /* End Point */
X;
X; General Line Draw
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_x1
X;var	2	14	_y1
X;var	2	16	_x2
X;var	2	18	_y2
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	move.w	12(a6),38(a0)
X	move.w	14(a6),40(a0)
X	move.w	16(a6),42(a0)
X	move.w	18(a6),44(a0)
X;
X	.dc.w	$a003		; Pseudo Instruction
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of line ***
X	.text
X	.globl	_mchide
X_mchide:
X; void mchide()
X; NO Variables
X;
X; Mouse Cursor Hide
X; Sozobon C Line-A Support by Jim Omura
X;
X	link	a6,#-0
X;
X	.dc.w	$a00a	; Pseudo Instruction
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of mchide ***
X	.text
X	.globl	_mcshow
X_mcshow:
X; void mcshow(spntr,fast)
X; LINE_A *spntr;
X; short fast; /* 0 = Fast, 0 != count MCHides */
X;
X; Mouse Cursor Show
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_fast
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0	; A0 = spntr
X	lea.l	4(a0),a1	; A1 points at CONTRL
X	movea.l	(a1),a1		; A1 = CONTRL
X	move.w	#0,2(a1)	; word CONTRL(1) = 0
X	move.w	#1,6(a1)	; word CONTRL(3) = 1
X;
X	lea	8(a0),a1	; A1 points at INTIN
X	movea.l	(a1),a1		; A1 = INTIN
X	move.w	12(a6),(a1)	; INTIN(0) = fast
X;
X	.dc.w	$a009		; Pseudo Instruction
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of mcshow ***
X	.text
X	.globl	_setclip
X_setclip:
X; void setclip(spntr,clip,xmnclip,ymnclip,xmxclip,ymxclip)
X; LINE_A *spntr;
X; int clip;
X; int xmnclip, ymnclip; Upper Left Corner
X; int xmxclip, ymxclip; Lower Right Corner
X;
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_clip
X;var	2	14	_xmnclip
X;var	2	16	_ymnclip
X;var	2	18	_xmxclip
X;var	2	20	_ymxclip
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0		; A0 = spntr
X	move.w	12(a6),54(a0)
X	move.w	14(a6),56(a0)
X	move.w	16(a6),58(a0)
X	move.w	18(a6),60(a0)
X	move.w	20(a6),62(a0)
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of setclip ***
X	.text
X	.globl	_setfmsk
X_setfmsk:
X; void setfmsk(spntr,wrtmod,patptr,patmsk)
X; LINE_A *spntr;
X; short wrtmod, *patptr, patmsk;
X;
X; Set Fill Mask
X; Line-A Support Module By Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_wrtmod
X;var	4	14	_patptr
X;var	2	18	_patmsk
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0		; A0 = spntr
X	move.w	12(a6),36(a0)
X	move.l	14(a6),46(a0)
X	move.w	18(a6),50(a0)
X;
X; No Pseudo Instruction -- Just setting parameters.
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of setfmsk ***
X	.text
X	.globl	_setlmsk
X_setlmsk:
X; void setlmsk(spntr,wrtmod,lnmask);
X; LINE_A *spntr;
X; int wrtmod;
X; int lnmsk;
X;
X; Set Line Mask
X; Sozobon C Line-A Support by Jim Omura
X;
X;var	4	8	_spntr
X;var	2	12	_wrtmod
X;var	2	14	_lnmask
X;
X	link	a6,#-0
X;
X	movea.l	8(a6),a0		; A0 = spntr
X	move.w	12(a6),36(a0)
X	move.w	#-1,32(a0)		; _LSTLIN is always -1
X	move.w	14(a6),34(a0)
X;
X; No Pseudo-Op needed -- Just setting data.
X;
X	unlk	a6
X	rts
X;
X	.data
X; *** End of setlmsk ***
SHAR_EOF
chmod 0644 line_a.s || echo "restore of line_a.s fails"
if [ $TOUCH = can ]
then
    touch -am 1110084790 line_a.s
fi
set `wc -c line_a.s`;Wc_c=$1
if test "$Wc_c" != "5113"
then echo original size 5113, current size $Wc_c;fi
exit 0
-- 
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
lsuc!jimomura
Byte Information eXchange: jimomura