;-----------------------------------------------------------------------------
; Tetrisvars.s © Copyright 1990 Software Alchemy All Rights Reserved
;-----------------------------------------------------------------------------

	include	'tetris.i'

RECT_LX		equ 6			; Playfield position of Player One
RECT_LY		equ 6
RECT_RX		equ 28			; Playfield position of Player Two
RECT_RY		equ 6

;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------

SentryOne					; SENTRY MARKER
						; Player Stats is FIRST!!!
PlayerStats		dc.l	0		; Alive.W  Level.B  Count.B
BlockPos		dc.l	0,0		; Suggested X,Y, Current X,Y
BlockSpeed		dc.l	0		; Velocity X,Y
BlockID			dc.w	0		; Block Color # + Last Case
LastButton		dc.b	0		; Player Last Button State
RotateFlag		dc.b	0		; Flag of right edge rotate
xbat			dc.l	0		; Mouse Position x,y
ybat			dc.l	0		;
olda			dc.l	0		; Player Mouse private info
RndSeed			dc.l	0		; Random # generator seed
LevelStuff		dc.l	0		; Level Specific Flags ect
Counter			dc.l	0

BlitRepairAddress	dc.l	0		; Address for damage repair
BlitWorkSpace		dcb.b	5*34*6,0	; Blitter Workspace

CollapseJunk		dc.l	0			; timer.b
			dc.l	0			; A3
			dc.l	0			; A2
			dc.w	0			; Line #


SentryOneEnd					; SENTRY MARKER

						; (pre-initialized data)
PlayerPort		dc.w	$0c,128		; Player 1 I/O to real world
PlayerArea		dc.w	44*RECT_LY+RECT_LX
PlayerXY		dc.b	RECT_LX+RECT_X/2,0,RECT_LY,0
PlayerArea2		dc.w	RECT_LY,RECT_LX

ScoreText		dc.w	RECT_LX*8+16,(RECT_LY+RECT_Y+2)*8-2
			dc.b	'00000000',0,0	; Score
LevelText		dc.w	(RECT_LX-4)*8,(RECT_LY+2)*8
			dc.b	'00',0,0
LayerText		dc.w	(RECT_LX-4)*8,(RECT_LY+RECT_Y/2)*8
			dc.b	'00',0,0	; Level

;-----------------------------------------------------------------------------
PlayerDataSize 		equ 15*4+2+5*34*6	; SentryOneEnd-SentryOne
PlayerPostSize		equ 11*4		; The data after SentryOneEnd
;-----------------------------------------------------------------------------
						; Player 2
SentryTwo
			dcb.b	PlayerDataSize,0
			dc.w	$0a,64		; Player x I/O to real world
			dc.w	44*RECT_RY+RECT_RX
			dc.b	RECT_RX+RECT_X/2,0,RECT_RY,0
			dc.w	RECT_RY,RECT_RX

			dc.w	RECT_RX*8+16,(RECT_RY+RECT_Y+2)*8-2
			dc.b	'00000000',0,0
			dc.w	(RECT_RX-4)*8,(RECT_RY+2)*8
			dc.b	'00',0,0
			dc.w	(RECT_RX-4)*8,(RECT_RY+RECT_Y/2)*8
			dc.b	'00',0,0


PlayerOneStart 		equ 0
PlayerTwoStart 		equ PlayerDataSize+PlayerPostSize ;SentryTwo-SentryOne
;PlayerThreeStart 	equ SentryThree-SentryOne  ; and so on and so on...
;-----------------------------------------------------------------------------


;	Shapes are in sets of 4 rotations per color, each rotation is 1 word.
;
;	%0100	<<< A Green Shape for example becomes >>> %0100 0110 0100 0000
;	%0110
;	%0100
;	%0000

