Menu

Voir les contributions

Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.

Voir les contributions Menu

Messages - faeldaniel

#1
Oh yes is one limit, I have an idea how to solve the problem, thanks  :D
#2
I booked address 0x0000 to 0x2FF0 only sprites, maps and tiles i am using from 0x3000, I believe you quoted as being a limit. But lets go, the code is not otmized.



//Oh yes is big array, but is only for tests, in the future i go reduce this :)
unsigned short sprTiles16px[300] = {0,2,4,6,8,10,12,14,32,34,36,38,40,42,44,46,64,66,68,70,72,74,76,78,96,98,100,102,104,106,108,110,128,130,132,134,136,138,140,142,160,162,164,166,168,170,172,174,192,194,196,198,200,202,204,206,224,226,228,230,232,234,236,238,256,258,260,262,264,266,268,270,288,290,292,294,296,298,300,302,320,322,324,326,328,330,332,334,352,354,356,358,360,362,364,366,384,386,388,390,392,394,396,398,416,418,420,422,424,426,428,430,448,450,452,454,456,458,460,462,480,482,484,486,488,490,492,494,512,514,516,518,520,522,524,526,544,546,548,550,552,554,556,558,576,578,580,582,584,586,588,590,608,610,612,614,616,618,620,622,640,642,644,646,648,650,652,654,672,674,676,678,680,682,684,686,704,706,708,710,712,714,716,718,736,738,740,742,744,746,748,750,768,770,772,774,776,778,780,782,800,802,804,806,808,810,812,814,832,834,836,838,840,842,844,846,864,866,868,870,872,874,876,878,896,898,900,902,904,906,908,910,928,930,932,934,936,938,940,942,960,962,964,966,968,970,972,974,992,994,996,998,1000,1002,1004,1006,1024,1026,1028,1030,1032,1034,1036,1038,1056,1058,1060,1062,1064,1066,1068,1070,1088,1090,1092,1094,1096,1098,1100,1102,1120,1122,1124,1126,1128,1130,1132,1134,1152,1154,1156,1158,1160,1162,1164,1166,1184,1186,1188,1190};

//Custom oamInitGfxAttr, my sprites having 16X32 (see Val 6 in table Sprite sizes http://www.portabledev.com/wiki/doku.php?id=sprites_en)
REG_OBSEL = (6<<5) | (0x0000 >> 13);

//Copy the heros graphics for vram with dma, this point using 0x0000 to 0xC000
WaitForVBlank(); dmaCopyVram(&tileSourceHeros, 0x0000, &tileSourceHerosEnd-&tileSourceHeros);

//Copy the heros palette for vram with dma
dmaCopyCGram(&paletteEntryHeros, (128+0*16), 32);

//Copy the civis graphics for vram with dma, this point using 0xC000 to 0x2000
WaitForVBlank(); dmaCopyVram(&tileSourceCivis, 0xC000 , &tileSourceCivisEnd - &tileSourceCivis);

//Copy the civis palette for vram with dma
dmaCopyCGram(&paletteEntryCivis, (128+1*16), 32);

//Copy the objs graphics for vram with dma, this point using 0x2000 to 0x3000
WaitForVBlank(); dmaCopyVram(&tileSourceObjs, 0x2000, &tileSourceObjsEnd - &tileSourceObjs);

//Copy the objs palette for vram with dma
dmaCopyCGram(&paletteEntryObjs, (128+2*16), 32);


/*Table offset

   Offset              Sprite             Addres Real
   0                     Hero               0x0000
   16                   Friend1           0x0400
   32                   Friend2           0x0800
   48                   Civil1              0x0C00
   64                   Civil2              0x1000
   80                   Civil3              0x1400
   96                   Civil4              0x1800
   112                 Civil5              0x1C00
   128                 OBJ1              0x2000 //Dont working
   144                 OBJ2              0x2400 //Dont working
   160                 OBJ3              0x2800 //Dont working
   176                 OBJ4              0x2C00 //Dont working



*/

//0x0000
oamSetEx(0, OBJ_SMALL, OBJ_SHOW);
oamSet(0,  hero.x, hero.y, 0, 0, 0, sprTiles16px[0], 0);

//0x0400
oamSetEx(4, OBJ_SMALL, OBJ_SHOW);
oamSet(4,  friend1.x, friend1.y, 0, 0, 0, sprTiles16px[16], 0);

