27Fermer29
chickendudeLe 27/11/2012 à 22:02
Génial ! grin Je ne savais pas que l'arm était si puissant, une instruction peut faire comme 10 choses à la fois !

deeph : il marche parfaitement, merci ! J'ai ajouté un peu d'information sur les sprites dans gba.inc, rien de nouveau mais peut-être il te (vous smile) sera utile.
@@ KEY PAD DEFINES @@
KEY_A 		= 1
KEY_B 		= 2
KEY_SELECT	= 4
KEY_START	= 8
KEY_RIGHT	= 16
KEY_LEFT	= 32
KEY_UP		= 64
KEY_DOWN	= 128
KEY_R		= 256
KEY_L		= 512
KEYS		= 0x04000130
KEYS_HIGH	= 0x04000000
KEYS_LOW	= 0x00000130

@@ Display @@
MODE_0 = 0x00
MODE_1 = 0x01
MODE_2 = 0x02
MODE_3 = 0x03
MODE_4 = 0x04
MODE_5 = 0x05

BACKBUFFER = 0x010
H_BLANK_OAM = 0x020

OBJ_MAP_2D = 0x00
OBJ_MAP_1D = 0x040

FORCE_BLANK = 0x080

BG0_ENABLE = 0x0100
BG1_ENABLE = 0x0200 
BG2_ENABLE = 0x0400
BG3_ENABLE = 0x0800
OBJ_ENABLE = 0x01000 
WIN1_ENABLE = 0x02000 
WIN2_ENABLE = 0x04000
WINOBJ_ENABLE = 0x08000
VRAM = 0x06000000
VPAL = 0x05000000
REG_DISPCNT = 0x04000000	@

@@ SPRITES @@

@*** Attribute 0 ***
@ F E D C  B A 9 8  7 6 5 4  3 2 1 0
@ S S A M  T T D R  J J J J  J J J J
@ 0-7	(J) = Y co-ordinate of the sprite (pixels)
@ 8		(R) = Rotation/Scaling on/off 
@ 9		(D) = 0 - sprite is single sized;
@			  1 - sprite is virtually double sized
@ A-B	(T) = 00 - normal
@			  01 - semi-transparent
@			  10 - obj window
@ C		(M) = enables mosaic for this sprite.
@ D		(A) = 256 color if on, 16 color if off 
@ E-F	(S) = Size, MSB in attribute 0, LSB in attribute 1

@ Byte 1 = Y coordinate of the sprite, in pixels
@ Byte 2
ROTATION_FLAG	=  0x100
SIZE_DOUBLE		=  0x200
MODE_NORMAL		=  0x000
MODE_TRANSPERANT=  0x400
MODE_WINDOWED	=  0x800
MOSAIC			= 0x1000
COLOR_16		= 0x0000
COLOR_256		= 0x2000
SIZE_8			= 0x0000 @ Only valid for SQUARE
SIZE_16			= 0x4000 
SIZE_32			= 0x8000 
SIZE_64			= 0xC000 

@*** Atribute 1 ***
@ FEDC BA98 7654 3210
@ SSVH XXXI IIII IIII	(standard sprites)
@ SSFF FFFI IIII IIII	(rotation/scaling on)
@ 0-8 (I) = X coordinate of the sprite (pixels)
@ C   (H) = flip horizinal bit
@ D   (V) = flip vertical bit
@ 9-D (F) = rotation index (0-31). rotation/scaling data in OAM attribute 3
@ E-F (S) = Size of the sprite (LSB)
@			4-bit value which sets the size of the sprite in the following way:
@			00 00: 8  x 8		10 00: 8  x 16
@			00 01: 16 x 16		10 01: 8  x 32
@			00 10: 32 x 32		10 10: 16 x 32
@			00 11: 64 x 64		10 11: 32 x 64
@			01 00: 16 x 8		11 00: Not used
@			01 01: 32 x 8		11 01: Not used
@			01 10: 32 x 16		11 10: Not used
@			01 11: 64 x 32		11 11: Not used

@ Byte 3+1 bit = X coordinate of the sprite, in pixels (9-bit value)
@ Byte 4
SQUARE			= 0x0000
WIDE			= 0x4000 
TALL			= 0x8000 
HORIZONTAL_FLIP	= 0x1000 
VERTICAL_FLIP	= 0x2000 
OAM				= 0x07000000  
OBJPAL			= 0x5000200 
CHARMEM			= 0x6010000 
CHARMEM_MODE3	= 0x6012BFD

@.macro DrawMode3Pic picDataLabel
@ldr r1,=picDataLabel
@ldr r0,=REG_DMA3SAD
@str r1,[r0]
@ldr r1,=VRAM
@ldr r0,=REG_DMA3DAD
@str r1,[r0]
@ldr r1,=(19200|DMA_32NOW)
@ldr r0,=REG_DMA3CNT
@str r1,[r0]
@.endm

@.macro CLS
@ldr r1,=REG_DISPCNT
@ldr r2,=[r1]
@ldr r0,=REG_DISPCNT
@ldr r1,=0
@str r1,[r0]
@str r2,[r0]
@.endm

@.macro RandNum Seed
@gba_rand:
@ldr	r3, =Seed		@ Point at seeds.
@ldmia	r3, {r1, r2}		@ Load them.
@tst	r2, r2, lsr .1		@ Top bit into carry.
@movs	r4, r1, rrx		@ 33 bit rotate right.
@adc	r2, r2, r2		@ Carry into lsb of Rb.
@eor	r4, r4, r1, lsl .12	@ (involved!)
@eor	r1, r4, r4, lsr .20	@ (similarly involved!)
@stmia	r3, {r1, r2}		@ Use these next time.
@.endm


EDIT: J'ai trouvé un petit problème, la palette change pour chaque sprite (donc les nibbles qui corréspond au couleur aussi). Il semble qu'il faudra pouvoir charger une palette pour que tous les sprites utilisent la même palette.