Posted: Mon Apr 25, 2011 5:11 pm
Hi,
I n' do not arrive at l' to use last version: it does not have makefile.gen ?
Je souhaite déplacer un sprite.
Voici l'ancienne version que j'utilise (racine C: ), que j'aimerai remplacer par la nouvelle.
http://www.mirari.fr/WmEw
I n' do not arrive at l' to use last version: it does not have makefile.gen ?
Je souhaite déplacer un sprite.
Code: Select all
// Philippe H. - Toulouse - 25/04/2011
#include "genesis.h"
/* ProgMD/Gendev/include/joy.h 13/01/2007
#ifndef _JOY_H_
#define _JOY_H_
#define JOY_1 0x0000
#define JOY_2 0x0001
#define JOY_3 0x0002
#define JOY_4 0x0003
#define JOY_5 0x0004
#define JOY_6 0x0005
#define JOY_7 0x0006
#define JOY_8 0x0007
#define JOY_NUM 0x0008
#define JOY_ALL 0xFFFF
#define BUTTON_UP 0x0001
#define BUTTON_DOWN 0x0002
#define BUTTON_LEFT 0x0004
#define BUTTON_RIGHT 0x0008
#define BUTTON_A 0x0040
#define BUTTON_B 0x0010
#define BUTTON_C 0x0020
#define BUTTON_START 0x0080
#define BUTTON_X 0x0100
#define BUTTON_Y 0x0200
#define BUTTON_Z 0x0400
#define BUTTON_MODE 0x0800
#define BUTTON_DIR 0x000F
#define BUTTON_BTN 0x0FF0
#define BUTTON_ALL 0x0FFF
#define JOY_SUPPORT_3BTN 0x01
#define JOY_SUPPORT_6BTN 0x02
#define JOY_SUPPORT_MOUSE 0x04
#define JOY_SUPPORT_TEAMPLAY 0x08
#define JOY_SUPPORT_MENACER 0x10
#define JOY_SUPPORT_ANALOGJOY 0x20
#define JOY_SUPPORT_KEYBOARD 0x40
typedef void _joyEventCallback(u16 joy, u16 changed, u16 state);
void JOY_init();
void JOY_setEventHandler(_joyEventCallback *CB);
void JOY_setSupport(u16 port, u16 support);
u16 JOY_readJoypad(u16 joy);
void JOY_waitPressBtn();
void JOY_waitPress(u16 joy, u16 btn);
void JOY_update();
#endif // _JOY_H_
*/
/**
* sprite tile data
*/
const unsigned short tiledata_palette[16] = {
0x0E0E,0x000E,0x0EEE,0x0620,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
};
const unsigned long tiledatb_tiles[512] = {
0x00000000, //' Tile #0
0x00000000,
0x00000000,
0x00000000,
0x00000001,
0x00000011,
0x00000111,
0x00001112,
0x00011122, //' Tile #1
0x00011122,
0x00111222,
0x00111222,
0x00112222,
0x00112222,
0x01112222,
0x01112222,
0x01112222, //' Tile #2
0x01112222,
0x00112222,
0x00112222,
0x00111222,
0x00111222,
0x00011122,
0x00011122,
0x00001112, //' Tile #3
0x00000111,
0x00000011,
0x00000001,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000, //' Tile #4
0x00000011,
0x00111111,
0x11111111,
0x11112222,
0x11222222,
0x22222222,
0x22222222,
0x22222222, //' Tile #5
0x22222222,
0x22222222,
0x22222222,
0x22222233,
0x22222322,
0x22222232,
0x22222232,
0x22222232, //' Tile #6
0x22222232,
0x22222232,
0x22222223,
0x22222222,
0x22222222,
0x22222222,
0x22222222,
0x22222222,//' Tile #7
0x22222222,
0x11222222,
0x11112222,
0x11111111,
0x00111111,
0x00000011,
0x00000000,
0x00000000, //' Tile #8
0x11000000,
0x11111100,
0x11111111,
0x22221111,
0x22222211,
0x22222222,
0x22222222,
0x22222222, //' Tile #9
0x22222222,
0x22222222,
0x22222222,
0x32222222,
0x23222222,
0x23222222,
0x23222222,
0x23222222, //' Tile #10
0x23222222,
0x23222222,
0x32222222,
0x22222222,
0x22222222,
0x22222222,
0x22222222,
0x22222222, //' Tile #11
0x22222222,
0x22222211,
0x22221111,
0x11111111,
0x11111100,
0x11000000,
0x00000000,
0x00000000, //' Tile #12
0x00000000,
0x00000000,
0x00000000,
0x10000000,
0x11000000,
0x11100000,
0x21110000,
0x22111000, //' Tile #13
0x22111000,
0x22211100,
0x22211100,
0x22221100,
0x22221100,
0x22221110,
0x22221110,
0x22221110, //' Tile #14
0x22221110,
0x22221100,
0x22221100,
0x22211100,
0x22211100,
0x22111000,
0x22111000,
0x21110000, //' Tile #15
0x11100000,
0x11000000,
0x10000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
u16 score;
//ushort i;
//,k=0,scrollx=0,scrolly=0;
//boucle principale
int main()
//ushort i,k=0,scrollx=0,scrolly=0;
{
long xpos=150;
long ypos=124;
long X=16;
long Y=1;
// initialisation du VDP + Joypad
VDP_init();
JOY_init();
// mise en Vram et CRAM des GFX
VDP_setPalette(2, (u16 *) tiledata_palette);
VDP_DoVRamDMA( (u32) tiledatb_tiles, 32, 512);
// ******************************
// ******************************
// ******************************
// *******************************
// et on affiche sur l écran ;)
// ushort i,k=0;
// uchar *pb,i;
// pb = 0x40;
// pb += 2;
/*set the ball sprite data at position (160,0 = 128+160= 288, 128+0= 128), 0xA=0101b=16x16 (sprite size in tiles),
* 32832 = 32768 + 64 = 1000000000000000b(priority/vflip/hflip) + 1000000b(vram position of tile data)
VDP_setSprite(0, width/2, 0, 0x5, TILE_ATTR_FULL(PAL0, 0, 0, 0, ballTileIdx) , 1);
VDP_setSprite(1, width/2, height - border, 0x8,TILE_ATTR_FULL(PAL1, 0, 0, 0, paddletileIdx), 0);
*/
//xpos=100;
// void VDP_setSprite(u16 index, u16 x, u16 y, u8 size, u16 tile_attr, u8 link)
VDP_setSprite(0, xpos, 150, 0xF, 0x4000+1, 1);
VDP_updateSprites();
while (1)
{
if (BUTTON_RIGHT) // move sprite
{
xpos+= 1;
}
if (BUTTON_LEFT) // move sprite
{
xpos-= 1;
}
if (BUTTON_UP) // move sprite
{
ypos-= 1;
}
if (BUTTON_DOWN) // move sprite
{
ypos-= 1;
}
if (BUTTON_START) // reset sprite position
{
xpos= 150;
ypos=124;
}
JOY_update();
VDP_setSprite(0, xpos, ypos, 0xF, 0x4000+1, 1);
VDP_updateSprites();
VDP_drawText(APLAN,"Sprite Test", 0x0000, X, Y);
VDP_waitVSync();
}
}
http://www.mirari.fr/WmEw