Subversion Repositories Kolibri OS

Rev

Rev 129 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 129 Rev 384
1
;
1
;
2
;   MenuetOS Driver (vmode.mdr)
2
;   MenuetOS Driver (vmode.mdr)
3
;   Target: Vertical Refresh Rate programming and videomode changing
3
;   Target: Vertical Refresh Rate programming and videomode changing
4
;
4
;
5
;   Author: Trans <<<<<13>>>>>
5
;   Author: Trans <<<<<13>>>>>
6
;   Date:   20.07.2003
6
;   Date:   20.07.2003
7
;
7
;
8
;   Version: 1.0
8
;   Version: 1.0
9
;   OS: MenuetOS
9
;   OS: MenuetOS
10
;   Compiler: FASM
10
;   Compiler: FASM
11
;
11
;
12
use32
12
use32
13
 
13
 
14
__DEBUG__ = 1
14
__DEBUG__ = 1
15
 
15
 
16
;macro align value { rb (value-1) - ($ + value-1) mod value }
16
;macro align value { rb (value-1) - ($ + value-1) mod value }
17
macro func name {
17
macro func name {
18
 if used name
18
 if used name
19
  align 4
19
  align 4
20
  name@of@func equ name
20
  name@of@func equ name
21
;  _numb `name,name
21
;  _numb `name,name
22
}
22
}
23
macro begin {
23
macro begin {
24
 align 4
24
 align 4
25
 name@of@func:
25
 name@of@func:
26
}
26
}
27
endf fix end if
27
endf fix end if
28
macro return _val {
28
macro return _val {
29
 if ~_val eq eax
29
 if ~_val eq eax
30
  mov  eax,_val
30
  mov  eax,_val
31
 end if
31
 end if
32
 ret
32
 ret
33
}
33
}
34
macro comment symb { ;s
34
macro comment symb { ;s
35
 if 0=1
35
 if 0=1
36
}
36
}
37
^ fix end if
37
^ fix end if
38
 
38
 
39
include 'struct.inc'
39
include 'struct.inc'
40
 
40
 
41
B_HOST fix HOST_BENDIAN ; HOST_LENDIAN
41
B_HOST fix HOST_BENDIAN ; HOST_LENDIAN
42
 
42
 
43
;-----------------------------------------------------------------------------
43
;-----------------------------------------------------------------------------
44
 
44
 
45
        org    0x760000
45
	org    0x760000
46
 
46
 
47
headerstart=$
47
headerstart=$
48
 
48
 
49
mdid    db     'MDAZ'              ; 4 byte id
49
mdid	db     'MDAZ'		   ; 4 byte id
50
mdhver  dd     0x00                ; header version
50
mdhver	dd     0x00		   ; header version
51
mdcode  dd     MDSTART             ; start of code
51
mdcode	dd     MDSTART		   ; start of code
52
mdver   dd     0x00000001          ; driver version (subversion*65536+version)
52
mdver	dd     0x00000001	   ; driver version (subversion*65536+version)
53
mdname  db     'Trans VideoDriver' ; 32 bytes of full driver name
53
mdname	db     'Trans VideoDriver' ; 32 bytes of full driver name
54
    times (32-($-mdname)) db ' '   ;
54
    times (32-($-mdname)) db ' '   ;
55
 
55
 
56
headerlen=$-headerstart
56
headerlen=$-headerstart
57
    times (256-headerlen) db 0     ; reserved area for future
57
    times (256-headerlen) db 0	   ; reserved area for future
58
 
58
 
59
MDSTART:    ; start of driver code ( base_adr+256 bytes)
59
MDSTART:    ; start of driver code ( base_adr+256 bytes)
60
; ebx(=ecx in program):
60
; ebx(=ecx in program):
61
;   1 - Get DriverInfo and Driver Initial Set
61
;   1 - Get DriverInfo and Driver Initial Set
62
;   2 - Get Current Video Mode With Vertical Refresh Rate
62
;   2 - Get Current Video Mode With Vertical Refresh Rate
63
;   3 - Change Video Mode
63
;   3 - Change Video Mode
64
;   4 - Return at Start System Video Mode
64
;   4 - Return at Start System Video Mode
65
;   5 - Change vertical and horizontal size of visible screen area
65
;   5 - Change vertical and horizontal size of visible screen area
66
;   6 - Change Vert/Hor position visible area on screen (not complete yet)
66
;   6 - Change Vert/Hor position visible area on screen (not complete yet)
67
;
67
;
68
;   MAXF - ...
68
;   MAXF - ...
69
MAXF=7
69
MAXF=7
70
 
70
 
71
;-------Main Manager-------------
71
;-------Main Manager-------------
72
    pushad
72
    pushad
73
    cmp ebx,1
73
    cmp ebx,1
74
    jb mdvm_00
74
    jb mdvm_00
75
    cmp ebx,MAXF
75
    cmp ebx,MAXF
76
    ja mdvm_00
76
    ja mdvm_00
77
    call dword [mdvm_func_table+ebx*4]
77
    call dword [mdvm_func_table+ebx*4]
78
    mov [esp+28],eax
78
    mov [esp+28],eax
79
    mov [esp+24],ecx
79
    mov [esp+24],ecx
80
    mov [esp+20],edx
80
    mov [esp+20],edx
81
    mov [esp+16],ebx
81
    mov [esp+16],ebx
82
    popad
82
    popad
83
    retn
83
    retn
84
mdvm_00:
84
mdvm_00:
85
    popad
85
    popad
86
    xor eax,eax
86
    xor eax,eax
87
    dec eax
87
    dec eax
