Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FILENAME = $(NAME).img
COM_FILENAME = flpybird.com

IMAGE = build/$(FILENAME)
FLOPPY_IMAGE = build/img/$(FILENAME)
ISO_IMAGE = build/iso/$(FILENAME)
ISO = build/$(NAME).iso
ISO_DIR = build/iso
Expand Down Expand Up @@ -46,8 +47,9 @@ usb:
sudo dd if=$(IMAGE) of=/dev/sdb

floppy:
dd bs=512 count=2880 if=/dev/zero of=$(ISO_IMAGE)
dd status=noxfer conv=notrunc if=$(IMAGE) of=$(ISO_IMAGE)
dd status=noxfer conv=notrunc iflag=nocache bs=512 count=2880 if=/dev/zero of=$(FLOPPY_IMAGE)
dd status=noxfer conv=notrunc iflag=nocache if=$(IMAGE) of=$(FLOPPY_IMAGE)
cp $(FLOPPY_IMAGE) $(ISO_IMAGE)

iso:
$(MAKE) floppy
Expand All @@ -63,9 +65,10 @@ dosbox:
dosbox -conf dosbox.conf $(COM_TARGET)

clean:
rm $(IMAGE)
rm $(ISO_IMAGE)
rm $(ISO)
rm $(COM_TARGET)
rm -f $(IMAGE)
rm -f $(FLOPPY_IMAGE)
rm -f $(ISO_IMAGE)
rm -f $(ISO)
rm -f $(COM_TARGET)

.PHONY: usb floppy iso qemu bochs dosbox clean
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ operating system, it is an *operating system* on its own.

![Floppy Bird](demo.gif?raw=true "Floppy Bird")

Controls
--------
* Escape - reboot
* Backspace - randomize background
* Tab - randomize bird
* Any key - start the game, flap the wings

