input sortof-works
[ld45_start_nothing] / src / main.asm
1 ; vi:filetype=nasm ts=8 sts=8 sw=8:
2         bits 32
3 %include "gfx.inc"
4 %include "keyb.inc"
5 %include "intr.inc"
6 %include "dbglog.inc"
7
8         ; this is placed at the beginning of our binary at 1mb (see game.ld)
9         ; and it's what gets executed directly by the boot loader
10         section .startup
11         jmp main
12
13         ; start of main
14         section .text
15 main:
16         call init_intr
17         call kb_init
18         call init_gfx
19
20         dbglog `hello\n`
21
22         sti
23 main_loop:
24         call update
25
26         call clear
27
28         push dword 0
29         mov eax, [ship_y]
30         shr eax, 8
31         push eax
32         mov eax, [ship_x]
33         shr eax, 8
34         push eax
35         push dword FRAMEBUF_ADDR
36         call sprsheet
37         add esp, 16
38
39         call wait_vsync
40         call swap_buffers
41         jmp main_loop
42
43 update:
44         check_key SC_W
45         jnc .not_w
46         dec dword [ship_y]
47 .not_w: check_key SC_S
48         jnc .not_s
49         inc dword [ship_y]
50 .not_s: check_key SC_A
51         jnc .not_a
52         dec dword [ship_x]
53 .not_a: check_key SC_D
54         jnc .not_d
55         inc dword [ship_x]
56 .not_d:
57         ret
58
59         section .data
60         align 4
61 ship_x: dd 160 << 8
62 ship_y: dd 100 << 8