88
    retn
88
    retn
89
 
89
 
90
; ------Drivers Functions----------
90
; ------Drivers Functions----------
91
 
91
 
92
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
92
; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set
93
;
93
;
94
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
94
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
95
; OUT:
95
; OUT:
96
;
96
;
97
func vm_info_init
97
func vm_info_init
98
begin
98
begin
99
      push ecx
99
      push ecx
100
      cmp [mdrvm],dword 0
100
      cmp [mdrvm],dword 0
101
      jnz .vmii_00
101
      jnz .vmii_00
102
      call vm_safe_reg
102
      call vm_safe_reg
103
      call vm_get_initial_videomode
103
      call vm_get_initial_videomode
104
      mov eax,[initvm]
104
      mov eax,[initvm]
105
      mov [currvm],eax
105
      mov [currvm],eax
106
;     call vm_search_sys_func_table
106
;     call vm_search_sys_func_table
107
      call vm_get_cur_vert_rate
107
      call vm_get_cur_vert_rate
108
      mov [initrr],eax
108
      mov [initrr],eax
109
      call vm_calc_pixelclock
109
      call vm_calc_pixelclock
110
      call vm_calc_refrate
110
      call vm_calc_refrate
111
      inc [mdrvm]
111
      inc [mdrvm]
112
.vmii_00:
112
.vmii_00:
113
      pop ecx
113
      pop ecx
114
      call vm_transfer_drv_info
114
      call vm_transfer_drv_info
115
      mov ebx,dword [refrate]
115
      mov ebx,dword [refrate]
116
      mov eax,dword [mdid]      ;dword [systlb]
116
      mov eax,dword [mdid]	;dword [systlb]
117
      retn
117
      retn
118
endf
118
endf
119
 
119
 
120
; EBX=2 (in applications ECX=2)- Get Current Video Mode
120
; EBX=2 (in applications ECX=2)- Get Current Video Mode
121
;
121
;
122
; OUT: eax = X_screen*65536+Y_screen
122
; OUT: eax = X_screen*65536+Y_screen
123
;      ebx = current vertical rate
123
;      ebx = current vertical rate
124
;      ecx = current video mode (number)
124
;      ecx = current video mode (number)
125
func vm_get_cur_mode
125
func vm_get_cur_mode
126
begin
126
begin
127
      cmp [mdrvm],dword 0
127
      cmp [mdrvm],dword 0
128
      jz .vmgcm_00
128
      jz .vmgcm_00
129
      call vm_get_cur_vert_rate
129
      call vm_get_cur_vert_rate
130
      mov eax,[0FE00h]
130
      mov eax,[0FE00h]
131
      mov ebx,[0FE04h]
131
      mov ebx,[0FE04h]
132
      shl eax,16
132
      shl eax,16
133
      add eax,ebx
133
      add eax,ebx
134
      add eax,00010001h
134
      add eax,00010001h
135
      mov ebx,[refrate]
135
      mov ebx,[refrate]
136
      mov ecx,[currvm]
136
      mov ecx,[currvm]
137
      retn
137
      retn
138
.vmgcm_00:
138
.vmgcm_00:
139
      xor eax,eax
139
      xor eax,eax
140
      dec eax
140
      dec eax
141
      retn
141
      retn
142
endf
142
endf
143
 
143
 
144
; EBX=3 (in applications ECX=3)- Change Video Mode
144
; EBX=3 (in applications ECX=3)- Change Video Mode
145
;
145
;
146
; IN:  ecx = VertRate*65536+VideoMode
146
; IN:  ecx = VertRate*65536+VideoMode
147
; OUT: eax = 0 if no error
147
; OUT: eax = 0 if no error
148
;
148
;
149
func vm_set_video_mode
149
func vm_set_video_mode
150
begin
150
begin
151
      cmp [mdrvm],dword 0
151
      cmp [mdrvm],dword 0
152
      jz .vmsvm_00
152
      jz .vmsvm_00
153
      call vm_set_selected_mode
153
      call vm_set_selected_mode
154
;      xor eax,eax
154
;      xor eax,eax
155
      retn
155
      retn
156
.vmsvm_00:
156
.vmsvm_00:
157
      xor eax,eax
157
      xor eax,eax
158
      dec eax
158
      dec eax
159
      retn
159
      retn
160
endf
160
endf
161
 
161
 
162
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
162
; EBX=4 (in applications ECX=4)- Return at Start System Video Mode
163
;
163
;
164
; IN:
164
; IN:
165
; OUT: eax = = 0 if no error
165
; OUT: eax = = 0 if no error
166
;
166
;
167
func vm_restore_init_video_mode
167
func vm_restore_init_video_mode
168
begin
168
begin
169
      cmp [mdrvm],dword 0
169
      cmp [mdrvm],dword 0
170
      jz .vmrivm_00
170
      jz .vmrivm_00
171
      call vm_restore_reg
171
      call vm_restore_reg
172
      xor eax,eax
172
      xor eax,eax
173
      retn
173
      retn
174
.vmrivm_00:
174
.vmrivm_00:
175
      xor eax,eax
175
      xor eax,eax
176
      dec eax
176
      dec eax
177
      retn
177
      retn
178
endf
178
endf
179
 
179
 
180
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
180
; EBX=5 (in applications ECX=5)- Change vertical and horizontal size
181
;                                 of visible screen area
181
;                                 of visible screen area
182
; IN:  ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
182
; IN:  ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position
183
;                        = 2/3 - -/+ vertical size on 1 position (8 pixels)
183
;                        = 2/3 - -/+ vertical size on 1 position (8 pixels)
184
;                          ^-^----- not complete yet
184
;                          ^-^----- not complete yet
185
; OUT: eax = = 0 if no error
185
; OUT: eax = = 0 if no error
186
;
186
;
187
func vm_change_screen_size
187
func vm_change_screen_size
188
begin
188
begin
189
      cmp [mdrvm],dword 0
