Browse Source

Tests for GUI implementation

Yann Weber 5 years ago
parent
commit
fc240bb1d5
4 changed files with 88 additions and 8 deletions
  1. 7
    0
      Makefile
  2. 5
    0
      utils.asm
  3. 73
    8
      yaglitch.asm
  4. 3
    0
      yaglitch_ui.asm

+ 7
- 0
Makefile View File

15
 ifeq ($(SDL), 2)
15
 ifeq ($(SDL), 2)
16
 	LDFLAGS += -lSDL2 -lSDL_ttf
16
 	LDFLAGS += -lSDL2 -lSDL_ttf
17
 	ASFLAGS += -DSDL2=1
17
 	ASFLAGS += -DSDL2=1
18
+	SDL_SCANCODE = /usr/include/SDL2/SDL_scancode.h
19
+	SDL_KEYCODE = /usr/include/SDL2/SDL_keycode.h
18
 else
20
 else
19
 	LDFLAGS += -lSDL -lSDL_ttf
21
 	LDFLAGS += -lSDL -lSDL_ttf
20
 	ASFLAGS += -DSDL1=1
22
 	ASFLAGS += -DSDL1=1
33
 $(OBJ): $(SRC) $(DEPS) Makefile
35
 $(OBJ): $(SRC) $(DEPS) Makefile
34
 	$(NASM) $(ASFLAGS) $<
36
 	$(NASM) $(ASFLAGS) $<
35
 
37
 
38
+sdl_keys_.asm:
39
+	echo "%%define SDLK_SCANCODE_MASK (1<<30)" > $@ ;
40
+	sed -nE 's/^[ \t]+(SDL_SCANCODE_[^ ]+) = ([^,]+),.*$$/%%define \1 \2/pg' $(SDL_SCANCODE) >> $@ ; 
41
+	sed -nE -e 's/SDL_SCANCODE_TO_KEYCODE\(([^\)]+)\)/(SDLK_SCANCODE_MASK | \1)/' -e "s/'/\"/g" -e 's/^[ \t]+(SDLK_[^ ]+) = ([^,]+),.*$$/%%define \1 \2/pg' $(SDL_KEYCODE) >> $@
42
+
36
 .PHONY: clean
43
 .PHONY: clean
37
 
44
 
38
 clean:
45
 clean:

+ 5
- 0
utils.asm View File

3
 	__%1_len:
3
 	__%1_len:
4
 	%define %1_len (__%1_len - %1)
4
 	%define %1_len (__%1_len - %1)
5
 %endmacro
5
 %endmacro
6
+
7
+%macro OPT_CHR 2
8
+	.%1: db %2
9
+	align 4, db 0
10
+%endmacro

+ 73
- 8
yaglitch.asm View File

49
 		dq OP.gt ; t
49
 		dq OP.gt ; t
50
 		dq OP.eq ; u
50
 		dq OP.eq ; u
51
 
51
 
52
+	opt_chr: ; pointers on OP chr repr
53
+		OPT_CHR a, "T"
54
+		OPT_CHR b, "Put"
55
+		OPT_CHR c, "Drop"
56
+		OPT_CHR d, "*"
57
+		OPT_CHR e, "/"
58
+		OPT_CHR f, "+"
59
+		OPT_CHR g, "-"
60
+		OPT_CHR h, "%"
61
+		OPT_CHR j, "<<"
62
+		OPT_CHR k, ">>"
63
+		OPT_CHR l, "&"
64
+		OPT_CHR m, "|"
65
+		OPT_CHR n, "^"
66
+		OPT_CHR o, "Not"
67
+		OPT_CHR p, "Dup"
68
+		OPT_CHR q, "Pck"
69
+		OPT_CHR r, "Swp"
70
+		OPT_CHR s, "<"
71
+		OPT_CHR t, ">"
72
+		OPT_CHR eq, "="
73
+
52
 
74
 
53
 	audiospec_wanted: ; SDL_audio configuration
75
 	audiospec_wanted: ; SDL_audio configuration
54
 		dd 8000 ; freq
76
 		dd 8000 ; freq
75
 	FC_FILE: db "file", 0x0
97
 	FC_FILE: db "file", 0x0
76
 	;FC_SPACING: db "spacing", 0x0
98
 	;FC_SPACING: db "spacing", 0x0
77
 	;FC_LANG: db "lang", 0x0
99
 	;FC_LANG: db "lang", 0x0
100
+	teststr: db "0123456789ABCDEF", 0x0
78
 
101
 
79
 section .bss
102
 section .bss
80
 
103
 
110
 		.rd: resd 1
133
 		.rd: resd 1
111
 		.wr: resd 1
134
 		.wr: resd 1
112
 
135
 
136
+	; visu_* are SDL stuff
113
 	visu_data_buff: resb 0x100
137
 	visu_data_buff: resb 0x100
138
+	visu_data_sz: resq 1
114
 
139
 
115
 	%ifdef SDL2
140
 	%ifdef SDL2
116
 		visu_win: resq 1
141
 		visu_win: resq 1
122
 
147
 
123
 	text_surf: resq 1
148
 	text_surf: resq 1
124
 
149
 
150
+	; ttf_* are SDL_ttf stuff
125
 	ttf_font: resq 1
151
 	ttf_font: resq 1
