/*********************************************************/
/* This source code copyright (c) 1991-2001, Aaron Giles */
/* See the Read Me file for licensing information.       */
/* Contact email: mac@aarongiles.com                     */
/*********************************************************/

// short *InitRegion(RgnPtr rgn, RgnBufferPtr rgnBuffer, Rect *boxRect)

	short *rgnData = (short *)(&rgn->rgnBBox + 1);
	long *bufData = rgnBuffer->buffer;
	long x;
	
	if (rgn->rgnSize == 10) {
		rgnBuffer->yCount = Height(&rgn->rgnBBox);
		*bufData++ = 0;
		*bufData++ = Width(&rgn->rgnBBox);
	} else
		if (!(rgnBuffer->yCount = *rgnData++ - boxRect->top)) {
			while ((x = *rgnData++) != 0x7fff)
				*bufData++ = x - boxRect->left;
			rgnBuffer->yCount = *rgnData++ - boxRect->top;
		}
	*bufData++ = 0x7fff;
	return rgnData;

/*
	r3 = rgn
	r4 = rgnBuffer
	r5 = boxRect

00000000: BFA1FFF4  stmw     r29,-12(SP)

	short *rgnData = (short *)(&rgn->rgnBBox + 1);
	long *bufData = rgnBuffer->buffer;
	long x;

00000004: A8C30000  lha      r6,0(rgn)					;r6 = rgn->rgnSize
00000008: 3BC3000A  addi     rgnData,rgn,10				;r30 = rgnData = (short *)(&rgn->rgnBBox + 1)
0000000C: 2C06000A  cmpwi    r6,10						;is rgn->rgnSize == 10?
00000010: 3BA40008  addi     bufData,rgnBuffer,8		;r29 = bufData = rgnBuffer->buffer
00000014: 40820040  bne      $00000054                 	;if (rgn->rgnSize == 10) {

	if (rgn->rgnSize == 10) {
		rgnBuffer->yCount = Height(&rgn->rgnBBox);
		*bufData++ = 0;
		*bufData++ = Width(&rgn->rgnBBox);
	} else

00000018: A8E30002  lha      r7,2(rgn)					;	r7 = rgn->rgnBBox.top
0000001C: A9030006  lha      r8,6(rgn)					;	r8 = rgn->rgnBBox.bottom
00000020: 7FAAEB78  mr       r10,bufData				;	r10 = r29 = bufData
00000024: 7CE74050  sub      r7,r8,r7					;	r7 = Height(&rgn->rgnBBox)
00000028: 90E40000  stw      r7,0(rgnBuffer)			;	rgnBuffer->yCount = r7
0000002C: 39200000  li       r9,0						;	r9 = 0
00000030: 912A0000  stw      r9,0(r10)					;	*r10 = r9 = 0
00000034: A9630004  lha      r11,4(rgn)					;	r11 = rgn->rgnBBox.left
00000038: A9830008  lha      r12,8(rgn)					;	r12 = rgn->rgnBBox.right
0000003C: 3BBD0004  addi     bufData,bufData,4			;	bufData++
00000040: 7FA6EB78  mr       r6,bufData					;	r6 = r29 = bufData
00000044: 7D6B6050  sub      r11,r12,r11				;	r11 = Width(&rgn->rgnBBox)
00000048: 3BBD0004  addi     bufData,bufData,4			;	bufData++
0000004C: 91660000  stw      r11,0(r6)					;	*r6 = r11
00000050: 42800068  bc       ALWAYS,cr0_LT,$000000B8  	;} else

		if (!(rgnBuffer->yCount = *rgnData++ - boxRect->top)) {
			while ((x = *rgnData++) != 0x7fff)
				*bufData++ = x - boxRect->left;
			rgnBuffer->yCount = *rgnData++ - boxRect->top;
		}

00000054: 7FC8F378  mr       r8,rgnData					;	r8 = r30 = rgnData
00000058: A8E50000  lha      r7,0(boxRect)				;	r7 = boxRect->top
0000005C: A9080000  lha      r8,0(r8)					;	r8 = *r8
00000060: 3BDE0002  addi     rgnData,rgnData,2			;	rgnData++
00000064: 7CE74050  sub      r7,r8,r7					;	r7 = r8 - boxRect->top
00000068: 2C070000  cmpwi    r7,0						;	is r7 0?
0000006C: 90E40000  stw      r7,0(rgnBuffer)			;	rgnBuffer->yCount = r7
00000070: 40820048  bne      $000000B8                  ;   if (!rgnBuffer->yCount) {
00000074: 42800018  bc       ALWAYS,cr0_LT,$0000008C    ;		while () {
00000078: A9250002  lha      r9,2(boxRect)				;			r9 = boxRect->left
0000007C: 7FAAEB78  mr       r10,bufData				;			r10 = bufData
00000080: 7D29F850  sub      r9,x,r9					;			r9 = r31 - r9
00000084: 3BBD0004  addi     bufData,bufData,4			;			bufData++
00000088: 912A0000  stw      r9,0(r10)					;			*r10 = r9
0000008C: 7FCBF378  mr       r11,rgnData				;			r11 = rgnData
00000090: ABEB0000  lha      x,0(r11)					;			r31 = *r11
00000094: 3BDE0002  addi     rgnData,rgnData,2			;			rgnData++
00000098: 2C1F7FFF  cmpwi    x,32767					;			is r31 == 0x7fff?
0000009C: 4082FFDC  bne      $00000078					;		}
000000A0: 7FC6F378  mr       r6,rgnData					;		r6 = rgnData
000000A4: A9850000  lha      r12,0(boxRect)				;		r12 = boxRect->top
000000A8: A8C60000  lha      r6,0(r6)					;		r6 = *r6
000000AC: 3BDE0002  addi     rgnData,rgnData,2			;		rgnData++
000000B0: 7D8C3050  sub      r12,r6,r12					;		r12 = r6 - r12
000000B4: 91840000  stw      r12,0(rgnBuffer)			;		rgnBuffer->yCount = r12
														;	}

	*bufData++ = 0x7fff;
	return rgnData;

000000B8: 7FA8EB78  mr       r8,bufData					;r8 = bufData
000000BC: 38E07FFF  li       r7,32767					;r7 = 0x7fff
000000C0: 3BBD0004  addi     bufData,bufData,4			;bufData++
000000C4: 90E80000  stw      r7,0(r8)					;*r8 = r7
000000C8: 7FC3F378  mr       r3,rgnData					;r3 = rgnData

000000CC: BBA1FFF4  lmw      r29,-12(SP)
000000D0: 4E800020  blr
*/