SPEED	EQU	1
;*======================================================================*
;*                TITLE:                  CREDITS.S 	                *
;*                                                                      *
;*              COPYRIGHT 1993 Atari Computer Corporation               *
;*          UNATHORIZED REPRODUCTION, ADAPTATION, DISTRIBUTION,         *
;*          PERFORMANCE OR DISPLAY OF THIS COMPUTER PROGRAM OR          *
;*        THE ASSOCIATED AUDIOVISUAL WORK IS STRICTLY PROHIBITED.       *
;*                            ALL RIGHTS RESERVED.                      *
;*                                                                      *
;*======================================================================*

;*======================================================================*
;*		INCLUDE FILES						*
;*======================================================================*
	include "jaguar.inc"
	include "blit.inc"
	include "joypad.inc"
	include "bzstruct.inc"
	include "gamedef.inc"

;*======================================================================*
;*		EXTERNAL SYMBOLS					*
;*======================================================================*
	.extern framecnt
	.extern draw_ptr, disp_ptr, zbuf_ptr
	.extern pad_shot, pad_now
	.extern _tank
	.extern _tmpturt
	.extern model_ptr		
;	.extern _en0_data
	.extern _ourtankdata
	.extern TXTCRZ_S
	.extern TXTCRZ_E
	.extern text3D
	.extern _extrnflag
	.extern dlistptr
	.extern olist_ram
	.extern a_vdb
	.extern a_vde
	.extern _ZoneRAM
	.extern _tankwas_hit
	.extern _enemytextures
	.extern _niteflag
	.extern _EEPROMData
	.extern video_x, video_y

;*======================================================================*
;*		EXTERNAL ROUTINES					*
;*======================================================================*
	.extern clrscreen
	.extern clrbuffer
		
	.extern readpad

	.extern _loadshots, _loadbig

	.extern gpuwait

	.extern  CopyObjList

	.extern _ResetTurtle
	.extern gpuload
	.extern do_fastdraw
	.extern _toggle_music
	.extern _DoTurtle
	.extern _TxtSFont
	.extern _TxtSBuffer
	.extern _STxtBlt
	.extern BuildLightModel
	.extern _Initialize
	.extern _memzero
	.extern __ultoa	
	.extern blitwait

;*======================================================================*
;*		GLOBAL SYMBOLS						*
;*======================================================================*
	.globl	cdisp_ptr
	.globl	_ram_scores
	.globl	_ram_names

;*======================================================================*
;*		GLOBAL ROUTINES						*
;*======================================================================*
	.globl	_do_credits
	.globl	do_delay
	.globl	_copyhighscores
	.globl  _CopyEEHighScores
	.globl  _SaveEEHighScores

;*======================================================================*
;*		DEFINES							*
;*======================================================================*

	NUMCREDITSTRINGS	equ	15
	MIDSCREEN		equ	160
	HIGHSCORE_XPOS		equ	216
	HIGHSCORE_YPOS		equ	32
	HIGHNAME_XPOS		equ	80

;*======================================================================*
;*		PROGRAM SEGMENT						*
;*======================================================================*

	.text
	.phrase

_do_credits:
	movem.l	d0-d7/a0-a5,-(sp)

	move.l	#0,CLUT			; Initialize color look up
	jsr	gpuwait			; wait for the gpu to be finished
	jsr	blitwait		; wait for the blitter to finish
	jsr	blitwait		; wait for the blitter to finish (twice)

	move.w	#0,_niteflag		; make it day
;
;	jsr	_copyhighscores		; Remove this later/copies from rom tables to ram buffers

	move.w	a_vde,d0
	sub.w	a_vdb,d0
	ext.l	d0
	move.l	d0,cobj_offset		; Y offset for overlay object

;
;	First fix up video
;
	move.l	#_ZoneRAM+15,d0		; Align text object buffer
	and.l	#~15,d0			; 
	move.l	d0,cdisp_ptr

	move.l	#_enemytextures+15,d0		; Align text object buffer
	and.l	#~15,d0			; 
	move.l	d0,c1disp_ptr

	move.w	#0,_tankwas_hit
	moveq.l	#0,d0			; Clear the screen buffers before
	move.l	disp_ptr,a0		; turning on the video
	jsr	clrbuffer
;	jsr	clrscreen