189
      cmp [mdrvm],dword 0
190
      jz .vmcss_00
190
      jz .vmcss_00
191
      cmp cl,1
191
      cmp cl,1
192
      ja .vmcss_01
192
      ja .vmcss_01
193
      mov eax,ecx
193
      mov eax,ecx
194
      call vm_inc_dec_width
194
      call vm_inc_dec_width
195
      xor eax,eax
195
      xor eax,eax
196
      retn
196
      retn
197
.vmcss_01:
197
.vmcss_01:
198
      and ecx,01h
198
      and ecx,01h
199
      mov eax,ecx
199
      mov eax,ecx
200
;     call vm_inc_dec_high   ; not complete yet
200
;     call vm_inc_dec_high   ; not complete yet
201
      xor eax,eax
201
      xor eax,eax
202
      retn
202
      retn
203
.vmcss_00:
203
.vmcss_00:
204
      xor eax,eax
204
      xor eax,eax
205
      dec eax
205
      dec eax
206
      retn
206
      retn
207
endf
207
endf
208
 
208
 
209
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
209
; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen
210
;
210
;
211
; IN:  ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
211
; IN:  ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point
212
;                        = 2/3 - -/+ vertical position on 1 pixel
212
;                        = 2/3 - -/+ vertical position on 1 pixel
213
;                          ^-^----- not complete yet
213
;                          ^-^----- not complete yet
214
; OUT: eax = 0 if no error
214
; OUT: eax = 0 if no error
215
;
215
;
216
func vm_change_position_screen
216
func vm_change_position_screen
217
begin
217
begin
218
      cmp [mdrvm],dword 0
218
      cmp [mdrvm],dword 0
219
      jz .vmcps_00
219
      jz .vmcps_00
220
  ; ...
220
  ; ...
221
      xor eax,eax
221
      xor eax,eax
222
      retn
222
      retn
223
.vmcps_00:
223
.vmcps_00:
224
      xor eax,eax
224
      xor eax,eax
225
      dec eax
225
      dec eax
226
      retn
226
      retn
227
endf
227
endf
228
 
228
 
229
;-----Drivers Subfunctions---------
229
;-----Drivers Subfunctions---------
230
 
230
 
231
;
231
;
232
; Searching i40 system functions pointer table in kernel area location
232
; Searching i40 system functions pointer table in kernel area location
233
;
233
;
234
func vm_search_sys_func_table
234
func vm_search_sys_func_table
235
begin
235
begin
236
      push eax     ; eax - current value
236
      push eax	   ; eax - current value
237
      push ecx     ; ecx - will be counter of equevalent value
237
      push ecx	   ; ecx - will be counter of equevalent value
238
      push edx     ; edx - last value
238
      push edx	   ; edx - last value
239
      push esi     ; esi - current address
239
      push esi	   ; esi - current address
240
      xor ecx,ecx
240
      xor ecx,ecx
241
      mov esi,010000h            ; Start address of kernel location
241
      mov esi,010000h		 ; Start address of kernel location
242
      lodsd
242
      lodsd
243
      mov edx,eax
243
      mov edx,eax
244
      cld
244
      cld
245
.vmssft_00:
245
.vmssft_00:
246
      cmp esi,30000h
246
      cmp esi,30000h
247
      ja .vmssft_03
247
      ja .vmssft_03
248
      inc ecx
248
      inc ecx
249
      lodsd
249
      lodsd
250
      cmp edx,eax
250
      cmp edx,eax
251
      mov edx,eax
251
      mov edx,eax
252
      je .vmssft_00
252
      je .vmssft_00
253
      cmp ecx,128
253
      cmp ecx,128
254
      ja .vmssft_02
254
      ja .vmssft_02
255
.vmssft_01:
255
.vmssft_01:
256
      xor ecx,ecx
256
      xor ecx,ecx
257
      jmp .vmssft_00
257
      jmp .vmssft_00
258
.vmssft_02:
258
.vmssft_02:
259
      cmp edx,0
259
      cmp edx,0
260
      je .vmssft_01
260
      je .vmssft_01
261
      sub esi,256*4-1
261
      sub esi,256*4-1
262
      mov [systlb],esi
262
      mov [systlb],esi
263
      xor ecx,ecx
263
      xor ecx,ecx
264
.vmssft_03_0:
264
.vmssft_03_0:
265
      inc ecx
265
      inc ecx
266
      lodsd
266
      lodsd
267
      cmp edx,eax
267
      cmp edx,eax
268
      mov edx,eax
268
      mov edx,eax
269
      jne .vmssft_03_0
269
      jne .vmssft_03_0
270
      mov esi,dword [systlb]
270
      mov esi,dword [systlb]
271
      cmp cx,60
271
      cmp cx,60
272
      jae .vmssft_03
272
      jae .vmssft_03
273
      add esi,256*4-4
273
      add esi,256*4-4
274
      lodsb
274
      lodsb
275
      mov edx,eax
275
      mov edx,eax
276
      jmp .vmssft_01
276
      jmp .vmssft_01
277
.vmssft_03:
277
.vmssft_03:
278
      mov [systlb],esi
278
      mov [systlb],esi
279
      pop esi
279
      pop esi
280
      pop edx
280
      pop edx
281
      pop ecx
281
      pop ecx
