Skip to content

Commit

Permalink
working version
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterIV committed Jan 28, 2018
1 parent 43648e1 commit 0dfa6d5
Show file tree
Hide file tree
Showing 23 changed files with 1,608 additions and 847 deletions.
41 changes: 29 additions & 12 deletions PostBot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ struct Vector {
void init_programming();
void init_level();
void init_victory();
void set_command(int row, int col);
void set_command(int row, int col, char dir) ;

//music
UINT16 currentBeat;
UINT8 timerCounter;
UINT8 muteChannel1;
UINT8 muteChannel4;

/* 0-09 main program
10-14 function 1
Expand All @@ -26,8 +32,11 @@ int screen;

// current level
int objectives;
UBYTE level;
UBYTE level = 0;
UBYTE current_level[360];
const UBYTE level_count = 8;

UBYTE joypad_prev;

// bank 1: title screen
void show_title();
Expand All @@ -51,10 +60,10 @@ void display_programming() {
}

// bank 4: victory
void show_victory();
void show_victory(unsigned char *dest);
void display_victory() {
SWITCH_ROM_MBC1(1);
show_victory();
show_victory(&current_level);
}


Expand All @@ -81,14 +90,13 @@ void update() {
update_level_idle();
break;
case 2:
update_music();
wait_vbl_done();
update_level_running();
break;
case 3:
update_programming();
break;
case 5:
update_victory();
break;
}
}

Expand All @@ -104,22 +112,31 @@ void main() {
SHOW_BKG;
DISPLAY_ON;

init_sounds();

play_jingle();

waitpad(255);

set_bkg_tiles(0, 0, 20, 18, current_level);

printf(" \n press select in\n level to program\n robot\n\n");
printf(" press a in level\n to run program\n\n");
printf(" press b to abort\n or return\n\n");
printf(" press start\n");
printf(" \n Program the robot\n to deliver all\n transmissions\n\n");
printf(" Press SELECT to\n program the robot\n\n");
printf(" Press A in level\n to run program\n\n");
printf(" Press start to\n continue\n");

waitpad(J_START);

SWITCH_ROM_MBC1(2);

program[0] = 1;
program[2] = 4;

init_level();

while(1) {
update();
delay(35);
update_music();
wait_vbl_done();
}
}
Binary file modified PostBot.gb
Binary file not shown.
11 changes: 8 additions & 3 deletions bank1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
#include "victory_sprites.tiles"
#include "victory.map"

void show_victory() {
set_bkg_data(0, 63, victory_sprites);
void show_victory(unsigned char *dest) {
int i;

set_bkg_data(0, 83, victory_sprites);
set_bkg_tiles(0, 0, 20, 18, victory);

for(i = 0; i < 360; i++)
dest[i] = victory[i];
}

void show_title() {
set_sprite_data(0, 68, sprites);
set_bkg_data(0, 138, title_sprites);
set_bkg_data(0, 140, title_sprites);
set_bkg_tiles(0, 0, 20, 18, title);
}
12 changes: 12 additions & 0 deletions bank2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "level_2.map"
#include "level_3.map"
#include "level_4.map"
#include "level_5.map"
#include "level_6.map"
#include "level_7.map"
#include "level_8.map"

int copy_map(unsigned char *dest, unsigned char *src) {
int i, objectives = 0;
Expand All @@ -30,5 +34,13 @@ int show_level(unsigned char level, unsigned char *dest) {
return copy_map(dest, level_3);
case 3:
return copy_map(dest, level_4);
case 4:
return copy_map(dest, level_5);
case 5:
return copy_map(dest, level_6);
case 6:
return copy_map(dest, level_8);
case 7:
return copy_map(dest, level_7);
}
}
29 changes: 19 additions & 10 deletions bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,28 @@ const unsigned char bot_sprit_down = 4;
const unsigned char bot_sprit_side = 44;

void turn_bot() {
unsigned char ani_offset = 0;

if(bot.animation > 0) {
ani_offset = 1+(bot.animation/4)*4;
}

if(bot.direction == 3) {
// right sprites
set_sprite_tile(0, bot_sprit_side+2);
set_sprite_tile(1, bot_sprit_side);
set_sprite_tile(0, ani_offset+bot_sprit_side+2);
set_sprite_tile(1, ani_offset+bot_sprit_side);
} else if(bot.direction == 1) {
// left sprites
set_sprite_tile(0, bot_sprit_side);
set_sprite_tile(1, bot_sprit_side+2);
set_sprite_tile(0, ani_offset+bot_sprit_side);
set_sprite_tile(1, ani_offset+bot_sprit_side+2);
} else if(bot.direction == 2) {
// down sprites
set_sprite_tile(0, bot_sprit_down);
set_sprite_tile(1, bot_sprit_down+2);
set_sprite_tile(0, ani_offset+bot_sprit_down);
set_sprite_tile(1, ani_offset+bot_sprit_down+2);
} else {
// up sprites
set_sprite_tile(0, bot_sprit_up);
set_sprite_tile(1, bot_sprit_up+2);
set_sprite_tile(0, ani_offset+bot_sprit_up);
set_sprite_tile(1, ani_offset+bot_sprit_up+2);
}

if(bot.direction == 3) {
Expand All @@ -50,7 +56,6 @@ void move_bot() {

void init_bot() {
bot.command = 0;
bot.direction = 0;
bot.animation = 0;
bot.delay = 0;

Expand All @@ -61,7 +66,9 @@ void init_bot() {
void command_move() {
set_velocity(bot.direction, &bot.velocity);

if(tile_at_next(&bot.position, &bot.velocity) < tile_objective_inactive)
walk_sound();

if(tile_at_next(&bot.position, &bot.velocity, 16) < tile_objective_inactive)
bot.animation = 16;
else
bot.delay = 10;
Expand Down Expand Up @@ -102,7 +109,9 @@ void update_bot() {
bot.animation--;
bot.position.x = bot.position.x + bot.velocity.x;
bot.position.y = bot.position.y + bot.velocity.y;

move_bot();
turn_bot();

if(bot.animation < 1)
bot.delay = 5;
Expand Down
12 changes: 7 additions & 5 deletions cursor.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
UBYTE joypad_prev;

struct Cursor {
unsigned char row;
unsigned char col;
} cursor;

void cursor_update() {
int cursor_update() {
UBYTE keys, diff;
int cx, cy, update_pos;

Expand All @@ -31,7 +29,9 @@ void cursor_update() {
case J_DOWN: if(cursor.row < row_max) cursor.row++; break;
case J_LEFT: if(cursor.col > col_min) cursor.col--; break;
case J_RIGHT: if(cursor.col < col_max) cursor.col++; break;
case J_A: set_command(cursor.row, cursor.col); break;
case J_A: set_command(cursor.row, cursor.col, 1); return 1;
case J_B: set_command(cursor.row, cursor.col, -1); return 1;
case J_SELECT: init_level(); return 0;
}

update_pos = 1;
Expand Down Expand Up @@ -73,6 +73,8 @@ void cursor_update() {
//bottom-right edge
move_sprite(7, cx + 16, cy + 16);
}

return 0;
}

void cursor_init() {
Expand Down Expand Up @@ -106,6 +108,6 @@ void cursor_init() {
set_sprite_tile(7, 2);
set_sprite_prop(7, S_FLIPX | S_FLIPY);

joypad_prev = 1;
joypad_prev = joypad();
cursor_update();
}
122 changes: 61 additions & 61 deletions level_4.map
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
/*
level_4.map
Background Tile Map File.
Generated by CloudBoy.
Dimensions: 20,18
Tiles: levelset.tiles
*/
/* Start of tile array. */
const UBYTE level_4[] = {
0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x19, 0x1a,
0x19, 0x1a, 0x19, 0x1a, 0x19, 0x1a, 0x19, 0x1a,
0x01, 0x02, 0x09, 0x0a, 0x03, 0x04, 0x03, 0x04,
0x03, 0x04, 0x1b, 0x1c, 0x1b, 0x1c, 0x1b, 0x1c,
0x1b, 0x1c, 0x1b, 0x1c, 0x03, 0x04, 0x0b, 0x0c,
0x01, 0x02, 0x19, 0x1a, 0x19, 0x1a, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02,
0x19, 0x1a, 0x01, 0x02, 0x03, 0x04, 0x1b, 0x1c,
0x1b, 0x1c, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x03, 0x04, 0x03, 0x04, 0x1b, 0x1c, 0x03, 0x04,
0x19, 0x1a, 0x11, 0x12, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x0d, 0x0e, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0f, 0x10, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x19, 0x1a, 0x11, 0x12, 0x0d, 0x0e, 0x01, 0x02,
0x09, 0x0a, 0x05, 0x06, 0x01, 0x02, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x0f, 0x10, 0x03, 0x04, 0x0b, 0x0c, 0x07, 0x08,
0x03, 0x04, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x19, 0x1a, 0x11, 0x12, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x09, 0x0a, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0b, 0x0c, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x19, 0x1a, 0x11, 0x12, 0x01, 0x02, 0x05, 0x06,
0x01, 0x02, 0x0d, 0x0e, 0x01, 0x02, 0x0d, 0x0e,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x03, 0x04, 0x07, 0x08, 0x03, 0x04, 0x0f, 0x10,
0x03, 0x04, 0x0f, 0x10, 0x13, 0x14, 0x1b, 0x1c,
0x19, 0x1a, 0x11, 0x12, 0x09, 0x0a, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x05, 0x06, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x0b, 0x0c, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x07, 0x08, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x05, 0x06, 0x19, 0x1a, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x09, 0x0a, 0x01, 0x02,
0x19, 0x1a, 0x01, 0x02, 0x07, 0x08, 0x1b, 0x1c,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0b, 0x0c, 0x03, 0x04, 0x1b, 0x1c, 0x03, 0x04,
0x01, 0x02, 0x01, 0x02, 0x19, 0x1a, 0x19, 0x1a,
0x19, 0x1a, 0x19, 0x1a, 0x19, 0x1a, 0x19, 0x1a,
0x01, 0x02, 0x09, 0x0a, 0x03, 0x04, 0x03, 0x04,
0x1b, 0x1c, 0x1b, 0x1c, 0x1b, 0x1c, 0x1b, 0x1c,
0x1b, 0x1c, 0x1b, 0x1c, 0x03, 0x04, 0x0b, 0x0c
};
/* End of level_4.C */
/*

level_4.map

Background Tile Map File.
Generated by CloudBoy.

Dimensions: 20,18
Tiles: levelset.tiles

*/

/* Start of tile array. */
const UBYTE level_4[] = {
0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x19, 0x1a,
0x1d, 0x1e, 0x19, 0x1a, 0x19, 0x1a, 0x21, 0x22,
0x01, 0x02, 0x09, 0x0a, 0x03, 0x04, 0x03, 0x04,
0x03, 0x04, 0x1b, 0x1c, 0x1f, 0x20, 0x1b, 0x1c,
0x1b, 0x1c, 0x23, 0x24, 0x03, 0x04, 0x0b, 0x0c,
0x01, 0x02, 0x21, 0x22, 0x21, 0x22, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02,
0x19, 0x1a, 0x01, 0x02, 0x03, 0x04, 0x23, 0x24,
0x23, 0x24, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x03, 0x04, 0x03, 0x04, 0x1b, 0x1c, 0x03, 0x04,
0x21, 0x22, 0x11, 0x12, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x0d, 0x0e, 0x01, 0x02,
0x11, 0x12, 0x21, 0x22, 0x23, 0x24, 0x13, 0x14,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0f, 0x10, 0x03, 0x04, 0x13, 0x14, 0x23, 0x24,
0x19, 0x1a, 0x11, 0x12, 0x0d, 0x0e, 0x01, 0x02,
0x09, 0x0a, 0x05, 0x06, 0x01, 0x02, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x0f, 0x10, 0x03, 0x04, 0x0b, 0x0c, 0x07, 0x08,
0x03, 0x04, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x1d, 0x1e, 0x11, 0x12, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x09, 0x0a, 0x01, 0x02,
0x11, 0x12, 0x1d, 0x1e, 0x1f, 0x20, 0x13, 0x14,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0b, 0x0c, 0x03, 0x04, 0x13, 0x14, 0x1f, 0x20,
0x19, 0x1a, 0x11, 0x12, 0x01, 0x02, 0x05, 0x06,
0x01, 0x02, 0x0d, 0x0e, 0x01, 0x02, 0x0d, 0x0e,
0x11, 0x12, 0x1d, 0x1e, 0x1b, 0x1c, 0x13, 0x14,
0x03, 0x04, 0x07, 0x08, 0x03, 0x04, 0x0f, 0x10,
0x03, 0x04, 0x0f, 0x10, 0x13, 0x14, 0x1f, 0x20,
0x19, 0x1a, 0x11, 0x12, 0x09, 0x0a, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x05, 0x06, 0x01, 0x02,
0x11, 0x12, 0x19, 0x1a, 0x1b, 0x1c, 0x13, 0x14,
0x0b, 0x0c, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x07, 0x08, 0x03, 0x04, 0x13, 0x14, 0x1b, 0x1c,
0x05, 0x06, 0x19, 0x1a, 0x01, 0x02, 0x01, 0x02,
0x01, 0x02, 0x01, 0x02, 0x09, 0x0a, 0x01, 0x02,
0x19, 0x1a, 0x01, 0x02, 0x07, 0x08, 0x1b, 0x1c,
0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04,
0x0b, 0x0c, 0x03, 0x04, 0x1b, 0x1c, 0x03, 0x04,
0x01, 0x02, 0x01, 0x02, 0x1d, 0x1e, 0x19, 0x1a,
0x21, 0x22, 0x21, 0x22, 0x1d, 0x1e, 0x19, 0x1a,
0x01, 0x02, 0x09, 0x0a, 0x03, 0x04, 0x03, 0x04,
0x1f, 0x20, 0x1b, 0x1c, 0x23, 0x24, 0x23, 0x24,
0x1f, 0x20, 0x1b, 0x1c, 0x03, 0x04, 0x0b, 0x0c
};
/* End of level_4.C */
Loading

0 comments on commit 0dfa6d5

Please sign in to comment.