;
;	Initialize the overlay buffer
;
	move.l	#320*200*2,-(sp)	; Zero out overlay buffer
	move.l	cdisp_ptr,-(sp)
	jsr	_memzero
	addq.l	#8,sp

	move.l	#320*200*2,-(sp)	; Zero out rmw buffer
	move.l	c1disp_ptr,-(sp)
	jsr	_memzero
	addq.l	#8,sp


	move.l	#4,-(sp)
	jsr	do_delay
	addq.l	#4,sp

	jsr 	_IniCreditsObjList

	move.l	#4,-(sp)
	jsr	do_delay
	addq.l	#4,sp

	jsr	CopyObjList		; Copy Object List

	move.l	#4,-(sp)
	jsr	do_delay
	addq.l	#4,sp

	jsr	_BuildCreditsObjList

;
;	INITIALIZATION
;

	move.l	#_tank,-(sp)
	jsr	_ResetTurtle
	addq.l	#4,sp
	move.l	#_tmpturt,-(sp)
	jsr	_ResetTurtle
	addq.l	#4,sp

	moveq.l	#0,d0
	lea	_tank,a0
	move.w	d0,xposn(a0)		; Set up viewing position
	move.w	d0,yposn(a0)
	move.w	d0,zposn(a0)
	lea	_tmpturt,a0
	move.w	d0,xposn(a0)		; Set up viewing position
	move.w	d0,yposn(a0)
	move.w	#5300,zposn(a0)		; Set tank at z = 300
;
	jsr	_Initialize
	; ----------------------------------------------
	; Light Model Handler
	; ----------------------------------------------

	jsr	BuildLightModel



	move.l	#_ourtankdata,model_ptr	; Set up turtles modelptr
	move.w	#0,_extrnflag
	move.w	#3,-(sp)
	jsr	_TxtSFont
	addq	#2,sp
	move.w	#5,-(sp)
	jsr	_TxtSBuffer
	addq	#2,sp

;
;	Print text onto the overlay buffer
;
	move.l	#NUMCREDITSTRINGS-1,d0
;
	lea.l	credarray,a0
	move.w	#0,d2			; ypos
.txtloop:
	move.l	(a0)+,a1
	move.b	(a1)+,d1		; Get number of chars in string
	and.l	#$ff,d1
	muls	#7,d1			; Times Width of a char
	asr.l	#1,d1			; Divide by 2
	move.l	#MIDSCREEN,d3
	sub.l	d1,d3
	move.l	a1,-(sp)
	move.w	d2,-(sp)		
	move.w	d3,-(sp)		; Centered Xpos
	jsr	_STxtBlt
	addq.l	#8,sp
	add.w	#12,d2			; Print on next line
	dbra	d0,.txtloop
;
;
;
	move.w	#0,d3			; d3 = state
	move.w	#49,d5			; number of frames for state 0
	move.l	framecnt,d7		; Init frame counter
framelp:

	jsr	clrscreen			; Clear the draw buffer with black



	; ----------------------------------------------
	; Draw the Scene, unless we've been hit
	; ----------------------------------------------

;
; DO STUFF HERE
;

; Draw Tank
;
;  Load in the gpu package
;
	lea	TXTCRZ_S,a0
	lea	text3D,a1
	move.l	#TXTCRZ_E,d0
	sub.l	#TXTCRZ_S,d0
	jsr	gpuload		; Load Polyhedron Draw Routine into GPU RAM
;
	move.l	#_tmpturt,d0
	jsr	do_fastdraw	; Draw the tank
;
	jsr	gpuwait	


	; ----------------------------------------------
	; Read the JoyPad
	; ----------------------------------------------
	jsr	readpad	


	move.l	disp_ptr,d0	; Swap buffers
	move.l	draw_ptr,disp_ptr
	move.l	d0,draw_ptr	

	; ----------------------------------------------
	; Object List Handler
	; ----------------------------------------------
.timeloop:	
	move.l	d7,d0
	add.l	#2,d0
	cmp.l	framecnt,d0
	bgt	.timeloop	


	jsr	_BuildCreditsObjList
	move.l	framecnt,d7		; Save d7

	; ----------------------------------------------
	; Wait for video sync
	; ----------------------------------------------
	move.l	framecnt,d0	; D0 = Current Frame for sync later
.wsync:	cmp.l	framecnt,d0
	beq	.wsync		; Wait for video sync