282
      pop eax
282
      pop eax
283
      retn
283
      retn
284
endf
284
endf
285
 
285
 
286
; IN:
286
; IN:
287
; OUT: eax= vertical rate in Hz
287
; OUT: eax= vertical rate in Hz
288
func vm_get_cur_vert_rate
288
func vm_get_cur_vert_rate
289
begin
289
begin
290
      push edx
290
      push edx
291
      push ebx
291
      push ebx
292
      xor eax,eax
292
      xor eax,eax
293
      mov edx,eax
293
      mov edx,eax
294
      mov ebx,eax
294
      mov ebx,eax
295
      mov dx,03DAh
295
      mov dx,03DAh
296
.vmgcvt_00:
296
.vmgcvt_00:
297
      in al,dx
297
      in al,dx
298
      test al,8
298
      test al,8
299
      jz .vmgcvt_00
299
      jz .vmgcvt_00
300
.vmgcvt_01:
300
.vmgcvt_01:
301
      in al,dx
301
      in al,dx
302
      test al,8
302
      test al,8
303
      jnz .vmgcvt_01
303
      jnz .vmgcvt_01
304
      mov ebx,edx
304
      mov ebx,edx
305
      rdtsc
305
      rdtsc
306
      mov edx,ebx
306
      mov edx,ebx
307
      mov ebx,eax
307
      mov ebx,eax
308
.vmgcvt_02:
308
.vmgcvt_02:
309
      in al,dx
309
      in al,dx
310
      test al,8
310
      test al,8
311
      jz .vmgcvt_02
311
      jz .vmgcvt_02
312
.vmgcvt_03:
312
.vmgcvt_03:
313
      in al,dx
313
      in al,dx
314
      test al,8
314
      test al,8
315
      jnz .vmgcvt_03
315
      jnz .vmgcvt_03
316
      rdtsc
316
      rdtsc
317
      sub eax,ebx
317
      sub eax,ebx
318
      mov ebx,eax
318
      mov ebx,eax
319
      mov eax,[0F600h]
319
      mov eax,[0F600h]
320
      xor edx,edx
320
      xor edx,edx
321
      div ebx
321
      div ebx
322
      inc eax
322
      inc eax
323
      mov [refrate],eax
323
      mov [refrate],eax
324
      pop ebx
324
      pop ebx
325
      pop edx
325
      pop edx
326
      retn
326
      retn
327
endf
327
endf
328
 
328
 
329
func vm_calc_pixelclock
329
func vm_calc_pixelclock
330
begin
330
begin
331
        push ebx
331
	push ebx
332
        push edx
332
	push edx
333
        xor eax,eax
333
	xor eax,eax
334
        mov al,[_00]
334
	mov al,[_00]
335
        add ax,5
335
	add ax,5
336
        shl eax,3
336
	shl eax,3
337
        xor ebx,ebx
337
	xor ebx,ebx
338
        mov bl,[_06]
338
	mov bl,[_06]
339
        mov bh,[_07]
339
	mov bh,[_07]
340
        and bh,00100001b
340
	and bh,00100001b
341
        btr bx,13
341
	btr bx,13
342
        jnc .vmcpc_00
342
	jnc .vmcpc_00
343
        or bh,2
343
	or bh,2
344
.vmcpc_00:
344
.vmcpc_00:
345
        xor edx,edx
345
	xor edx,edx
346
        mul ebx
346
	mul ebx
347
        xor edx,edx
347
	xor edx,edx
348
        mul [initrr]
348
	mul [initrr]
349
        mov [pclock],eax
349
	mov [pclock],eax
350
        pop edx
350
	pop edx
351
        pop ebx
351
	pop ebx
352
        retn
352
	retn
353
endf
353
endf
354
 
354
 
355
;
355
;
356
; Safe of initial CRTC state
356
; Safe of initial CRTC state
357
;
357
;
358
func vm_safe_reg
358
func vm_safe_reg
359
begin
359
begin
360
    push edx
360
    push edx
361
    push ebx
361
    push ebx
362
    push ecx
362
    push ecx
363
    push edi
363
    push edi
364
    cli
364
    cli
365
    mov dx,3d4h  ; CRTC
365
    mov dx,3d4h  ; CRTC
366
    mov al,11h
366
    mov al,11h
367
    out dx,al
367
    out dx,al
368
    inc dx
368
    inc dx
369
    in al,dx
369
    in al,dx
370
    and al,7fh
370
    and al,7fh
371
    out dx,al    ; Clear protection bit
371
    out dx,al	 ; Clear protection bit
372
    dec dx
372
    dec dx
373
    xor ecx,ecx
373
    xor ecx,ecx
374
    mov cl,19h
374
    mov cl,19h
375
    xor bl,bl
375
    xor bl,bl
376
    mov edi,CRTCreg
376
    mov edi,CRTCreg
377
.vmsr_00:
377
.vmsr_00:
378
    mov al,bl
378
    mov al,bl
379
    out dx,al
379
    out dx,al
380
    inc dx
380
    inc dx
381
    in al,dx
381
    in al,dx
382
    dec dx
382
    dec dx
383
    stosb
383
    stosb
384
    inc bl
384
    inc bl
385
    loop .vmsr_00
385
    loop .vmsr_00
386
    sti
386
    sti
387
    pop edi
387
    pop edi
388
    pop ecx
388
    pop ecx
389
    pop ebx
389
    pop ebx
390
    pop edx
390
    pop edx
391
    retn
391
    retn
392
endf
392
endf
393
 
393
 
