;-----------------------------------------------------------------------------
; Tetris © Copyright 1990 Software Alchemy All Rights Reserved, V0.1 28-Dec-89
;-----------------------------------------------------------------------------
	include	'tetris.i'


;
;	Print Text, Access the ROMFont
;		A0 = Pointer to Text String (null terminated) + x,y pos
;		A1 = Screen


PrintText
	moveq	#0,d0
	move.l	d0,d1
	move.w	(a0)+,d0
	move.w	(a0)+,d1

	mulu	#44*5,d1			; Real Y Pos of Write
	add.l	d1,a1				; Delta Write
	move.w	d0,d3				; Save X
	lsr.w	#3,d0				; Get X Byte Position
	add.w	d0,a1				; A1 = Text Write Address
	move.l	a1,a3				; (save)
	move.l	a1,d5				; (save)

	and.w	#7,d3				; D3 = Bit Shift
	sub.w	#8,d3
	neg.w	d3

2$	moveq	#0,d0				; Get char
	move.b	(a0)+,d0
	beq.s	Print900			; EXIT

	cmp.b	#13,d0				; RETURN
	bne.s	3$
	add.l	#9*44*5,d5
	move.l	d5,a1				; Next VLine
	move.l	d5,a3
	bra	2$

3$	cmp.b	#$80,d0				; COLORIZE
	bcs.s	4$
	and.b	#15,d0				; (clean.l)
	mulu	#44,d0
	add.w	d0,a1
	add.w	d0,a3
	sub.w	#44*3,a1
	sub.w	#44*3,a3
	bra.s	2$
4$

	sub.w	#32,d0				; Offset Properly
	move.l	Characters(pc),a2		; Source of Characters
	add.w	d0,a2				; Current Character to Dump
						; Dump a Character
	move.w	#7,d4				; 8 Pixels Tall
1$
;	move.b	(a1),d0				; D0 = Dest Read
;	lsl.w	#8,d0
;	move.b	1(a1),d0
;	moveq	#0,d1
	move.b	(a2),d1				; D1 = Character Read
;	lsl.w	d3,d1				; D1 = Bit Shifted Char Read
;	eor.w	d1,d0				; Dest + Character
 move.b d1,d0				;(no eor)
;	move.b	d0,1(a1)			; Dest Write
;	lsr.w	#8,d0
	move.b	d0,(a1)
	add.w	#$c0,a2				; Char Src + Modulo = Next VLine
	add.w	#220,a1				; Dest + Modulo = Next VLine
	dbf	d4,1$
	add.w	#1,a3				; NeXT Horizontal Write Please
	move.l	a3,a1				; Reset Horizontal Pos
	bra.s	2$				; NeXT Letter Please!
Print900:
	rts


;
; D0 = Character
;
PrintColumn

;	moveq	#1,d2
8$	cmp.b	#$f8,$dff006
	bne.s	8$
9$	cmp.b	#$fa,$dff006
	bne.s	9$
	movem.w	d0-d2,-(a7)			; shift entire field over.
	bsr	DrawScroller
	movem.w	(a7)+,d0-d2
;	dbf	d2,8$

	bsr	DrawScrollClear
						; D1 = Column #7-0
						; D0 = Character
	and.w	#$ff,d0
	move.w	d0,d4
	and.w	#7,d4
	cmp.w	#7,d4				; (isn't really an 8th color)
	bne.s	7$
	clr.w	d4
7$	lsl.w	#5,d4
	move.l	Characters(pc),a0		; Source of Characters
	sub.w	#32,d0
	add.w	d0,a0				; Current Character to Dump
	moveq	#7,d2
	clr.b	d3
1$	move.b	(a0),d0

	btst	d1,d0
	beq.s	5$

	movem.l	d0-d2/a0,-(a7)
	tst.b	d3
	bne.s	2$
	moveq	#42,d1				; Get Horiz
	moveq	#26,d0
	sub.w	d2,d0				; Vert
	moveq	#7,d2
	or.w	d4,d2
	bsr	DrawScrollBit
	movem.l	(a7),d0-d2/a0

2$	st	d3
	moveq	#42,d1				; Get Horiz
	moveq	#27,d0
	sub.w	d2,d0				; Vert
	moveq	#6,d2
	or.w	d4,d2
	bsr	DrawScrollBit
	movem.l	(a7)+,d0-d2/a0
	bra.s	6$
5$	clr.b	d3
6$	add.w	#$c0,a0				; Next Down
	dbf	d2,1$
	rts					; A0 = Ptr to CharList

GetTopaz
	move.l	4,a6
	lea	GfxName(pc),a1
	jsr	-408(a6)		; OpenLibrary("graphics.library");
	move.l	d0,a6

 move.l $94(a6),d0

; Apparently there is a problem with OpenFont under 1.3 with a custom font, and a 68030
; so I changed to a direct scam off the graphics structure...which I can't
; test but I hope is a more robust solution.

;	lea	TopazName(pc),a2
;	lea	TextAttr(pc),a0
;	move.l	a2,(A0)			; OpenFont(TextAttr);
;	jsr	$ffb8(a6)

	move.l	d0,a1
	lea	Characters(pc),a0
	move.l	$22(a1),(a0)
 rts
;	jmp	$ffb2(a6)		; CloseFont (pass TextFont in A1);

TextAttr	dc.l	0		; ta_Name.l
		dc.w	8,0		; ta_YSize.w, ta_Style.b, ta_Flags.b

TopazName	dc.b	'topaz.font',0
GfxName		dc.b	'graphics.library',0
Characters 	dc.l	0

