#include "soundbank.h"
extern char SOUNDBANK__;
extern char jumpsnd, jumpsndend;
#define GRAVITY 48
#define JUMPVALUE (GRAVITY * 20)
#define MARIO_MAXACCEL 0x0140
#define MARIO_ACCEL 0x0038
#define MARIO_JUMPING 0x0394
#define MARIO_HIJUMPING 0x0594
enum
{
MARIODOWN = 0,
MARIOJUMPING = 1,
MARIOWALK = 2,
MARIOSTAND = 6
};
extern char tileset, tilesetend, tilepal;
extern char tilesetdef, tilesetatt;
extern char mapmario, objmario;
extern char mariogfx, mariogfx_end;
extern char mariopal;
extern char snesfont, snespal;
u16 pad0;
s16 *marioox, *mariooy;
s16 *marioxv, *marioyv;
u16 mariox, marioy;
u8 mariofidx, marioflp, flip;
void marioinit(u16 xp, u16 yp, u16 type, u16 minx, u16 maxx)
{
if (
objNew(type, xp, yp) == 0)
return;
marioox = (u16 *)&(marioobj->
xpos + 1);
mariooy = (u16 *)&(marioobj->
ypos + 1);
marioxv = (
short *)&(marioobj->
xvel);
marioyv = (
short *)&(marioobj->
yvel);
mariofidx = 0;
marioflp = 0;
}
void mariowalk(u8 idx)
{
flip++;
if ((flip & 3) == 3)
{
mariofidx++;
mariofidx = mariofidx & 1;
}
if (*marioyv != 0)
else if ((*marioxv == 0) && (*marioyv == 0))
}
void mariofall(u8 idx)
{
if (*marioyv == 0)
{
}
}
void mariojump(u8 idx)
{
{
}
if (*marioyv >= 0)
}
void marioupdate(u8 idx)
{
{
{
if ((marioflp > 3) || (marioflp < 2))
{
marioflp = 2;
}
*marioxv -= (MARIO_ACCEL);
if (*marioxv <= (-MARIO_MAXACCEL))
*marioxv = (-MARIO_MAXACCEL);
}
{
if ((marioflp > 3) || (marioflp < 2))
{
marioflp = 2;
}
*marioxv += (MARIO_ACCEL);
if (*marioxv >= (MARIO_MAXACCEL))
*marioxv = (MARIO_MAXACCEL);
}
{
{
*marioyv = -(MARIO_HIJUMPING);
else
*marioyv = -(MARIO_JUMPING);
}
}
}
mariowalk(idx);
mariofall(idx);
mariojump(idx);
if (*marioox <= 0)
*marioox = 0;
if (*mariooy <= 0)
*mariooy = 0;
mariox = (*marioox);
marioy = (*mariooy);
}
int main(void)
{
bgInitTileSet(0, &tileset, &tilepal, 0, (&tilesetend - &tileset), 16 * 2, BG_16COLORS, 0x2000);
mapLoad((u8 *)&mapmario, (u8 *)&tilesetdef, (u8 *)&tilesetatt);
while (1)
{
}
return 0;
}
void bgSetGfxPtr(u8 bgNumber, u16 address)
Definition of each background address.
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgSetMapPtr(u8 bgNumber, u16 address, u8 mapSize)
Change Background Map address.
void bgInitTileSet(u8 bgNumber, u8 *tileSource, u8 *tilePalette, u8 paletteEntry, u16 tileSize, u16 paletteSize, u16 colorMode, u16 address)
Initializes a Tile Set and Loads the Tile GFX into VRAM.
void consoleSetTextVramAdr(u16 vramfont)
Change text graphics address (4K aligned)
void consoleNocashMessage(char *fmt,...)
Send a message to the no$sns debug window.
void consoleInitText(u8 palnum, u8 palsize, u8 *tilfont, u8 *palfont)
Initialize the Text System.
void consoleInit(void)
Initialize console.
void consoleDrawText(u16 x, u16 y, char *fmt,...)
Output formatted string on a screen (tiles mode)
void consoleSetTextVramBGAdr(u16 offsetfont)
Change text Background map address for display (must be BG address)
void WaitForVBlank(void)
Wait for vblank interrupt
void mapVblank(void)
Display map regarding current buffer (must be done once per frame, near Vblank)
#define ACT_STAND
Action type STAND for object.
Definition: map.h:45
void mapUpdate(void)
Update map regarding current camera position (must be done once per frame)
#define ACT_JUMP
Action type JUMP for object.
Definition: map.h:47
u16 y_pos
Current value of camera in x & y coordinates.
Definition: map.h:57
#define ACT_FALL
Action type FALL for object.
Definition: map.h:48
#define ACT_WALK
Action type WALK for object.
Definition: map.h:46
void mapLoad(u8 *layer1map, u8 *layertiles, u8 *tilesprop)
Load map definition into memory.
void mapUpdateCamera(u16 xpos, u16 ypos)
Update map camera (must be done once per frame)
void objUpdateXY(u16 objhandle)
Update X & Y coordinates of object regarding its own velocitys.
t_objs objbuffers[OB_MAX]
current object buffer with all objects
u16 objNew(u8 objtype, u16 x, u16 y)
Initialize a new object in game, objgetid will has the id of the object.
void objCollidMap(u16 objhandle)
check if an object collides the map
void objInitFunctions(u8 objtype, void *initfct, void *updfct, void *reffct)
Initialize the object type functions (initialize, update)
u16 objptr
pointer to current object
void objUpdateAll(void)
call update function for all objects currently active (if they are in "virtual screen" coordinates).
void objGetPointer(u16 objhandle)
get the pointer to an object from its handle (need to do -1 to have offset after),...
void objInitEngine(void)
Initialize object engine, need to be called once.
u16 objgetid
id of current object (useful when creating it)
void objLoadObjects(u8 *sourceO)
Load all objects for a specific table in memory.
the master include file for snes applications.
void spcAllocateSoundRegion(u8 size)
set the size of the sound region (this must be big enough to hold your longest/largest sound) this fu...
void spcLoad(u16 musIndex)
load module into sm-spc. this function may take some time to execute
void spcSetSoundEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr)
set the values and address of the SOUND TABLE for a sound entry
void spcPlaySound(u8 sndIndex)
Play sound from memory (using default arguments)
void spcSetBank(u8 *bank)
set soundbank origin. soundbank must have dedicated bank(s)
void spcProcess(void)
Process messages This function will try to give messages to the spc until a few scanlines pass.
void spcBoot(void)
boots the spc700 with sm-spc. call once at startup
void spcSetModuleVolume(u8 vol)
set the module playback volume
void spcPlay(u8 startPos)
play module. note: this simply queues a message, use spcFlush if you want to wait until the message i...
t_sprites oambuffer[128]
Sprite Table (from no$sns help file) Contains data for 128 OBJs. OAM Size is 512+32 Bytes....
void oamVramQueueUpdate(void)
Update VRAM graphics for sprites 32x32, 16x16 and 8x8 (can but call in Vblank if needed).
#define OBJ_SIZE8_L16
default OAM size 8x8 (SM) and 16x16 (LG) pix for OBJSEL register
Definition: sprite.h:39
void oamInitDynamicSpriteEndFrame(void)
Must be call at the end of the frame, initialize the dynamic sprite engine for the next frame.
void oamInitDynamicSprite(u16 gfxsp0adr, u16 gfxsp1adr, u16 oamsp0init, u16 oamsp1init, u8 oamsize)
initialize the dynamic sprite engine with each sprite size entries
void oamDynamic16Draw(u16 id)
Add a 16x16 sprite on screen. oambuffer[id] needs to be populate before.
brr sample sound header(8 bytes)
Definition: sound.h:51
object definition (64 bytes)
Definition: object.h:49
s16 xvel
Definition: object.h:68
u16 height
Definition: object.h:65
s16 yvel
Definition: object.h:69
u16 width
Definition: object.h:64
u8 xpos[3]
Definition: object.h:60
u16 tilestand
Definition: object.h:70
u8 ypos[3]
Definition: object.h:61
u16 action
Definition: object.h:74
u16 oamframeid
4 frame index in graphic file of the sprite
Definition: sprite.h:62
s16 oamx
0 x position on the screen
Definition: sprite.h:60
u8 * oamgraphics
8..11 pointer to graphic file
Definition: sprite.h:65
s16 oamy
2 y position on the screen
Definition: sprite.h:61
u8 oamattribute
6 sprite attribute value (vhoopppc v : vertical flip h: horizontal flip o: priority bits p: palette n...
Definition: sprite.h:63
u8 oamrefresh
7 =1 if we need to load graphics from graphic file
Definition: sprite.h:64
void setScreenOn(void)
Put screen On.
#define setPalette(palette, paletteEntry, paletteSize)
Change a palette in CGRAM.
Definition: video.h:388
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.