소스 검색

Split yaglitch.asm

Yann Weber 5 년 전
부모
커밋
2e062c0f55
4개의 변경된 파일292개의 추가작업 그리고 284개의 파일을 삭제
  1. 2
    1
      Makefile
  2. 3
    283
      yaglitch.asm
  3. 225
    0
      yaglitch_op.asm
  4. 62
    0
      yaglitch_ui.asm

+ 2
- 1
Makefile 파일 보기

@@ -23,13 +23,14 @@ endif
23 23
 
24 24
 OBJ=$(TARGET).o
25 25
 SRC=$(TARGET).asm
26
+DEPS=sdl.asm yaglitch_op.asm yaglitch_ui.asm
26 27
 
27 28
 all: $(TARGET)
28 29
 
29 30
 $(TARGET): $(OBJ)
30 31
 	ld $(LDFLAGS) $< -o $@
31 32
 
32
-$(OBJ): $(SRC) sdl.asm Makefile
33
+$(OBJ): $(SRC) $(DEPS) Makefile
33 34
 	$(NASM) $(ASFLAGS) $<
34 35
 
35 36
 .PHONY: clean

+ 3
- 283
yaglitch.asm 파일 보기

@@ -423,66 +423,7 @@ sdl_init:
423 423
 	pop rcx
424 424
 	pop rcx
425 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
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
-
426
+	call clear_screen
486 427
 
487 428
 	%ifdef MIX_AUDIO
488 429
 		; init callback heap infos
@@ -886,228 +827,7 @@ run_glitch:
886 827
 ; /DEBUG
887 828
 	ret
888 829
 