TetrisShapes		dc.w %1100010001000000		; Purple
			dc.w %1110100000000000
			dc.w %1000100011000000
			dc.w %0010111000000000
			dc.w %0100110001000000		; Green
			dc.w %1110010000000000
			dc.w %1000110010000000
			dc.w %0100111000000000
			dc.w %0100110010000000		; Light Blue
			dc.w %1100011000000000
			dc.w %0100110010000000
			dc.w %1100011000000000
			dc.w %1000110001000000		; Orange
			dc.w %0110110000000000
			dc.w %1000110001000000
			dc.w %0110110000000000
			dc.w %1100100010000000		; Yellow
			dc.w %1000111000000000
			dc.w %0100010011000000
			dc.w %1110001000000000
			dc.w %1100110000000000		; Blue
			dc.w %1100110000000000
			dc.w %1100110000000000
			dc.w %1100110000000000
			dc.w %1000100010001000		; Red
			dc.w %0000111100000000
			dc.w %1000100010001000
			dc.w %0000111100000000

;
;	The system will perform the mind-dumbing work of calculating what
;	type of pieces make up each rotation of each object in each color 
;	Each of 7 basic objects is 4 bytes wide by 4 bytes high as well
;	there are 4 rotations per object.
;
			dcb.b	16,0		; (teat must see zero)
TetrisDetails		dcb.b	7*4*16,0
			dcb.b	16,0		; <<< Null Object is #7*4

;
;	Tetris thinks on an internal byte map
;
TetrisByteMap		dcb.l	11*30,0



;
;Aside from background, there are these attributes of each level:
;	0x2 - raising blocks
;	0x4 - random blocks
;
;Second byte of each level block contains this information


TetrisLevels

	; (10 bits backdrop, 6 bits other info)

	dc.b	%00000000,%00000000	; Level 0 (unused)
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000

	dc.b	%10000000,%01000000	; Level 1
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000

	dc.b	%00000000,%00000000	; Level 2
	dc.b	%00110011,%00000000
	dc.b	%00110011,%00000000
	dc.b	%10000000,%01000000
	dc.b	%01111111,%10000000

	dc.b	%10000000,%01000000	; Level 3
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000
	dc.b	%10000000,%01000000

	dc.b	%10101101,%00000000	; Level 4
	dc.b	%00110001,%00000000
	dc.b	%00100000,%00000000
	dc.b	%00011010,%10000000
	dc.b	%01001001,%00000000

	dc.b	%00001100,%00000001	; Level 5
	dc.b	%00010010,%00000000
	dc.b	%00101101,%00000000
	dc.b	%01010010,%10000000
	dc.b	%10101101,%01000000

	dc.b	%00000000,%00000010	; Level 6
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%10101010,%10000000

	dc.b	%00000000,%00000110	; Level 7
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%11111111,%11000000

	dc.b	%00010000,%11000111	; Level 8
	dc.b	%00111001,%10000000
	dc.b	%11111111,%11000000
	dc.b	%01101110,%00000000
	dc.b	%11000100,%00000000

	dc.b	%01110000,%00000111	; Level 9
	dc.b	%10001000,%00000000
	dc.b	%11111000,%00000000
	dc.b	%10001000,%00000000
	dc.b	%10001000,%00000000

	dc.b	%10001000,%00000111	; Level 10
	dc.b	%10001000,%00000000
	dc.b	%11111000,%00000000
	dc.b	%10001000,%00000000
	dc.b	%10001000,%00000000

	dc.b	%00000000,%00000111	; Level 11
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000

	dc.b	%00000000,%00000111	; Level 12
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000

	dc.b	%00000000,%00000111	; Level 13
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000

	dc.b	%00000000,%00000111	; Level 14
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000

	dc.b	%00000000,%00000111	; Level 15
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000
	dc.b	%00000000,%00000000


;-----------------------------------------------------------------------------
;
;	Format of line-draw list:
;		Start.w (x+y*44), length.w-1, Type.b, Color.b
;	Where Type.b is:
;		 0=Horizontal Line
;		 1=Vertical Line
;		 2=Angled Line
;		-n=Area
;	Where Area format is:
;		Start.w (x+y*44), width.w-1, $80+height.b-1, color.b
;

PlayFieldOutline	dc.w	0, RECT_Y-1,$0104
			dc.w	RECT_X+2-1,RECT_Y-1,$0104
PlayFieldClear		dc.w	1, RECT_X-1
			dc.b	$80+RECT_Y-1,0
			dc.w	RECT_Y*44,RECT_X+2-1,$0005
			dc.w	-1
;-----------------------------------------------------------------------------

;
;	System Support Related vars
;

