gdma.s 5.39 KB

/**************************************************************************
 *								          *
 *               Copyright (C) 1994, Silicon Graphics, Inc.       	  *
 *								          *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *								          *
 *************************************************************************/

/*
 * File:		gdma.s
 * Creator:		hsa@sgi.com
 * Create Date:		Fri Jun 24 13:54:58 PDT 1994
 *
 * This file holds the top-level of the DMA command processing, and
 * related routines.
 *
 */



 ############################################################################
 #
 # The following code processes the DMA type display list commands.
 # Registers on input:	
 #	gfx0	- first word of display list command
 #	gfx1	- second word of display list command
 #	in_bufp - where the data has been read into
 #	dinp	- points to the *next* display list command
 #
	
 ### IMPORTANT!!!: The first instruction here is a branch delay slot 
 ### from grdp.s

		.ent	doDMA
	
doDMA:
	# $2 is shifted in the delay slot of the branch that 
	# brought us here...
	
	# 'switch' to correct DMA command:
		andi	$2, $2, 0x1fe		# shifted up 1 for offset
		lh	$2, DMA_JMP_OFFSET($2)
	
	# 'len' is the same for all commands. But we don't need it here?
	
	# Not double-buffered yet, so we have to wait here for the data...
		jal	DMAwait
		lbu	$1, (0-7)(dinp)	# pick off first field

		jr	$2
	# this is the same for some commands, so save code space
	# and do it here in the delay slot.
		andi	$6, $1, 0x0f	# pick off 'v0' field
	
		.end	doDMA
	
 #
 #
 ############################################################################
	

 ############################################################################
 #
 # Transform, project, & shade as we load into the points buffer.
 #
 # $1 holds n and v0
 # in_bufp holds pointer to data
 #
	
.name	tmp,	$8
	
  case_G_VTX:	
	lh	tmp,GFXDONE(zero)
	sh	tmp,RETURNJUMP(zero)
.unname	tmp

#ifdef	F3DLP_GBI
#include "glvtx.s"
#else
#include "gvtx.s"
#endif

.name	tmp,	$8
xfm_done:
	# NOTE! the first statement here is a branch delay slot
	# from the loop in gvtx.s
	
	lh	tmp,RETURNJUMP($0)
	jr	tmp
#if 0
	nop	# この命令を消すために VTX 命令を移動させる
#endif

.unname	tmp

 #
 #
 #
 ############################################################################

	
 ############################################################################
 #
 # Process the G_MTX command.
 #
 # 	$1 holds param
 # 	in_bufp holds pointer to data
 #

 #.name param, 		$5
	
 #  case_G_MTX:	
 #		add	param, zero, $1		# move param somewhere safe
#include "gmtx.s"

 #.unname param
	
 #
 #
 #
 ############################################################################
	
	
	
 ############################################################################
 #
 #  MOVEMEM handles the VIEWPORT and LIGHT input.
 #
.name outptr,	$5
.name target,	$1
.name buff,	$v0
	
		.ent	case_G_MOVEMEM
	
  case_G_MOVEMEM:	
	# $1 (target) holds n (index to target address*2)
	#             (hi bit set for causing light recomputation)
	# in_bufp holds pointer to data
	lqv	buff[0], 0(in_bufp)			# get 4 words
	lh	outptr,(MOVEMEM_TBL - 0x80)(target)	# get target address
	j	GfxDone					# return
	sqv	buff[0], 0(outptr)			# store 4 words
	
		.end	case_G_MOVEMEM
	
.unname outptr
.unname target
.unname buff
 #
 #
 #
 ############################################################################
	
	
 ############################################################################
 #
.name stack_sz,	$2
.name stack_p,	$3
.name tmp,	$4
		
		.ent	case_G_DL
  case_G_DL:	
	# $1 holds param
	# in_bufp holds pointer to data
	
	# check param to see if we need to push
		bgtz	$1, G_DL_noPush
		# note delay slot...
	
	# if push:	
		lb	stack_sz, RSP_STATE_DL_N(rsp_state)
	
 #-YASU
 #  
 #  DL のスタックの最大を増やす (10=>18 に)
 #
 #  FIFO ucode に固定した為に使用可能となった DMEM の残り (OUTPUT バッファの
 #   Double バッファ化, 頂点キャッシュを 32 にした残り)の 32byte を使う
 #
 #-YASU
	# check to see if stack is full (10 entries max)
#ifdef	MOREDLLNK
		addi	tmp, stack_sz, -36-32
#else
		addi	tmp, stack_sz, -36
#endif
		bgtz	tmp, GfxDone
		# note delay slot
	
		addi	stack_p, stack_sz, RSP_DLSTACK_OFFSET
		addi	stack_sz, stack_sz, 4
#ifdef	SMARTINP
		add	inp, inp, dinp
		sub	inp, inp, dlcount
#endif
		sw	inp,     0(stack_p)	# pointer of DL
		sb	stack_sz, RSP_STATE_DL_N(rsp_state)

	# set some state, prepare to read next list
	# set inp to the new pointer, jump to load...

	G_DL_noPush:
		jal	AddrFixup
		add	$19, gfx1, zero		# delay slot
		add	inp, $19, zero	
		j	GfxDone
#ifdef	SMARTDLCOUNT
		addi	dlcount, dinp, 0	# delay slot
#else
		addi	dlcount, zero, 0	# delay slot
#endif
			
		.end	case_G_DL
.unname stack_sz
.unname stack_p
.unname tmp
 #
 #
 #
 ############################################################################

 ############################################################################
 #
 # Process the G_SPRITE command.
 #
 # 	in_bufp holds pointer to data
 #

#ifdef SPRITE2D

#include "gsprite.s"

		j      GfxDone
		nop

#endif /* SPRITE2D */

 #
 #
 #
 ############################################################################