Author Topic: Ball Bouncery - Source Code  (Read 6438 times)

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
Ball Bouncery - Source Code
« on: November 04, 2004, 01:12:38 am »
#include <gb/gb.h>
#include <stdio.h>
#include <string.h>
#include <gb/drawing.h>
#include <gb/sample.h>
#include <time.h>
#include "tiles.c"
#include "haztiles.c"

#define MAXVEL 10

unsigned char tilemap[32 * 32];

unsigned char hazmap[] = {1, 1, 1, 2, 3, 4, 5, 4, 6, 7, 8, 4, 9, 10, 2, 11, 12, 13};


void main()
{       
INT16 j,i;
INT16 x, y, xvel, yvel;
INT8 scrolldir;
UINT16 oldtime, currenttime;

DISPLAY_ON;

HIDE_WIN;
HIDE_BKG;
HIDE_SPRITES;

delay(1000);
set_bkg_data(0, 14, HazTiles);
set_bkg_tiles(1, 0, 18, 1, hazmap);
scroll_bkg(0, 10);

SHOW_BKG;

scrolldir = -1;

for (i = 0; i < 75; i++)
{
  scroll_bkg(0,scrolldir);
  delay(50);
}

delay(3000);

move_bkg(0,0);

printf(" \n");
printf("\n\n\n\n");
printf("  SUPA BAWL BOUNCE\n");
printf("\n\n");
printf("   By: FyberOptic");
printf("\n\n\n\n\n\n\n");
printf("    Press a key");


waitpad(0xFF);
waitpadup();

OBP0_REG = 0x27U;

set_bkg_data(0, 5, GameTiles);


for (j = 0; j < 32 * 32; j++) tilemap[j] = 0;
set_bkg_tiles(0, 0, 32, 32, tilemap);


set_sprite_data(0,5,GameTiles);
set_sprite_tile(0,1);
x = SCREENWIDTH / 2;
y = SCREENHEIGHT / 2;
xvel = 2;
yvel = 0;

SHOW_SPRITES;


while (1)
{
        i = joypad();
        if(i)
        {
          if(i & J_UP) yvel -= 1; 
          if(i & J_DOWN) yvel += 1; 
          if(i & J_LEFT) xvel -= 1;
          if(i & J_RIGHT) xvel += 1;
        }
        if (xvel > MAXVEL) xvel = MAXVEL;
        if (yvel > MAXVEL) yvel = MAXVEL;
        x += xvel;
        y += yvel;
        if (x > 160) {x = 160; xvel = -xvel; }
        if (x < 7) {x = 7; xvel = -xvel; }
        if (y < 15) {y = 15; yvel = -yvel; }
        if (y > 152) {y = 152; yvel = -yvel; }
        move_sprite(0,x,y);
       
        delay(60);
}


}

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
Re: Ball Bouncery - Source Code
« Reply #1 on: November 04, 2004, 01:13:04 am »
/*

 HAZTILES.C

 Tile Source File.

 Info:
  Form                 : All tiles as one unit.
  Format               : Gameboy 4 color.
  Compression          : None.
  Counter              : None.
  Tile size            : 8 x 8
  Tiles                : 0 to 13

  Palette colors       : None.
  SGB Palette          : None.
  CGB Palette          : None.

  Convert to metatiles : No.

 This file was generated by GBTD v2.2

*/

/* Start of tile array. */
unsigned char HazTiles[] =
{
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x44,
  0x54,0x54,0x28,0x28,0x28,0x28,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x00,
  0x00,0x00,0x00,0x00,0x24,0x24,0x24,0x24,
  0x3C,0x3C,0x24,0x24,0x24,0x24,0x00,0x00,
  0x00,0x00,0x00,0x00,0x18,0x18,0x24,0x24,
  0x3C,0x3C,0x24,0x24,0x24,0x24,0x00,0x00,
  0x00,0x00,0x00,0x00,0x38,0x38,0x08,0x08,
  0x10,0x10,0x20,0x20,0x38,0x38,0x00,0x00,
  0x00,0x00,0x00,0x00,0x38,0x38,0x24,0x24,
  0x38,0x38,0x24,0x24,0x24,0x24,0x00,0x00,
  0x00,0x00,0x00,0x00,0x38,0x38,0x24,0x24,
  0x24,0x24,0x24,0x24,0x38,0x38,0x00,0x00,
  0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,
  0x20,0x20,0x20,0x20,0x3C,0x3C,0x00,0x00,
  0x00,0x00,0x00,0x00,0x38,0x38,0x24,0x24,
  0x38,0x38,0x24,0x24,0x38,0x38,0x00,0x00,
  0x00,0x00,0x00,0x00,0x1C,0x1C,0x20,0x20,
  0x18,0x18,0x04,0x04,0x38,0x38,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,
  0x20,0x20,0x20,0x20,0x18,0x18,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,
  0x24,0x24,0x24,0x24,0x18,0x18,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x14,
  0x2A,0x2A,0x22,0x22,0x22,0x22,0x00,0x00
};

/* End of HAZTILES.C */

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
Re: Ball Bouncery - Source Code
« Reply #2 on: November 04, 2004, 01:13:24 am »
/*

 TILES.C

 Tile Source File.

 Info:
  Form                 : All tiles as one unit.
  Format               : Gameboy 4 color.
  Compression          : None.
  Counter              : None.
  Tile size            : 8 x 8
  Tiles                : 0 to 5

  Palette colors       : None.
  SGB Palette          : None.
  CGB Palette          : None.

  Convert to metatiles : No.

 This file was generated by GBTD v2.2

*/

/* Start of tile array. */
unsigned char GameTiles[] =
{
  0xFE,0xFF,0xFF,0xDF,0xFF,0xFF,0xFF,0xFB,
  0xFF,0xFF,0xFD,0xFF,0xBF,0xFF,0xFF,0xFF,
  0x00,0x00,0x00,0x3C,0x3C,0x5A,0x3C,0x7E,
  0x3C,0x7E,0x3C,0x5A,0x00,0x3C,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

/* End of TILES.C */

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
Re: Ball Bouncery - Source Code
« Reply #3 on: November 04, 2004, 01:13:41 am »
OKAY SO there you go.  I believe that's pretty much everything.  I could have modified the source after I compiled the ROM, to test other junks, but I believe I fixed it back to how it should go.  I created the tiles there for this ROM too, so I figured I'd include those files as well, in case you actually did want to compile it.

Also, this was done with the GameBoy Developers Kit, which may have been updated since I last downloaded it.  But I recommend it to anyone wanting to develop ROMS for the GB and GBC.