//0x0800
oamSetEx(8, OBJ_SMALL, OBJ_SHOW);
oamSet(8,  friend2.x, friend2.y, 0, 0, 0, sprTiles16px[32], 0);

//0x0C00
oamSetEx(12, OBJ_SMALL, OBJ_SHOW);
oamSet(12,  civil1.x, civil1.y, 0, 0, 0, sprTiles16px[48], 1);

//0x1000
oamSetEx(16, OBJ_SMALL, OBJ_SHOW);
oamSet(16,  civil2.x, civil2.y, 0, 0, 0, sprTiles16px[64], 1);

//0x1400
oamSetEx(20, OBJ_SMALL, OBJ_SHOW);
oamSet(20,  civil3.x, civil3.y, 0, 0, 0, sprTiles16px[80], 1);

//0x1800
oamSetEx(24, OBJ_SMALL, OBJ_SHOW);
oamSet(24,  civil4.x, civil4.y, 0, 0, 0, sprTiles16px[96], 1);

//0x1C00
oamSetEx(28, OBJ_SMALL, OBJ_SHOW);
oamSet(28,  civil5.x, civil5.y, 0, 0, 0, sprTiles16px[112], 1);

//0x2000 - Dont working
oamSetEx(32, OBJ_SMALL, OBJ_SHOW);
oamSet(32,  obj1.x, obj1.y, 0, 0, 0, sprTiles16px[128], 2);

//0x2400 - Dont working
oamSetEx(36, OBJ_SMALL, OBJ_SHOW);
oamSet(36,  obj2.x, obj2.y, 0, 0, 0, sprTiles16px[144], 2);

//0x2800 - Dont working
oamSetEx(40, OBJ_SMALL, OBJ_SHOW);
oamSet(40,  obj3.x, obj3.y, 0, 0, 0, sprTiles16px[160], 2);

//0x2C00 - Dont working
oamSetEx(44, OBJ_SMALL, OBJ_SHOW);
oamSet(44,  obj4.x, obj4.y, 0, 0, 0, sprTiles16px[176], 2);


#3
I am put all graphics in VRAM with DMA Copy, the size of address of Sprites I am just using:
void oamInitGfxAttr(0x0000, OBJ_SIZE8);

Because i can only use  Sprites from address 0x0000 to 0x1FF0 (size 0x1FF0?) in gfxoffset? I need using between 0x0000 to 0x2FF0 for the Sprites, but the sprites is not operate from 0x2000, is one limit?
#4
Hi alekmaul,

Remember that bug with the function oamSetXYEx, if your set oamSetEx as OBJ_SMALL and value of X in oamSetXYEx as value negative the sprite is changed for OBJ_LARGE while this sprite is negative I quoted here http://www.portabledev.com/smf/index.php?topic=324.0

you can find any solution?
#5
My code for rpg is very large and you take a long time to understand but if one day you're curious about some of my routines I can send to you brother.

I go creat new code for exemple Mode1Scroll with sprites using my engine based for we working in colission and you can post in the future realeases of exemples in lib. Anyway I want to give my contribution :)
#6
I try this but dont working, honestly I have no idea what's going on can. this would be a good challenge for you, take this my image and try with your code. I am using map with SC_64x32, X maximum 512pixel and Y 756, vram is update and only Y axis.
#7
Yes I know, &mapcol  is one address and not usigned, this example is not correct, i am showing one possible solution for my problem, but lets go, my problem is Collision Map,I can not understand how it works, my backgrounds has 512px / 756px, this is one example below, i think this function is valid for my imagem, but dont working.


u16 checkMapCol(short OBJX, short OBJY, u8 *mapCol){
         
        //512 pixel width 512/8 = 64
        //768 pixel height -> 768/8 = 96     
u16 *ptrMap = (u16 *) &mapCol +  (OBJY>>3)*64 + (OBJX>>3)*96;

return (*ptrMap);
}


Original image:
http://faeldaniel.com.br/stg_1_1_col.bmp


That's the only problem I could not solve yet and i need your help for this.
#8
Hello alekmaul,

I am created my Routine for get Map Collision, I need to know what is the value a certain tile, for exemple, i having one Map Collision with Width 256 and Heigth 512 and genarate my Collision Map, your name is definide as &mapcol for this imagem, i liked get value of 14º tile and return if is 1st or 2st tile becouse Map Collision has only 2 tiles.

Citation
shot valueOfTile;