; Move Tank

	jsr	_loadbig
	move.w	#0,-(sp)
	move.l	#0,-(sp)		; Velocity is state dependant
	move.l	#0,-(sp)
	move.l	#6,-(sp)
	move.l	#0,-(sp)
	move.l	#_tmpturt,-(sp)
	jsr	_DoTurtle
	add.l	#22,sp



	; ----------------------------------------------
	; JoyPad Input Handler
	; ----------------------------------------------


	move.l	pad_shot,d0
	btst.l	#FIRE_A,d0	; FIRE_A - exit to title
	beq	.noA
	move.w	#1,d0		; Fire A,b,c = Start game
	bra	.exit
.noA:
	btst.l	#FIRE_B,d0	; FIRE_A - exit to title
	beq	.noB
	move.w	#1,d0		; Fire A,b,c = Start game
	bra	.exit
.noB:
	btst.l	#FIRE_C,d0	; FIRE_A - exit to title
	beq	.noC
	move.w	#1,d0		; Fire A,b,c = Start game
	bra	.exit
.noC:
	btst.l	#KEY_0,d0	; KEY_0 - toggle music
	beq	.no0
	jsr	_toggle_music
.no0:
	move.l	pad_now,d0
	btst.l	#KEY_STAR,d0	; RESET - KEY_STAR + KEY_HASH
	beq	.no_reset

	btst.l	#KEY_HASH,d0
	beq	.no_reset
	move.w	#RESET,d0	; 1 = RESET
	bra	.exit

.no_reset:




	; ----------------------------------------------
	; End of Frame Loop
	; ----------------------------------------------

	cmp.w	#0,d3
	bne	.nostate0
	cmp.w	#0,d5
	beq	.done0
	sub.w	#1,d5
	lea	_tmpturt,a0
	sub.w	#100,zposn(a0)		; Set up viewing position
	bra 	.nextframe
.done0:
	move.w	#1,d3			; Go on to state 1
	move.w	#0,d6			; zero out velocity
	bra	.nextframe
.nostate0:
	cmp.w	#1,d3
	bne	.nostate1

	move.l	cobj_offset,d0
	cmp.l	#3,d0
	ble	.done1
;	beq	.done1
	sub.l	#3,cobj_offset
	bra	.nextframe
.done1:
	move.w	#2,d3			; set state 2
	move.w	#50,d5			; set #frames for state 2
	move.w	#-100,d6		; set velocity
	bra	.nextframe
.nostate1:
	cmp.w	#2,d3
	bne	.nostate2
	cmp.w	#0,d5
	beq	.timeout
	lea	_tmpturt,a0
	add.w	#100,zposn(a0)		; Set up viewing position
	sub.w	#1,d5
	bra	.nextframe
.nostate2:
	bra	.timeout
.nextframe:
	bra	framelp

.timeout:
;
;
; Fade credits out here

	move.l 	#0,d7
.fadeloop1:
	move.w	d7,CLUT
	cmp.b	#$80,d7
	beq	.do_scores
	sub.b	#8,d7

	; ----------------------------------------------
	; Wait for video sync
	; ----------------------------------------------
	move.l	framecnt,d0	; D0 = Current Frame for sync later
.wsync2:
	cmp.l	framecnt,d0
	beq	.wsync2		; Wait for video sync

	bra	.fadeloop1

.do_scores:
;
;	Clear credits screen and print scores onto it

	move.l	#320*200*2,-(sp)	; Zero out overlay buffer
	move.l	cdisp_ptr,-(sp)
	jsr	_memzero
	addq.l	#8,sp
;
	move.l	#9,d2			; Print out 10 scores
	lea.l	ram_names,a0
	lea.l	ram_scores,a1
	move.w	#HIGHSCORE_YPOS,d1
.prscorelp1:
	move.w	#3,-(sp)
	jsr	_TxtSFont
	addq	#2,sp
	move.l	a0,-(sp)
	move.w	d1,-(sp)
	move.w	#HIGHNAME_XPOS,-(sp)
	jsr	_STxtBlt
	addq.l	#8,sp
	lea.l	4(a0),a0
;
;	Convert score to a string
;
	movem.l	d0-d2/a0-a2,-(sp)
	move.w	#0,-(sp)
	move.w	#10,-(sp)
	move.l	#score_buffer,-(sp)
	move.l	(a1),-(sp)
	jsr	__ultoa
	add.l	#12,sp
	movem.l	(sp)+,d0-d2/a0-a2
	adda.l	#4,a1
;	
;
;	Now print it out
;	
	move.w	#2,-(sp)			; Select number font
	jsr	_TxtSFont
	addq	#2,sp
	move.l	#score_buffer,-(sp)
	move.w	d1,-(sp)
	move.w	#HIGHSCORE_XPOS,-(sp)
	jsr	_STxtBlt
	addq.l	#8,sp
	add.w	#12,d1
	dbra	d2,.prscorelp1
	
