Rev 9172 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9172 | turbocat | 1 | ; |
2 | ; x86 format converters for HERMES |
||
3 | ; Some routines Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at) |
||
4 | ; This source code is licensed under the GNU LGPL |
||
5 | ; |
||
6 | ; Please refer to the file COPYING.LIB contained in the distribution for |
||
7 | ; licensing conditions |
||
8 | ; |
||
9 | ; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission |
||
10 | ; |
||
11 | |||
12 | BITS 32 |
||
13 | |||
14 | %include "common.inc" |
||
15 | |||
16 | SDL_FUNC _ConvertX86 |
||
17 | SDL_FUNC _Hermes_X86_CPU |
||
18 | |||
9202 | turbocat | 19 | SDL_FUNC ConvertX86 |
20 | SDL_FUNC Hermes_X86_CPU |
||
21 | |||
9172 | turbocat | 22 | SECTION .data |
23 | cpu_flags dd 0 |
||
24 | |||
25 | SECTION .text |
||
26 | |||
27 | ;; _ConvertX86: |
||
28 | ;; [ESP+8] ConverterInfo* |
||
29 | ;; -------------------------------------------------------------------------- |
||
30 | ;; ConverterInfo (ebp+..) |
||
31 | ;; 0: void *s_pixels |
||
32 | ;; 4: int s_width |
||
33 | ;; 8: int s_height |
||
34 | ;; 12: int s_add |
||
35 | ;; 16: void *d_pixels |
||
36 | ;; 20: int d_width |
||
37 | ;; 24: int d_height |
||
38 | ;; 28: int d_add |
||
39 | ;; 32: void (*converter_function)() |
||
40 | ;; 36: int32 *lookup |
||
9202 | turbocat | 41 | |
42 | ConvertX86: |
||
9172 | turbocat | 43 | _ConvertX86: |
44 | push ebp |
||
45 | mov ebp,esp |
||
46 | |||
47 | ; Save the registers used by the blitters, necessary for optimized code |
||
48 | pusha |
||
49 | |||
50 | mov eax,[ebp+8] |
||
51 | |||
52 | cmp dword [eax+4],BYTE 0 |
||
53 | je endconvert |
||
54 | |||
55 | mov ebp,eax |
||
56 | |||
57 | mov esi,[ebp+0] |
||
58 | mov edi,[ebp+16] |
||
59 | |||
60 | y_loop: |
||
61 | mov ecx,[ebp+4] |
||
62 | |||
63 | call [ebp+32] |
||
64 | |||
65 | add esi,[ebp+12] |
||
66 | add edi,[ebp+28] |
||
67 | |||
68 | dec dword [ebp+8] |
||
69 | jnz y_loop |
||
70 | |||
71 | ; Restore the registers used by the blitters, necessary for optimized code |
||
72 | popa |
||
73 | |||
74 | pop ebp |
||
75 | |||
76 | endconvert: |
||
77 | ret |
||
78 | |||
9202 | turbocat | 79 | Hermes_X86_CPU: |
9172 | turbocat | 80 | _Hermes_X86_CPU: |
81 | pushfd |
||
82 | pop eax |
||
83 | |||
84 | mov ecx,eax |
||
85 | |||
86 | xor eax,040000h |
||
87 | push eax |
||
88 | |||
89 | popfd |
||
90 | pushfd |
||
91 | |||
92 | pop eax |
||
93 | xor eax,ecx |
||
94 | jz .L1 ; Processor is 386 |
||
95 | |||
96 | push ecx |
||
97 | popfd |
||
98 | |||
99 | mov eax,ecx |
||
100 | xor eax,200000h |
||
101 | |||
102 | push eax |
||
103 | popfd |
||
104 | pushfd |
||
105 | |||
106 | pop eax |
||
107 | xor eax,ecx |
||
108 | je .L1 |
||
109 | |||
110 | pusha |
||
111 | |||
112 | mov eax,1 |
||
113 | cpuid |
||
114 | |||
115 | mov [cpu_flags],edx |
||
116 | |||
117 | popa |
||
118 | |||
119 | mov eax,[cpu_flags] |
||
120 | |||
121 | .L1: |
||
122 | ret |
||
123 | |||
124 | |||
125 | %ifidn __OUTPUT_FORMAT__,elf32 |
||
126 | section .note.GNU-stack noalloc noexec nowrite progbits |
||
127 | %endif |