aboutsummaryrefslogtreecommitdiff
path: root/src/main.S
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2026-02-18 15:24:23 +0100
committerFelix Morgner <felix.morgner@gmail.com>2026-02-18 15:24:23 +0100
commit943e24c81926f2392c341001cca69b58536c8129 (patch)
tree4b1873fa69c75af91b33b3a384218f8a38743b1a /src/main.S
parent2a1f31365dade481c32efc3307f94cc052d00f7f (diff)
downloadsnake.s-943e24c81926f2392c341001cca69b58536c8129.tar.xz
snake.s-943e24c81926f2392c341001cca69b58536c8129.zip
feat: create a simple square
Diffstat (limited to 'src/main.S')
-rw-r--r--src/main.S21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.S b/src/main.S
index 3a0da8a..9069c8a 100644
--- a/src/main.S
+++ b/src/main.S
@@ -1,5 +1,6 @@
#include "helpers/function.S"
#include "SDL/init.S"
+#include "SDL/rect.S"
#include "SDL/render.S"
#include "SDL/video.S"
@@ -27,6 +28,7 @@
define_local window_handle, 8
define_local renderer_handle, 8
+ define_local rect, SIZE_SDL_Rect
allocate_locals
// initialize SDL
@@ -61,7 +63,7 @@
lea failed_to_create_window(%rip), %rdi
call _print_sdl_error@PLT
mov $1, %rax
- function_exit
+ jmp .Lquit_sdl
1:
lea succeeded_to_create_window(%rip), %rdi
xor %rax, %rax
@@ -85,16 +87,31 @@
xor %rax, %rax
call printf@PLT
+ mov $(SCREEN_HEIGHT / 2), %r8
+ mov $(SCREEN_WIDTH / 2), %r9
+
+ address_of_local rect, %rdi
+ mov %r8, OFFSET_SDL_Rect_w(%rdi)
+ mov %r8, OFFSET_SDL_Rect_h(%rdi)
+ mov %r9, %r10
+ shr $1, %r9
+ sub %r9, %r10
+ mov %r10, OFFSET_SDL_Rect_x(%rdi)
+ mov %r8, %r10
+ sub %r9, %r10
+ mov %r10, OFFSET_SDL_Rect_y(%rdi)
+
.Ldestroy_renderer:
// destroy the renderer
load_local renderer_handle, %rdi
- call SDL_DestroyRenderer
+ call SDL_DestroyRenderer@PLT
.Ldestroy_window:
// destroy the window
load_local window_handle, %rdi
call SDL_DestroyWindow@PLT
+ .Lquit_sdl:
call SDL_Quit@PLT
xor %rax, %rax