Kaynağa Gözat

Useless bugfix for MixAudio

Still broken on SDL2
Yann Weber 5 yıl önce
ebeveyn
işleme
11e1e1f7d9
1 değiştirilmiş dosya ile 29 ekleme ve 3 silme
  1. 29
    3
      yaglitch.asm

+ 29
- 3
yaglitch.asm Dosyayı Görüntüle

@@ -17,6 +17,8 @@
17 17
 
18 18
 [bits 64]
19 19
 
20
+%define MIX_AUDIO ; allowing to write all the buffer at once in IPC pipe
21
+
20 22
 %include "sdl.asm"
21 23
 %include "utils.asm"
22 24
 
@@ -101,6 +103,11 @@ section .bss
101 103
 		cllbck_heapsz: resw 1
102 104
 	%endif
103 105
 
106
+	; Pipe allowing callback to send data to main thread
107
+	ipc_pipe:
108
+		.rd: resq 1
109
+		.wr: resq 1
110
+
104 111
 section .text
105 112
 global _start
106 113
 _start:
@@ -348,6 +355,14 @@ stack_init:
348 355
 	mov [tosp], eax
349 356
 
350 357
 sdl_init:
358
+	
359
+	; Opening IPC pipe
360
+	mov rax, 0x16 ; sys_pipe
361
+	mov rdi, ipc_pipe
362
+	syscall
363
+	test rax, rax
364
+	jnz exit_fatal
365
+
351 366
 	mov rdi, 0x0000FFFF
352 367
 	call SDL_Init
353 368
 
@@ -650,7 +665,7 @@ audio_cllbck:
650 665
 	push rbx
651 666
 	mov rcx, [cllbck_heapsz]
652 667
 	cmp rcx, rdx
653
-	jle .heap_brk
668
+	jl .heap_brk
654 669
 	.continue:
655 670
 		mov rdi, [cllbck_heap]
656 671
 		push rdx ; len
@@ -669,7 +684,19 @@ audio_cllbck:
669 684
 		pop rdi ; *stream
670 685
 		pop rsi ; heap_start
671 686
 		pop rdx ; len
687
+		;mov rsi, [rsp] ; heap_start
688
+		;mov rdx, [rsp+8] ; len
672 689
 		mov rcx, SDL_MAX_VOLUME
690
+		call SDL_MixAudio
691
+
692
+		;mov rax, 0x1 ; sys_write
693
+		;mov rdi, [ipc_pipe.wr]
694
+		;pop rsi ; heap_start
695
+		;pop rdx ; len
696
+		;syscall
697
+		;cmp rax, -1
698
+		;je exit_fatal
699
+
673 700
 		pop rbx
674 701
 		ret
675 702
 	.heap_brk: ; resize heap to handle 
@@ -678,13 +705,12 @@ audio_cllbck:
678 705
 		push rdx
679 706
 		mov rdi, [cllbck_heap]
680 707
 		add rdi, rdx
681
-		sub rdi, rcx
682 708
 		mov rax, 0xc ; brk
683 709
 		syscall
684
-		mov [cllbck_heap], rax
685 710
 		pop rdx
686 711
 		pop rsi
687 712
 		pop rdi
713
+		mov [cllbck_heapsz], rdx
688 714
 		jmp .continue
689 715
 %endif
690 716
 

Loading…
İptal
Kaydet