 *
 * Mesa 3-D graphics library
 * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *

* Assembler implementations of functions in ADisp_SW.c (Sam Jordan)

		mc68040
		fpu

		include "GL/Amigamesa.i"

		XDEF    _SWD_clear_LUT8
		XDEF    _SWD_clear_ARGB

;// SWD_clear_LUT8
*
* void SWD_clear_LUT8(GLcontext *ctx,GLboolean all,
*                     GLint x, GLint y,GLint width, GLint height )
*
*
_SWD_clear_LUT8

		rsreset
.fpuregs        rs.x    0
.regs           rs.l    7
		rs.l    1
.ctx            rs.l    1
.all            rs.b    1
		rs.b    1
.x              rs.l    1
.y              rs.l    1
.width          rs.l    1
.height         rs.l    1

		movem.l d2-d7/a2,-(sp)
		move.l  .ctx(sp),a0
		move.l  .x(sp),d0
		move.l  .y(sp),d1
		move.l  .width(sp),d2
		move.l  .height(sp),d3

		move.l  GL_DRIVERCTX(a0),a1
		move.l  AMC_CLEARPIXEL(a1),d4

		tst.b   .all(sp)
		beq.b   .partial_clear
.full_clear
		move.l  AMC_BACKARRAY(a1),a2
		move.l  d4,d5
		lsl.l   #8,d5
		or.b    d4,d5
		move.l  d5,d4
		swap    d4
		or      d5,d4
		mulu    d2,d3
		move.l  d3,d2
		and.l   #$f,d2
		lsr.l   #4,d3
		beq.b   .clearslow
.clearfast
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		subq.l  #1,d3
		bne.b   .clearfast
.clearslow
		subq    #1,d2
		bmi.b   .end
.loop
		move.b  d4,(a2)+
		dbra    d2,.loop
		bra.b   .end
.partial_clear
		move.l  AMC_BACKARRAY(a1),a2
		move.l  AMC_HEIGHT(a1),d5
		move.l  d3,d7
		sub.l   d1,d5
		sub.l   d3,d5
		mulu    d2,d5
		add.l   d0,d5
		add.l   d5,a2
		move.l  d4,d5
		lsl.l   #8,d5
		or.b    d4,d5
		move.l  d5,d4
		swap    d4
		or      d5,d4
		move.l  AMC_WIDTH(a1),d5
		sub.l   d2,d5
		move.l  d2,d3
		and.l   #$f,d2
		lsr.l   #4,d3
		subq    #1,d7
		bmi.b   .end
.loop2
		move    d3,d6
		subq    #1,d6
		bmi.b   .cont
.loop3
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		dbra    d6,.loop3
.cont
		move    d2,d6
		subq    #1,d6
		bmi.b   .cont2
.loop4
		move.b  d4,(a2)+
		dbra    d6,.loop4
.cont2
		add.l   d5,a2
		dbra    d7,.loop2
.end
		movem.l (sp)+,d2-d7/a2
		rts
;;/
;// SWD_clear_ARGB
*
* void SWD_clear_ARGB(GLcontext *ctx,GLboolean all,
*                GLint x, GLint y, GLint width, GLint height )
*
*
_SWD_clear_ARGB

		rsreset
.fpuregs        rs.x    0
.regs           rs.l    7
		rs.l    1
.ctx            rs.l    1
.all            rs.b    1
		rs.b    1
.x              rs.l    1
.y              rs.l    1
.width          rs.l    1
.height         rs.l    1

		movem.l d2-d7/a2,-(sp)
		move.l  .ctx(sp),a0
		move.l  .x(sp),d0
		move.l  .y(sp),d1
		move.l  .width(sp),d2
		move.l  .height(sp),d3

		move.l  GL_DRIVERCTX(a0),a1
		move.l  AMC_CLEARPIXEL(a1),d4

		tst.b   .all(sp)
		beq.b   .partial_clear
.full_clear
		move.l  AMC_BACKARRAY(a1),a2
		mulu    d2,d3
		move.l  d3,d2
		and.l   #$3,d2
		lsr.l   #2,d3
		beq.b   .clearslow
.clearfast
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		subq.l  #1,d3
		bne.b   .clearfast
.clearslow
		subq    #1,d2
		bmi.b   .end
.loop
		move.l  d4,(a2)+
		dbra    d2,.loop
		bra.b   .end
.partial_clear
		move.l  AMC_BACKARRAY(a1),a2
		move.l  AMC_HEIGHT(a1),d5
		move.l  d5,d7
		sub.l   d1,d5
		sub.l   d3,d5
		mulu    d2,d5
		add.l   d0,d5
		lsl.l   #2,d5
		add.l   d5,a2
		move.l  AMC_WIDTH(a1),d5
		sub.l   d2,d5
		lsl.l   #2,d5
		move.l  d2,d3
		and.l   #$3,d2
		lsr.l   #2,d3
		subq    #1,d7
		bmi.b   .end
.loop2
		move    d3,d6
		subq    #1,d6
		bmi.b   .cont
.loop3
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		move.l  d4,(a2)+
		dbra    d6,.loop3
.cont
		move    d2,d6
		subq    #1,d6
		bmi.b   .cont2
.loop4
		move.l  d4,(a2)+
		dbra    d6,.loop4
.cont2
		add.l   d5,a2
		dbra    d7,.loop2
.end
		movem.l (sp)+,d2-d7/a2
		rts
;;/