Getting Started
---------------
If you just want to try it out there's no need to install the
Expand All @@ -28,6 +35,15 @@ make
make iso
```

How to edit the TGA images with GIMP (tested at 2.8.22)
-------------------------------------------------------
* install the required VGA palette located at `./data/rgb/palette/` to GIMP
* import the source image from the rgb directory - i.e. `./data/rgb/bird.tga`
* Image -> Mode -> Indexed... , Use custom palette (don't remove the unused colors)
* if needed (i.e. `bird.tga`) add a new background layer, fill with black then merge
* do your edits, if needed update the sizes at `./src/game/data.asm` and other places
* export as uncompressed TGA with origin set to Top-Left and 256 color map (palette)

##### Versions

* `build/floppybird.img` - Image for Floppy / USB Drives
Expand Down
Binary file modified build/floppybird.img
Binary file not shown.
Binary file modified build/floppybird.iso
Binary file not shown.
Binary file modified build/flpybird.com
Binary file not shown.
Empty file added build/img/.gitkeep
Empty file.
Binary file added build/img/floppybird.img
Binary file not shown.
1 change: 1 addition & 0 deletions build/img/sha256sum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
249f77da69ba5d3295ed0c9180e4ffc646fb24f545630448fd55d5de2aec1455 ./floppybird.img
Binary file modified build/iso/floppybird.img
Binary file not shown.
2 changes: 2 additions & 0 deletions build/iso/sha256sum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
249f77da69ba5d3295ed0c9180e4ffc646fb24f545630448fd55d5de2aec1455 ./floppybird.img
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ./.gitkeep
3 changes: 3 additions & 0 deletions build/sha256sum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
49beea041de38c27d6ce931feb23b90b0d49cc04446e8f8219457556a310d2ab ./floppybird.img
4a7d4cbb090fb237c4f702e3f9c22533d281a8c19ae996aba8dab262ff3246da ./floppybird.iso
c94349ffb13a22eb1d534e7521791b16302deea2c27a21451604501932d1a989 ./flpybird.com
Binary file added data/bird_small.tga
Binary file not shown.
Binary file added data/pipe_small.tga
Binary file not shown.
Binary file added data/pipe_top_small.tga
Binary file not shown.
42 changes: 26 additions & 16 deletions src/game/bird.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,37 @@ center_bird:

update_bird:
mov ax, word [bird_pos + 2] ; sy
cmp ax, 0 ; top
cmp ax, 0 ; top
jle .collide ; reached sky?

add ax, word [bird_pos + 6] ; sh
cmp ax, 156 ; bottom (ground)
jg .collide ; reached ground?
cmp ax, 156 ; bottom (ground)
jg .collide ; reached ground?

call kbhit
add ax, word [bird_pos + 8] ; add stage_of_jump to return value

test al, al ; no key was ...
jz .fall ; pressed then just fall ...
test al, al ; if no key has been pressed and
jz .fall ; stage_of_jump is 0, then just fall

call animate_bird ; animate bird
call animate_bird ; animate bird

.move:
sub word [bird_pos + 2], 6 ; move 4 pixels up on the Y axis
add word [bird_pos + 8], 1
sub word [bird_pos + 2], 6 ; move 6 pixels up on the Y axis

mov ax, word [bird_pos + 8]
cmp ax, 3
jl .keep_jumping

mov word [bird_pos + 8], 0

.keep_jumping:
clc
ret

.fall:
add word [bird_pos + 2], 2 ; move 2 pixels down on the Y axis
add word [bird_pos + 2], 2 ; move 2 pixels down on the Y axis
clc
ret

Expand All @@ -39,25 +49,25 @@ update_bird:
ret

animate_bird:
add word [bird_frm], 32 ; advance fly animation by one frame
cmp word [bird_frm], 64 ; did we reach the last frame yet?
jle .end ; if not, then we can jump right away
add word [bird_frm], 16 ; advance fly animation by one frame
cmp word [bird_frm], 32 ; did we reach the last frame yet?
jle .end ; if not, then we can jump right away

mov word [bird_frm], 0 ; reset animation to the first frame
.end:
ret

draw_bird:
push bird
push 96 ; pw
push 24 ; ph
push 48 ; pw
push 12 ; ph
push word [bird_frm] ; sx
push 0 ; sy
push 0 ; sy
push word [bird_pos + 4] ; sw
push word [bird_pos + 6] ; sh
push word [bird_pos + 0] ; dx
push word [bird_pos + 2] ; dy
push 0 ; transparent color
push 0 ; transparent color
push word [bird_tint] ; tint
call blit_fast
ret
Expand All @@ -68,6 +78,6 @@ randomize_birdcolor:
mov word [bird_tint], ax
ret

bird_pos: dw 60, 60, 32, 24 ; x, y, w, h
bird_pos: dw 60, 60, 16, 12, 0 ; x, y, w, h, stage_of_jump
bird_frm: dw 0 ; current animation frame (X in pixels)
bird_tint: dw 0 ; crazy tint :P
14 changes: 7 additions & 7 deletions src/game/data.asm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
; Uncompressed TGA with origin set to Top-Left and 256 color map
; Uncompressed TGA with origin set to Top-Left and 256 color map ( + ./data/rgb/palette/ ! )
%define TGA_HEADER_COLORMAP 18 + 1028 ; 18 bytes header + 1028 bytes 256 colormap

bird: incbin "../data/bird.tga", TGA_HEADER_COLORMAP, 96 * 24
grass: incbin "../data/grass.tga", TGA_HEADER_COLORMAP, 16 * 10
pipe: incbin "../data/pipe.tga", TGA_HEADER_COLORMAP, 64 * 4
pipe_top: incbin "../data/pipe_top.tga", TGA_HEADER_COLORMAP, 68 * 8
bird: incbin "../data/bird_small.tga", TGA_HEADER_COLORMAP, 48 * 12
grass: incbin "../data/grass.tga", TGA_HEADER_COLORMAP, 8 * 4
pipe: incbin "../data/pipe_small.tga", TGA_HEADER_COLORMAP, 16 * 4
pipe_top: incbin "../data/pipe_top_small.tga", TGA_HEADER_COLORMAP, 18 * 8

flats: incbin "../data/flats.tga", TGA_HEADER_COLORMAP, 40 * 50
clouds: incbin "../data/cloud.tga", TGA_HEADER_COLORMAP, 40 * 16
flats: incbin "../data/flats.tga", TGA_HEADER_COLORMAP, 40 * 50
clouds: incbin "../data/cloud.tga", TGA_HEADER_COLORMAP, 40 * 16
font: incbin "../data/font.tga", TGA_HEADER_COLORMAP, 80 * 8
41 changes: 20 additions & 21 deletions src/game/pipes.asm
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ collide_pipe:
mov si, pipes
add si, [pipe_a]

cmp word [si], 92
cmp word [si], 74 ; front edge of the pipe
jg .end

cmp word [si], 28
cmp word [si], 48 ; back edge of the pipe
jl .score

mov ax, word [bird_pos + 2]
Expand Down Expand Up @@ -140,11 +140,11 @@ draw_pipe:

.body:
push pipe
push 32 ; w
push 16 ; w
push 2 ; h
push 0 ; sx
push 0 ; sy
push 32 ; sw
push 16 ; sw
push 2 ; sh
push word [bp+8]; dx
push ax ; dy
Expand All @@ -168,13 +168,13 @@ draw_pipe:
sub dx, 2

push pipe_top
push 36 ; w
push 18 ; w
push 4 ; h

push 0 ; sx
push 0 ; sy

push 36 ; sw
push 18 ; sw
push 4 ; sh

push dx ; dx
Expand Down Expand Up @@ -220,14 +220,14 @@ randomize_pipe_3:

randomize_pipe_height:
call random
cmp ax, 42

cmp ax, 116 ; 120 - 6 = 114 will be a max value
jge randomize_pipe_height

cmp ax, 18
cmp ax, 40 ; 6 (pipe) + 36 (window) = 42 will be a min value
jle randomize_pipe_height

mov cx, ax
mov cx, ax ; test if a random number is even (divides by 2)
mov bx, 2
xor dx, dx
div bx
Expand All @@ -245,29 +245,28 @@ randomize_pipe:
push si
pusha

call randomize_pipe_height
call randomize_pipe_height ; UPPER PIPE

mov bx, 78
sub bx, ax
mov bx, ax ; range of values: 6 (small) ... 114 (big)

mov si, [bp + 4]

mov word [si + 2], bx

call randomize_pipe_height

mov bx, 78
sub bx, ax
; BOTTOM PIPE (depends on the upper pipe)
mov bx, 120
sub bx, ax ; range of values: 6 (small) ... 114 (big)

mov word [si + 6], bx

add ax, 78
mov ax, 156 ; 156 is a ground
sub ax, bx ; root of a bottom pipe
mov word [si + 4], ax

popa
pop si
pop bp
ret 2 ; 1 params * 2 bytes
ret 2 ; 1 params * 2 bytes

random_pipe_position:
call random
Expand All @@ -281,8 +280,8 @@ random_pipe_position:
ret

reset_pipes:
mov word [PIPE_1], 120
mov word [PIPE_2], 260
mov word [PIPE_1], 160
mov word [PIPE_2], 280
mov word [PIPE_3], 400
mov word [pipe_a], 0
ret
Expand Down
2 changes: 1 addition & 1 deletion src/game/score.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_score:
add word [score], 50
add word [score], 1
ret

new_highscore:
Expand Down