;
;	Now fade in scores
;
	move.b	#$80,d7
.fadeloop2:
	move.w	d7,CLUT
	cmp.b	#0,d7
	beq	.fadeindone

	add.b	#8,d7

	; ----------------------------------------------
	; Wait for video sync
	; ----------------------------------------------
	move.l	framecnt,d0	; D0 = Current Frame for sync later
.wsync3:
	cmp.l	framecnt,d0
	beq	.wsync3		; Wait for video sync

	bra	.fadeloop2
.fadeindone:
;
;	Delay 60 frames
;
	move.l	#4*60,-(sp)	; 5 seconds ntsc
	jsr	do_delay
	addq	#4,sp
;
;	Now fade them back out
;

;
; Fade scores out here

	move.l 	#0,d7
.fadeloop3:
	move.w	d7,CLUT
	cmp.b	#$80,d7
	beq	.exit

	sub.b	#8,d7

	; ----------------------------------------------
	; Wait for video sync
	; ----------------------------------------------
	move.l	framecnt,d0	; D0 = Current Frame for sync later
.wsync4:
	cmp.l	framecnt,d0
	beq	.wsync4		; Wait for video sync

	bra	.fadeloop3
	move.w	#0,d0

.exit:

	movem.l	(sp)+,d0-d7/a0-a5
	rts






;
; Delay number of frames given on the stack

do_delay:
	move.l	d0,-(sp)

	move.l	framecnt,d0	; D0 = Current Frame for sync later
	add.l	4+4(sp),d0
.delayloop:
	cmp.l	framecnt,d0
	bgt	.delayloop
	move.l	(sp)+,d0
	rts




; Copy the EEPROM High Scores to the ram area
_CopyEEHighScores:
	movem.l	d0/a0-a1,-(sp)
	lea.l	_EEPROMData,a0
	add.w	#EENAMES,a0	; EEPROM Data -> 10 names
	lea.l	ram_names,a1
	move.l	#9,d0		; Loop through 10 scores
.cpyloop1:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop1	
;
	lea.l	_EEPROMData,a0
	add.w	#EEHIGH_SCORES,a0	; EEPROM Data -> 10 high scores
	lea.l	ram_scores,a1
	move.l	#9,d0
.cpyloop2:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop2
	movem.l	(sp)+,d0/a0-a1
	rts



; save the ram area high scores to the EEPROMData
_SaveEEHighScores:
	movem.l	d0/a0-a1,-(sp)
	lea.l	ram_names,a0
	lea.l	_EEPROMData,a1
	add.w	#EENAMES,a1	; EEPROMData -> 10 names
	move.l	#9,d0		; Loop through 10 scores
.cpyloop1:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop1	
;
	lea.l	ram_scores,a0
	lea.l	_EEPROMData,a1
	add.w	#EEHIGH_SCORES,a1	; EEPROMData -> 10 high scores
	move.l	#9,d0
.cpyloop2:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop2
	movem.l	(sp)+,d0/a0-a1
	rts



;
_copyhighscores:
	movem.l	d0/a0-a1,-(sp)
	lea.l	rom_names,a0
	lea.l	ram_names,a1
	move.l	#9,d0		; Loop through 10 scores
.cpyloop1:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop1	
;
	lea.l	rom_scores,a0
	lea.l	ram_scores,a1
	move.l	#9,d0
.cpyloop2:
	move.l	(a0)+,(a1)+
	dbra	d0,.cpyloop2
	movem.l	(sp)+,d0/a0-a1
	rts


;
; ***********************************************************************
;

_IniCreditsObjList:
	move.l	dlistptr,d0
;
	lea	ClistROM,a0	;ROM copy	
	lea	olist_ram,a1	;RAM shadow that needs a little fixing
	move.l	a1,a2		;save RAM shadow for future use
	moveq	#(Cendlist-ClistROM)/4-1,d1
.OLlp:	
	move.l	(a0)+,(a2)+	;get all longs for all objects from ROM
	dbra	d1,.OLlp
