************************************************
* This routine is for use with the Flippix     *
* routine in Personal Pascal.                  *
* Use this in high rez only.                   *
*                                              *
* Written by Bruce Wiebe                       *
* Copyright 1989 Antic Publishing Inc.         *
*                                              *
************************************************

 	COMMENT	PASCAL
	XDEF	FLIPPIX
	SECTION	TEXT
FLIPPIX
    	move.l	(sp)+,d5	*pop  off return address
	move.l	(sp)+,d0	*pop y off stack
	move.l	(sp)+,d1	*pop x off stack
	move.l	(sp)+,a0	*get screen address
	lsl.l	#7,d0		*multiply by 128
	move.l	d0,d4		*save the result
	add.l	d4,d0		*the result
	add.l	d4,d0		*of all this is to
	add.l	d4,d0		*multiply by 640
	add.l	d4,d0		*without using mul

	add.l	d1,d0		*add x to get pixnumber
	divs.w	#16,d0		*get byte offset 
	swap	d0		*exchange high and low byte
	move.b	d0,bitnumber	*save the remainder
	swap	d0		*flip bytes back

	and.l	#$0000FFFF,d0	*clear high byte
	lsl.l	#1,d0		*multiply by 2 the fast way
	add.l 	d0,a0		*find address of screen byte 
	move.w	#15,d3		*get bitnumber to AND with
	sub.b	bitnumber,d3	*d3 is number of bits to shift
	move.w	#1,d4		*put a 1 in d4
	lsl.w	d3,d4		*shift bit to correct position
	move.w	(a0),d1		*load word of screen to d1
	eor.w	d4,d1		*toggle bit 
	move.w	d1,(a0)		*write directly to screen
	move.l	d5,-(sp)	*push return address on stack
	rts

bitnumber	even
	dc.b	0


