GBA Tutorial - Elf Show

xiaoxiao2021-03-06  18

Source program http://cgdn.net/gba/tutor/sprite.zip Now let's take a look at the display of the elves. GBA uses 0x06010000 to 0x06017ffe 32K space to store the wizard block, then 1024bytes from 0x07000000 to control the properties of the elves, which is OAM (Object Attribute Memory), support up to 128 elves, each elf 8bytes OAM. The buddy can be used in this step directly to see the application method directly to this step): bytes 1 and 2f e d c b A 9 8 7 6 5 4 3 2 1 0s s x x x x x j J J J J J JJ = Elf Y coordinate BYTES 3 and 4F e d C B A 9 ​​8 7 6 5 4 3 2 1 0s s x x x x i i i i i i i is = Elf size 0000: 8 x 8 1000: 8 x 16 0001: 16 x 16 号 x 32 1010: 16 x 32 0011: 64 x 64 1011: 32 x 64 0100: 16 x 8 0101: 32 x 8 0110: 32 x 16 0110: 32 x 16 011: 64 x 32 = Elf X coordinate bytes 5 and 6f e d C B A 9 ​​8 7 6 5 4 3 2 1 0x x x x x x x x x x xp = Elf, the elves will be drawn after BG3, and preferred to other BG 10: Elf will be drawn after BG2 and BG3, and preferred to BG0 and BG1 01: Elf will be drawn after BG1, BG2, and BG3, And preferred to BG0 00: The wizard will draw the serial number of T = tiles after all background layers. That is, the starting index number of the tile arranged. BYTES 7 and 8 is used to control the rotation and zoom of the wizard. Now let's look at the content of the elves in MyGba.h: 1. Elf Structure TypedEf struct tagoAmentry {u16 attribute0; u16 attribute1; u16 attribute2; u16 attribute3;} OAMENTRY, * POAMENTRY; here four words (Word) is We just saw Bytes 1 & 2,3 & 4 ... 2. Initialization Elf Properties Void InitializesPrites (Void) {Int loop; for (loop = 0; Loop <128; Loop ) {sprites [loop] .attribute0 = 160 ; // y> 159, sprite offscreen sprites [loop] .attribute1 = 240; // x> 239, sprite offscreen sprites [loop] .attribute2 = 0; // zero out}} put the wizard outside the screen, otherwise you Nothing, will also display a color block (bug ??) on the top left corner (0, 0).

转载请注明原文地址:https://www.9cbs.com/read-44339.html

New Post(0)