-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 42ce2b5
Showing
26 changed files
with
2,277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Abigos' Mountain - Batata's Adventure | ||
|
||
FlappyBird clone for the original Game Boy, fully written in assembly | ||
|
||
![Mountain's Gameplay](img/mountain.gif) | ||
|
||
## How to play | ||
|
||
You will need to [install RGBDS](https://rgbds.gbdev.io/install). On windows you can run `build.bat` from the repository root folder. On other platforms run: | ||
|
||
``` | ||
rgbasm -o build/mountain.o mountain.asm | ||
rgblink -o build/mountain.gb build/mountain.o | ||
rgbfix -v -p 0 build/mountain.gb | ||
``` | ||
|
||
Your rom will be available on `build/mountain.gb`. You can open it on any Game Boy emulator. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rgbasm -o build\mountain.o mountain.asm | ||
rgblink -o build\mountain.gb build\mountain.o | ||
rgbfix -v -p 0 build\mountain.gb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
IF !DEF(CONSTANTS_INC) | ||
CONSTANTS_INC SET 1 | ||
|
||
OBSTACLE_START_X EQU 168 | ||
PLAYER_START_Y EQU 54 | ||
PLAYER_MAX_VEL EQU 2 | ||
PLAYER_IMPULSE_VEL EQU 7 | ||
|
||
_PAD EQU _RAM | ||
_OBSTACLE_X EQU _RAM + 1 | ||
_PLAYER_Y EQU _RAM + 2 | ||
_PLAYER_VEL_Y EQU _RAM + 3 | ||
_PLAYER_ACTIVE EQU _RAM + 4 | ||
_ANIM_COUNTER EQU _RAM + 5 | ||
_GAME_OVER EQU _RAM + 6 | ||
_IS_PRESSING_A EQU _RAM + 7 | ||
|
||
_SPRITES EQU $C100 | ||
_SPRITES_END EQU $C1A0 | ||
|
||
_S_PLAYER_TL_Y EQU _SPRITES | ||
_S_PLAYER_TL_X EQU _S_PLAYER_TL_Y + 1 | ||
_S_PLAYER_TL_TILE EQU _S_PLAYER_TL_Y + 2 | ||
_S_PLAYER_TL_ATTRIBUTES EQU _S_PLAYER_TL_Y + 3 | ||
|
||
_S_PLAYER_TR_Y EQU _S_PLAYER_TL_Y + 4 | ||
_S_PLAYER_TR_X EQU _S_PLAYER_TR_Y + 1 | ||
_S_PLAYER_TR_TILE EQU _S_PLAYER_TR_Y + 2 | ||
_S_PLAYER_TR_ATTRIBUTES EQU _S_PLAYER_TR_Y + 3 | ||
|
||
_S_PLAYER_BL_Y EQU _S_PLAYER_TR_Y + 4 | ||
_S_PLAYER_BL_X EQU _S_PLAYER_BL_Y + 1 | ||
_S_PLAYER_BL_TILE EQU _S_PLAYER_BL_Y + 2 | ||
_S_PLAYER_BL_ATTRIBUTES EQU _S_PLAYER_BL_Y + 3 | ||
|
||
_S_PLAYER_BR_Y EQU _S_PLAYER_BL_Y + 4 | ||
_S_PLAYER_BR_X EQU _S_PLAYER_BR_Y + 1 | ||
_S_PLAYER_BR_TILE EQU _S_PLAYER_BR_Y + 2 | ||
_S_PLAYER_BR_ATTRIBUTES EQU _S_PLAYER_BR_Y + 3 | ||
|
||
_S_OBS_TL_Y EQU _S_PLAYER_BR_Y + 4 | ||
_S_OBS_TL_X EQU _S_OBS_TL_Y + 1 | ||
_S_OBS_TL_TILE EQU _S_OBS_TL_Y + 2 | ||
_S_OBS_TL_ATTRIBUTES EQU _S_OBS_TL_Y + 3 | ||
|
||
_S_OBS_TR_Y EQU _S_OBS_TL_Y + 4 | ||
_S_OBS_TR_X EQU _S_OBS_TR_Y + 1 | ||
_S_OBS_TR_TILE EQU _S_OBS_TR_Y + 2 | ||
_S_OBS_TR_ATTRIBUTES EQU _S_OBS_TR_Y + 3 | ||
|
||
_S_OBS_BL_Y EQU _S_OBS_TR_Y + 4 | ||
_S_OBS_BL_X EQU _S_OBS_BL_Y + 1 | ||
_S_OBS_BL_TILE EQU _S_OBS_BL_Y + 2 | ||
_S_OBS_BL_ATTRIBUTES EQU _S_OBS_BL_Y + 3 | ||
|
||
_S_OBS_BR_Y EQU _S_OBS_BL_Y + 4 | ||
_S_OBS_BR_X EQU _S_OBS_BR_Y + 1 | ||
_S_OBS_BR_TILE EQU _S_OBS_BR_Y + 2 | ||
_S_OBS_BR_ATTRIBUTES EQU _S_OBS_BR_Y + 3 | ||
|
||
_S_OBS_LY EQU _S_OBS_BR_Y + 4 | ||
_S_OBS_LX EQU _S_OBS_LY + 1 | ||
_S_OBS_LTILE EQU _S_OBS_LY + 2 | ||
_S_OBS_LATTRIBUTES EQU _S_OBS_LY + 3 | ||
|
||
_S_OBS_RY EQU _S_OBS_LY + 4 | ||
_S_OBS_RX EQU _S_OBS_RY + 1 | ||
_S_OBS_RTILE EQU _S_OBS_RY + 2 | ||
_S_OBS_RATTRIBUTES EQU _S_OBS_RY + 3 | ||
|
||
StartDMA EQU _HRAM | ||
|
||
ENDC ;CONSTANTS_INC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
IF !DEF(GAME_INC) | ||
GAME_INC SET 1 | ||
|
||
INCLUDE "player.inc" | ||
INCLUDE "obstacles.inc" | ||
|
||
SECTION "game routines", ROM0 | ||
|
||
LoadGame: | ||
call LoadBackground | ||
call LoadObjects | ||
call SetPlayerInactive | ||
call ResetAnimCounter | ||
call ResetPlayerVelocity | ||
ret | ||
|
||
LoadBackground: | ||
call LoadBackgroundTiles | ||
call LoadBackgroundMap | ||
call SetBackgroundPalette | ||
call ResetWindowPosition | ||
ret | ||
|
||
LoadBackgroundTiles: | ||
ld hl, _VRAM9000 | ||
ld de, TileSet | ||
ld bc, TileSetEnd - TileSet | ||
call MemCpy | ||
ret | ||
|
||
LoadBackgroundMap: | ||
ld hl, _SCRN0 | ||
ld de, TileMap | ||
ld bc, TileMapEnd - TileMap | ||
call MemCpy | ||
ret | ||
|
||
SetBackgroundPalette: | ||
ld a, %11100100 ; 3 B, 2 LG, 1 DG, 0 W | ||
ld [rBGP], a | ||
ret | ||
|
||
LoadObjects: | ||
call ClearSpriteAttributes | ||
call LoadSpriteTiles | ||
call InitPlayerSprite | ||
call InitPlayerYPos | ||
call SetPlayerSpriteY | ||
call InitObstacleSprites | ||
call SetObjectPalette | ||
call StartDMA | ||
ret | ||
|
||
LoadSpriteTiles: | ||
ld hl, _VRAM | ||
ld de, Sprites | ||
ld bc, SpritesEnd - Sprites | ||
call MemCpy | ||
ret | ||
|
||
SetObjectPalette: | ||
; Change OBJ 0 palette | ||
ld a, %11010000 ; 3 B, 2 LG, 1 W | ||
ld [rOBP0], a | ||
|
||
; Change OBJ 1 palette | ||
ld a, %11100100 ; 3 B, 2 DG, 1 LG | ||
ld [rOBP1], a | ||
ret | ||
|
||
ResetAnimCounter: | ||
xor a | ||
ld [_ANIM_COUNTER], a | ||
ret | ||
|
||
UpdateGame: | ||
ld a, [_PLAYER_ACTIVE] | ||
cp 1 | ||
jp z, .updateGameActive | ||
.updateGameInactive: | ||
call MoveBackground | ||
call AnimatePlayerSprite | ||
call ActivatePlayer | ||
call StartDMA | ||
call UpdatePressingA | ||
ret | ||
.updateGameActive: | ||
call MoveBackground | ||
call AnimatePlayerSprite | ||
call MovePlayer | ||
call MoveObstacles | ||
call StartDMA | ||
call CheckCollisions | ||
call UpdatePressingA | ||
ret | ||
|
||
MoveBackground: | ||
ld a, [rSCX] | ||
inc a | ||
ld [rSCX], a | ||
ret | ||
|
||
CheckCollisions: | ||
call CheckPipeCollision | ||
call CheckCeilingCollision | ||
call CheckFloorCollision | ||
ret | ||
|
||
CheckCeilingCollision: | ||
ld a, [_S_PLAYER_TL_Y] | ||
cp 16 | ||
call c, SetGameOver | ||
ret | ||
|
||
CheckFloorCollision: | ||
ld a, [_S_PLAYER_BL_Y] | ||
add 8 | ||
cp 160 | ||
call nc, SetGameOver | ||
ret | ||
|
||
CheckPipeCollision: | ||
; Check if player is to the right of the beggining of the obstacle | ||
ld a, [_OBSTACLE_X] | ||
ld b, a | ||
ld a, [_S_PLAYER_TR_X] | ||
add a, 8 | ||
cp b | ||
ret c | ||
|
||
; Check if player is to the left of the end of the obstacle | ||
ld a, [_OBSTACLE_X] | ||
add a, 16 | ||
ld b, a | ||
ld a, [_S_PLAYER_TL_X] | ||
cp b | ||
ret nc | ||
|
||
; We know the player is in between the pipes | ||
|
||
ld a, [_S_OBS_TL_Y] | ||
add a, 8 | ||
ld b, a | ||
ld a, [_S_PLAYER_TL_Y] | ||
cp b | ||
jp nc, .checkBottom | ||
call SetGameOver | ||
ret | ||
|
||
.checkBottom | ||
ld a, [_S_OBS_BL_Y] | ||
ld b, a | ||
ld a, [_S_PLAYER_BL_Y] | ||
add a, 8 | ||
cp b | ||
call nc, SetGameOver | ||
ret | ||
|
||
|
||
SECTION "TileSet", ROM0 | ||
TileSet: | ||
INCBIN "tile.bin" | ||
TileSetEnd: | ||
|
||
SECTION "TileMap", ROM0 | ||
TileMap: | ||
INCBIN "map.bin" | ||
TileMapEnd: | ||
|
||
SECTION "Sprites", ROM0 | ||
Sprites: | ||
INCBIN "sprites.bin" | ||
SpritesEnd: | ||
|
||
ENDC ;GAME_INC |
Oops, something went wrong.