A Flappy Bird clone in 512 bytes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

petty.asm 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. use16
  2. org 0x7c00
  3. DISTANCE = 56
  4. POLE_WIDTH = 20
  5. GAP_HEIGHT = 35
  6. mov ax,0x13
  7. int 0x10
  8. push word 0xa000
  9. pop es
  10. xor ax,ax
  11. mov ds,ax
  12. out 0x70,al
  13. in al,0x70
  14. mov [random],al
  15. xor bp,bp
  16. main_loop:
  17. inc bp
  18. mov cx,200
  19. mov di,1
  20. draw_pole_loop:
  21. add di,319
  22. cmp bp,POLE_WIDTH
  23. ja no_pole
  24. mov ax,cx
  25. mov dl,[random]
  26. and dx,0x7f
  27. sub ax,dx
  28. js is_pole
  29. cmp ax,GAP_HEIGHT
  30. jae is_pole
  31. no_pole:
  32. xor al,al
  33. jmp draw_bg
  34. is_pole:
  35. mov al,47
  36. draw_bg:
  37. stosb
  38. loop draw_pole_loop
  39. cmp bp,DISTANCE
  40. jb not_next
  41. sub bp,DISTANCE
  42. mov al,[random]
  43. mov dl,al
  44. shl dl,7
  45. xor al,dl
  46. mov dl,al
  47. shr dl,5
  48. xor al,dl
  49. mov dl,al
  50. shl dl,3
  51. xor al,dl
  52. mov [random],al
  53. not_next:
  54. mov ah,1
  55. int 0x16
  56. mov ax,[y_pos]
  57. jnz flap
  58. inc word [y_speed]
  59. add ax,[y_speed]
  60. jmp draw_bird
  61. flap:
  62. push ax
  63. xor ah,ah
  64. int 0x16
  65. pop ax
  66. mov word [y_speed],0xfffa
  67. add ax,0xfffa
  68. draw_bird:
  69. cmp ax,200
  70. jae crash
  71. mov [y_pos],ax
  72. mov cx,320
  73. mul cx
  74. add ax,42
  75. mov di,ax
  76. cmp byte [es:di],0
  77. jne crash
  78. mov al,44
  79. stosb
  80. mov si,1
  81. xor di,di
  82. mov cx,320*200
  83. push ds
  84. push es
  85. pop ds
  86. rep movsb
  87. pop ds
  88. mov si,system_time
  89. wait_timer:
  90. hlt
  91. xor ah,ah
  92. int 0x1a
  93. cmp dx,[si]
  94. je wait_timer
  95. mov [si],dx
  96. jmp main_loop
  97. crash:
  98. hlt
  99. jmp crash
  100. y_pos dw 100
  101. y_speed dw 0
  102. times 510-($-$$) db 0
  103. dw 0xaa55
  104. random = 0x7e00 ; db
  105. system_time = 0x7e02 ; dw