GameVideo		dc.l	0		; Address of Amiga Screen Mem
GameVideo2		dc.l	0		; Address of Screen / 2
GameCopper		dc.l	0		; Address of active Copper
KeyEvent		dc.b	0,0		; Last key pressed/released
BaseSeed		dc.l	0		; Random Seed for all players

PiecesMem		dc.l	$68000		; System Allocated Memory Ptrs
;AudioMem		dc.l	$68000
ScreenMem		dc.l	$70000

ColorTable
		dc.w	$0000,$0653,$0ff0,$0fff
		dc.w	$0909,$0b0b,$0d0d,$0f0f
		dc.w	$0060,$0091,$00c1,$00f3
		dc.w	$0920,$0b40,$0d70,$0fb0
		dc.w	$0088,$00aa,$00cc,$00ff
		dc.w	$0840,$0f80,$0fb0,$0ff0
		dc.w	$000b,$011c,$032e,$054f
		dc.w	$0900,$0b00,$0d00,$0f00

CopperList
;
; (i had some problems getting sprites off, so I just wanted to make
;  sure that they wouldn't show up at all ever in a public release)
;
	dc.w	$120,0,$122,0,$124,0,$126,0,$128,0,$12a,0,$12c,0,$12e,0
	dc.w	$130,0,$132,0,$134,0,$136,0,$138,0,$13a,0,$13c,0,$13e,0
	dc.w	$140,0,$148,0,$150,0,$158,0,$160,0,$168,0,$170,0,$178,0
	dc.w	$0096,$0020		; Kills sprites dead

	dc.w	$0100,$5300		; 5 bitplanes, lo-res genlock allowd
	dc.w	$0102,$0000		; Other bits
	dc.w	$008e,$1171		; Vertical/Horiz visible region
	dc.w	$0090,$00d1
	dc.w	$0092,$0030		; Overscan screen
	dc.w	$0094,$00d8
	dc.w	$0108,44*4		; Modulo for screen
	dc.w	$010a,44*4

CopperPlanes
	dc.w	$00e0,0
	dc.w	$00e2,0
	dc.w	$00e4,0
	dc.w	$00e6,0
	dc.w	$00e8,0
	dc.w	$00ea,0
	dc.w	$00ec,0
	dc.w	$00ee,0
	dc.w	$00f0,0
	dc.w	$00f2,0

	dc.w	$0120,$0		; (force sprites off)
	dc.w	$0122,$0
	dc.w	$0124,$0
	dc.w	$0126,$0
	dc.w	$0128,$0
	dc.w	$012a,$0
	dc.w	$012c,$0
	dc.w	$012e,$0
	dc.w	$0130,$0
	dc.w	$0132,$0
	dc.w	$0134,$0
	dc.w	$0136,$0
	dc.w	$0138,$0
	dc.w	$013a,$0
	dc.w	$013c,$0
	dc.w	$013e,$0
CopperColors
	dc.w	$0180,$0000			; Screen Colors
	dc.w	$0182,$0000
	dc.w	$0184,$0000
	dc.w	$0186,$0000
	dc.w	$0188,$0000
	dc.w	$018a,$0000
	dc.w	$018c,$0000
	dc.w	$018e,$0000

	dc.w	$0190,$0000
	dc.w	$0192,$0000
	dc.w	$0194,$0000
	dc.w	$0196,$0000
	dc.w	$0198,$0000
	dc.w	$019a,$0000
	dc.w	$019c,$0000
	dc.w	$019e,$0000

	dc.w	$01a0,$0000
	dc.w	$01a2,$0000
	dc.w	$01a4,$0000
	dc.w	$01a6,$0000
	dc.w	$01a8,$0000
	dc.w	$01aa,$0000
	dc.w	$01ac,$0000
	dc.w	$01ae,$0000
	dc.w	$01b0,$0000
	dc.w	$01b2,$0000
	dc.w	$01b4,$0000
	dc.w	$01b6,$0000
	dc.w	$01b8,$0000
	dc.w	$01ba,$0000
	dc.w	$01bc,$0000
	dc.w	$01be,$0000
	dc.w	$ffff,$fffe		; Wait forever
CopperListEnd

; end of tetrisvars.s
