Explorar el Código

Tests for GUI implementation

Yann Weber hace 5 años
padre
commit
fc240bb1d5
Se han modificado 4 ficheros con 88 adiciones y 8 borrados
  1. 7
    0
      Makefile
  2. 5
    0
      utils.asm
  3. 73
    8
      yaglitch.asm
  4. 3
    0
      yaglitch_ui.asm

+ 7
- 0
Makefile Ver fichero

@@ -15,6 +15,8 @@ endif
15 15
 ifeq ($(SDL), 2)
16 16
 	LDFLAGS += -lSDL2 -lSDL_ttf
17 17
 	ASFLAGS += -DSDL2=1
18
+	SDL_SCANCODE = /usr/include/SDL2/SDL_scancode.h
19
+	SDL_KEYCODE = /usr/include/SDL2/SDL_keycode.h
18 20
 else
19 21
 	LDFLAGS += -lSDL -lSDL_ttf
20 22
 	ASFLAGS += -DSDL1=1
@@ -33,6 +35,11 @@ $(TARGET): $(OBJ)
33 35
 $(OBJ): $(SRC) $(DEPS) Makefile
34 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 43
 .PHONY: clean
37 44
 
38 45
 clean:

+ 5
- 0
utils.asm Ver fichero

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

+ 73
- 8
yaglitch.asm Ver fichero

@@ -49,6 +49,28 @@ section .data
49 49
 		dq OP.gt ; t
50 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 75
 	audiospec_wanted: ; SDL_audio configuration
54 76
 		dd 8000 ; freq
@@ -75,6 +97,7 @@ section .data
75 97
 	FC_FILE: db "file", 0x0
76 98
 	;FC_SPACING: db "spacing", 0x0
77 99
 	;FC_LANG: db "lang", 0x0
100
+	teststr: db "0123456789ABCDEF", 0x0
78 101
 
79 102
 section .bss
80 103
 
@@ -110,7 +133,9 @@ section .bss
110 133
 		.rd: resd 1
111 134
 		.wr: resd 1
112 135
 
136
+	; visu_* are SDL stuff
113 137
 	visu_data_buff: resb 0x100
138
+	visu_data_sz: resq 1
114 139
 
115 140
 	%ifdef SDL2
116 141
 		visu_win: resq 1
@@ -122,18 +147,20 @@ section .bss
122 147
 
123 148
 	text_surf: resq 1
124 149
 
150
+	; ttf_* are SDL_ttf stuff
125 151
 	ttf_font: resq 1
126 152
 
127 153
 	ttf_font_surf: resq 1
128 154
 
129 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 165
 section .text
139 166
 global _start
@@ -480,6 +507,9 @@ sdl_init:
480 507
 	; RAZ surface & blit
481 508
 	;call clear_screen ;useless
482 509
 
510
+	;
511
+	; Print glitch name in window (left for further utilisation)
512
+	;
483 513
 
484 514
 	; init fontconfig
485 515
 	call FcInitLoadConfigAndFonts
@@ -527,7 +557,8 @@ dbg:
527 557
 
528 558
 	mov dword [sdl_color], 0xFFFFFFFF
529 559
 	mov rdi, [ttf_font]
530
-	mov rsi, glitch_name
560
+	;mov rsi, glitch_name
561
+	mov rsi, teststr
531 562
 	mov rdx, [sdl_color]
532 563
 	call TTF_RenderText_Solid ; render text in surface
533 564
 	mov [ttf_font_surf], rax
@@ -563,7 +594,7 @@ loop_event:
563 594
 evt: ; not exit event
564 595
 
565 596
 
566
-visu:
597
+visu_upd:
567 598
 	; starts by reading from IPC pipe
568 599
 	xor rax, rax ; sys_read
569 600
 	xor rdi, rdi
@@ -573,6 +604,40 @@ visu:
573 604
 	syscall
574 605
 	cmp rax, -1
575 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 642
 	jmp loop_event ; loop again
578 643
 

+ 3
- 0
yaglitch_ui.asm Ver fichero

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

Loading…
Cancelar
Guardar