394
;
394
;
395
; Restore of initial CRTC state
395
; Restore of initial CRTC state
396
;
396
;
397
func vm_restore_reg
397
func vm_restore_reg
398
begin
398
begin
399
    push eax
399
    push eax
400
    push ebx
400
    push ebx
401
    push edx
401
    push edx
402
    push esi
402
    push esi
403
    mov eax,[oldX]
403
    mov eax,[oldX]
404
    mov [0FE00h],eax
404
    mov [0FE00h],eax
405
    mov eax,[oldY]
405
    mov eax,[oldY]
406
    mov [0FE04h],eax
406
    mov [0FE04h],eax
407
    mov dx,03dah
407
    mov dx,03dah
408
.vmrr_00:
408
.vmrr_00:
409
    in al,dx
409
    in al,dx
410
    test al,8
410
    test al,8
411
    jnz .vmrr_00
411
    jnz .vmrr_00
412
.vmrr_01:
412
.vmrr_01:
413
    in al,dx
413
    in al,dx
414
    test al,8
414
    test al,8
415
    jnz .vmrr_01
415
    jnz .vmrr_01
416
    cli
416
    cli
417
    mov dx,03c4h
417
    mov dx,03c4h
418
    mov ax,0101h
418
    mov ax,0101h
419
    out dx,ax
419
    out dx,ax
420
    mov dx,3d4h  ; CRTC
420
    mov dx,3d4h  ; CRTC
421
    mov al,11h
421
    mov al,11h
422
    out dx,al
422
    out dx,al
423
    inc dx
423
    inc dx
424
    in al,dx
424
    in al,dx
425
    and al,7fh  ; Clear Protection bit
425
    and al,7fh	; Clear Protection bit
426
    out dx,al
426
    out dx,al
427
    dec dx
427
    dec dx
428
    xor ecx,ecx
428
    xor ecx,ecx
429
    mov cl,19h
429
    mov cl,19h
430
    mov esi,CRTCreg
430
    mov esi,CRTCreg
431
    xor bl,bl
431
    xor bl,bl
432
.vmrr_02:
432
.vmrr_02:
433
    lodsb
433
    lodsb
434
    mov ah,al
434
    mov ah,al
435
    mov al,bl
435
    mov al,bl
436
    out dx,ax
436
    out dx,ax
437
    inc bl
437
    inc bl
438
    loop .vmrr_02
438
    loop .vmrr_02
439
    sti
439
    sti
440
;    call ref_screen
440
;    call ref_screen
441
    pop esi
441
    pop esi
442
    pop edx
442
    pop edx
443
    pop ecx
443
    pop ecx
444
    pop eax
444
    pop eax
445
    retn
445
    retn
446
endf
446
endf
447
 
447
 
448
; Calculate of possible vertical refrash rate
448
; Calculate of possible vertical refrash rate
449
;  (light version of function)
449
;  (light version of function)
450
func vm_calc_refrate
450
func vm_calc_refrate
451
begin
451
begin
452
        push ebx
452
	push ebx
453
        push ecx
453
	push ecx
454
        push edx
454
	push edx
455
        push edi
455
	push edi
456
        push esi
456
	push esi
457
        mov eax,[pclock]
457
	mov eax,[pclock]
458
        xor edx,edx
458
	xor edx,edx
459
        mov edi,_m1
459
	mov edi,_m1
460
        mov ebx,eax
460
	mov ebx,eax
461
        mov ecx,(1696*1065)
461
	mov ecx,(1696*1065)
462
        div ecx
462
	div ecx
463
        xor edx,edx
463
	xor edx,edx
464
        stosw
464
	stosw
465
        add edi,8
465
	add edi,8
466
        mov eax,ebx
466
	mov eax,ebx
467
        mov ecx,(1344*804)
467
	mov ecx,(1344*804)
468
        div ecx
468
	div ecx
469
        xor edx,edx
469
	xor edx,edx
470
        stosw
470
	stosw
471
        add edi,8
471
	add edi,8
472
        mov eax,ebx
472
	mov eax,ebx
473
        mov ecx,(1056*636)
473
	mov ecx,(1056*636)
474
        div ecx
474
	div ecx
475
        xor edx,edx
475
	xor edx,edx
476
        stosw
476
	stosw
477
        add edi,8
477
	add edi,8
478
        mov eax,ebx
478
	mov eax,ebx
479
        mov ecx,(800*524)
479
	mov ecx,(800*524)
480
        div ecx
480
	div ecx
481
        xor edx,edx
481
	xor edx,edx
482
        stosw
482
	stosw
483
        mov edi,_m1
483
	mov edi,_m1
484
        mov esi,edi
484
	mov esi,edi
485
        mov ecx,5*4
485
	mov ecx,5*4
486
.vmcrr_00:
486
.vmcrr_00:
487
        lodsw
487
	lodsw
488
        cmp ax,55
488
	cmp ax,55
489
        jb .vmcrr_01
489
	jb .vmcrr_01
490
        stosw
490
	stosw
491
        loop .vmcrr_00
491
	loop .vmcrr_00
492
        pop esi
492
	pop esi
493
        pop edi
493
	pop edi
494
        pop edx
494
	pop edx
495
        pop ecx
495
	pop ecx
496
        pop ebx
496
	pop ebx
497
        retn
497
	retn
498
.vmcrr_01:
498
.vmcrr_01:
499
        xor ax,ax
499
	xor ax,ax
500
        stosw
500
	stosw
501
        loop .vmcrr_00
501
	loop .vmcrr_00
502
        pop esi
502
	pop esi
503
        pop edi
503
	pop edi
504
        pop edx
504
	pop edx
505
        pop ecx