889
-OP:
890
-	.numeric:
891
-		; rdi contain the number
892
-		shr rdi, 32
893
-	._push:
894
-		; push rdi (edi) on stack_buff
895
-		mov eax, edi
896
-		xor rbx, rbx
897
-		mov ebx, [tosp]
898
-		add ebx, 4
899
-		cmp ebx, STACK_SZ * 4
900
-		jl .go_push
901
-		mov ebx, 0
902
-		.go_push:
903
-			mov [tosp], ebx
904
-			lea rdi, [stack_buff+rbx]
905
-			stosd
906
-		ret
907
-
908
-	.drop: ; drop just calls pop
909
-	._pop:
910
-		; pop eax from stack_buff
911
-		xor rbx, rbx
912
-		mov ebx, [tosp]
913
-		lea rsi, [stack_buff+rbx]
914
-		xor rax, rax
915
-		lodsd
916
-		test ebx, ebx
917
-		jz .pop_no_dec
918
-		sub ebx, 4
919
-		jmp .pop_end
920
-		.pop_no_dec:
921
-			mov ebx, (STACK_SZ-1) * 4
922
-		.pop_end:
923
-			mov [tosp], ebx
924
-		ret
925
-
926
-
927
-	.t: ; push t on the stack
928
-		mov edi, [t]
929
-		call ._push
930
-		ret
931
-
932
-	.put:
933
-		pushf
934
-		cld
935
-		xor rbx, rbx
936
-		xor rax, rax
937
-		mov ebx, [tosp]
938
-		lea rsi, [stack_buff+rbx]
939
-		lodsd
940
-		and eax, 0xFF
941
-		inc eax
942
-		mov edx, eax
943
-		lodsd
944
-		neg rdx
945
-		lea rdi, [stack_buff + rdx]
946
-		stosq
947
-		call OP._pop
948
-		popf
949
-		ret
950
-	.mul:
951
-		call .prep_2arg
952
-		mul ebx
953
-		mov edi, eax
954
-		call OP._push
955
-		ret
956
-	.div:
957
-		call .prep_2arg
958
-		test ebx, ebx
959
-		jz .nodiv
960
-		xor rdx, rdx
961
-		div ebx
962
-		jmp .divend
963
-		.nodiv:
964
-		xor eax, eax
965
-		.divend:
966
-		mov edi, eax
967
-		call OP._push
968
-		ret
969
-	.add:
970
-		call .prep_2arg
971
-		add eax, ebx
972
-		mov edi, eax
973
-		call OP._push
974
-		ret
975
-	.sub:
976
-		call .prep_2arg
977
-		sub eax, ebx
978
-		mov edi, eax
979
-		call OP._push
980
-		ret
981
-	.mod:
982
-		call .prep_2arg
983
-		test rbx, rbx
984
-		jz .nomod
985
-		xor edx, edx
986
-		div ebx
987
-		jmp .endmod
988
-		.nomod:
989
-		xor edx, edx
990
-		.endmod:
991
-		mov edi, edx
992
-		call OP._push
993
-		ret
994
-	.lshift:
995
-		call OP._pop
996
-		push rax
997
-		call OP._pop
998
-		pop rcx
999
-		shl eax, cl
1000
-		mov edi, eax
1001
-		call OP._push
1002
-		ret
1003
-	.rshift:
1004
-		call OP._pop
1005
-		push rax
1006
-		call OP._pop
1007
-		pop rcx
1008
-		shr eax, cl
1009
-		mov edi, eax
1010
-		call OP._push
1011
-		ret
1012
-	.and:
1013
-		call .prep_2arg
1014
-		and eax, ebx
1015
-		mov edi, eax
1016
-		call OP._push
1017
-		ret
1018
-	.or:
1019
-		call .prep_2arg
1020
-		or eax, ebx
1021
-		mov edi, eax
1022
-		call OP._push
1023
-		ret
1024
-	.xor:
1025
-		call .prep_2arg
1026
-		xor eax, ebx
1027
-		mov edi, eax
1028
-		call OP._push
1029
-		ret
1030
-	.not:
1031
-		call OP._pop
1032
-		not eax
1033
-		mov edi, eax
1034
-		call OP._push
1035
-		ret
1036
-	.dup:
1037
-		call OP._pop
1038
-		push rax
1039
-		mov edi, eax
1040
-		call OP._push
1041
-		pop rdi
1042
-		call OP._push
1043
-		ret
1044
-	.pick:
1045
-		call OP._pop
1046
-		inc eax
1047
-		and eax, 0xFF
1048
-		mov ebx, 4
1049
-		mov ecx, [tosp]
1050
-		mul ebx ; mul by data size
1051
-		cmp eax, [tosp]
1052
-		jg .pick_loop
1053
-		sub ecx, eax
1054
-		jmp .pick_lea
1055
-		.pick_loop: ; eax > tosp
1056
-		sub eax, ecx
1057
-		mov ecx, (STACK_SZ - 1) * 4
1058
-		sub ecx, eax
1059
-		.pick_lea:
1060
-		lea rsi, [stack_buff+ecx]
1061
-		lodsd
1062
-		push rax
1063
-		call OP._pop
1064
-		pop rdi
1065
-		call OP._push
1066
-		ret
1067
-
830
+%include "yaglitch_op.asm"
1068 831
 
1069
-	.swap:
1070
-		call OP._pop
1071
-		push rax
1072
-		call OP._pop
1073
-		xchg rax, [rsp]
1074
-		mov edi, eax
1075
-		call OP._push
1076
-		pop rdi
1077
-		call OP._push
1078
-		ret
1079
-	.lt:
1080
-		call .prep_2arg
1081
-		xor rdi, rdi
1082
-		cmp eax, ebx
1083
-		jge .lt_false
1084
-		not rdi
1085
-		.lt_false:
1086
-		call OP._push
1087
-		ret
1088
-	.gt:
1089
-		call .prep_2arg
1090
-		xor rdi, rdi
1091
-		cmp eax, ebx
1092
-		jle .gt_false
1093
-		not rdi
1094
-		.gt_false:
1095
-		call OP._push
1096
-		ret
1097
-	.eq:
1098
-		call .prep_2arg
1099
-		xor rdi, rdi
1100
-		cmp eax, ebx
1101
-		jne .eq_false
1102
-		not rdi
1103
-		.eq_false:
1104
-		call OP._push
1105
-		ret
832
+%include "yaglitch_ui.asm"
1106 833
 
1107
-	.prep_2arg:
1108
-		; utils that pop both arguments V1 in eax, V2 in ebx
1109
-		call OP._pop
1110
-		push rax
1111
-		call OP._pop
1112
-		pop rbx
1113
-		ret

+ 225
- 0
yaglitch_op.asm 파일 보기

