97Fermer99
deleted2Le 16/04/2009 à 23:28
Et ya aussi GribOnAllocPlanes2, qui alloue deux plans contigus, alignés komilfô évidemment, sur tous les HW, et en utilisant le handler de f-line (-50 bytes) cheeky
GribOnAllocPlanes2

	.include	"os.h"
	.include	"grib.h"

|=========================================
|	GribOnAllocPlanes2
|=========================================
|	Alloc 2 consecutive planes and activate the gray handler (LCD_MEM is never used)
|	Warning : a f-line handler must be installed for ROM calls
|
|	input	a0	**plane0
|		a1	**plane1
|	return	d0.w	handle
|	destroy	d0-d2/a0
|
|=========================================
FunctionSection	GribOnAllocPlanes2
	movem.l	%a0-%a1,-(%sp)	|save a0-a1
	pea.l	2*3840+8.w	|two consecutive and aligned planes
	RC	HeapAllocHigh	|try to alloc and lock
	move.w	%d0,(%sp)		|push the handle and test is (doesn't change sp)
	beq.s	Failed		|not enough RAM, quit
	RC	HeapDeref
	move.l	%a0,%d0		|alignment
	addq.l	#7,%d0		|for HW1
	andi.b	#~7,%d0
	move.l	%d0,%d1		|prepare the args
	addi.l	#3840.w,%d1	|for GribOn
Failed:	movem.l	%d0-%d1,-(%sp)	|save the args, because we have to fill a0-a1
	beq.s	NoInstallGrib	|H_NULL? Doesn't install the gray handler (else the Z-Flag isn't set (addi.l #3840,%d1)
	jbsr	GribOn
NoInstallGrib:
	movem.l	(%sp)+,%d0-%d2/%a0-%a1	|we have :	- *planes in d0-d1 (or H_NULL if the alloc failed)
					|		- the handle in the upper word of d2 (even if the alloc failed)
					|		- **planes in a0-a1 (even if the alloc failed)
	move.l	%d0,(%a0)			|send the planes adresses
	move.l	%d1,(%a1)			|to the program
	movea.l	%d0,%a0			|first byte of the planes, used to clear them
	swap.w	%d2			|put the handle in the lower word
	move.w	%d2,%d0			|output of the function in d0.w
	beq.s	Quit			|H_NULL? So quit without clearing any plane
	move.w	#(3840*2)/4-1,%d1		|counter
ClearPlanes:
	clr.l	(%a0)+			|clear planes
	dbra.w	%d1,ClearPlanes
Quit:	rts