505
	pop ecx
506
        pop ebx
506
	pop ebx
507
        retn
507
	retn
508
endf
508
endf
509
 
509
 
510
func vm_get_initial_videomode
510
func vm_get_initial_videomode
511
begin
511
begin
512
    push eax
512
    push eax
513
    mov eax,dword [0FE00h]
513
    mov eax,dword [0FE00h]
514
    mov [oldX],eax
514
    mov [oldX],eax
515
    mov eax,dword [0FE04h]
515
    mov eax,dword [0FE04h]
516
    mov [oldY],eax
516
    mov [oldY],eax
517
    mov eax,dword [0FE0Ch] ; initial video mode
517
    mov eax,dword [0FE0Ch] ; initial video mode
518
    and ax,01FFh
518
    and ax,01FFh
519
    mov dword [initvm],eax
519
    mov dword [initvm],eax
520
    pop eax
520
    pop eax
521
    retn
521
    retn
522
endf
522
endf
523
 
523
 
524
; IN: eax = 0/1  -  -/+ 1 position of width
524
; IN: eax = 0/1  -  -/+ 1 position of width
525
func vm_inc_dec_width
525
func vm_inc_dec_width
526
begin
526
begin
527
    push ebx
527
    push ebx
528
    push edx
528
    push edx
529
    mov ebx,eax
529
    mov ebx,eax
530
    mov dx,3d4h  ; CRTC
530
    mov dx,3d4h  ; CRTC
531
    mov al,11h
531
    mov al,11h
532
    out dx,al
532
    out dx,al
533
    inc dx
533
    inc dx
534
    in al,dx
534
    in al,dx
535
    and al,7fh  ; Clear Protection bit
535
    and al,7fh	; Clear Protection bit
536
    out dx,al
536
    out dx,al
537
    dec dx
537
    dec dx
538
    xor al,al
538
    xor al,al
539
    out dx,al
539
    out dx,al
540
    inc dx
540
    inc dx
541
    in al,dx
541
    in al,dx
542
    dec al
542
    dec al
543
    cmp bl,0
543
    cmp bl,0
544
    jnz .vmidr_00
544
    jnz .vmidr_00
545
    inc al
545
    inc al
546
    inc al
546
    inc al
547
.vmidr_00:
547
.vmidr_00:
548
    out dx,al
548
    out dx,al
549
    pop edx
549
    pop edx
550
    pop ebx
550
    pop ebx
551
    retn
551
    retn
552
endf
552
endf
553
 
553
 
554
;
554
;
555
; Copy driver info to application area
555
; Copy driver info to application area
556
;
556
;
557
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
557
; IN: ecx (in app. edx) - pointer to 512-bytes info area in application
558
; OUT:
558
; OUT:
559
func vm_transfer_drv_info
559
func vm_transfer_drv_info
560
begin
560
begin
561
        push ecx
561
	push ecx
562
        push edi
562
	push edi
563
        push esi
563
	push esi
564
        mov eax,ecx
564
	mov eax,ecx
565
        xor ecx,ecx
565
	xor ecx,ecx
566
        mov cl,32/4
566
	mov cl,32/4
567
        mov esi,mdname
567
	mov esi,mdname
568
        mov edi,drvname
568
	mov edi,drvname
569
        rep movsd
569
	rep movsd
570
        mov ecx,eax
570
	mov ecx,eax
571
        mov eax,[mdver]
571
	mov eax,[mdver]
572
        mov [drvver],eax
572
	mov [drvver],eax
573
        mov edi,[3010h]
573
	mov edi,[3010h]
574
        mov edi,[edi+10h]
574
	mov edi,[edi+10h]
575
        add edi,ecx
575
	add edi,ecx
576
        mov esi,drvinfo
576
	mov esi,drvinfo
577
        xor ecx,ecx
577
	xor ecx,ecx
578
        mov cx,512
578
	mov cx,512
579
        rep movsb
579
	rep movsb
580
        pop esi
580
	pop esi
581
        pop edi
581
	pop edi
582
        pop ecx
582
	pop ecx
583
        retn
583
	retn
584
endf
584
endf
585
 
585
 
586
;
586
;
587
; Set selected video mode
587
; Set selected video mode
588
; (light version)
588
; (light version)
589
;
589
;
590
; IN: ecx = VertRate*65536+VideoMode
590
; IN: ecx = VertRate*65536+VideoMode
591
;
591
;
592
func vm_set_selected_mode
592
func vm_set_selected_mode
593
begin
593
begin
594
    push edx
594
    push edx
595
    push ecx
595
    push ecx
596
    push esi
596
    push esi
597
    ror ecx,16
597
    ror ecx,16
598
    cmp cx,00h
598
    cmp cx,00h
599
    je .vmssm_03
599
    je .vmssm_03
600
    rol ecx,16
600
    rol ecx,16
601
    mov eax,ecx
601
    mov eax,ecx
602
    shl eax,16
602
    shl eax,16
603
    shr eax,16
603
    shr eax,16
604
    mov [currvm],eax
604
    mov [currvm],eax
605
    cmp cx,112h
605
    cmp cx,112h
606
    jne .vmssm_00
606
    jne .vmssm_00
607
    mov esi,mode0
607
    mov esi,mode0
608
    mov ecx,639
608
    mov ecx,639
609
    mov edx,479
609
    mov edx,479
610
    jmp .vmssm_st00
610
    jmp .vmssm_st00
611
.vmssm_00:
611
.vmssm_00:
612
    cmp cx,115h
612
    cmp cx,115h
613
    jne .vmssm_01
613
    jne .vmssm_01
614
    mov esi,mode1
614
    mov esi,mode1
615
    mov ecx,799
615
    mov ecx,799
616
    mov edx,599
616
    mov edx,599
617
    jmp .vmssm_st00
617
    jmp .vmssm_st00
618
.vmssm_01:
618
.vmssm_01:
619
    cmp cx,118h
619
    cmp cx,118h
620
    jne .vmssm_02
620
    jne .vmssm_02
621
    mov esi,mode2
621
    mov esi,mode2
622
    mov ecx,1023
622
    mov ecx,1023
623
    mov edx,767
623
    mov edx,767
624
    jmp .vmssm_st00
624
    jmp .vmssm_st00
625
.vmssm_02:
625
.vmssm_02:
626
    cmp cx,11Bh
626
    cmp cx,11Bh
627
    jne .vmssm_03
627
    jne .vmssm_03
628
    mov esi,mode2
628
    mov esi,mode2
629
    mov ecx,1279
629
    mov ecx,1279
630
    mov edx,1023
630
    mov edx,1023
631
    jmp .vmssm_st00
631
    jmp .vmssm_st00
632
.vmssm_03:
632
.vmssm_03:
633
    xor eax,eax
633
    xor eax,eax
634
    dec eax
634
    dec eax
635
    pop esi
635
    pop esi
636
    pop ecx
636
    pop ecx
637
    pop edx
637
    pop edx
638
    retn
638
    retn
639
.vmssm_st00:
639
.vmssm_st00:
640
    mov [0FE00h],ecx
640
    mov [0FE00h],ecx
641
    mov [0FE04h],edx
641
    mov [0FE04h],edx
642
    cli
642
    cli
643
    mov dx,03c4h
643
    mov dx,03c4h
644
    lodsw
644
    lodsw
645
    out dx,ax
645
    out dx,ax
646
    mov dx,03d4h
646
    mov dx,03d4h
647
    mov al,11h
647
    mov al,11h
648
    out dx,al
648
    out dx,al
649
    inc dx
649
    inc dx
650
    in al,dx
650
    in al,dx
651
    and al,7fh
651
    and al,7fh
652
    out dx,al
652
    out dx,al
653
    dec dx
653
    dec dx
654
    mov ecx,13
654
    mov ecx,13
655
.vmssm_st01:
655
.vmssm_st01:
656
    lodsw
656
    lodsw
657
    out dx,ax
657
    out dx,ax
658
    loop .vmssm_st01
658
    loop .vmssm_st01
659
    sti
659
    sti
660
    xor eax,eax
660
    xor eax,eax
661
    pop esi
661
    pop esi
662
    pop ecx
662
    pop ecx
663
    pop edx
663
    pop edx
664
    retn
664
    retn
665
endf
665
endf
666
 
666
 
667
;-[ mike.dld ]- begin ---------------
667
;-[ mike.dld ]- begin ---------------
668
 
668
 
669
include 'normal.asm'
669
include 'normal.asm'
670
 
670
 
671
;-[ mike.dld ]- end -----------------
671
;-[ mike.dld ]- end -----------------
672
 
672
 
673
;------------DATA AREA---------------
673
;------------DATA AREA---------------
674
 
674
 
675
align 4
675
align 4
676
 
676
 
677
mdvm_func_table:
677
mdvm_func_table:
678
        dd MDSTART
678
	dd MDSTART
679
        dd vm_info_init,          vm_get_cur_mode
679
	dd vm_info_init,	  vm_get_cur_mode
680
        dd vm_set_video_mode,     vm_restore_init_video_mode
680
	dd vm_set_video_mode,	  vm_restore_init_video_mode
681
        dd vm_change_screen_size ;vm_change_position_screen
681
	dd vm_change_screen_size ;vm_change_position_screen
682
 
682
 
683
;-[ mike.dld ]- begin ---------------
683
;-[ mike.dld ]- begin ---------------
684
 
684
 
685
        dd vm_mike_init
685
	dd vm_mike_init
686
;       dd vm_mike_cursor_pos
686
;       dd vm_mike_cursor_pos
687
        dd vm_mike_uninit
687
	dd vm_mike_uninit
688
 
688
 
689
;-[ mike.dld ]- end -----------------
689
;-[ mike.dld ]- end -----------------
690
 
690
 
691
;1280x1024 - 11Bh
691
;1280x1024 - 11Bh
692
mode3:
692
mode3:
693
      dw 0101h
693
      dw 0101h
694
      dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
694
      dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h
695
      dw 0110h,8411h,0ff12h,0ff15h,2916h
695
      dw 0110h,8411h,0ff12h,0ff15h,2916h
696
 
696
 
697
;1024x768 - 118h
697
;1024x768 - 118h
698
mode2:
698
mode2:
699
      dw 0101h
699
      dw 0101h
700
      dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
700
      dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h
701
      dw 0310h,8911h,0ff12h,0ff15h,2516h
701
      dw 0310h,8911h,0ff12h,0ff15h,2516h
702
 
702
 
703
;800x600  - 115h
703
;800x600  - 115h
704
mode1:
704
mode1:
705
      dw 0101h
705
      dw 0101h
706
      dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
706
      dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h
707
      dw 5910h,8d11h,5712h,5715h,7316h
707
      dw 5910h,8d11h,5712h,5715h,7316h
708
 
708
 
709
;640x480 - 112h, 12h
709
;640x480 - 112h, 12h
710
mode0:
710
mode0:
711
      dw 0101h
711
      dw 0101h
712
      dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
712
      dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h
713
      dw 0ea10h,8c11h,0df12h,0df15h,0c16h