;
;  Link branch objects and object 1 to stop object
;
	moveq	#Cstopobj-ClistROM,d1	;this works if within 127 bytes
	add.l	d0,d1		;dynamically form link ptr to stop object
	lsl.l	#5,d1		;align SRC [22:03] to DST [27:08]
	andi.l	#$07ffff00,d1
	or.l	d1,Cobject5-ClistROM+2(a1)
	or.l	d1,Cbranch0-ClistROM+2(a1)
	or.l	d1,Cbranch1-ClistROM+2(a1)

;
; Link object1 to object 2
;
	moveq	#Cobject2-ClistROM,d1	;this works if within 127 bytes
	add.l	d0,d1		;dynamically form link ptr to stop object
	lsl.l	#5,d1		;align SRC [22:03] to DST [27:08]
	andi.l	#$07ffff00,d1
	or.l	d1,Cobject1-ClistROM+2(a1)

;
; Link object2 to object 3
;
	moveq	#Cobject3-ClistROM,d1	;this works if within 127 bytes
	add.l	d0,d1		;dynamically form link ptr to stop object
	lsl.l	#5,d1		;align SRC [22:03] to DST [27:08]
	andi.l	#$07ffff00,d1
	or.l	d1,Cobject2-ClistROM+2(a1)

;
; Link object3 to object 4
;
	moveq	#Cobject4-ClistROM,d1	;this works if within 127 bytes
	add.l	d0,d1		;dynamically form link ptr to stop object
	lsl.l	#5,d1		;align SRC [22:03] to DST [27:08]
	andi.l	#$07ffff00,d1
	or.l	d1,Cobject3-ClistROM+2(a1)

;
; Link object4 to object 5
;
	moveq	#Cobject5-ClistROM,d1	;this works if within 127 bytes
	add.l	d0,d1		;dynamically form link ptr to stop object
	lsl.l	#5,d1		;align SRC [22:03] to DST [27:08]
	andi.l	#$07ffff00,d1
	or.l	d1,Cobject4-ClistROM+2(a1)

;
;	Fix up ypos in first link object
;

	move.w	a_vdb,d0
	ext.l	d0
	lsl.l	#3,d0
	move.l	4(a1),d1
	or.l	d0,d1
	move.l	d1,4(a1)
;
;	Fix up ypos in second link object
;
	move.w	a_vde,d0
	ext.l	d0
	lsl.l	#3,d0
	move.l	12(a1),d1
	or.l	d0,d1
	move.l	d1,12(a1)

;
;	Fix up ypos in main screen object
;
	move.w	video_y,d0
	ext.l	d0
	move.l	d0,d5

	lsl.l	#3,d0
	move.l	20(a1),d1		; Position of first long in screen object after the 2 branches
	or.l	d0,d1
	move.l	d1,20(a1)

	move.w	video_x,d5
	ext.l	d5
	move.l	28(a1),d2			; Position of first long in second phrase in screen object after the 2 branches
	andi.l	#%11111111111111111111000000000000,d2
	or.l	d5,d2
	move.l	d2,28(a1)
;
;	Fix up ypos in overlay screen object
;
	move.l	52(a1),d1		; Position of first long in screen object after the 2 branches
	or.l	d0,d1
	move.l	d1,52(a1)

	move.w	video_x,d5
	ext.l	d5
	move.l	60(a1),d2			; Position of first long in second phrase in screen object after the 2 branches
	andi.l	#%11111111111111111111000000000000,d2
	or.l	d5,d2
	move.l	d2,60(a1)

;
;	Fix up ypos in rmw screen object
;
	move.l	84(a1),d1		; Position of first long in screen object after the 2 branches
	or.l	d0,d1
	move.l	d1,84(a1)

