#include "superscope.h"
#include "sin_cos.h"
extern char tilfont, palfont;
extern unsigned char sprites_map, sprites_map_end, sprites_palette;
extern unsigned char aim_target_tileset, aim_target_tileset_end, aim_target_map, aim_target_palette;
void hideSprites()
{
u8 i;
for (i = 0; i < 128; i++)
}
void resetGame()
{
hideSprites();
targets_shot = 0;
enable_fire = false;
bullet_id = 0;
shot_bullets = 0;
u8 i;
for (i = 0; i < max_bullets; i++)
{
difuse_xn[i] = 0;
difuse_yn[i] = 0;
difuse_x[i] = 0;
difuse_y[i] = 0;
bullet_frame[i] = 0;
bullet_draw[i] = 0;
bullet_frame_n[i] = 0;
bullet_gravity[i] = 0;
bullet_diff[i] = 0;
}
for (target_id = 0; target_id < 8; target_id++)
{
target_kill[target_id] = false;
target_kill_count[target_id] = 0;
target_gravity[target_id] = 0;
}
}
int main(void)
{
bgInitTileSet(0, &aim_target_tileset, &aim_target_palette, 0, (&aim_target_tileset_end - &aim_target_tileset), 16 * 2, BG_16COLORS, 0x3000);
u8 i;
for (i = 0; i < max_targets; i++)
{
oamSet(16 + (i << 2), 0, 0, 2, 0, 0, 0x84, 1);
oamSetEx(16 + (i << 2), OBJ_SMALL, OBJ_HIDE);
}
START_OVER:
if (pause_adjust)
else
{
else
}
oamSet(0, 0, 0, 2, 0, 0, 0x80, 2);
{
}
if (pause_adjust == false)
ADJUST_AIM:
while (1)
{
{
sscope_disconnected = true;
}
else
{
if (sscope_disconnected)
{
sscope_disconnected = false;
goto ADJUST_AIM;
}
enable_fire = true;
if (pause_adjust)
{
oamSet(0, 0, 0, 2, 0, 0, 0, 0);
pause_adjust = false;
goto CONTINUE_GAME;
}
if (enable_fire)
{
{
enable_fire = false;
break;
}
}
}
}
if (pause_adjust)
while (1)
{
{
sscope_disconnected = true;
}
else
{
if (sscope_disconnected)
{
sscope_disconnected = false;
goto ADJUST_AIM;
}
enable_fire = true;
if (enable_fire)
{
{
enable_fire = false;
break;
}
}
}
}
if (pause_adjust)
{
}
else
{
}
while (1)
{
{
sscope_disconnected = true;
}
else
{
enable_cursor = true;
if (sscope_disconnected)
{
sscope_disconnected = false;
goto ADJUST_AIM;
}
{
if (pause_adjust)
{
oamSet(0, 0, 0, 2, 0, 0, 0, 0);
pause_adjust = false;
goto CONTINUE_GAME;
}
else
goto ADJUST_AIM;
}
if (enable_cursor)
{
enable_cursor = false;
if (pause_adjust)
{
goto ADJUST_AIM;
}
else
break;
}
}
}
while (bullet_frame[0] < 8)
{
oamSet(bullet_draw[0] << 2, 0, 0, 2, 0, 0, bullet_frames[bullet_frame[0]], 0);
bullet_draw[0]++;
if (bullet_draw[0] == 4)
bullet_draw[0] = 68;
bullet_frame_n[0]++;
if (bullet_frame_n[0] > ((bullet_frame[0] - 4) << 3))
{
bullet_frame[0]++;
bullet_frame_n[0] = 0;
}
}
scope_holddelay = 60;
PLAY_GAME:
for (target_id = 0; target_id < 8; target_id++)
{
target_x_inc[target_id] = target_id << 6;
target_y_inc[target_id] = target_id << 6;
target_oam_id[target_id] = 16 + target_id << 2;
}
bool print_once = true;
u8 text_timer = 0;
CONTINUE_GAME:
if (text_timer < 120)
{
}
while (1)
{
switch (text_timer)
{
case 120:
default:
text_timer++;
break;
case 121:
break;
}
{
sscope_disconnected = true;
}
else
{
if (sscope_disconnected)
{
sscope_disconnected = false;
}
enable_fire = true;
enable_pause = true;
enable_cursor = true;
if (enable_fire)
{
if (cool_down < 2)
cool_down++;
cool_down = 0;
{
bullet_id++;
if (bullet_id == 32)
bullet_id = 0;
{
else
bullet_y[bullet_id] = 0xE0;
}
else
{
bullet_x[bullet_id] = 0x110;
bullet_y[bullet_id] = 0xE0;
}
bullet_frame[bullet_id] = 0;
bullet_draw[bullet_id] = 0;
bullet_gravity[bullet_id] = 0;
difuse_xn[bullet_id] = 0;
difuse_yn[bullet_id] = 0;
difuse_x[bullet_id] = (
rand() & 0x0F) - 8;
difuse_y[bullet_id] = ((
rand() & 0xF0) >> 4) - 8;
shot_bullets++;
ready_to_fire = 0;
}
if (cool_down < 2)
{
if (ready_to_fire < normal_fire_rate)
ready_to_fire++;
}
else
ready_to_fire = 0;
for (bullet_num = 0; bullet_num < shot_bullets; bullet_num++)
{
s8 id = bullet_id - bullet_num;
if (id < 0)
id += 32;
if (bullet_frame[id] < 8)
{
if (bullet_draw[id])
oamSetVisible((bullet_draw[
id] - bullet_diff[
id]) << 2, OBJ_HIDE);
difuse_xn[id] += difuse_x[id];
bullet_gravity[id]++;
difuse_yn[id] += difuse_y[id] + (bullet_gravity[id] >> 2);
oamSetXY(bullet_draw[
id] << 2, bullet_x[
id] + (difuse_xn[
id] >> 6), bullet_y[
id] + (difuse_yn[
id] >> 6));
bullet_draw[id]++;
if (bullet_draw[id] == 4)
{
bullet_draw[id] = 68;
bullet_diff[id] = 65;
}
else
bullet_diff[id] = 1;
bullet_frame_n[id]++;
if (bullet_frame_n[id] > ((bullet_frame[id] - 4) << 3))
{
bullet_frame[id]++;
bullet_frame_n[id] = 0;
}
}
else if (bullet_frame[id] == 8)
{
shot_bullets--;
bullet_frame[id]++;
}
}
}
if (targets_shot < 8)
{
if (enable_pause)
{
hideSprites();
pause_adjust = true;
enable_fire = false;
enable_cursor = false;
goto START_OVER;
}
for (target_id = 0; target_id < 8; target_id++)
{
if (target_kill[target_id] == false)
{
target_x_inc[target_id]++;
target_y_inc[target_id]++;
if (target_x_inc[target_id] > 511)
target_x_inc[target_id] = 0;
if (target_y_inc[target_id] > 511)
target_y_inc[target_id] = 0;
target_x[target_id] = ((cos_table(target_x_inc[target_id]) << 1) / 3) + 27;
target_y[target_id] = ((sin_table(target_y_inc[target_id]) << 1) / 3) + 11;
oamSetXY(target_oam_id[target_id], target_x[target_id], target_y[target_id]);
target_collision_x[target_id] =
oamGetX(target_oam_id[target_id]) -
oamGetX(12);
target_collision_y[target_id] =
oamGetY(target_oam_id[target_id]) -
oamGetY(12);
if ((target_collision_x[target_id] > -12) && (target_collision_x[target_id] < 12) && (target_collision_y[target_id] > -12) && (target_collision_y[target_id] < 12))
target_kill[target_id] = true;
}
if (target_kill[target_id])
{
switch (target_kill_count[target_id])
{
case 0:
target_x[target_id] -= 16;
target_y[target_id] -= 16;
oamSetXY(target_oam_id[target_id], target_x[target_id], target_y[target_id]);
oamSetEx(target_oam_id[target_id], OBJ_LARGE, OBJ_SHOW);
break;
case 3:
break;
case 6:
break;
case 12:
oamSetEx(target_oam_id[target_id], OBJ_SMALL, OBJ_HIDE);
targets_shot++;
enable_pause = false;
enable_cursor = false;
target_kill_count[target_id]++;
break;
}
if (target_kill_count[target_id] < 12)
{
target_gravity[target_id]++;
oamSetXY(target_oam_id[target_id], target_x[target_id], target_y[target_id] + (target_gravity[target_id] >> 2));
target_kill_count[target_id]++;
if (target_kill_count[target_id] & 0x02)
}
}
}
}
else
{
if (print_once == true)
{
print_once = false;
}
if (enable_cursor)
{
resetGame();
goto PLAY_GAME;
}
if (enable_pause)
{
resetGame();
goto START_OVER;
}
}
}
}
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 bgSetScroll(u8 bgNumber, u16 x, u16 y)
Sets the scroll hardware to the specified location.
void bgInitMapSet(u8 bgNumber, u8 *mapSource, u16 mapSize, u8 sizeMode, u16 address)
Initializes a Map Set and loads it into SNES VRAM.
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.
u16 rand(void)
return a randomized number
void consoleSetTextVramAdr(u16 vramfont)
Change text graphics address (4K aligned)
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 consoleSetTextOffset(u16 offsetfont)
Change text Background map address for display (must be BG address)
void consoleSetTextVramBGAdr(u16 offsetfont)
Change text Background map address for display (must be BG address)
void dmaFillVram(u8 *source, u16 address, u16 size)
fill the source data to destination using channel 0 of DMA available channels in half words
void WaitForVBlank(void)
Wait for vblank interrupt
void WaitNVBlank(u16 ntime)
Wait for vblank interrupt ntime times
the master include file for snes applications.
signed char s8
8 bit volatile unsigned integer.
Definition: snestypes.h:37
#define OBJ_SIZE16_L32
default OAM size 16x16 (SM) and 32x32 (LG) pix for OBJSEL register
Definition: sprite.h:42
void oamSetVisible(u16 id, u8 hide)
Hide or show a sprite.
void oamSetEx(u16 id, u8 size, u8 hide)
Put the correct size and hide or show a sprite.
#define OBJ_SIZE32_L64
default OAM size 32x32 (SM) and 64x64 (LG) pix for OBJSEL register
Definition: sprite.h:44
void oamInitGfxSet(u8 *tileSource, u16 tileSize, u8 *tilePalette, u16 paletteSize, u8 tilePaletteNumber, u16 address, u8 oamsize)
Initializes a sprites Gfx and Loads the GFX into VRAM.
void oamSetXY(u16 id, u16 xspr, u16 yspr)
sets an oam coordinate to the supplied values
void oamSetGfxOffset(u16 id, u16 gfxoffset)
sets an oam graphic offset to the supplied values
void oamSet(u16 id, u16 xspr, u16 yspr, u8 priority, u8 hflip, u8 vflip, u16 gfxoffset, u8 paletteoffset)
sets an oam entry to the supplied values
void oamInitGfxAttr(u16 address, u8 oamsize)
Initializes the default sprite size and address in VRAM.
#define oamGetX(id)
get the x oam coordinate to the supplied values
Definition: sprite.h:216
#define oamGetY(id)
get the y oam coordinate to the supplied values
Definition: sprite.h:221
#define setPaletteColor(paletteEntry, paletteColor)
Change a color palette in CGRAM.
Definition: video.h:395
void setScreenOn(void)
Put screen On.
void setFadeEffect(u8 mode)
Do a fadein or fadeout effect.
#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.