diff --git a/Makefile b/Makefile index 40dc188..5e751b7 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 diff --git a/README.md b/README.md index c01fda6..62f1c8a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/build/floppybird.img b/build/floppybird.img index 0b61085..8be0cbe 100644 Binary files a/build/floppybird.img and b/build/floppybird.img differ diff --git a/build/floppybird.iso b/build/floppybird.iso index 4dfcaf4..edded47 100644 Binary files a/build/floppybird.iso and b/build/floppybird.iso differ diff --git a/build/flpybird.com b/build/flpybird.com index c34905d..3f3b134 100644 Binary files a/build/flpybird.com and b/build/flpybird.com differ diff --git a/build/img/.gitkeep b/build/img/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/build/img/floppybird.img b/build/img/floppybird.img new file mode 100644 index 0000000..39c0168 Binary files /dev/null and b/build/img/floppybird.img differ diff --git a/build/img/sha256sum.txt b/build/img/sha256sum.txt new file mode 100644 index 0000000..d1dc532 --- /dev/null +++ b/build/img/sha256sum.txt @@ -0,0 +1 @@ +249f77da69ba5d3295ed0c9180e4ffc646fb24f545630448fd55d5de2aec1455 ./floppybird.img diff --git a/build/iso/floppybird.img b/build/iso/floppybird.img index 01e2a71..39c0168 100644 Binary files a/build/iso/floppybird.img and b/build/iso/floppybird.img differ diff --git a/build/iso/sha256sum.txt b/build/iso/sha256sum.txt new file mode 100644 index 0000000..25d0dd2 --- /dev/null +++ b/build/iso/sha256sum.txt @@ -0,0 +1,2 @@ +249f77da69ba5d3295ed0c9180e4ffc646fb24f545630448fd55d5de2aec1455 ./floppybird.img +e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ./.gitkeep diff --git a/build/sha256sum.txt b/build/sha256sum.txt new file mode 100644 index 0000000..f779923 --- /dev/null +++ b/build/sha256sum.txt @@ -0,0 +1,3 @@ +49beea041de38c27d6ce931feb23b90b0d49cc04446e8f8219457556a310d2ab ./floppybird.img +4a7d4cbb090fb237c4f702e3f9c22533d281a8c19ae996aba8dab262ff3246da ./floppybird.iso +c94349ffb13a22eb1d534e7521791b16302deea2c27a21451604501932d1a989 ./flpybird.com diff --git a/data/bird_small.tga b/data/bird_small.tga new file mode 100644 index 0000000..0f189d1 Binary files /dev/null and b/data/bird_small.tga differ diff --git a/data/pipe_small.tga b/data/pipe_small.tga new file mode 100644 index 0000000..1cd5894 Binary files /dev/null and b/data/pipe_small.tga differ diff --git a/data/pipe_top_small.tga b/data/pipe_top_small.tga new file mode 100644 index 0000000..5520a4f Binary files /dev/null and b/data/pipe_top_small.tga differ diff --git a/src/game/bird.asm b/src/game/bird.asm index 4de6ef7..f09db47 100644 --- a/src/game/bird.asm +++ b/src/game/bird.asm @@ -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 @@ -39,9 +49,9 @@ 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: @@ -49,15 +59,15 @@ animate_bird: 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 @@ -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 diff --git a/src/game/data.asm b/src/game/data.asm index 15b326f..a921725 100644 --- a/src/game/data.asm +++ b/src/game/data.asm @@ -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 diff --git a/src/game/pipes.asm b/src/game/pipes.asm index 984060b..01a279a 100644 --- a/src/game/pipes.asm +++ b/src/game/pipes.asm @@ -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] @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/game/score.asm b/src/game/score.asm index f5a59bf..cd2055c 100644 --- a/src/game/score.asm +++ b/src/game/score.asm @@ -1,5 +1,5 @@ add_score: - add word [score], 50 + add word [score], 1 ret new_highscore: