holloway@drivax.UUCP (Bruce Holloway) (06/18/87)
Yet another munching squares program. This one is entirely written in assembly,
and works in all resolutions. It was assembled with the assembler that comes
with the Atari ST Developer's Kit.
It takes one argument - the seed value, which defaults to 0881. It munches
the screen twice, then exits. There is one compile time switch which determines
the length of a side - the smaller, the faster. The length of a side is
2**SIDE pixels.
This works best from a shell, such as ASH or GULAM, but works okay from the
desktop. Also, with a little work, this program could be made to do interesting
fades from one screen to another - replacing the "Eor" statements with a
command to get the appropriate bits from a screen buffer, and removing the
"Lsl.L #2,D7" statement at the bottom of the paragraph that starts with
"gudarg:".
(The Lsl.L statement sets the number of munches -
Shift # # Munches
============= ===============
0 .5
1 1
2 2
3 4
4 8 etc.
)
-- Cut Here -- Cut Here -- Cut Here -- Cut Here -- Cut Here -- Cut Here --
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# munch.s
# munch.uue
# This archive created: Thu Jun 18 09:23:01 1987
# By: Bruce Holloway (Digitalis Research, Inc.)
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'munch.s'" '(3292 characters)'
if test -f 'munch.s'
then
echo shar: "will not over-write existing file 'munch.s'"
else
sed 's/^ X//' << \SHAR_EOF > 'munch.s'
X .Data
X
Xrez Dc.W 0
X
X .Text
X
XSIDE Equ 10
X
X .Globl main,loop
X
Xmain: Move #4,-(SP) Get screen resolution
X Trap #14
X Move D0,rez
X Add #2,SP
X
X Move #2,-(SP) Get the physical base of the screen
X Trap #14
X Add #2,SP
X Clr.L D4 Seed the (dare I?) seed
X
X Move.L 4(SP),A0 Get the base address
X Add #$80,A0 Get the address of the command tail
X
X Cmp.B #0,(A0) If nothing there, continue
X Beq noarg
X
Xgetarg: Add #1,A0
X Cmp.B #$20,(A0) A space?
X Beq getarg Then continue
X Cmp.B #$30,(A0) Not a number?
X Blt noarg Then exit.
X Cmp.B #$39,(A0)
X Bgt noarg
X Lsl.L #1,D4 Multiply it by 10
X Move.L D4,D3
X Lsl.L #2,D4
X Add.L D3,D4
X Move.B (A0),D3 Add the digit
X Sub #$30,D3
X Ext.L D3
X Add.L D3,D4
X Bra getarg
X
Xnoarg: Or.L D4,D4 Null argument?
X Bne gudarg
X Move.L #0881,D4 Then fill it with a default value.
X
Xgudarg: Move.L D0,A1 And save it for later use
X Clr.L D3 Clear the accumulator
X Move #SIDE,D5 Shift amount
X Move #1,D6 Number of bits set == D5
X Lsl D5,D6
X Move D6,D7 Get repetition count
X Sub #1,D6
X Mulu D7,D7 Square it - 1/2 iteration
X Lsl.L #2,D7 8 full iterations
X
X Move rez,D0 Go to correct handler
X Beq loop0
X Cmp #2,D0
X Beq loop2
X
Xloop: Move #0,D1 Initially clear X & Y
X Move D1,D2
X
X Move D3,D1 Set X = Lower ten bits
X And D6,D1
X Cmp #640,D1 Continue if outside screen
X Bge acc
X Move.L D3,D2 Set Y = Upper ten bits
X Lsr.L D5,D2
X And D6,D2
X Cmp #200,D2 Continue if outside screen
X Bge acc
X Move.L A1,A0 Get screen address
X Lsl #5,D2 Add in the row offset
X Add D2,A0
X Lsl #2,D2
X Add D2,A0
X Move D1,D0 Add in the column offset
X Lsr #4,D0
X Lsl #2,D0
X Add D0,A0
X Move.L #$80008000,D0 Now make the bitmask
X And #$F,D1
X Lsr.L D1,D0
X Eor.L D0,(A0) Munch the bits
X* Move.L D0,(A0)
X
Xacc: Add.L D4,D3 Bump the accumulator
X Sub.L #1,D7 And continue for a while...
X Bne loop
X
Xout: Clr -(SP) Exit
X Move #$4C,-(SP)
X Trap #1
X
Xloop0: Move #0,D1 Initially clear X & Y
X Move D1,D2
X
X Move D3,D1 Set X = Lower ten bits
X And D6,D1
X Cmp #320,D1 Continue if outside screen
X Bge acc0
X Move.L D3,D2 Set Y = Upper ten bits
X Lsr.L D5,D2
X And D6,D2
X Cmp #200,D2 Continue if outside screen
X Bge acc0
X
X Move.L A1,A0 Get screen address
X Lsl #5,D2 Add in the row offset
X Add D2,A0
X Lsl #2,D2
X Add D2,A0
X Move D1,D0 Add in the column offset
X Lsr #4,D0
X Lsl #3,D0
X Add D0,A0
X Move.L #$80008000,D0 Now make the bitmask
X And #$F,D1
X Lsr.L D1,D0
X Eor.L D0,(A0)+ Munch the bits
X Eor.L D0,(A0)
X
Xacc0: Add.L D4,D3 Bump the accumulator
X Sub.L #1,D7 And continue for a while...
X Bne loop0
X
X Jmp out
X
X
Xloop2: Move #0,D1 Initially clear X & Y
X Move D1,D2
X
X Move D3,D1 Set X = Lower ten bits
X And D6,D1
X Cmp #640,D1 Continue if outside screen
X Bge acc0
X Move.L D3,D2 Set Y = Upper ten bits
X Lsr.L D5,D2
X And D6,D2
X Cmp #400,D2 Continue if outside screen
X Bge acc0
X
X Move.L A1,A0 Get screen address
X Lsl #4,D2 Add in the row offset
X Add D2,A0
X Lsl #2,D2
X Add D2,A0
X Move D1,D0 Add in the column offset
X Lsr #4,D0
X Lsl #1,D0
X Add D0,A0
X Move #$8000,D0 Now make the bitmask
X And #$F,D1
X Lsr D1,D0
X Eor D0,(A0) Munch the bits
X
Xacc2: Add.L D4,D3 Bump the accumulator
X Sub.L #1,D7 And continue for a while...
X Bne loop2
X
X Jmp out
X
X End
SHAR_EOF
if test 3292 -ne "`wc -c < 'munch.s'`"
then
echo shar: "error transmitting 'munch.s'" '(should have been 3292 characters)'
fi
fi
echo shar: "extracting 'munch.uue'" '(540 characters)'
if test -f 'munch.uue'
then
echo shar: "will not over-write existing file 'munch.uue'"
else
sed 's/^ X//' << \SHAR_EOF > 'munch.uue'
Xbegin 644 munch.prg
XM8!H %. @ #\\ 1.3C/ !3E1//SP
XM DY.5$]"A"!O 30_ " #! &<H4D@,$ @9_@,$ P;1H,$ Y;A3CC"8$
XMY8S8@Q80EGP ,$C#V(-@V(B$9@8H/ W$B0$*#>@I\ >MN/@931L['Y8\P
XM.0 4YG4+!\ )G "2<@ T 3(#PD:R? * ;"PD ^JJQ$:T? #(;" @2>M*
XMT,+E2M#", 'H2.5(T, @/( @ #"? /XJBQD-:$4X=FP$)G/SP 3$Y!<@ T
XM 3(#PD:R? % ;"XD ^JJQ$:T? #(;"(@2>M*T,+E2M#", 'H2.=(T, @/(
XM@ #"? /XJBQF+&0UH13AV:^3OD "Z<@ T 3(#PD:R? * ;.8D ^JJQ$:T
XM? &0;-H@2>E*T,+E2M#", 'H2.-(T, P/( PGP #^)HL5#6A%.'9L).^0
X, +H ADFD0
X
Xend
SHAR_EOF
if test 540 -ne "`wc -c < 'munch.uue'`"
then
echo shar: "error transmitting 'munch.uue'" '(should have been 540 characters)'
fi
fi
exit 0
# End of shell archive
--
Bruce Holloway - Terminal Netnews Addict {seismo,sun}!amdahl!drivax!holloway
ALBATROSS, ATARI*TROS @ Plink ALBATROSS @ Delphi
>>> HI, KARL! <<<