126
 
152
 
127
 	ttf_font_surf: resq 1
153
 	ttf_font_surf: resq 1
128
 
154
 
129
 	sdl_color: resd 1
155
 	sdl_color: resd 1
130
 
156
 
131
-	fc_config: resq 1
132
-	fc_pattern: resq 1
133
-	fc_object_set: resq 1
134
-	fc_font_set: resq 1
135
-	fc_font_file_ptr: resq 1
136
-	fc_result: resd 1
157
+	; fc_* are fontconfig stuff
158
+	fc_config: resq 1 ; ptr on FcConfig
159
+	fc_pattern: resq 1 ; ptr on FcPatter
160
+	fc_object_set: resq 1 ; object set (listing wanted property)
161
+	fc_font_set: resq 1 ; font set (when listing fonts)
162
+	fc_font_file_ptr: resq 1 ; pointer on filename ptr
163
+	fc_result: resd 1 ; an FcResult memory space
137
 
164
 
138
 section .text
165
 section .text
139
 global _start
166
 global _start
480
 	; RAZ surface & blit
507
 	; RAZ surface & blit
481
 	;call clear_screen ;useless
508
 	;call clear_screen ;useless
482
 
509
 
510
+	;
511
+	; Print glitch name in window (left for further utilisation)
512
+	;
483
 
513
 
484
 	; init fontconfig
514
 	; init fontconfig
485
 	call FcInitLoadConfigAndFonts
515
 	call FcInitLoadConfigAndFonts
527
 
557
 
528
 	mov dword [sdl_color], 0xFFFFFFFF
558
 	mov dword [sdl_color], 0xFFFFFFFF
529
 	mov rdi, [ttf_font]
559
 	mov rdi, [ttf_font]
530
-	mov rsi, glitch_name
560
+	;mov rsi, glitch_name
561
+	mov rsi, teststr
531
 	mov rdx, [sdl_color]
562
 	mov rdx, [sdl_color]
532
 	call TTF_RenderText_Solid ; render text in surface
563
 	call TTF_RenderText_Solid ; render text in surface
533
 	mov [ttf_font_surf], rax
564
 	mov [ttf_font_surf], rax
563
 evt: ; not exit event
594
 evt: ; not exit event
564
 
595
 
565
 
596
 
566
-visu:
597
+visu_upd:
567
 	; starts by reading from IPC pipe
598
 	; starts by reading from IPC pipe
568
 	xor rax, rax ; sys_read
599
 	xor rax, rax ; sys_read
569
 	xor rdi, rdi
600
 	xor rdi, rdi
573
 	syscall
604
 	syscall
574
 	cmp rax, -1
605
 	cmp rax, -1
575
 	je exit_fatal
606
 	je exit_fatal
607
+	test rax, rax
608
+	jz loop_event ; no data in pipe, loop again
609
+	; datas in pipe, updating screen
610
+	mov [visu_data_sz], rax
611
+
612
+	mov rdi, [visu_surf]
613
+	push rdi
614
+	call SDL_LockSurface
615
+
616
+	pushf
617
+	mov rsi, [rsp]
618
+	xor rcx, rcx
619
+	mov ecx, [rsi+16] ; surf_w
620
+	push rcx
621
+	dec qword [rsp] ; surf_w - 1, droping last colon
622
+	xor rax, rax
623
+	xor rdx, rdx
624
+	mov eax, [rsi+24] ; surf_pitch
625
+	mul ecx
626
+	mov rdx, rax ; line size in bytes
627
+
628
+	mov rsi, [rsi+32] ; surf_pixels
629
+	mov rcx, [rsp] ; surf_w - 1
630
+	add rsi, [rsp]
631
+	mov rdi, rsi
632
+	inc rdi ; destination is last colon
633
+	push rdi
634
+	mov rsi, [visu_data_buff]
635
+	.loop_shift:
636
+		mov rcx, 0xFF ; shift all 0xff pixels on colons
637
+	
638
+	pop rdi
639
+	pop rcx
640
+	popf
576
 
641
 
577
 	jmp loop_event ; loop again
642
 	jmp loop_event ; loop again
578
 
643
 

+ 3
- 0
yaglitch_ui.asm View File

1
 
1
 
2
 
2
 
3
 clear_screen:
3
 clear_screen:
4
+	; fill screen with a color
4
 	mov rdi, [visu_surf]
5
 	mov rdi, [visu_surf]
5
 	push rdi
6
 	push rdi
6
 	call SDL_LockSurface
7
 	call SDL_LockSurface
32
 	mov rdi, [visu_surf]
33
 	mov rdi, [visu_surf]
33
 
34
 
34
 blitflip_visu:
35
 blitflip_visu:
36
+	; blit a suface on screen and flip screen
35
 	; with rdi the src surface
37
 	; with rdi the src surface
36
 
38
 
37
 	xor rsi, rsi
39
 	xor rsi, rsi
42
 	jnz sdl_error
44
 	jnz sdl_error
43
 
45
 
44
 flip_visu:
46
 flip_visu:
47
+	; flip screen
45
 
48
 
46
 	%ifdef SDL2
49
 	%ifdef SDL2
47
 		mov rdi, [visu_win]
50
 		mov rdi, [visu_win]

Loading…
Cancel
Save