ScrollMessage

	dc.b	"Slick Cool Fun Games! its what everybody wants to write. " 
	dc.b	"And now, Anselm Hook, Software Designer who has worked on "
	dc.b	"projects like Datastorm, Vortex, Dragons Lair II, Hybris "
	dc.b	"to name a few "
	dc.b	"reveals the coding techniques behind todays hot products "
	dc.b	"in 'Tetris.s' - a stunning compendium of programming "
	dc.b	"tips and tricks that will leave you breathless. "

	dc.b	"                                           "

	dc.b	"Hey, whats' this? A Trashy ScrollText???       "
	dc.b	"Well in that case....        I think I feel "
	dc.b	"the need, the need for *greetings*!!! yay! "

	dc.b "HI Jenn3!, S0ren Gr0nbech, Randy Linden, Andreas Hommel, Julian Lefay, "
	dc.b "Chris Chirogene, Jasper, Thanos, David3, Mark Vange and Fulvio Ciano. "
	dc.b "(and Daniel Shields too). Andrea and Allison.  Martin Pederson, Torben Bakager, "
	dc.b "Paul Lombardi.  Oh and Richard Smith, Nancy Picard and Diana...and Morro and Jenna. "
	dc.b "And everyone at AMUC, FAUG, The Computer Shop of Calgary,  Armando Ruggeri. "
	dc.b "And Chris Mate and Weaver.  And Stephen Vermulen, and Gary Rhyason. "
	dc.b "Rich, I hear Discovery went belly up! Feel like working in Canada? "
	dc.b "RED-SECTOR, I thought your vectorballs demo was incredible. "
	dc.b "SPREADPOINT, vectorscrolltextwow! "
	dc.b "DOC, Jasper ect I'd like to hear from you again. Hows the disk mag? I see you finally sold IMPLODER! "
	dc.b "Leo Schwab, if you send me the source + graphics for marketroids "
	dc.b "I'll turn it into a public domain game 50/50 Name credits. "
	dc.b "PARANOMIA, Vortex wasn't protected you losers!  Woa, you're such piti"
	dc.b "ful hackers you can barely crack unprotected software!!! "
	dc.b "Wait till you come up against The BlackBox, children... "
	dc.b "Hey Mr. Linden, you might find this useful for DL2: move.w #32,$dff1dc. "
	dc.b "It basically speeds up a super-fat Amiga.  HAVE FUN WITH MY MONEY. "
	dc.b "Hey S0ren, when are you going to visit Canada?  Call me. Jan 90 "
	dc.b "P.S. My development system is a 68030!!! (2630) Na na na na bo bo... "
	dc.b "My NeXT development system is just waiting for me to pay for it... "
	dc.b "(You should just try the NeXT interface...I think I'll go write a "
	dc.b "NeXT-Like Dock Application for the Amiga now,since this is all done;-) "
	dc.b "  -> -> -> The End <- <- <-                             "
	dc.b 0

; end of tetrisprint.s



; If after you look at this code, you think something like "Hmmm, I could
; write stuff pretty easily, but the Amiga isn't that big a seller.".
;
; My response is:
;
;     1) Somebody has to produce product such that the market
;        can get larger, and thus sustain more product.
;
;     2) Moreover the Amiga is incredibly powerful, sometimes I use
;        an IBM and I just can't believe how totally backwards those
;        systems are.  Its truly amazing that a machine as old as the
;        Amiga is still an order of magnitude superior to any other
;        micro on the market, with the possible exception of the NeXT by
;        Steve Jobs.
;
;     3) The Amiga simply outpowers the Macintosh, Atari XXt.  And
;        even the new 486 machines still have the cumbersome
;        non-multitasking "interface" (haha) which makes working with them
;        wretched, and with the Amiga sublime.
;
;     4)  The Amiga is *the* defacto development system, most Development
;         Groups realize this, for example an estimated %50 of Amiga Owners
;         are interested or have Assemblers.  You can develop on the Amiga for
;         other machines and have fun doing it.  Another example is I am
;	  finishing an Atari game right now, guess which machine compiles it!
;
;     5)  While the headcount of Amiga Owners may be small, they are very
;	  strong, that is users use it for work, are active in the public
;	  eye, and *Very* vocal.  Its an extremely strong public platform
;         and I predict in the upcoming year that the number of installed
;         Amigas will explode, quadruple quintiple even more, barring any
;         kind of major recession or Acts-Of-Commodore.
;
;     6)  Fred Fish, at your fingertips you have a dazzling array of
;	  public domain software.  Much of it in source code.
;
;     7)  I have for the first time started to see "definitive" software,
;	  where the software is limited by only the developers imagination.
;	  Caligari is a prime example, the developers here believe in an
;	  almost CyberSpace ethic, an all encompassing real-time 3d interface
;	  for operation on data.  (I expect to see the next workbench for the
;	  Amiga to skip directly to 3d, from there its only a short step
;	  and a few network connections to true anticipatory democracy!).
;
;  I do have complaints about the Amiga, such as the poor effort on
;  WorkBench (at least compared to the NeXT), the dearth of truly competent
;  software, the Company which "manages" it, and the price.
;  But I criticize the Amiga on a different level than the IBM-Clones the
;  Amiga needs work, primarily in software.  The Clones need to be shot.
;
;  P.S. You can try a NeXT at your local University.  I suggest that somebody
;  port some of their utilities over to the Amiga, or write a NeXT emulator.
;  I particularily like the Dock, as a tool-space versus the amigas workbench
;  which is primarily an information space.
