Browse Source

Removed MIX_AUDIO references + bugfix for SDL1 in audio callback

rbx need to be saved & restored
Yann Weber 3 years ago
parent
commit
494a54b65e
2 changed files with 3 additions and 74 deletions
  1. 0
    4
      sdl.asm
  2. 3
    70
      yaglitch.asm

+ 0
- 4
sdl.asm View File

@@ -15,10 +15,6 @@ Extern SDL_GetError
15 15
 	%define SDL_QUIT 0x100
16 16
 	%define SDL_AUDIODEVICEADDED 0x1100
17 17
 %endif
18
-%ifdef MIX_AUDIO
19
-	Extern SDL_MixAudio
20
-	%define SDL_MAX_VOLUME 128
21
-%endif
22 18
 
23 19
 %define SDL_SWSURFACE 0
24 20
 

+ 3
- 70
yaglitch.asm View File

@@ -95,10 +95,6 @@ section .bss
95 95
 		event: resb 56
96 96
 		evt_cnt: resb 1
97 97
 	%endif
98
-	%ifdef MIX_AUDIO
99
-		cllbck_heap: resq 1
100
-		cllbck_heapsz: resw 1
101
-	%endif
102 98
 
103 99
 section .text
104 100
 global _start
@@ -366,16 +362,6 @@ dbginit:
366 362
 		;start audio
367 363
 		xor rdi, rdi
368 364
 		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 365
 
380 366
 loop_event:
381 367
 	xor rdi, rdi
@@ -386,7 +372,7 @@ loop_event:
386 372
 	je sdl_error ; error fetching event...
387 373
 	xor rdi, rdi
388 374
 	%ifdef SDL1
389
-			mov dil, [event]
375
+			mov dil, [event] ; 8bit evt
390 376
 			cmp dil, SDL_QUIT
391 377
 			je exit
392 378
 	%endif
@@ -604,15 +590,12 @@ print_hnum:
604 590
 		add al, "A" - 10
605 591
 		ret
606 592
 
607
-%ifndef MIX_AUDIO
608 593
 ; simplest/shortes audio_callback : copy byte returned by run_glitch in *stream
609 594
 audio_cllbck:
610 595
 	; rdi -> *userdata
611 596
 	; rsi -> *stream
612 597
 	; rdx -> stream_len
613
-	%ifdef SDL2
614
-		push rbx ; strange, but nescessary...
615
-	%endif
598
+		push rbx ; stores rbx
616 599
 		mov rcx, rdx
617 600
 		mov rdi, rsi
618 601
 		.loop:
@@ -624,58 +607,8 @@ audio_cllbck:
624 607
 			pop rcx
625 608
 			inc dword [t]
626 609
 			loop .loop
627
-	%ifdef SDL2
628
-		pop rbx ; if rbx change SDL2 segfault :/
629
-	%endif
610
+		pop rbx ; rbx restore
630 611
 		ret
631
-%endif
632
-%ifdef MIX_AUDIO
633
-; another version of the audio callback using heap to store the data
634
-; and SDL_MixAudio to copy data in *stream
635
-audio_cllbck:
636
-	; rdi -> *userdata
637
-	; rsi -> *stream
638
-	; rdx -> stream_len
639
-	push rbx
640
-	mov rcx, [cllbck_heapsz]
641
-	cmp rcx, rdx
642
-	jle .heap_brk
643
-	.continue:
644
-		mov rdi, [cllbck_heap]
645
-		push rdx ; len
646
-		push rdi
647
-		push rsi ; *stream, dst
648
-		mov rcx, rdx
649
-		.pop_loop: ; populating heap with glitch datas
650
-			push rcx
651
-			push rdi
652
-			call run_glitch
653
-			pop rdi
654
-			stosb
655
-			pop rcx
656
-			inc dword [t]
657
-			loop .pop_loop
658
-		pop rdi ; *stream
659
-		pop rsi ; heap_start
660
-		pop rdx ; len
661
-		mov rcx, SDL_MAX_VOLUME
662
-		pop rbx
663
-		ret
664
-	.heap_brk: ; resize heap to handle 
665
-		push rdi
666
-		push rsi
667
-		push rdx
668
-		mov rdi, [cllbck_heap]
669
-		add rdi, rdx
670
-		sub rdi, rcx
671
-		mov rax, 0xc ; brk
672
-		syscall
673
-		mov [cllbck_heap], rax
674
-		pop rdx
675
-		pop rsi
676
-		pop rdi
677
-		jmp .continue
678
-%endif
679 612
 
680 613
 run_glitch:
681 614
 	; Run the glitch_pgm

Loading…
Cancel
Save