Browse Source

Adds window creation

Yann Weber 5 years ago
parent
commit
e55dc0ce05
2 changed files with 36 additions and 19 deletions
  1. 7
    1
      sdl.asm
  2. 29
    18
      yaglitch.asm

+ 7
- 1
sdl.asm View File

@@ -1,7 +1,6 @@
1 1
 
2 2
 EXTERN SDL_Init
3 3
 Extern SDL_Quit
4
-Extern SDL_SetVideoMode
5 4
 Extern SDL_Delay
6 5
 Extern SDL_OpenAudio
7 6
 Extern SDL_PauseAudio
@@ -10,10 +9,17 @@ Extern SDL_GetError
10 9
 
11 10
 %ifdef SDL1
12 11
 	%define SDL_QUIT 0x0C
12
+	Extern SDL_SetVideoMode
13 13
 %endif
14 14
 %ifdef SDL2
15
+	; events
15 16
 	%define SDL_QUIT 0x100
16 17
 	%define SDL_AUDIODEVICEADDED 0x1100
18
+	; values
19
+	%define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
20
+	%define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_MASK | 0 ; display 0
21
+	; function
22
+	Extern SDL_CreateWindow
17 23
 %endif
18 24
 %ifdef MIX_AUDIO
19 25
 	Extern SDL_MixAudio

+ 29
- 18
yaglitch.asm View File

@@ -70,6 +70,7 @@ section .data
70 70
 	def_str bigline_error, {"Line with more than 16 tokens !", 0xA}
71 71
 	def_str nl_error, {"Character \n is not the last one", 0xA}
72 72
 	def_str badop_error, {"Bad OP", 0xA}
73
+	window_title: db "Yaglitch", 0x0
73 74
 
74 75
 section .bss
75 76
 
@@ -353,29 +354,39 @@ sdl_init:
353 354
 	mov rdi, audiospec_wanted
354 355
 	mov rsi, audiospec_recv
355 356
 	call SDL_OpenAudio
356
-dbginit:
357
-	; 256*256 window
358
-	;mov rdi, 256
359
-	;mov rsi, 255
360
-	;mov rdx, 32
361
-	;;mov rcx, SDL_SWSURFACE
362
-	;xor rcx, rcx
363
-	;call SDL_SetVideoMode
357
+	; video init 256*256 window
358
+	%ifdef SDL1
359
+		mov rdi, 256
360
+		mov rsi, 256
361
+		mov rdx, 32
362
+		;mov rcx, SDL_SWSURFACE
363
+		xor rcx, rcx
364
+		call SDL_SetVideoMode
365
+	%endif
366
+	%ifdef SDL2
367
+		mov rdi, window_title
368
+		mov rsi, SDL_WINDOWPOS_UNDEFINED
369
+		mov rdx, SDL_WINDOWPOS_UNDEFINED
370
+		mov rcx, 256
371
+		mov r8, 256
372
+		xor r9, r9
373
+		call SDL_CreateWindow
374
+	%endif
375
+	%ifdef MIX_AUDIO
376
+		; init callback heap infos
377
+		mov rax, 0xc ; brk
378
+		xor rdi, rdi ; get heap start addr
379
+		mov [cllbck_heapsz], rdi
380
+		syscall
381
+		cmp rax, -1
382
+		je exit_fatal
383
+		mov [cllbck_heap], rax
384
+	%endif
364 385
 
365 386
 	audio_start:
366 387
 		;start audio
367 388
 		xor rdi, rdi
368 389
 		call SDL_PauseAudio
369
-%ifdef MIX_AUDIO
370
-	; init callback heap infos
371
-	mov rax, 0xc ; brk
372
-	xor rdi, rdi ; get heap start addr
373
-	mov [cllbck_heapsz], rdi
374
-	syscall
375
-	cmp rax, -1
376
-	je exit_fatal
377
-	mov [cllbck_heap], rax
378
-%endif
379 390
 
380 391
 loop_event:
381 392
 	xor rdi, rdi

Loading…
Cancel
Save