@@ -0,0 +1,225 @@
1
+OP:
2
+	.numeric:
3
+		; rdi contain the number
4
+		shr rdi, 32
5
+	._push:
6
+		; push rdi (edi) on stack_buff
7
+		mov eax, edi
8
+		xor rbx, rbx
9
+		mov ebx, [tosp]
10
+		add ebx, 4
11
+		cmp ebx, STACK_SZ * 4
12
+		jl .go_push
13
+		mov ebx, 0
14
+		.go_push:
15
+			mov [tosp], ebx
16
+			lea rdi, [stack_buff+rbx]
17
+			stosd
18
+		ret
19
+
20
+	.drop: ; drop just calls pop
21
+	._pop:
22
+		; pop eax from stack_buff
23
+		xor rbx, rbx
24
+		mov ebx, [tosp]
25
+		lea rsi, [stack_buff+rbx]
26
+		xor rax, rax
27
+		lodsd
28
+		test ebx, ebx
29
+		jz .pop_no_dec
30
+		sub ebx, 4
31
+		jmp .pop_end
32
+		.pop_no_dec:
33
+			mov ebx, (STACK_SZ-1) * 4
34
+		.pop_end:
35
+			mov [tosp], ebx
36
+		ret
37
+
38
+
39
+	.t: ; push t on the stack
40
+		mov edi, [t]
41
+		call ._push
42
+		ret
43
+
44
+	.put:
45
+		pushf
46
+		cld
47
+		xor rbx, rbx
48
+		xor rax, rax
49
+		mov ebx, [tosp]
50
+		lea rsi, [stack_buff+rbx]
51
+		lodsd
52
+		and eax, 0xFF
53
+		inc eax
54
+		mov edx, eax
55
+		lodsd
56
+		neg rdx
57
+		lea rdi, [stack_buff + rdx]
58
+		stosq
59
+		call OP._pop
60
+		popf
61
+		ret
62
+	.mul:
63
+		call .prep_2arg
64
+		mul ebx
65
+		mov edi, eax
66
+		call OP._push
67
+		ret
68
+	.div:
69
+		call .prep_2arg
70
+		test ebx, ebx
71
+		jz .nodiv
72
+		xor rdx, rdx
73
+		div ebx
74
+		jmp .divend
75
+		.nodiv:
76
+		xor eax, eax
77
+		.divend:
78
+		mov edi, eax
79
+		call OP._push
80
+		ret
81
+	.add:
82
+		call .prep_2arg
83
+		add eax, ebx
84
+		mov edi, eax
85
+		call OP._push
86
+		ret
87
+	.sub:
88
+		call .prep_2arg
89
+		sub eax, ebx
90
+		mov edi, eax
91
+		call OP._push
92
+		ret
93
+	.mod:
94
+		call .prep_2arg
95
+		test rbx, rbx
96
+		jz .nomod
97
+		xor edx, edx
98
+		div ebx
99
+		jmp .endmod
100
+		.nomod:
101
+		xor edx, edx
102
+		.endmod:
103
+		mov edi, edx
104
+		call OP._push
105
+		ret
106
+	.lshift:
107
+		call OP._pop
108
+		push rax
109
+		call OP._pop
110
+		pop rcx
111
+		shl eax, cl
112
+		mov edi, eax
113
+		call OP._push
114
+		ret
115
+	.rshift:
116
+		call OP._pop
117
+		push rax
118
+		call OP._pop
119
+		pop rcx
120
+		shr eax, cl
121
+		mov edi, eax
122
+		call OP._push
123
+		ret
124
+	.and:
125
+		call .prep_2arg
126
+		and eax, ebx
127
+		mov edi, eax
128
+		call OP._push
129
+		ret
130
+	.or:
131
+		call .prep_2arg
132
+		or eax, ebx
133
+		mov edi, eax
134
+		call OP._push
135
+		ret
136
+	.xor:
137
+		call .prep_2arg
138
+		xor eax, ebx
139
+		mov edi, eax
140
+		call OP._push
141
+		ret
142
+	.not:
143
+		call OP._pop
144
+		not eax
145
+		mov edi, eax
146
+		call OP._push
147
+		ret
148
+	.dup:
149
+		call OP._pop
150
+		push rax
151
+		mov edi, eax
152
+		call OP._push
153
+		pop rdi
154
+		call OP._push
155
+		ret
156
+	.pick:
157
+		call OP._pop
158
+		inc eax
159
+		and eax, 0xFF
160
+		mov ebx, 4
161
+		mov ecx, [tosp]
162
+		mul ebx ; mul by data size
163
+		cmp eax, [tosp]
164
+		jg .pick_loop
165
+		sub ecx, eax
166
+		jmp .pick_lea
167
+		.pick_loop: ; eax > tosp
168
+		sub eax, ecx
169
+		mov ecx, (STACK_SZ - 1) * 4
170
+		sub ecx, eax
171
+		.pick_lea:
172
+		lea rsi, [stack_buff+ecx]
173
+		lodsd
174
+		push rax
175
+		call OP._pop
176
+		pop rdi
177
+		call OP._push
178
+		ret
179
+
180
+
181
+	.swap:
182
+		call OP._pop
183
+		push rax
184
+		call OP._pop
185
+		xchg rax, [rsp]
186
+		mov edi, eax
187
+		call OP._push
188
+		pop rdi
189
+		call OP._push
190
+		ret
191
+	.lt:
192
+		call .prep_2arg
193
+		xor rdi, rdi
194
+		cmp eax, ebx
195
+		jge .lt_false
196
+		not rdi
197
+		.lt_false:
198
+		call OP._push
199
+		ret
200
+	.gt:
201
+		call .prep_2arg
202
+		xor rdi, rdi
203
+		cmp eax, ebx
204
+		jle .gt_false
205
+		not rdi
206
+		.gt_false:
207
+		call OP._push
208
+		ret
209
+	.eq:
210
+		call .prep_2arg
211
+		xor rdi, rdi
212
+		cmp eax, ebx
213
+		jne .eq_false
214
+		not rdi
215
+		.eq_false:
216
+		call OP._push
217
+		ret
218
+
219
+	.prep_2arg:
220
+		; utils that pop both arguments V1 in eax, V2 in ebx
221
+		call OP._pop
222
+		push rax
223
+		call OP._pop
224
+		pop rbx
225
+		ret

