|
@@ -108,6 +108,14 @@ section .bss
|
108
|
108
|
|
109
|
109
|
visu_data_buff: resb 0x100
|
110
|
110
|
|
|
111
|
+ %ifdef SDL2
|
|
112
|
+ visu_win: resq 1
|
|
113
|
+ %endif
|
|
114
|
+
|
|
115
|
+ visu_scr: resq 1
|
|
116
|
+
|
|
117
|
+ visu_surf: resq 1
|
|
118
|
+
|
111
|
119
|
section .text
|
112
|
120
|
global _start
|
113
|
121
|
_start:
|
|
@@ -369,14 +377,18 @@ sdl_init:
|
369
|
377
|
mov rdi, audiospec_wanted
|
370
|
378
|
mov rsi, audiospec_recv
|
371
|
379
|
call SDL_OpenAudio
|
|
380
|
+
|
372
|
381
|
; video init 256*256 window
|
|
382
|
+ ; init visu_scr : *screen
|
373
|
383
|
%ifdef SDL1
|
374
|
384
|
mov rdi, 256
|
375
|
385
|
mov rsi, 256
|
376
|
386
|
mov rdx, 32
|
377
|
387
|
;mov rcx, SDL_SWSURFACE
|
378
|
|
- xor rcx, rcx
|
|
388
|
+ mov rcx, SDL_DOUBLEBUF
|
379
|
389
|
call SDL_SetVideoMode
|
|
390
|
+ call SDL_GetVideoSurface
|
|
391
|
+ mov [visu_scr], rax
|
380
|
392
|
%endif
|
381
|
393
|
%ifdef SDL2
|
382
|
394
|
mov rdi, window_title
|
|
@@ -386,7 +398,92 @@ sdl_init:
|
386
|
398
|
mov r8, 256
|
387
|
399
|
xor r9, r9
|
388
|
400
|
call SDL_CreateWindow
|
|
401
|
+ mov [visu_win], rax
|
|
402
|
+ mov rdi, rax
|
|
403
|
+ call SDL_GetWindowSurface
|
|
404
|
+ mov [visu_scr], rax
|
|
405
|
+ %endif
|
|
406
|
+
|
|
407
|
+ ; init SDL surface according to SDL screen in visu_surf
|
|
408
|
+ xor rdi, rdi ; flasg
|
|
409
|
+ mov rsi, 256 ; width
|
|
410
|
+ mov rdx, 256 ; height
|
|
411
|
+ mov rcx, 32 ; 32 bits depth
|
|
412
|
+ mov r8, 0xff ; rmask
|
|
413
|
+ mov r9, 0xff00 ; gmask
|
|
414
|
+ mov rax, 0xff0000 ; bmask
|
|
415
|
+ push rax
|
|
416
|
+ push rax
|
|
417
|
+ shl rax, 8 ; amask
|
|
418
|
+ mov [rsp+8], rax
|
|
419
|
+ call SDL_CreateRGBSurface
|
|
420
|
+ mov [visu_surf], rax
|
|
421
|
+ test rax, rax
|
|
422
|
+ jz sdl_error
|
|
423
|
+ pop rcx
|
|
424
|
+ pop rcx
|
|
425
|
+ ; RAZ surface & blit
|
|
426
|
+ push rax ; push surface addr
|
|
427
|
+ mov rdi, rax
|
|
428
|
+ call SDL_LockSurface
|
|
429
|
+
|
|
430
|
+ %ifdef SDL2
|
|
431
|
+ xor rdx, rdx
|
|
432
|
+ xor rcx, rcx
|
|
433
|
+ MOV_surf_w ecx, visu_surf
|
|
434
|
+ xor rax, rax
|
|
435
|
+ MOV_surf_pitch eax, visu_surf
|
|
436
|
+ mul ecx
|
|
437
|
+ MOV_surf_pixels rdi, visu_surf
|
|
438
|
+ xor rsi, rsi
|
|
439
|
+ ;mov rsi, 0xFF ;white
|
|
440
|
+ mov rdx, rax
|
|
441
|
+ call SDL_memset ; seems to malloc the pixels
|
|
442
|
+ %endif
|
|
443
|
+
|
|
444
|
+ %ifdef SDL1
|
|
445
|
+ xor rcx, rcx
|
|
446
|
+ MOV_surf_w ecx, visu_surf
|
|
447
|
+ push rcx
|
|
448
|
+ MOV_surf_h ecx, visu_surf
|
|
449
|
+ MOV_surf_pixels rdi, visu_surf
|
|
450
|
+ ;mov rax, 0xffcc22ff ; magenta
|
|
451
|
+ ;mov rax, 0xffffffff ; white
|
|
452
|
+ dec rcx
|
|
453
|
+ .loop_razh:
|
|
454
|
+ push rcx
|
|
455
|
+ mov rcx, [rsp+8]
|
|
456
|
+ dec rcx
|
|
457
|
+ .loop_razw:
|
|
458
|
+ stosd
|
|
459
|
+ loop .loop_razw
|
|
460
|
+ pop rcx
|
|
461
|
+ loop .loop_razh
|
|
462
|
+ pop rcx
|
389
|
463
|
%endif
|
|
464
|
+
|
|
465
|
+ pop rdi ; surface addr
|
|
466
|
+ call SDL_UnlockSurface
|
|
467
|
+
|
|
468
|
+ mov rdi, [visu_surf]
|
|
469
|
+ xor rsi, rsi
|
|
470
|
+ mov rdx, [visu_scr]
|
|
471
|
+ xor rcx, rcx
|
|
472
|
+ call SDL_BlitSurface
|
|
473
|
+ test rax, rax
|
|
474
|
+ jnz sdl_error
|
|
475
|
+
|
|
476
|
+ %ifdef SDL2
|
|
477
|
+ mov rdi, [visu_win]
|
|
478
|
+ call SDL_UpdateWindowSurface
|
|
479
|
+ %endif
|
|
480
|
+ %ifdef SDL1
|
|
481
|
+ mov rdi, [visu_scr]
|
|
482
|
+ call SDL_Flip
|
|
483
|
+ %endif
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
390
|
487
|
%ifdef MIX_AUDIO
|
391
|
488
|
; init callback heap infos
|
392
|
489
|
mov rax, 0xc ; brk
|
|
@@ -441,19 +538,34 @@ sdl_error:
|
441
|
538
|
; display error & exit
|
442
|
539
|
call SDL_GetError
|
443
|
540
|
push rax
|
|
541
|
+.dbg:
|
|
542
|
+ test rax, rax
|
|
543
|
+ jz .no_err
|
|
544
|
+ mov rdi, rax
|
444
|
545
|
call strlen
|
|
546
|
+ .printerr:
|
445
|
547
|
mov rdx, rsi ; msglen
|
446
|
548
|
pop rdi ; msg
|
447
|
549
|
mov rax, 1 ; write
|
448
|
550
|
mov rdi, 2 ; stderr
|
449
|
551
|
syscall
|
450
|
552
|
mov rdi, 0xF
|
451
|
|
- jmp exit.exit_err
|
|
553
|
+ jmp sdl_exit_err
|
|
554
|
+ .no_err:
|
|
555
|
+ mov rdi, 0x5
|
|
556
|
+ jmp sdl_exit_err
|
452
|
557
|
|
453
|
558
|
exit_fatal:
|
454
|
559
|
mov rdi, 42
|
455
|
560
|
jmp exit.exit_err
|
456
|
561
|
|
|
562
|
+sdl_exit_err:
|
|
563
|
+ push rdi
|
|
564
|
+ call SDL_Quit
|
|
565
|
+ pop rdi
|
|
566
|
+ mov rax, 0x3c
|
|
567
|
+ syscall
|
|
568
|
+
|
457
|
569
|
exit:
|
458
|
570
|
call SDL_Quit
|
459
|
571
|
|
|
@@ -649,9 +761,7 @@ audio_cllbck:
|
649
|
761
|
; rdi -> *userdata
|
650
|
762
|
; rsi -> *stream
|
651
|
763
|
; rdx -> stream_len
|
652
|
|
- %ifdef SDL2
|
653
|
|
- push rbx ; strange, but nescessary...
|
654
|
|
- %endif
|
|
764
|
+ push rbx
|
655
|
765
|
mov rcx, rdx
|
656
|
766
|
mov rdi, rsi
|
657
|
767
|
push rsi
|
|
@@ -674,10 +784,8 @@ audio_cllbck:
|
674
|
784
|
syscall
|
675
|
785
|
cmp rax, -1
|
676
|
786
|
je exit_fatal
|
677
|
|
- %ifdef SDL2
|
678
|
|
- pop rbx ; if rbx change SDL2 segfault :/
|
679
|
|
- %endif
|
680
|
|
- ret
|
|
787
|
+ pop rbx
|
|
788
|
+ ret
|
681
|
789
|
%endif
|
682
|
790
|
%ifdef MIX_AUDIO
|
683
|
791
|
; another version of the audio callback using heap to store the data
|