713
      dw 0ea10h,8c11h,0df12h,0df15h,0c16h
714
 
714
 
715
; 640x400
715
; 640x400
716
;mymode0:
716
;mymode0:
717
; dw 0101h
717
; dw 0101h
718
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
718
;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h
719
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
719
; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h
720
 
720
 
721
; 640x800
721
; 640x800
722
;mymode1:
722
;mymode1:
723
; dw 0101h
723
; dw 0101h
724
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
724
; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h
725
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
725
; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h
726
 
726
 
727
align 4
727
align 4
728
 
728
 
729
;-[ mike.dld ]- begin ---------------
729
;-[ mike.dld ]- begin ---------------
730
;oldX      dd ?
730
;oldX      dd ?
731
;oldY      dd ?
731
;oldY      dd ?
732
;initvm    dd ?
732
;initvm    dd ?
733
currvm     dd 0
733
currvm	   dd 0
734
refrate    dd 0
734
refrate    dd 0
735
initrr     dd 0
735
initrr	   dd 0
736
systlb     dd 0
736
systlb	   dd 0
737
;pclock    dd ?
737
;pclock    dd ?
738
mdrvm      dd 0 ; 0 - not drv init yet, 1 - already drv init
738
mdrvm	   dd 0 ; 0 - not drv init yet, 1 - already drv init
739
;-[ mike.dld ]- end -----------------
739
;-[ mike.dld ]- end -----------------
740
 
740
 
741
 
741
 
742
drvinfo:
742
drvinfo:
743
drvname:   times 32 db ' '
743
drvname:   times 32 db ' '
744
drvver     dd 0
744
drvver	   dd 0
745
           times (32-($-drvver))/4 dd 0
745
	   times (32-($-drvver))/4 dd 0
746
drvmode    dw 011Bh,0118h,0115h,0112h
746
drvmode    dw 011Bh,0118h,0115h,0112h
747
           times (64-($-drvmode))/2 dw 00h
747
	   times (64-($-drvmode))/2 dw 00h
748
_m1        dw 0,0,0,0,0
748
_m1	   dw 0,0,0,0,0
749
_m2        dw 0,0,0,0,0
749
_m2	   dw 0,0,0,0,0
750
_m3        dw 0,0,0,0,0
750
_m3	   dw 0,0,0,0,0
751
_m4        dw 0,0,0,0,0
751
_m4	   dw 0,0,0,0,0
752
_m5        dw 0,0,0,0,0
752
_m5	   dw 0,0,0,0,0
753
           times (512-($-drvinfo)) db 0
753
	   times (512-($-drvinfo)) db 0
754
drvinfoend:
754
drvinfoend:
755
 
755
 
756
;-[ mike.dld ]- begin ---------------
756
;-[ mike.dld ]- begin ---------------
757
 
757
 
758
align 4
758
align 4
759
include_debug_strings
759
include_debug_strings
760
 
760
 
761
;-[ mike.dld ]- end -----------------
761
;-[ mike.dld ]- end -----------------
762
 
762
 
763
DRVM_END:
763
DRVM_END:
764
 
764
 
765
align 4
765
align 4
766
 
766
 
767
;-[ mike.dld ]- begin ---------------
767
;-[ mike.dld ]- begin ---------------
768
oldX       dd ?
768
oldX	   dd ?
769
oldY       dd ?
769
oldY	   dd ?
770
initvm     dd ?
770
initvm	   dd ?
771
pclock     dd ?
771
pclock	   dd ?
772
;-[ mike.dld ]- end -----------------
772
;-[ mike.dld ]- end -----------------
773
 
773
 
774
CRTCreg:
774
CRTCreg:
775
_00  db ?
775
_00  db ?
776
_01  db ?
776
_01  db ?
777
_02  db ?
777
_02  db ?
778
_03  db ?
778
_03  db ?
779
_04  db ?
779
_04  db ?
780
_05  db ?
780
_05  db ?
781
_06  db ?
781
_06  db ?
782
_07  db ?
782
_07  db ?
783
_08  db ?
783
_08  db ?
784
_09  db ?
784
_09  db ?
785
_0a  db ?
785
_0a  db ?
786
_0b  db ?
786
_0b  db ?
787
_0c  db ?
787
_0c  db ?
788
_0d  db ?
788
_0d  db ?
789
_0e  db ?
789
_0e  db ?
790
_0f  db ?
790
_0f  db ?
791
_10  db ?
791
_10  db ?
792
_11  db ?
792
_11  db ?
793
_12  db ?
793
_12  db ?
794
_13  db ?
794
_13  db ?
795
_14  db ?
795
_14  db ?
796
_15  db ?
796
_15  db ?
797
_16  db ?
797
_16  db ?
798
_17  db ?
798
_17  db ?
799
_18  db ?
799
_18  db ?
800
_19  db ?
800
_19  db ?
801
 
801
 
802
;-[ mike.dld ]- begin ---------------
802
;-[ mike.dld ]- begin ---------------
803
 
-
 
804
align 4
-
 
805
 x_res  fix 0x0000FE00 ;  dd ?
-
 
806
 y_res  fix 0x0000FE04 ;  dd ?
-
 
807
 
803
 
808
 cnt      dd ?
804
 cnt	  dd ?
809
align 16
805
align 16
810
 tr       RECT
806
 tr	  RECT
811
 rct      RECT
807
 rct	  RECT
812
;rb       40*sizeof.RECT
808
;rb       40*sizeof.RECT
813
 
809
 
814
;-[ mike.dld ]- end -----------------
810
;-[ mike.dld ]- end -----------------