+ 62
- 0
yaglitch_ui.asm 파일 보기

@@ -0,0 +1,62 @@
1
+clear_screen:
2
+	mov rdi, [visu_surf]
3
+	push rdi
4
+	call SDL_LockSurface
5
+
6
+	%ifdef SDL2
7
+		xor rdx, rdx
8
+		xor rcx, rcx
9
+		MOV_surf_w ecx, visu_surf
10
+		xor rax, rax
11
+		MOV_surf_pitch eax, visu_surf
12
+		mul ecx
13
+		MOV_surf_pixels rdi, visu_surf
14
+		xor rsi, rsi
15
+		;mov rsi, 0xFF ;white
16
+		mov rdx, rax
17
+		call SDL_memset ; seems to malloc the pixels
18
+	%endif
19
+
20
+	%ifdef SDL1
21
+		xor rcx, rcx
22
+		MOV_surf_w ecx, visu_surf
23
+		push rcx
24
+		MOV_surf_h ecx, visu_surf
25
+		MOV_surf_pixels rdi, visu_surf
26
+		;mov rax, 0xffcc22ff ; magenta
27
+		;mov rax, 0xffffffff ; white
28
+		dec rcx
29
+		.loop_razh:
30
+			push rcx
31
+			mov rcx, [rsp+8]
32
+			dec rcx
33
+			.loop_razw:
34
+				stosd
35
+				loop .loop_razw
36
+			pop rcx
37
+			loop .loop_razh
38
+		pop rcx
39
+	%endif
40
+
41
+	pop rdi ; surface addr
42
+	call SDL_UnlockSurface
43
+
44
+	mov rdi, [visu_surf]
45
+	xor rsi, rsi
46
+	mov rdx, [visu_scr]
47
+	xor rcx, rcx
48
+	call SDL_BlitSurface
49
+	test rax, rax
50
+	jnz sdl_error
51
+
52
+	%ifdef SDL2
53
+		mov rdi, [visu_win]
54
+		call SDL_UpdateWindowSurface
55
+	%endif
56
+	%ifdef SDL1
57
+		mov rdi, [visu_scr]
58
+		call SDL_Flip
59
+	%endif
60
+	
61
+	ret
62
+

Loading…
취소
저장