;
;	Set data pointer of object #1 to disp_ptr
;
	move.l	disp_ptr,d1		; Address of display
	lsl.l	#8,d1
	move.l	16(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,16(a1)

;
;	Set data pointer of release bit object
;
	move.l	disp_ptr,d1		; Address of display
	lsl.l	#8,d1
	move.l	32(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,32(a1)

;
;	Set data pointer of object #2 to cdisp_ptr
;
	move.l	cdisp_ptr,d1
	lsl.l	#8,d1
	move.l	48(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,48(a1)

;
;	Set data pointer of release bit object
;
	move.l	disp_ptr,d1		; Address of display
	lsl.l	#8,d1
	move.l	64(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,64(a1)

;
;	Set data pointer of object #3 to c1disp_ptr
;
	move.l	c1disp_ptr,d1
	lsl.l	#8,d1
	move.l	80(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,80(a1)

	rts
;
_BuildCreditsObjList:
	movem.l	a0-a5/d0-d7,-(sp)

	lea	olist_ram,a1		; Ram shadow object in a1
	move.l	a1,a4			; Save this address for setting stop object links
	move.l	disp_ptr,d1		; Address of display
	move.l	dlistptr,d3		; Address of real object list (for linking)
;
;
;	Fix up ypos in main screen object
;
;	move.w	a_vdb,d0
	move.w	video_y,d0
	ext.l	d0
;	add.l	#40,d0
	move.l	d0,d7			; Save off vertical position

	lsl.l	#3,d0
	move.l	20(a1),d2		; Position of first long in screen object after the 2 branches
	andi.l	#%11111111111111111100000000000111,d2
	or.l	d0,d2
	move.l	d2,20(a1)

;
;	Fix up ypos in rmw screen object
;
	move.l	84(a1),d2		; Position of first long in screen object after the 2 branches
	andi.l	#%11111111111111111100000000000111,d2
	or.l	d0,d2
	move.l	d2,84(a1)


	move.l	d7,d0
	add.l	cobj_offset,d0
	lsl.l	#3,d0
	move.l	52(a1),d2		; Position of first long in screen object after the 2 branches
	andi.l	#%11111111111111111100000000000111,d2
	or.l	d0,d2
	move.l	d2,52(a1)

;
;	Set data pointer of object #1 to disp_ptr
;
	lsl.l	#8,d1
	move.l	16(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,16(a1)

;
;	Set data pointer of object #2 to cdisp_ptr
;
	move.l	cdisp_ptr,d1
	lsl.l	#8,d1
	move.l	48(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,48(a1)

;
;	Set data pointer of object #2 to cdisp_ptr
;
	move.l	c1disp_ptr,d1
	lsl.l	#8,d1
	move.l	80(a1),d0
	andi.l	#%00000000000000000000011111111111,d0
	or.l	d1,d0
	move.l	d0,80(a1)

	movem.l	(sp)+,a0-a5/d0-d7	
	rts
;

	.phrase


	.data
	.phrase
;
;  Object type (Bits 0-2 in 1st 64-bit phrase of object)
; 
BMAPTYP		equ	0	;Bit-Map object
SCALTYP		equ	1	;Scaled Bit-Map object
GPUTYP		equ	2	;Graphics Processor interrupt Object
BRTYP		equ	3	;Branch Object
STOPTYP		equ	4	;Stop Object
;
;
;
;
;
ClistROM:
;
;
;  First 2 objects are branch objects
;  Branch object (br if YPOS < 66)
YPOS		set	25
OBJTYPE		set	BRTYP
BRCC		set	1		;YPOS > VC
;
Cbranch0:
 dc.l	0
 dc.l	(BRCC << 14) + (YPOS << 3) + OBJTYPE
;
;
;  Branch object (br if YPOS > 266)
YPOS		set	507
OBJTYPE		set	BRTYP
BRCC		set	2		;YPOS < VC
;
Cbranch1:
 dc.l	0
 dc.l	(BRCC << 14) + (YPOS << 3) + OBJTYPE
;
;
;  3rd object is the screen
;  Next Object is a full screen Bit-map, so it needs a 2-phrase header
;
;
;  Our  Next Bit-Map object Display list set-up
;
OBJTYPE		set	BMAPTYP	;1st object is a Bit-Map object

HEIGHT		set	200*2	;fill the screen
;YPOS		set	66	;from the top
YPOS		set	0	;PLACEHOLDER TO BE FILLED IN INIT CODE
XPOS		set	0	;from the left edge

FIRSTPIX	set	0	;no left edge clipping
RELEASE		set	0	;release bus between image data fetches
TRANSPAR	set	0	;make logical color 0 transparent
RMW		set	0	;no read-modify-write
REFLECT		set	0	;no horizontal reflect
INDEX		set	0	;palette offset if 1-4 bits/pix
IWIDTH		set	80	;80 phrases in displayed image
DWIDTH		set	240	;240 phrases in source form

PITCH		set	3	;increment by 1 phrase for next fetch
DEPTH		set	4	;16 bits/pixel (65536 color)
;
;
Cobject1:
;  1st phrase
 dc.l 0
 dc.l (HEIGHT << 13) + (YPOS << 3) + OBJTYPE
;
;  2nd phrase
 dc.w (FIRSTPIX << 1) + RELEASE
 dc.w (TRANSPAR << 15) + (RMW << 14) + (REFLECT <<13) + (INDEX << 6) + (IWIDTH >> 4)
 dc.w ((IWIDTH & $0F) << 12) + (DWIDTH << 2) + ((PITCH & $06) >> 1 )
 dc.w ((PITCH & 1) << 15) + (DEPTH << 12) + XPOS
;


;
;
;  4th object is a release bit object
;
;
;  Our  Next Bit-Map object Display list set-up
;
OBJTYPE		set	BMAPTYP	;1st object is a Bit-Map object

HEIGHT		set	200*2	;fill the screen
YPOS		set	0	;PLACEHOLDER TO BE FILLED IN INIT CODE
XPOS		set	384	;from the left edge

FIRSTPIX	set	0	;no left edge clipping
RELEASE		set	1	;release bus between image data fetches
TRANSPAR	set	0	;make logical color 0 transparent
RMW		set	0	;no read-modify-write
REFLECT		set	0	;no horizontal reflect
INDEX		set	0	;palette offset if 1-4 bits/pix
IWIDTH		set	1	;80 phrases in displayed image
DWIDTH		set	1	;240 phrases in source form

PITCH		set	1	;increment by 1 phrase for next fetch
DEPTH		set	3	;16 bits/pixel (65536 color)
;
;
Cobject2:
;  1st phrase
 dc.l 0
 dc.l (HEIGHT << 13) + (YPOS << 3) + OBJTYPE
;
;  2nd phrase
 dc.w (FIRSTPIX << 1) + RELEASE
 dc.w (TRANSPAR << 15) + (RMW << 14) + (REFLECT <<13) + (INDEX << 6) + (IWIDTH >> 4)
 dc.w ((IWIDTH & $0F) << 12) + (DWIDTH << 2) + ((PITCH & $06) >> 1 )
 dc.w ((PITCH & 1) << 15) + (DEPTH << 12) + XPOS
;

;
;  Text overlay object
;
;
;  Our  Next Bit-Map object Display list set-up
;
OBJTYPE		set	BMAPTYP	;1st object is a Bit-Map object

HEIGHT		set	200*2	;fill the screen
;YPOS		set	66	;from the top
YPOS		set	0	;PLACEHOLDER TO BE FILLED IN INIT CODE
XPOS		set	0	;from the left edge

FIRSTPIX	set	0	;no left edge clipping
RELEASE		set	1	;release bus between image data fetches
TRANSPAR	set	1	;make logical color 0 transparent
RMW		set	0	;no read-modify-write
REFLECT		set	0	;no horizontal reflect
INDEX		set	0	;palette offset if 1-4 bits/pix
IWIDTH		set	40	;80 phrases in displayed image
DWIDTH		set	40	;240 phrases in source form

PITCH		set	1	;increment by 1 phrase for next fetch
DEPTH		set	3	;16 bits/pixel (65536 color)
;
;
Cobject3:
;  1st phrase
 dc.l 0
 dc.l (HEIGHT << 13) + (YPOS << 3) + OBJTYPE
;
;  2nd phrase
 dc.w (FIRSTPIX << 1) + RELEASE
 dc.w (TRANSPAR << 15) + (RMW << 14) + (REFLECT <<13) + (INDEX << 6) + (IWIDTH >> 4)
 dc.w ((IWIDTH & $0F) << 12) + (DWIDTH << 2) + ((PITCH & $06) >> 1 )
 dc.w ((PITCH & 1) << 15) + (DEPTH << 12) + XPOS


;
;
;  Release bit object
;
;
;  Our  Next Bit-Map object Display list set-up
;
OBJTYPE		set	BMAPTYP	;1st object is a Bit-Map object

HEIGHT		set	200*2	;fill the screen
YPOS		set	0	;PLACEHOLDER TO BE FILLED IN INIT CODE
XPOS		set	384	;from the left edge

FIRSTPIX	set	0	;no left edge clipping
RELEASE		set	1	;release bus between image data fetches
TRANSPAR	set	0	;make logical color 0 transparent
RMW		set	0	;no read-modify-write
REFLECT		set	0	;no horizontal reflect
INDEX		set	0	;palette offset if 1-4 bits/pix
IWIDTH		set	1	;80 phrases in displayed image
DWIDTH		set	1	;240 phrases in source form

PITCH		set	1	;increment by 1 phrase for next fetch
DEPTH		set	3	;16 bits/pixel (65536 color)
;
;
Cobject4:
;  1st phrase
 dc.l 0
 dc.l (HEIGHT << 13) + (YPOS << 3) + OBJTYPE
;
;  2nd phrase
 dc.w (FIRSTPIX << 1) + RELEASE
 dc.w (TRANSPAR << 15) + (RMW << 14) + (REFLECT <<13) + (INDEX << 6) + (IWIDTH >> 4)
 dc.w ((IWIDTH & $0F) << 12) + (DWIDTH << 2) + ((PITCH & $06) >> 1 )
 dc.w ((PITCH & 1) << 15) + (DEPTH << 12) + XPOS
;

;
;
;  RMW OVERLAY object
;
;
;  Our  Next Bit-Map object Display list set-up
;
OBJTYPE		set	BMAPTYP	;1st object is a Bit-Map object

HEIGHT		set	200*2	;fill the screen
;YPOS		set	66	;from the top
YPOS		set	0	;PLACEHOLDER TO BE FILLED IN INIT CODE
XPOS		set	0	;from the left edge

FIRSTPIX	set	0	;no left edge clipping
RELEASE		set	0	;release bus between image data fetches
TRANSPAR	set	0	;make logical color 0 transparent
RMW		set	1	;no read-modify-write
REFLECT		set	0	;no horizontal reflect
INDEX		set	0	;palette offset if 1-4 bits/pix
IWIDTH		set	10	;80 phrases in displayed image
DWIDTH		set	10	;240 phrases in source form

PITCH		set	1	;increment by 1 phrase for next fetch
DEPTH		set	1	;1 bit per pixel
;
;
Cobject5:
;  1st phrase
 dc.l 0
 dc.l (HEIGHT << 13) + (YPOS << 3) + OBJTYPE
;
;  2nd phrase
 dc.w (FIRSTPIX << 1) + RELEASE
 dc.w (TRANSPAR << 15) + (RMW << 14) + (REFLECT <<13) + (INDEX << 6) + (IWIDTH >> 4)
 dc.w ((IWIDTH & $0F) << 12) + (DWIDTH << 2) + ((PITCH & $06) >> 1 )
 dc.w ((PITCH & 1) << 15) + (DEPTH << 12) + XPOS
;

;
;
;
;  9th Object is a STOP object (only 1 phrase needed)
;
OBJTYPE		set	STOPTYP	
;
Cstopobj:
	dc.l	0,OBJTYPE
;
Cendlist:
;
	.phrase

credblank:
	dc.s	2," ",0
credprtitle:
	dc.s	8,"PRODUCER",0
credpr1:
	dc.s	15,"LEONARD TRAMIEL",0
credswtitle:
	dc.s	11,"PROGRAMMERS",0
credsw1:
	dc.s	32,"DENIS FUNG  CARY GEE  CRAIG SUKO",0
credmutitle:
	dc.s	22,"MUSIC AND SOUND DESIGN",0
credmusic:
	dc.s	9,"BRAD WAIT",0
credartitle:
	dc.s    7,"ARTISTS",0
credar1:
	dc.s	24,"ED PEARSON  KEN SAUNDERS",0
credar2:
	dc.s	27,"CHRIS THOMPSON  DONALD WANG",0
credar3:
	dc.s	15,"KEONI LOS BANOS",0
.long
credarray:
	dc.l	credblank
	dc.l	credblank
	dc.l	credprtitle
	dc.l	credpr1
	dc.l	credblank
	dc.l	credswtitle
	dc.l	credsw1
	dc.l	credblank
	dc.l	credmutitle
	dc.l	credmusic
	dc.l	credblank
	dc.l	credartitle
	dc.l	credar1
	dc.l	credar2
	dc.l	credar3

	.phrase

rom_names:
	dc.s	"ABC",0		; hey, let's put some real initials here...
	dc.s	"DEF",0
	dc.s	"GHI",0
	dc.s	"JKL",0
	dc.s	"MNO",0
	dc.s	"PQR",0
	dc.s	"STU",0
	dc.s	"VWX",0
	dc.s	"YZA",0
	dc.s	"BCD",0
rom_scores:
	dc.l	90000,10000,9000,8000,7000,6000,5000,4000,3000,2000


	.bss
	.phrase
cdisp_ptr:
	.ds.l 	1
c1disp_ptr:
	.ds.l	1
cobj_offset:
	.ds.l	1
_ram_scores:
ram_scores:
	.ds.l	10
score_buffer:
	.ds.b	10
_ram_names:
ram_names:
	.ds.b	40
	.phrase
	.end

;*======================================================================*
;*                                 EOF                                  *
;*======================================================================*
