koreth@panarthea.ebay.sun.com (Steven Grimm) (10/04/89)
Submitted-by: kruysbergen@hnykun53.bitnet (Noud van Kruysbergen)
Posting-number: Volume 2, Issue 86
Archive-name: degadesk
These are the sources to the DESKTOP1.UUE programs [posted to binaries -sg].
Greetings,
Noud van Kruysbergen
kruysbergen@hnykun53.bitnet
#!/bin/sh
# shar: Shell Archiver (v1.22)
#
# Run the following text with /bin/sh to create:
# DESKTOP1.C
# DESKTOP3.C
# DESKTOP2.S
#
sed 's/^X//' << 'SHAR_EOF' > DESKTOP1.C &&
X; **************************************************************************
X; This is the source of DESKTOP.ACC, a program that changes the normal gray
X; background with a Degas P?3 file. This source is public domain, but I
X; would appreciate it very much if a program that uses (part) of this
X; source respects the name of the author!
X; **************************************************************************
X; This source is written for Megamax C, with the inline assembly.
X; **************************************************************************
X; Noud van Kruysbergen
X; N.I.C.I.
X; P.O. Box 9104
X; 6500 HE Nijmegen
X; The Netherlands
X; email: kruysbergen@hnykun53.bitnet
X; **************************************************************************
X#include <gemdefs.h>
X#include <stdio.h>
X#include <osbind.h>
X#include <gembind.h>
X
Xint status=1;
Xint handle;
Xint menu_id,msgbf[8];
Xint i,j;
Xlong l,picstart,bufcount,piccount;
X
Xstatic long _oldgem();
Xstatic long _newgem();
X
Xstatic int _style(),_interior(),_mode();
Xextern int gl_apid;
Xstatic long _buffer();
Xlong buffer;
X
Xstatic int _clipx0(),_clipy0(),_clipx1(),_clipy1();
Xchar path[50],file[14];
Xchar t[70];
X
Xchar newdta[44];
X
Xnewroutines()
X{
X asm
X {
X dc.l 0x58425241
X dc.l 0x4e5f4450
X dc.l 0L
X
X _newgem: cmpi.w #115,D0
X bne gemquit
X movem.l D0-A3,-(A7)
X
X move.l D1,A0
X move.l (A0),A0
X move.w (A0),D0
X
X cmpi.w #114,D0
X bne nofill
X lea _interior,A0
X move.w (A0),D0
X cmpi.w #2,D0
X bne gemrest
X lea _style,A0
X move.w (A0),D0
X cmpi.w #4,D0
X bne gemrest
X
X lea _mode,A0
X move.w (A0),D0
X beq gemrest
X move.l D1,A0
X move.l 8(A0),A0
X move.w (A0)+,D0
X bne gemrest
X move.w (A0)+,D0
X cmpi.w #19,D0
X beq menu
X tst.w D0
X bne gemrest
X menu: move.w (A0)+,D0
X cmpi.w #639,D0
X bne gemrest
X move.w (A0),D0
X cmpi.w #399,D0
X bne gemrest
X
X move.l 0x44e,A1
X; A1: screenadress
X move.w _clipy0,D0
X move.w D0,D2
X; D2: y0
X muls #80,D0
X adda.l D0,A1
X; A1: screenadress + y0 offset
X lea _buffer,A0
X move.l (A0),A0
X; A0: pictureadress
X adda.l D0,A0
X; A0: pictureadress + y0 offset
X move.w _clipy1,D0
X sub.w D2,D0
X move.w D0,D2
X; D2: total number of lines
X move.w _clipx0,D3
X; D3: x0
X move.w D3,D7
X ext.l D7
X divs #8,D7
X move.w D7,D3
X adda.l D3,A0
X adda.l D3,A1
X; D3: x0/8
X swap D7
X move.w D7,D4
X; D4: x0%8
X move.w _clipx1,D5
X addq.w #1,D5
X; D5: x1
X move.w D5,D7
X ext.l D7
X divs #8,D7
X move.w D7,D5
X; D5: x1/8
X swap D7
X move.w D7,D6
X; D6: x1%8
X move.l D5,D0
X sub.l D3,D0
X bne label3
X
X move.w D6,D7
X subi.w #8,D7
X neg.w D7
X move.b #-1,D3
X lsr.b D7,D3
X lsl.b D7,D3
X lsl.b D4,D3
X lsr.b D4,D3
X loop2: move.b D3,D5
X move.b (A0),D7
X and.b D5,D7
X not.b D5
X and.b (A1),D5
X add.b D5,D7
X move.b D7,(A1)
X adda.l #80,A0
X adda.l #80,A1
X dbf D2,loop2
X bra selfok
X
X label3: subq.w #1,D0
X tst.w D4
X seq D5
X beq yloop
X tst.w D0
X sne D5
X beq yloop
X subq.w #1,D0
X; first incomplete byte
X yloop: move.l A0,A2
X move.l A1,A3
X tst.w D4
X beq nostart
X move.b (A2)+,D3
X move.b #-1,D7
X lsr.b D4,D7
X and.b D7,D3
X not.b D7
X and.b (A3),D7
X; D1 contains lowest picturebits, D7 highest backgroundbits
X add.b D3,D7
X move.b D7,(A3)+
X
X nostart: move.w D0,D7
X tst.w D5
X beq endbyte
X xloop: move.b (A2)+,(A3)+
X dbf D7,xloop
X; last incomplete byte
X endbyte: tst.w D6
X beq no_end
X move.b (A2)+,D3
X move.b #-1,D7
X lsr.b D6,D7
X not.b D7
X and.b D7,D3
X not.b D7
X and.b (A3),D7
X add.b D3,D7
X move.b D7,(A3)
X
X no_end: adda.l #80,A0
X adda.l #80,A1
X label1: dbf D2,yloop
X
X selfok: movem.l (A7)+,D0-A3
X rte
X
X nofill: move.l D1,A0
X move.l 4(A0),A0
X move.w (A0),D2
X cmpi.w #23,D0
X bne nointerior
X lea _interior,A0
X move.w D2,(A0)
X bra gemrest
X
X nointerior:cmpi.w #24,D0
X bne nostyle
X lea _style,A0
X move.w D2,(A0)
X bra gemrest
X
X nostyle: cmpi.w #129,D0
X bne gemrest
X lea _mode,A0
X move.w D2,(A0)
X beq gemrest
X move.l D1,A0
X move.l 8(A0),A0
X lea _clipx0,A1
X move.w (A0)+,(A1)
X lea _clipy0,A1
X move.w (A0)+,(A1)
X lea _clipx1,A1
X move.w (A0)+,(A1)
X lea _clipy1,A1
X move.w (A0),(A1)
X
X gemrest: movem.l (A7)+,D0-A3
X gemquit: move.l _oldgem,-(A7)
X rts
X
X _oldgem: dc.l 0L
X _buffer: dc.l 0L
X _style: dc.w 0
X _interior:dc.w 0
X _mode: dc.w 0
X _clipx0: dc.w 0
X _clipy0: dc.w 0
X _clipx1: dc.w 0
X _clipy1: dc.w 0
X }
X}
X
XReadfile()
X{
X handle=-1;
X strcpy(t,path);
X j=0;
X while(t[j++]!='*' && j<70);
X if (j<70)
X {
X path[j]=0;
X t[--j]=0;
X strcat(path,".P?3");
X strcat(t,file);
X if ((handle=Fopen(t,0))>=0)
X {
X Fseek(34L,handle,0);
X j=strlen(file);
X if (file[--j]=='3' && file[--j]=='C')
X {
X l=Fsetdta(newdta);
X Fsfirst(t,0);
X Fsetdta(l);
X l=*(long *)(newdta+26);
X if (piccount=picstart=Malloc(l))
X {
X l=Fread(handle,l,picstart);
X bufcount=buffer;
X do
X {
X asm
X {
X move.l piccount(A4),A0
X move.b (A0),D0
X ext.w D0
X and.w #0xff,D0
X move.w D0,j(A4)
X addq.l #1,piccount(A4)
X }
X if (j<128)
X {
X asm
X {
X move.l bufcount(A4),A2
X move.l piccount(A4),A1
X move.w j(A4),D0
X pic1loop: move.b (A1)+,(A2)+
X dbf D0,pic1loop
X move.l A1,piccount(A4)
X move.l A2,bufcount(A4)
X }
X }
X else
X {
X if (j!=128)
X {
X j^=255;
X asm
X {
X move.l bufcount(A4),A2
X move.l piccount(A4),A1
X move.w j(A4),D0
X addq.w #1,D0
X pic2loop: move.b (A1),(A2)+
X dbf D0,pic2loop
X addq.l #1,piccount(A4)
X move.l A2,bufcount(A4)
X }
X }
X }
X }
X while((piccount-picstart<l) && (bufcount-buffer<32000L));
X Mfree(picstart);
X }
X else form_error(8);
X }
X else Fread(handle,32000L,buffer);
X Fclose(handle);
X }
X }
X return(handle);
X}
X
XInstall()
X{
X asm
X {
X lea _oldgem,A0
X move.l 0x88,(A0)
X lea _newgem,A1
X move.l A1,0x88
X move.l (A0),-4(A1)
X }
X}
X
Xmain()
X{
X appl_init();
X buffer=Malloc(32000L);
X asm
X {
X lea _buffer,A0
X move.l buffer(A4),(A0)
X }
X strcpy(t,"A:\\DESKTOP.P?3");
X strcpy(path,"A:\\*.P?3");
X t[file[0]=0]=path[0]=(char)(Dgetdrv()+65);
X Fsetdta(newdta);
X i=Fsfirst(t,0);
X if (!i)
X {
X strcpy(file,(char *)(newdta+30));
X if (Readfile()<0) status=file[0]=0;
X else Supexec(Install);
X }
X menu_id=menu_register(gl_apid," Desktop Picture");
X while ()
X {
X evnt_mesag(msgbf);
X/*************************************************************
X--- for version 2.01: include these lines ---
X if (status)
X {
X l=Super(0L);
X asm
X {
X lea _newgem,A1
X cmpa.l 0x88,A1
X beq already
X lea _oldgem,A0
X move.l 0x88,(A0)
X move.l A1,0x88
X move.l (A0),-4(A1)
X already:
X }
X Super(l);
X }
X***************************************************************/
X if (msgbf[0]==AC_OPEN && msgbf[4]==menu_id)
X {
X i=form_alert(3-status,"[2][| Desktop Picture 2.01|= Noud van Kruysbergen|][New| On |Off]");
X if (i!=3-status)
X {
X wind_update(BEG_UPDATE);
X form_dial(FMD_START,0,0,0,0,0,0,640,400);
X if ((i==2 && file[0]==0) || i==1)
X {
X fsel_input(path,file,&j);
X if (j && Readfile()<0)
X {
X form_error(2);
X file[0]=0;
X }
X }
X if (((i==2 && file[0]!=0) || i==3) && status!=(j=3-i))
X {
X if (status=j) Supexec(Install);
X else
X {
X l=Super(0L);
X asm
X {
X lea _oldgem,A0
X move.l (A0),0x88
X }
X Super(l);
X }
X }
X form_dial(FMD_FINISH,0,0,0,0,0,0,640,400);
X wind_update(END_UPDATE);
X }
X }
X }
X}
X
SHAR_EOF
chmod 0600 DESKTOP1.C || echo "restore of DESKTOP1.C fails"
sed 's/^X//' << 'SHAR_EOF' > DESKTOP3.C &&
X; **************************************************************************
X; This is the source of DESKTOP.ACC, a program that changes the normal gray
X; background with a Degas P?3 file. This source is public domain, but I
X; would appreciate it very much if a program that uses (part) of this
X; source respects the name of the author!
X; **************************************************************************
X; This source is written for Megamax C, with the inline assembly.
X; **************************************************************************
X; This program needs DESKTOP.PRG version 1.0.
X; **************************************************************************
X; Noud van Kruysbergen
X; N.I.C.I.
X; P.O. Box 9104
X; 6500 HE Nijmegen
X; The Netherlands
X; email: kruysbergen@hnykun53.bitnet
X; **************************************************************************
X#include <gemdefs.h>
X#include <stdio.h>
X#include <osbind.h>
X#include <gembind.h>
X
Xint handle;
Xint menu_id,msgbf[8];
Xint i;
X
Xint clip[4]={0,0,639,399};
X
Xint contrl[12],intin[128],ptsin[128],intout[128],ptsout[128];
Xint work_out[57],work_in[11]={1,1,1,1,1,1,1,1,1,1,2};
X
Xextern int gl_apid;
Xextern long addr_out[2];
X
Xlong picture=0L;
Xlong l,picstart,bufcount,piccount;
X
Xchar newdta[44];
Xchar path[50],file[14];
Xchar t[70];
X
Xmain()
X{
X appl_init();
X v_opnvwk(work_in,&handle,work_out);
X vs_clip(handle,-1,clip);
X if (*(long *)intout==0x4e5f4450) picture=*(long *)(intout+4);
X strcpy(path,"A:\\*.P?3");
X file[0]=0;
X path[0]=(char)(Dgetdrv()+65);
X menu_id=menu_register(gl_apid," Desktop Picture");
X while ()
X {
X evnt_mesag(msgbf);
X if (msgbf[0]==AC_OPEN && msgbf[4]==menu_id)
X {
X if (picture==0L) form_alert(1,"[3][DESKTOP 1.1 not resident][Cancel]");
X else
X {
X i=form_alert(3,"[2][| Desktop Picture 2.03|(with DESKTOP.PRG 1.1)|= Noud van Kruysbergen|][P?3|Gray|Cancel]");
X if (i<3)
X {
X wind_update(BEG_UPDATE);
X form_dial(FMD_START,0,0,0,0,0,0,640,400);
X if (i==1)
X {
X fsel_input(path,file,&i);
X if (i)
X {
X strcpy(t,path);
X i=0;
X while(t[i++]!='*' && i<70);
X if (i<70)
X {
X path[i]=0;
X t[--i]=0;
X strcat(path,".P?3");
X strcat(t,file);
X if ((handle=Fopen(t,0))>=0)
X {
X Fseek(34L,handle,0);
X i=strlen(file);
X if (file[i-2]=='C')
X {
X l=Fsetdta(newdta);
X Fsfirst(t,0);
X Fsetdta(l);
X l=*(long *)(newdta+26);
X if (piccount=picstart=Malloc(l))
X {
X l=Fread(handle,l,picstart);
X bufcount=picture;
X do
X {
X asm
X {
X move.l piccount(A4),A0
X move.b (A0),D0
X ext.w D0
X and.w #0xff,D0
X move.w D0,i(A4)
X addq.l #1,piccount(A4)
X }
X if (i<128)
X {
X asm
X {
X move.l bufcount(A4),A2
X move.l piccount(A4),A1
X move.w i(A4),D0
X pic1loop: move.b (A1)+,(A2)+
X dbf D0,pic1loop
X move.l A1,piccount(A4)
X move.l A2,bufcount(A4)
X }
X }
X else
X {
X if (i!=128)
X {
X i^=255;
X asm
X {
X move.l bufcount(A4),A2
X move.l piccount(A4),A1
X move.w i(A4),D0
X addq.w #1,D0
X pic2loop: move.b (A1),(A2)+
X dbf D0,pic2loop
X addq.l #1,piccount(A4)
X move.l A2,bufcount(A4)
X }
X }
X }
X }
X while((piccount-picstart<l) && (bufcount-picture<32000L));
X Mfree(picstart);
X }
X else form_error(8);
X }
X else Fread(handle,32000L,picture);
X Fclose(handle);
X }
X else
X {
X form_error(2);
X file[0]=0;
X }
X }
X }
X }
X else
X {
X asm
X {
X move.l picture(A4),A0
X move.l A0,A1
X move.w #199,D1
X loop1: adda.l #80,A1
X move.w #79,D0
X loop2: move.b #0x55,(A0)+
X move.b #0xaa,(A1)+
X dbf D0,loop2
X adda.l #80,A0
X dbf D1,loop1
X }
X }
X form_dial(FMD_FINISH,0,0,0,0,0,0,640,400);
X wind_update(END_UPDATE);
X }
X }
X }
X }
X}
X
SHAR_EOF
chmod 0600 DESKTOP3.C || echo "restore of DESKTOP3.C fails"
sed 's/^X//' << 'SHAR_EOF' > DESKTOP2.S &&
X; **************************************************************************
X; This is the source of DESKTOP.PRG, a program that changes the normal gray
X; background with a Degas PI3 file. This source is public domain, but I
X; would appreciate it very much if a program that uses (part) of this
X; source respects the name of the author!
X; **************************************************************************
X; This specific version (1.1) returns the picture adress in intout[2]
X; when vs_clip() is called. "N_DP" is returned in intout[0] to
X; be able to check whether this adress is valid.
X; **************************************************************************
X; Noud van Kruysbergen
X; N.I.C.I.
X; P.O. Box 9104
X; 6500 HE Nijmegen
X; The Netherlands
X; email: kruysbergen@hnykun53.bitnet
X; **************************************************************************
X
X text
X
X move.l 4(A7),A0 ; these lines are the normal
X move.l #$100,D4 ; ones for a TSR program
X add.l 12(A0),D4 ; there's nothing interesting
X add.l 20(A0),D4 ; here.
X add.l 28(A0),D4 ; You only have to add 32000 bytes
X add.l #32000,D4 ; for the (PI3) picture.
X
X lea noudtext,A0 ; show the copyright lines
X bsr cconws ; to the screen
X
X clr.w -(A7) ; try to open the file
X pea file1 ; "DESKTOP.PI3" in the AUTO
X move.w #$3d,-(A7) ; folder.
X trap #1 ; D3 = Fopen("AUTO\DESKTOP.PI3",0);
X addq.l #8,A7
X move.w D0,D3
X bpl ok1 ; File exists: goto ok1
X
X clr.w -(A7) ; If the file does not exist:
X pea file2 ; try to open "DESKTOP.PI3" in the
X move.w #$3d,-(A7) ; root directory.
X trap #1 ; D3 = Fopen("DESKTOP.PI3",0);
X addq.l #8,A7
X move.w D0,D3
X bpl ok1 ; File exist: goto ok1
X
X lea error1,A0 ; No "DESKTOP.PI3" exists
X bsr cconws ; print this to screen
X move.w #7,-(A7) ; let the bell ring
X move.w #2,-(A7)
X trap #1 ; Cconout(7);
X addq.l #4,A7
X bsr wait ; wait for a moment to be able to
X clr.w -(A7) ; read the message and
X trap #1 ; Pterm0();
X
Xok1: clr.w -(A7) ; The file exists. Skip the
X move.w D3,-(A7) ; PI3 header info (34 bytes).
X move.l #34,-(A7)
X move.w #$42,-(A7)
X trap #1 ; Fseek(34L,D3,0);
X adda.l #10,A7
X
X pea picbuffer ; Read the picture in the
X move.l #32000,-(A7) ; buffer (which begins at
X move.w D3,-(A7) ; 'picbuffer'.
X move.w #$3f,-(A7)
X trap #1 ; Fread(D3,32000L,picbuffer);
X adda.l #12,A7
X cmpi.l #32000,D0 ; 32000 bytes read?
X beq ok2 ; goto ok2
X lea error2,A0 ; else print warning to screen
X bsr cconws
X bsr wait ; wait, but do install!
X
Xok2: pea gemnew ; the new gem vector
X move.w #34,-(A7)
X move.w #5,-(A7)
X trap #13 ; gemold=Setexc(34,gemnew);
X addq.l #8,A7
X move.l D0,gemold
X lea gemnew,A0
X move.l D0,-4(A0) ; return adress for XBRA protocol
X
X move.w D3,-(A7) ; close the file
X move.w #$3e,-(A7)
X trap #1 ; Fclose(D3);
X addq.l #4,A7
X
X clr.w -(A7) ; terminate and stay resident
X move.l D4,-(A7) ; with no errorcode
X move.w #$31,-(A7)
X trap #1 ; Pterm(D4,0);
X
X; --------------------------------------------------------------------------
X
Xcconws: move.l A0,-(A7) ; routine to print line to screen
X move.w #9,-(A7)
X trap #1 ; Cconws(A0);
X addq.l #6,A7
X rts
X
Xwait: move.w #1000,D1 ; routine that eats up CPU time
Xwait1: move.w #1000,D0 ; simply to wait
Xwait2: dbf D0,wait2
X dbf D1,wait1
X rts
X
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X; this is where it all is about. The new gemvector starts here.
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X
X dc.b "XBRAN_DP"
X dc.l 0
Xgemnew: cmpi.w #115,D0 ; test whether it is a VDI call
X bne gemquit
X
X; *************************************************************************
X; It is a VDI call!
X
X movem.l D0-A3,-(A7) ; save registers
X
X move.l D1,A0
X move.l (A0),A0 ; D0 = control[0];
X move.w (A0),D0 ; what VDI call is it?
X
X; **************************************************************************
X; Is the VDI call vr_recfl()?
X
X cmpi.w #114,D0
X bne nofill
X cmpi.w #2,interior ; Has vsf_interior(handle,2);
X bne gemrest ; been called?
X cmpi.w #4,style ; Has vsf_style(handle,4);
X bne gemrest ; been called?
X
X tst.w mode ; Is it in the clipping mode?
X beq gemrest
X move.l D1,A0
X move.l 8(A0),A0 ; D0 = intin[0] etc..
X move.w (A0)+,D0 ; x0==0
X bne gemrest
X move.w (A0)+,D0 ; y0==0 || y0==19
X cmpi.w #19,D0
X beq menu
X tst.w D0
X bne gemrest
Xmenu: move.w (A0)+,D0 ; x1==639
X cmpi.w #639,D0
X bne gemrest
X move.w (A0),D0 ; y1==399
X cmpi.w #399,D0
X bne gemrest
X
X; All the conditions are true. They mean that a gray background should
X; be drawn. The exact size is set in the clipping variables. They are
X; used to draw the background.
X
X move.l $44e,A1 ; A1 = *(long *)0x44e;
X move.w clipy0,D0
X move.w D0,D2 ; D0 = D2 = clipy0;
X muls #80,D0 ; D0 *= 80 /* 80 characters per line */
X adda.l D0,A1 ; A1 = screenadres + clipy0 offset;
X lea picbuffer,A0 ; A0 = pictureadres;
X adda.l D0,A0 ; A0 = pictureadres + clipy0 offset;
X move.w clipy1,D0 ; D0 = clipy1;
X sub.w D2,D0 ; D0 = clipy1 - clipy0;
X move.w D0,D2 ; D2 = total number of lines;
X move clipx0,D3 ; D3 = x0;
X move.w D3,D7
X ext.l D7
X divs #8,D7
X move.w D7,D3
X adda.l D3,A0
X adda.l D3,A1 ; D3 = clipx0/8;
X swap D7
X move.w D7,D4 ; D4 = clipx0%8;
X move.w clipx1,D5
X addq.w #1,D5
X move.w D5,D7
X ext.l D7
X divs #8,D7
X move.w D7,D5 ; D5 = clipx1/8;
X swap D7
X move.w D7,D6 ; D6 = clipx1%8;
X move.l D5,D0
X sub.l D3,D0
X bne label3 ; if (D3>D5) goto label3;
X
X; --------------------------------------------------------------------------
X; This routine takes care of the times when the desktop has to be redrawn
X; within one character (for instance from bit 2 to bit 5).
X; --------------------------------------------------------------------------
X
X move.w D6,D7 ; D7 = D6; /* D6=5+1 */
X subi.w #8,D7
X neg.w D7 ; D7 = -(D6-8); /* D7=2 */
X move.b #-1,D3 ; D3 = 11111111 /* in binary mode */
X lsr.b D7,D3 ; D3 = 00111111
X lsl.b D7,D3 ; D3 = 11111100
X lsl.b D4,D3 ; D3 = 11110000 /* D4=2 */
X lsr.b D4,D3 ; D3 = 00111100
X
X; This is a very elegant way to make a byte that has the bits set that
X; should contain the background information. A zero in this byte means that
X; what is on screen at that location should stay there. In this case only
X; the bits 5,4,3 and 2 (numbers 2,3,4 and 5 from the left) have to be updated.
X
Xbyteloop: move.b D3,D0 ; D0 = 00111100
X move.b (A0),D7 ; D7 = picturebyte
X and.b D0,D7 ; D7 &= 00111100
X not.b D0 ; D0 = 11000011
X and.b (A1),D0 ; screenbyte &= 11000011
X add.b D0,D7 ; D7 = picturebyte + screenbyte
X move.b D7,(A1) ; screenbyte = D7
X adda.l #80,A0 ; next pictureline
X adda.l #80,A1 ; next screenline
X dbf D2,byteloop ; do this for all # lines
X bra selfok ; quit the GEM call
X
X; --------------------------------------------------------------------------
X; More than one byte have to be redrawn.
X; --------------------------------------------------------------------------
X
Xlabel3: subq.w #1,D0 ; # bytes -= 1 for 'dbf' sake.
X tst.w D4 ; xclip0 on a byte-boundairy?
X seq D5 ; yes : set D5
X beq yloop ; : goto yloop
X tst.w D0 ; D0==0? /* only 1 byte? */
X sne D5 ; no : set D5
X beq yloop ; yes : goto yloop
X subq.w #1,D0 ; more than one byte: D0 -= 1;
X
X; --------------------------------------------------------------------------
X; Start of the actual updating routine.
X; --------------------------------------------------------------------------
X
X; We first have to draw the remainder of the first byte. If there is no
X; remainder (D4=0) we don't have to do this. Suppose we have to redraw
X; from bit 4 (from the left, so actually bit 5): D4=3.
X
Xyloop: move.l A0,A2 ; A2 = pictureadres
X move.l A1,A3 ; A3 = screenadres
X tst.w D4 ; if no remainder has to be drawn
X beq nostart ; then don't do this
X move.b (A2)+,D3 ; D3 = picturebyte
X move.b #-1,D7 ; D7 = 11111111
X lsr.b D4,D7 ; D7 = 00011111
X and.b D7,D3 ; D3 &= 00011111 /* picturebits */
X not.b D7 ; D7 = 11100000
X and.b (A3),D7 ; D7 &= screenbyte /* screenbits */
X add.b D3,D7 ; D7 += D3 /* picture+screen */
X
X; D7 contains the high bits from the old background and the low bits from
X; the redrawn background.
X
X move.b D7,(A3)+ ; screenbyte = D7
X
X; When we arrived here, we are at a byte boundary. We are going to copy
X; bytes from the picture to the screen if necessary (D5 was set)
X
Xnostart: move.w D0,D7 ; D7 = # bytes
X tst.w D5
X beq endbyte ; D5 not set: goto endbyte
Xxloop: move.b (A2)+,(A3)+ ; screenbyte = picturebyte
X dbf D7,xloop ; do this # bytes times
X
X; We still are at a byte boundary. Are there any bits to draw any further?
X
Xendbyte: tst.w D6
X beq no_end
X
X; If not, skip this part. D6 contains the number of bits to update, say 3.
X
X move.b (A2)+,D3 ; D3 = picturebyte
X move.b #-1,D7 ; D7 = 11111111
X lsr.b D6,D7 ; D7 = 00011111
X not.b D7 ; D7 = 11100000
X and.b D7,D3 ; D3 &= 11100000 /* picturebits */
X not.b D7 ; D7 = 00011111
X and.b (A3),D7 ; D7 &= screenbyte
X add.b D3,D7 ; D7 = screenbits + picturebits
X move.b D7,(A3) ; screenbyte = D7
X
Xno_end: adda.l #80,A0 ; next picture line
X adda.l #80,A1 ; next screen line
Xlabel1: dbf D2,yloop ; do this # lines times
X
Xselfok: movem.l (A7)+,D0-A3 ; quit the GEM call
X rte
X
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X; This is were the redrawing of the background ends. It all is in fact
X; nothing more than shifting a proper amount of bits at a proper time!
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X
X; **************************************************************************
X; Is the VDI call vst_interior()?
X
Xnofill: move.l D1,A0
X move.l 4(A0),A0
X move.w (A0),D2 ; D2 = intin[0];
X
X cmpi.w #23,D0
X bne nointerior
X move.w D2,interior ; interior = intin[0];
X bra gemrest
X
X; **************************************************************************
X; Is the VDI call vst_style()?
X
Xnointerior:cmpi.w #24,D0
X bne nostyle
X move.w D2,style ; style = intin[0];
X bra gemrest
X
X; **************************************************************************
X; Is the VDI call vs_clip()?
X
Xnostyle: cmpi.w #129,D0
X bne gemrest
X move.w D2,mode ; mode = intin[0];
X beq gemrest ; if (mode==0) no clipping;
X
X cmpi.w #-1,D2
X bne normal
X
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X; for version 1.0 exclude the part between the ...++++++... lines !!!
X;
X; We return the picture adress in intout[2] when vs_clip(x,-1,x) is called.
X; This is an illegal not documented feature! When DESKTOP.PRG is not
X; installed the content of intout[2] is NOT the picture adress!
X; This can be controlled by intout[0]: if *(long *)intout==$4e5f4450
X; ("N_DP") the value *(long *)(intout+4) is a valid picture adress.
X
X move.l D1,A0
X move.l 12(A0),A0
X move.l #$4e5f4450,(A0)+ ; *(ong *)intout=0x4e5f4450
X clr.l (A0)+
X lea picbuffer,A1
X move.l A1,(A0) ; *(long *)(intout+4)=picbuffer;
X bra selfok
X
X; This is the normal clipping procedure
X; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X
Xnormal: move.l D1,A0
X move.l 8(A0),A0
X move.w (A0)+,clipx0 ; clipx0 = intin[0];
X move.w (A0)+,clipy0 ; clipy0 = intin[1];
X move.w (A0)+,clipx1 ; clipx1 = intin[2];
X move.w (A0),clipy1 ; clipy1 = intin[3];
X
Xgemrest: movem.l (A7)+,D0-A3 ; restore registers
Xgemquit: move.l gemold,-(A7) ; put old GEM vector on the stack
X rts ; and jump to it...
X
X data
X
Xnoudtext: dc.b 27,'E',13,10,10," ",27,'p'," Desktop Picture V1.1 "
X dc.b 27,'q',13,10," ",27,'p'," Noud van Kruysbergen ",27,'q',13,10,10,0
Xerror1: dc.b " **** Error: DESKTOP.PI3 ? ****",13,10,0
Xerror2: dc.b " Warning: DESKTOP.PI3 < 32034",13,10,0
Xfile1: dc.b "AUTO\DESKTOP.PI3",0
Xfile2: dc.b "DESKTOP.PI3",0
X even
X
X bss
X
Xstyle: ds.w 1
Xinterior: ds.w 1
Xmode: ds.w 1
Xclipx0: ds.w 1
Xclipy0: ds.w 1
Xclipx1: ds.w 1
Xclipy1: ds.w 1
Xgemold: ds.l 1
Xpicbuffer:ds.l 1 ; 32000 bytes are reserved from here.
X
X end
X
SHAR_EOF
chmod 0600 DESKTOP2.S || echo "restore of DESKTOP2.S fails"
exit 0