valueOfTile = &mapcol / (13); //13st tile, return 1 or 1st Tile
valueOfTile = &mapcol / (14); //14st tile, Return 1 or 1st Tile
valueOfTile = &mapcol / (15); //15st tile, Return 2 or 2st Tile
valueOfTile = &mapcol / (16); //16st tile, Return 2 or 2st Tile
valueOfTile = &mapcol / (17); //17st tile, Return 1 or 1st Tile
valueOfTile = &mapcol / (18); //18st tile, Return 2 or 2st Tile

...

#10
Sorry  :-[ i did not read the documentation of gfx2snes, just use the parameter -mp (Convert the whole picture with high priority) and the graphic is convert with high priority.  ;D
#11
Hello alekmaul,

I have this problem in my initial studies and whait becouse this is not important in moment, i soluvied all problems for my game but the only one persister, this Background Priority, i need with the background layer in mode 1:

"Front" < BG3, BG2, SPRITES, BG1 > "Behind"

I control individual layers perfectly in VRAM, i developed my implementation for show dialog for texts in BG3 its it work very good because I have had problem with native consoleDrawText() in BG3.

My view structure is thus:

<Front Screen>
BG3 -> Here Dialog texts (I need set bit priority for 1, default is 0)
BG2 -> Here will be for example, leaf of trees, to create depth effect for the sprite (I need set bit priority for 1, default is 0)
OBJ -> Are all sprites (The priority i set in 2 and working becouse is native in function OamSet)
BG1 -> Here all background for my map (the bit priority default is 0, so no need to do anything)
<Behind>


From what I read this is possible becouse i see in the official documentation as provided by Nintendo in the page 214, this point talk about this http://99.10.161.154/alcaro/docs/book1_text.pdf simply to set priorities so:
BG3 -> priority 1
BG2 -> priority 1
OBJ -> priority 2
BG1 -> priority 0


I see too in No$sns in Vram Viewer in tabs individual BGs i see filder "Priority".

Talking with KungFuFurby he also commented that:
CitationThis is how you get that type of arrangement (if I interpreted http://nocash.emubase.de/fullsnes.htm#snespictureprocessingunitppu 's background priority chart correctly)

I need set this priority flag, this should be done with graphics (gfx2snes) converter correct?
#12
Hello alekmaul,

i did not understand how the collision in unique existing example in "likemario"  :-\

As I understand it you must create an image with two color palettes where the first color is pink, the second color is the collision. Having as an example of "AnimatedSprite" how do I image that the sprite does not move through the squares reds? below is how I did it so does not work.

This is my example "AnimatedSprite" but not work, this is link for the project test the collision https://anonfiles.com/file/d156b7840b851b865b018ff44df47b41:



/*---------------------------------------------------------------------------------
Animated Sprite demo
-- alekmaul
Sprite from Stephen "Redshrike" Challener), http://opengameart.org
---------------------------------------------------------------------------------*/
#include <snes.h>

extern char gfxpsrite, gfxpsrite_end;
extern char palsprite, palsprite_end;

extern char patterns, patterns_end;
extern char palette, palette_end;
extern char map, map_end;

extern char col, col_e;

#define FRAMES_PER_ANIMATION 3 // 3 sprites per direction

//---------------------------------------------------------------------
// The Monster sprite
//---------------------------------------------------------------------
typedef struct
{
short x, y;
int gfx_frame;
int state;
int anim_frame;
int flipx;
} Monster;

//---------------------------------------------------------------------
// The state of the sprite (which way it is walking)
//---------------------------------------------------------------------
enum SpriteState {W_DOWN = 0, W_UP = 1, W_RIGHT = 2,  W_LEFT = 2};

//---------------------------------------------------------------------
// Screen dimentions
//---------------------------------------------------------------------
enum {SCREEN_TOP = 0, SCREEN_BOTTOM = 224, SCREEN_LEFT = 0, SCREEN_RIGHT = 256};

char sprTiles[9]={0,2,4, 6,8,10, 12,14,32};  // Remeber that sprites are interleave with 128 pix width,


//---------------------------------------------------------------------
// The magic function for collision
//---------------------------------------------------------------------
u16 getCollisionTile(u16 x, u16 y) {
u16 *ptrMap = (u16 *) &col + (y) + (x);

return (*ptrMap);
}

//---------------------------------------------------------------------------------
int main(void) {
unsigned short pad0,i;
Monster monster = {10,10};

    // Initialize SNES
consoleInit();

// Init Sprites gfx and palette with default size of 16x16
oamInitGfxSet(&gfxpsrite, (&gfxpsrite_end-&gfxpsrite), &palsprite, (&palsprite_end-&palsprite), 0, 0x0000, OBJ_SIZE16);


// Copy tiles to VRAM
bgInitTileSet(0, &patterns, &palette, 0, (&patterns_end - &patterns), (&palette_end - &palette), BG_16COLORS, 0x4000);

// Copy Map to VRAM
bgInitMapSet(0, &map, (&map_end - &map),SC_32x32, 0x1000);


// Define sprites parameters
oamSet(0,  monster.x, monster.y, 0, 0, 0, 0, 0);
oamSetEx(0, OBJ_SMALL, OBJ_SHOW);


// Now Put in 16 color mode and disable all backgrounds
setMode(BG_MODE1,0); bgSetDisable(1); bgSetDisable(2);

// Wait VBL 'and update sprites too ;-)
WaitForVBlank();

// Wait for nothing :P
while(1) {
// Refresh pad values
scanPads();

// Get current #0 pad
pad0 = padsCurrent(0);

if (pad0) {
// Update sprite with current pad
if(pad0 & KEY_UP) {
if (getCollisionTile((monster.x), ((monster.y) - 1)) == 0) {
if(monster.y >= SCREEN_TOP) monster.y--;
}
monster.state = W_UP;
monster.flipx = 0;
}
if(pad0 & KEY_LEFT) {
if (getCollisionTile(((monster.x) - 1), (monster.y)) == 0) {
if(monster.x >= SCREEN_LEFT) monster.x--;
}
monster.state = W_LEFT;
monster.flipx = 1;
}
if(pad0 & KEY_RIGHT) {
if (getCollisionTile(((monster.x) + 1), (monster.y)) == 0) {
if(monster.x <= SCREEN_RIGHT) monster.x++;
}
monster.state = W_LEFT;
monster.flipx = 0;
}
if(pad0 & KEY_DOWN) {
if (getCollisionTile((monster.x), ((monster.y) + 1)) == 0) {
if(monster.y <= SCREEN_BOTTOM) monster.y++;
}
monster.state = W_DOWN;
monster.flipx = 0;
}
monster.anim_frame++;
if(monster.anim_frame >= FRAMES_PER_ANIMATION){
monster.anim_frame = 0;
}
}

// Now, get current sprite in current animation
monster.gfx_frame = sprTiles[monster.anim_frame + monster.state*FRAMES_PER_ANIMATION ];
oamSet(0,  monster.x, monster.y, 3, monster.flipx, 0, monster.gfx_frame, 0);


// Wait VBL 'and update sprites too ;-) )
WaitForVBlank();
}
return 0;
}




Fix this code for me?  ;D
#13
Citation de: RonaldCoLtd le 14 Juillet 2013 à 18:31:09
Citation de: faeldaniel le 14 Juillet 2013 à 05:33:40
alekmaul not yet started their studies this point however how to adapt this function that you used in the LikeMario for bg collision of 512px X 512px?

u16 getCollisionTile(u16 x, u16 y) {
u16 *ptrMap = (u16 *) &mapcol + (y>>3)*300 + (x>>3);

return (*ptrMap);
}


( Sorry I wasn't very descriptive ) I meant sprite by sprite. I.e., Sprite 1 touches Sprite 2 and Sprite 1 disappears.

Hixbox algorithm is amazing solution and functional but if you are not understand look at this function:

if((oamGetX(ID_SPRITE_1) == oamGetX(ID_SPRITE_2)) & oamGetY(ID_SPRITE_1) == oamGetY(ID_SPRITE_2) ){
   oamSetEx(ID_SPRITE_1, OBJ_SMALL, OBJ_HIDE);
}

The problem for it is that the sprite disappears when the two stay exactly in the same position, remember you need to take into consideration the size of the sprite so this function does not work well
#14
PVSnesLib English section / Re : Adding Collision?
14 Juillet 2013 à 05:33:40
alekmaul not yet started their studies this point however how to adapt this function that you used in the LikeMario for bg collision of 512px X 512px?

u16 getCollisionTile(u16 x, u16 y) {
u16 *ptrMap = (u16 *) &mapcol + (y>>3)*300 + (x>>3);

return (*ptrMap);
}
#15
Brother it will be wonderful for me, I'll be looking forward to this moment, again thanks for the wonderful work, you have a big fan ;D