Browse Source

Fixing SDL1 event handling

Yann Weber 5 years ago
parent
commit
294785e308
2 changed files with 30 additions and 6 deletions
  1. 2
    0
      sdl.asm
  2. 28
    6
      yaglitch.asm

+ 2
- 0
sdl.asm View File

@@ -6,8 +6,10 @@ Extern SDL_Delay
6 6
 Extern SDL_OpenAudio
7 7
 Extern SDL_PauseAudio
8 8
 Extern SDL_WaitEvent
9
+Extern SDL_GetError
9 10
 
10 11
 
12
+%define SDL_QuitEvent 0x0C
11 13
 
12 14
 %define SDL_SWSURFACE 0
13 15
 

+ 28
- 6
yaglitch.asm View File

@@ -358,17 +358,39 @@ audio_start:
358 358
 	call SDL_PauseAudio
359 359
 
360 360
 loop_event:
361
+	xor rdi, rdi
362
+	mov [event], rdi
361 363
 	mov rdi, event
362 364
 	call SDL_WaitEvent
363
-
365
+	cmp rax, 0
366
+	je sdl_error ; error fetching event...
364 367
 	xor rdi, rdi
365
-	mov edi, [event]
366
-	cmp edi, 0
367
-	jl exit ; SIGINT
368
-	cmp edi, 0x00010001 ; SDL_QUIT PRESS ?
369
-	je exit
368
+	mov di, [event]
369
+
370
+dbg:
371
+	;mov rsi, 1
372
+	;push rdi
373
+	;call print_hnum
374
+	;pop rdi
375
+
376
+	test di, SDL_QuitEvent
377
+	jnz exit
378
+
370 379
 	jmp loop_event
371 380
 
381
+sdl_error:
382
+	; display error & exit
383
+	call SDL_GetError
384
+	push rax
385
+	call strlen
386
+	mov rdx, rsi ; msglen
387
+	pop rdi ; msg
388
+	mov rax, 1 ; write
389
+	mov rdi, 2 ; stderr
390
+	syscall
391
+	mov rdi, 0xF
392
+	jmp exit.exit_err
393
+
372 394
 exit:
373 395
 	call SDL_Quit
374 396
 

Loading…
Cancel
Save