Browse Source

Removed MIX_AUDIO references + bugfix for SDL1 in audio callback

rbx need to be saved & restored
Yann Weber 4 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
 	%define SDL_QUIT 0x100
15
 	%define SDL_QUIT 0x100
16
 	%define SDL_AUDIODEVICEADDED 0x1100
16
 	%define SDL_AUDIODEVICEADDED 0x1100
17
 %endif
17
 %endif
18
-%ifdef MIX_AUDIO
19
-	Extern SDL_MixAudio
20
-	%define SDL_MAX_VOLUME 128
21
-%endif
22
 
18
 
23
 %define SDL_SWSURFACE 0
19
 %define SDL_SWSURFACE 0
24
 
20
 

+ 3
- 70
yaglitch.asm View File

95
 		event: resb 56
95
 		event: resb 56
96
 		evt_cnt: resb 1
96
 		evt_cnt: resb 1
97
 	%endif
97
 	%endif
98
-	%ifdef MIX_AUDIO
99
-		cllbck_heap: resq 1
100
-		cllbck_heapsz: resw 1
101
-	%endif
102
 
98
 
103
 section .text
99
 section .text
104
 global _start
100
 global _start
366
 		;start audio
362
 		;start audio
367
 		xor rdi, rdi
363
 		xor rdi, rdi
368
 		call SDL_PauseAudio
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
 loop_event:
366
 loop_event:
381
 	xor rdi, rdi
367
 	xor rdi, rdi
386
 	je sdl_error ; error fetching event...
372
 	je sdl_error ; error fetching event...
387
 	xor rdi, rdi
373
 	xor rdi, rdi
388
 	%ifdef SDL1
374
 	%ifdef SDL1
389
-			mov dil, [event]
375
+			mov dil, [event] ; 8bit evt
390
 			cmp dil, SDL_QUIT
376
 			cmp dil, SDL_QUIT
391
 			je exit
377
 			je exit
392
 	%endif
378
 	%endif
604
 		add al, "A" - 10
590
 		add al, "A" - 10
605
 		ret
591
 		ret
606
 
592
 
607
-%ifndef MIX_AUDIO
608
 ; simplest/shortes audio_callback : copy byte returned by run_glitch in *stream
593
 ; simplest/shortes audio_callback : copy byte returned by run_glitch in *stream
609
 audio_cllbck:
594
 audio_cllbck:
610
 	; rdi -> *userdata
595
 	; rdi -> *userdata
611
 	; rsi -> *stream
596
 	; rsi -> *stream
612
 	; rdx -> stream_len
597
 	; rdx -> stream_len
613
-	%ifdef SDL2
614
-		push rbx ; strange, but nescessary...
615
-	%endif
598
+		push rbx ; stores rbx
616
 		mov rcx, rdx
599
 		mov rcx, rdx
617
 		mov rdi, rsi
600
 		mov rdi, rsi
618
 		.loop:
601
 		.loop:
624
 			pop rcx
607
 			pop rcx
625
 			inc dword [t]
608
 			inc dword [t]
626
 			loop .loop
609
 			loop .loop
627
-	%ifdef SDL2
628
-		pop rbx ; if rbx change SDL2 segfault :/
629
-	%endif
610
+		pop rbx ; rbx restore
630
 		ret
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
 run_glitch:
613
 run_glitch:
681
 	; Run the glitch_pgm
614
 	; Run the glitch_pgm

Loading…
Cancel
Save