COME ON!!! There must be a vertical retrace interrupt in the VGA!!!!

Come on guys!!! whats going on!!! I have been searching for information about how to handle the interrupt that VGA makes when it goes to vertical retrace.

The only thing I can find, again and again is the odd routine that reads port 3DAh of the VGA card.
----------Code start -------------
label
l1, l2;
asm
mov dx,3DAh
l1:
in al,dx
and al,08h
jnz l1
l2:
in al,dx
and al,08h
jz l2
end;
----------Code end -------------
I don't say it isn't usefull, I think it is great, It can let your program sync with vertical retrace (VBlank) and solve well known graphic problems when you change video buffer at random time.

BUT WHAT ABOUT USING A VGA VBLANK INTERRUPT!?!!?!?!?
I DON'T WANT TO WASTE MY CPU SCANNING AGAIN AND AGAIN THAT PORT!!!

I think that VGA MUST run some interrupt when it goes to vertical retrace!!!

It is a must!!!

Even the Nintendo Entertainment Systes (NES) have both, a port scaning metod (like the 3DAh port scanning code) and a VBLANK interrupt!, how is posible that VGA don't have it!?!!!?!?!

I give up!! I have been searching for it!!! I can't find how to handle that int!!!

I have been handling IRQ2 and IRQ10, in the same way that you handle int 1ch or int 8 for timing.

I make my program go for a delay (and idle loop) but the ISRoutine I redirect for IRQ2 or IRQ10 never starts!!!

I have a ATI Radeon 7000, it aresources are:
IRQ10
I/O 3B0-3BB, 3C0-3BF
MEM:A0000-AFFFF, B0000-BFFFF,...
as shown in Windows 98 hardware report.

Don't say that VGA card don't have a VBLANK interrupt because I can't believe that.

Maybe I have to program some port of the VGA to say to it start making VBLANK interrupts and then I believe that depending how your card is configured in your system you can handle it on IRQ9(INT #71h, vector address 0000:01C4h) or in IRQ10(INT #72h, vector address 0000:01C8h)
I did that but I neve get an INT 71h or INT 72h from the VGA card :(

What I am doing brong?

Maybe that INT are masked in some way? I have to do something before I can habdle that INTS? maybe I have to program de 8259 PIC (programable interrupt controler) before?

HELP!!!!!

I am studing DOS, real mode, 80286, assembler coding. I can't use Win32 stuff to handle this problem (maybe some VESA hardware register, etc I don't know), I am in DOS, if you know how to handle it in Win32 maybe could be interesting but I want to do it on DOS.

Comments

  • : Come on guys!!! whats going on!!! I have been searching for information about how to handle the interrupt that VGA makes when it goes to vertical retrace.
    :
    : The only thing I can find, again and again is the odd routine that reads port 3DAh of the VGA card.
    : ----------Code start -------------
    : label
    : l1, l2;
    : asm
    : mov dx,3DAh
    : l1:
    : in al,dx
    : and al,08h
    : jnz l1
    : l2:
    : in al,dx
    : and al,08h
    : jz l2
    : end;
    : ----------Code end -------------
    : I don't say it isn't usefull, I think it is great, It can let your program sync with vertical retrace (VBlank) and solve well known graphic problems when you change video buffer at random time.
    :
    : BUT WHAT ABOUT USING A VGA VBLANK INTERRUPT!?!!?!?!?
    : I DON'T WANT TO WASTE MY CPU SCANNING AGAIN AND AGAIN THAT PORT!!!
    :
    : I think that VGA MUST run some interrupt when it goes to vertical retrace!!!
    [green]
    If there is I have never heard of it.
    [/green]
    : It is a must!!!
    :
    : Even the Nintendo Entertainment Systes (NES) have both, a port scaning metod (like the 3DAh port scanning code) and a VBLANK interrupt!, how is posible that VGA don't have it!?!!!?!?!
    :
    : I give up!! I have been searching for it!!! I can't find how to handle that int!!!
    :
    : I have been handling IRQ2 and IRQ10, in the same way that you handle int 1ch or int 8 for timing.
    :
    : I make my program go for a delay (and idle loop) but the ISRoutine I redirect for IRQ2 or IRQ10 never starts!!!
    :
    : I have a ATI Radeon 7000, it aresources are:
    : IRQ10
    : I/O 3B0-3BB, 3C0-3BF
    : MEM:A0000-AFFFF, B0000-BFFFF,...
    : as shown in Windows 98 hardware report.
    :
    : Don't say that VGA card don't have a VBLANK interrupt because I can't believe that.
    :
    : Maybe I have to program some port of the VGA to say to it start making VBLANK interrupts and then I believe that depending how your card is configured in your system you can handle it on IRQ9(INT #71h, vector address 0000:01C4h) or in IRQ10(INT #72h, vector address 0000:01C8h)
    : I did that but I neve get an INT 71h or INT 72h from the VGA card :(
    :
    : What I am doing brong?
    :
    : Maybe that INT are masked in some way? I have to do something before I can habdle that INTS? maybe I have to program de 8259 PIC (programable interrupt controler) before?
    :
    : HELP!!!!!
    :
    : I am studing DOS, real mode, 80286, assembler coding. I can't use Win32 stuff to handle this problem (maybe some VESA hardware register, etc I don't know), I am in DOS, if you know how to handle it in Win32 maybe could be interesting but I want to do it on DOS.
    :
    :
    [green]
    All I can do is recommend a site that has a ton of usefull info on ports, interrupts, embedded chips, and OS info. Sorry I couldn't of been more helpfull than that. :-(

    http://www.clipx.net/norton.php

    [/green]

  • : : Come on guys!!! whats going on!!! I have been searching for information about how to handle the interrupt that VGA makes when it goes to vertical retrace.
    : :
    : : The only thing I can find, again and again is the odd routine that reads port 3DAh of the VGA card.
    : : ----------Code start -------------
    : : label
    : : l1, l2;
    : : asm
    : : mov dx,3DAh
    : : l1:
    : : in al,dx
    : : and al,08h
    : : jnz l1
    : : l2:
    : : in al,dx
    : : and al,08h
    : : jz l2
    : : end;
    : : ----------Code end -------------
    : : I don't say it isn't usefull, I think it is great, It can let your program sync with vertical retrace (VBlank) and solve well known graphic problems when you change video buffer at random time.
    : :
    : : BUT WHAT ABOUT USING A VGA VBLANK INTERRUPT!?!!?!?!?
    : : I DON'T WANT TO WASTE MY CPU SCANNING AGAIN AND AGAIN THAT PORT!!!
    : :
    : : I think that VGA MUST run some interrupt when it goes to vertical retrace!!!
    : [green]
    : If there is I have never heard of it.
    : [/green]
    : : It is a must!!!
    : :
    : : Even the Nintendo Entertainment Systes (NES) have both, a port scaning metod (like the 3DAh port scanning code) and a VBLANK interrupt!, how is posible that VGA don't have it!?!!!?!?!
    : :
    : : I give up!! I have been searching for it!!! I can't find how to handle that int!!!
    : :
    : : I have been handling IRQ2 and IRQ10, in the same way that you handle int 1ch or int 8 for timing.
    : :
    : : I make my program go for a delay (and idle loop) but the ISRoutine I redirect for IRQ2 or IRQ10 never starts!!!
    : :
    : : I have a ATI Radeon 7000, it aresources are:
    : : IRQ10
    : : I/O 3B0-3BB, 3C0-3BF
    : : MEM:A0000-AFFFF, B0000-BFFFF,...
    : : as shown in Windows 98 hardware report.
    : :
    : : Don't say that VGA card don't have a VBLANK interrupt because I can't believe that.
    : :
    : : Maybe I have to program some port of the VGA to say to it start making VBLANK interrupts and then I believe that depending how your card is configured in your system you can handle it on IRQ9(INT #71h, vector address 0000:01C4h) or in IRQ10(INT #72h, vector address 0000:01C8h)
    : : I did that but I neve get an INT 71h or INT 72h from the VGA card :(
    : :
    : : What I am doing brong?
    : :
    : : Maybe that INT are masked in some way? I have to do something before I can habdle that INTS? maybe I have to program de 8259 PIC (programable interrupt controler) before?
    : :
    : : HELP!!!!!
    : :
    : : I am studing DOS, real mode, 80286, assembler coding. I can't use Win32 stuff to handle this problem (maybe some VESA hardware register, etc I don't know), I am in DOS, if you know how to handle it in Win32 maybe could be interesting but I want to do it on DOS.
    : :
    : :
    : [green]
    : All I can do is recommend a site that has a ton of usefull info on ports, interrupts, embedded chips, and OS info. Sorry I couldn't of been more helpfull than that. :-(
    :
    : http://www.clipx.net/norton.php
    :
    : [/green]
    :
    :

    Thanks, this page is great!!! :) has a lot of code for many langueges. thanks a lot shaolin007.
    But I have looking around and I found again that port 3DAh scanning routine to detect vertical retrace!! I hate it!!! :/

    ok, the answer is still there, How we can handle de VGA VBLANK interrupt. Note that in any interrupt table you can see IRQ2 as EGA vertical retrace interrupt!! O god!!! we are near!!! BUT!!!...

    As I know, original IRQ2 (use by old video cards) was used to put another PIC (programable interrupt controler) in newber IBM PCs to have more IRQ lines (we are talking about 286 or later machines) so IRQ2 of the first PIC recibes an interrupt from the second PIC. To make shorter this story, IRQ2 of the first PIC was replaced by the IRQ9 of the second. So if you want to handle original IRQ2, in fact you have to handle IRQ9...

    But it dosen't matter for me, because when I seen my hardware list on Windows 98 I can see my ATI Radeon 7000 video card using only IRQ10

    So, fron now, the only fact is that there os some way to handle IRQ10(IRQ10 = INT #72h (hex) = 0000:01C8h (hex seg:off))
    (in my case is IRQ10, maybe in your PC you have your video card using other IRQ, maybe IRQ9, that comes from the old practice of using IRQ2 for video card VBlank. I think my PCI ATI card uses IRQ10 and not IRQ9 because my mother board has as a (now disabled) integrated AGP card, so the use of IRQ9 must be a common practice that comes from the old EGA cards (see any interrupt table and note IRQ2 INT# 0Ah slave 8259 or EGA/VGA vertical retrace))

    for example take a look at this IBM PC Hardware Interrupt table
    http://members.tripod.com/~oldboard/assembly/int_table.html

    This time I am going to include the program I use to handle any interrupt, you can use it to handle great the interrut INT 1Ch, that is a clock tick hardware interrupt that is called 18.206Hz, in this case this routine handle the INT 1Ch and runs a "new_proc" procedure that prints Hello! 18.206 time every seccond. To see the INT working, this program have a delay loop that makes nothing, If your PC is too fast just increase the value of CX or DX. I was compiled using TASM for DOS.

    ------------- handler.asm, BEGINNING ---------------------------------
    title IRQ2 EGA/VGA Vertical retrace handle
    dosseg
    .286
    .model tiny
    .stack
    .data
    old_proc dd ?
    string db "Hello!$"
    .code
    int_to_handle equ 1Ch ; <--- HERE! you set the interrupt you want
    ; to handle
    vector_off_address equ int_to_handle*4
    vector_seg_address equ int_to_handle*4+2
    include cstd.a ; <------ Delete this, you don't have this lib
    main proc near
    saveold: mov ax, @data
    mov ds, ax
    mov ax, 0
    mov es, ax
    mov ax, word ptr es:[vector_off_address]
    mov word ptr ds:[old_proc], ax
    mov ax, word ptr es:[vector_seg_address]
    mov word ptr ds:[old_proc+2], ax
    setnew: cli
    mov word ptr es:[vector_off_address], offset new_proc
    mov word ptr es:[vector_seg_address], seg new_proc
    sti
    intinit: ; Code to init the new int service, only if needed
    delay: mov cx, 1FFFh
    again00:mov dx, 0FFFFh
    again01:dec dx
    jnz again01
    loop again00
    intdeinit: ; Code to deinit the new int service, only if needed
    restoreold: cli
    mov ax, @data
    mov ds, ax
    mov ax, 0
    mov es, ax
    mov ax, word ptr ds:[old_proc]
    mov word ptr es:[vector_off_address], ax
    mov ax, word ptr ds:[old_proc+2]
    mov word ptr es:[vector_seg_address], ax
    sti
    exittodos: mov ax, 4C00h
    int 21h
    main endp
    new_proc proc far
    oldcall: push ds
    push ax
    mov ax, @data
    mov ds, ax
    pop ax
    pushf
    call dword ptr ds:[old_proc]
    pop ds
    printscall: push ax
    push dx
    push ds
    mov ax, @data
    mov ds, ax
    mov dx, offset string
    call near ptr prints
    pop ds
    pop dx
    pop ax
    exitint: iret
    new_proc endp
    end main
    ------------- handler.asm, BEGINNING ---------------------------------

    Replace the routine "printscall:" in "new_proc" procedure by any thing you want your program to do when the hardware interrupt triggers(in this case 1Ch is triggered). The procedure I am calling (call near ptr prints) is only a little code that print on screen the string at pointer ds:dx
    It uses DOS function 09 (ah <-- 09), so you can replace the "call near ptr prints" line with:
    .
    . <--ds and dx are allready poiting to "string" (it has the "Hello!")
    .
    mov ah, 09
    int 21h
    .
    .
    .

    I am not sure if is recomended to use a DOS service inside this interrupt service routine (new_proc is a ISR), maybe not bad at all. I am going to test my video card IRQ10 (common IRQ9) with this program but now changing "printscall:" with another routine that don't use a DOS servide. Maybe that is the problem!!! Maybe my video card hardware INT 10h makes a CLI (Iflag <-- 0, interrupt calls disabled) before it reaches "new_proc" (using a PUSHF, CALL FAR instead of a INT) and for that reason when I use this progam with INT 10h it appears that my video card is apparently dead, because it apparently never calls "new_proc" but!! in fact maybe it is calling it, and the only problem is that int 21h is disabled until the end of "end_proc", maybe...

    (I got some inspiration writing this post)
    Let's hands to work... :)

    Please help, this VBlank interrupt could be very usefull for DOS assembler.










  • : : : Come on guys!!! whats going on!!! I have been searching for information about how to handle the interrupt that VGA makes when it goes to vertical retrace.
    : : :
    : : : The only thing I can find, again and again is the odd routine that reads port 3DAh of the VGA card.
    : : : ----------Code start -------------
    : : : label
    : : : l1, l2;
    : : : asm
    : : : mov dx,3DAh
    : : : l1:
    : : : in al,dx
    : : : and al,08h
    : : : jnz l1
    : : : l2:
    : : : in al,dx
    : : : and al,08h
    : : : jz l2
    : : : end;
    : : : ----------Code end -------------
    : : : I don't say it isn't usefull, I think it is great, It can let your program sync with vertical retrace (VBlank) and solve well known graphic problems when you change video buffer at random time.
    : : :
    : : : BUT WHAT ABOUT USING A VGA VBLANK INTERRUPT!?!!?!?!?
    : : : I DON'T WANT TO WASTE MY CPU SCANNING AGAIN AND AGAIN THAT PORT!!!
    : : :
    : : : I think that VGA MUST run some interrupt when it goes to vertical retrace!!!
    : : [green]
    : : If there is I have never heard of it.
    : : [/green]
    : : : It is a must!!!
    : : :
    : : : Even the Nintendo Entertainment Systes (NES) have both, a port scaning metod (like the 3DAh port scanning code) and a VBLANK interrupt!, how is posible that VGA don't have it!?!!!?!?!
    : : :
    : : : I give up!! I have been searching for it!!! I can't find how to handle that int!!!
    : : :
    : : : I have been handling IRQ2 and IRQ10, in the same way that you handle int 1ch or int 8 for timing.
    : : :
    : : : I make my program go for a delay (and idle loop) but the ISRoutine I redirect for IRQ2 or IRQ10 never starts!!!
    : : :
    : : : I have a ATI Radeon 7000, it aresources are:
    : : : IRQ10
    : : : I/O 3B0-3BB, 3C0-3BF
    : : : MEM:A0000-AFFFF, B0000-BFFFF,...
    : : : as shown in Windows 98 hardware report.
    : : :
    : : : Don't say that VGA card don't have a VBLANK interrupt because I can't believe that.
    : : :
    : : : Maybe I have to program some port of the VGA to say to it start making VBLANK interrupts and then I believe that depending how your card is configured in your system you can handle it on IRQ9(INT #71h, vector address 0000:01C4h) or in IRQ10(INT #72h, vector address 0000:01C8h)
    : : : I did that but I neve get an INT 71h or INT 72h from the VGA card :(
    : : :
    : : : What I am doing brong?
    : : :
    : : : Maybe that INT are masked in some way? I have to do something before I can habdle that INTS? maybe I have to program de 8259 PIC (programable interrupt controler) before?
    : : :
    : : : HELP!!!!!
    : : :
    : : : I am studing DOS, real mode, 80286, assembler coding. I can't use Win32 stuff to handle this problem (maybe some VESA hardware register, etc I don't know), I am in DOS, if you know how to handle it in Win32 maybe could be interesting but I want to do it on DOS.
    : : :
    : : :
    : : [green]
    : : All I can do is recommend a site that has a ton of usefull info on ports, interrupts, embedded chips, and OS info. Sorry I couldn't of been more helpfull than that. :-(
    : :
    : : http://www.clipx.net/norton.php
    : :
    : : [/green]
    : :
    : :
    :
    : Thanks, this page is great!!! :) has a lot of code for many langueges. thanks a lot shaolin007.
    : But I have looking around and I found again that port 3DAh scanning routine to detect vertical retrace!! I hate it!!! :/
    :
    : ok, the answer is still there, How we can handle de VGA VBLANK interrupt. Note that in any interrupt table you can see IRQ2 as EGA vertical retrace interrupt!! O god!!! we are near!!! BUT!!!...
    :
    : As I know, original IRQ2 (use by old video cards) was used to put another PIC (programable interrupt controler) in newber IBM PCs to have more IRQ lines (we are talking about 286 or later machines) so IRQ2 of the first PIC recibes an interrupt from the second PIC. To make shorter this story, IRQ2 of the first PIC was replaced by the IRQ9 of the second. So if you want to handle original IRQ2, in fact you have to handle IRQ9...
    :
    : But it dosen't matter for me, because when I seen my hardware list on Windows 98 I can see my ATI Radeon 7000 video card using only IRQ10
    :
    : So, fron now, the only fact is that there os some way to handle IRQ10(IRQ10 = INT #72h (hex) = 0000:01C8h (hex seg:off))
    : (in my case is IRQ10, maybe in your PC you have your video card using other IRQ, maybe IRQ9, that comes from the old practice of using IRQ2 for video card VBlank. I think my PCI ATI card uses IRQ10 and not IRQ9 because my mother board has as a (now disabled) integrated AGP card, so the use of IRQ9 must be a common practice that comes from the old EGA cards (see any interrupt table and note IRQ2 INT# 0Ah slave 8259 or EGA/VGA vertical retrace))
    :
    : for example take a look at this IBM PC Hardware Interrupt table
    : http://members.tripod.com/~oldboard/assembly/int_table.html
    :
    : This time I am going to include the program I use to handle any interrupt, you can use it to handle great the interrut INT 1Ch, that is a clock tick hardware interrupt that is called 18.206Hz, in this case this routine handle the INT 1Ch and runs a "new_proc" procedure that prints Hello! 18.206 time every seccond. To see the INT working, this program have a delay loop that makes nothing, If your PC is too fast just increase the value of CX or DX. I was compiled using TASM for DOS.
    :
    : ------------- handler.asm, BEGINNING ---------------------------------
    : title IRQ2 EGA/VGA Vertical retrace handle
    : dosseg
    : .286
    : .model tiny
    : .stack
    : .data
    : old_proc dd ?
    : string db "Hello!$"
    : .code
    : int_to_handle equ 1Ch ; <--- HERE! you set the interrupt you want
    : ; to handle
    : vector_off_address equ int_to_handle*4
    : vector_seg_address equ int_to_handle*4+2
    : include cstd.a ; <------ Delete this, you don't have this lib
    : main proc near
    : saveold: mov ax, @data
    : mov ds, ax
    : mov ax, 0
    : mov es, ax
    : mov ax, word ptr es:[vector_off_address]
    : mov word ptr ds:[old_proc], ax
    : mov ax, word ptr es:[vector_seg_address]
    : mov word ptr ds:[old_proc+2], ax
    : setnew: cli
    : mov word ptr es:[vector_off_address], offset new_proc
    : mov word ptr es:[vector_seg_address], seg new_proc
    : sti
    : intinit: ; Code to init the new int service, only if needed
    : delay: mov cx, 1FFFh
    : again00:mov dx, 0FFFFh
    : again01:dec dx
    : jnz again01
    : loop again00
    : intdeinit: ; Code to deinit the new int service, only if needed
    : restoreold: cli
    : mov ax, @data
    : mov ds, ax
    : mov ax, 0
    : mov es, ax
    : mov ax, word ptr ds:[old_proc]
    : mov word ptr es:[vector_off_address], ax
    : mov ax, word ptr ds:[old_proc+2]
    : mov word ptr es:[vector_seg_address], ax
    : sti
    : exittodos: mov ax, 4C00h
    : int 21h
    : main endp
    : new_proc proc far
    : oldcall: push ds
    : push ax
    : mov ax, @data
    : mov ds, ax
    : pop ax
    : pushf
    : call dword ptr ds:[old_proc]
    : pop ds
    : printscall: push ax
    : push dx
    : push ds
    : mov ax, @data
    : mov ds, ax
    : mov dx, offset string
    : call near ptr prints
    : pop ds
    : pop dx
    : pop ax
    : exitint: iret
    : new_proc endp
    : end main
    : ------------- handler.asm, BEGINNING ---------------------------------
    :
    : Replace the routine "printscall:" in "new_proc" procedure by any thing you want your program to do when the hardware interrupt triggers(in this case 1Ch is triggered). The procedure I am calling (call near ptr prints) is only a little code that print on screen the string at pointer ds:dx
    : It uses DOS function 09 (ah <-- 09), so you can replace the "call near ptr prints" line with:
    : .
    : . <--ds and dx are allready poiting to "string" (it has the "Hello!")
    : .
    : mov ah, 09
    : int 21h
    : .
    : .
    : .
    :
    : I am not sure if is recomended to use a DOS service inside this interrupt service routine (new_proc is a ISR), maybe not bad at all. I am going to test my video card IRQ10 (common IRQ9) with this program but now changing "printscall:" with another routine that don't use a DOS servide. Maybe that is the problem!!! Maybe my video card hardware INT 10h makes a CLI (Iflag <-- 0, interrupt calls disabled) before it reaches "new_proc" (using a PUSHF, CALL FAR instead of a INT) and for that reason when I use this progam with INT 10h it appears that my video card is apparently dead, because it apparently never calls "new_proc" but!! in fact maybe it is calling it, and the only problem is that int 21h is disabled until the end of "end_proc", maybe...
    :
    : (I got some inspiration writing this post)
    : Let's hands to work... :)
    :
    : Please help, this VBlank interrupt could be very usefull for DOS assembler.


    NOPE! I changed the program, I am not using any DOS service on It, and IRQ10 (common IRQ9 or IRQ2) of my video card never triggers the "new_proc" redirected ISR.

    I give up.

    I hate you port 3DAh!!! please help, I want to send it to hell.






  • [green]
    I think your making a mountain out of a mole hill. All you need to do from what I have read, is 1st detect port 3dah to see if a retrace is in progress and then wait until the next retrace.

    [code]

    Wait_VTrace:
    push dx
    mov dx, 03dah
    in al, dx
    test al, 8 ;one already in progress?
    jnz .Wait ;if so then wait until it starts again
    jmp .Dont_Wait

    .Wait:
    in al, dx
    test al, 8 ;wait until it is done
    jnz .Wait

    .Dont_Wait:
    pop dx
    ret
    [/code]
    I hope the code works. I didn't test it, sorry. :-)
    [/green]

  • @- com5, I think you may be missing the point , that wait is very Handy for making game run at the same speed, by making the V-retrace control the game lop, it is more likely that people V-retrace rate are the same, then there PC.

    \\||////
    @)
    ASHLEY4.

    Batteries not included, Some assembly required.
  • : @- com5, I think you may be missing the point , that wait is very Handy for making game run at the same speed, by making the V-retrace control the game lop, it is more likely that people V-retrace rate are the same, then there PC.
    :
    : \\||////
    @)
    : ASHLEY4.
    :
    : Batteries not included, Some assembly required.
    :
    Yes, you are absolutely right. I was looking for a VBlank VGA card hardware interrupt for vertical retrace, because I believed that It was the facto standard for game coding, But I was brong. Maybe the 3DAh port polling routine is the best a easy way to get the VBlank period.

    Now I want to handle other harware interrupt, I want to handle de parallel port interrupt. It is bery usefull if you want to monitor some selfdeveloped device connecter to the port.

    You can find a GREAT!! site dedicated to the parallel port development here:
    D:DatabaseInformticaProgramingHardwareParallel PortInterfacing the Standard Parallel Port.htm
    there is an example to handle parallel port interrupt.

    Thanks, for cour comments.
  • : : @- com5, I think you may be missing the point , that wait is very Handy for making game run at the same speed, by making the V-retrace control the game lop, it is more likely that people V-retrace rate are the same, then there PC.
    : :
    : : \\||////
    @)
    : : ASHLEY4.
    : :
    : : Batteries not included, Some assembly required.
    : :
    : Yes, you are absolutely right. I was looking for a VBlank VGA card hardware interrupt for vertical retrace, because I believed that It was the facto standard for game coding, But I was brong. Maybe the 3DAh port polling routine is the best a easy way to get the VBlank period.
    :
    : Now I want to handle other harware interrupt, I want to handle de parallel port interrupt. It is bery usefull if you want to monitor some selfdeveloped device connecter to the port.
    :
    : You can find a GREAT!! site dedicated to the parallel port development here:
    : D:DatabaseInformticaProgramingHardwareParallel PortInterfacing the Standard Parallel Port.htm
    : there is an example to handle parallel port interrupt.
    :
    : Thanks, for cour comments.

    I agree with the above, that it will be very usefull, but i think it is better to control the hole OS, that why i and a group of others are making a moden 32bit pmode Dos OS.

    \\||////
    @)
    ASHLEY4.

    Batteries not included, Some assembly required.
  • [b][red]This message was edited by blip at 2005-1-28 21:30:0[/red][/b][hr]
    I am truly sorry you have been so frustrated by this problem and annoyed by the same piece of code you found over and over again... but the solution actually lies in using that code in a timing routine to set up another interrupt to emulate the vertical retrace interrupt, just read on (UNTESTED):
    [code]
    ;Note that according to the VBE 3.0 spec some video cards and/or modes
    ;may not support checking the vertical retrace status, so it would be
    ;nice to include such code to prevent a hang. But for a test program
    ;that will remain undistributed, it doesn't matter at all.

    in al,61h ;Read PPI
    push ax ;Save for restoration later
    or al,00000001b ;Enable PIT counter 2 so we can time :P
    and al,11111101b ;Disable speaker output else the user may hear something
    out 61h,al

    mov al,0B6h ;Setup PIT counter 2 for LSB/MSB loading and 16-bit binary countdown
    out 43h,al ;Look in a port doc for more detail...

    call vret ;Get to the beginning of a retrace before continuing
    xor al,al ;Start countdown value at 0, interpreted as 65536 by PIT
    out 42h,al ;Load the LSB
    out 42h,al ;And the MSB
    call vret ;Now we're to the beginning of the next retrace when this returns
    in al,42h ;Get the LSB
    mov bl,al
    in al,42h ;Then the MSB
    mov bh,al
    neg bx ;This is a countdown value, remember?

    pop ax
    out 61h,al

    ;...

    ;the VILE code follows hehe
    vret:
    mov dx,3DAh
    VRT1:
    in al,dx
    test al,8
    jnz VRT1
    VRT2:
    in al,dx
    test al,8
    jz VRT2
    ret
    [/code]

    You can then use the output value in BX to load up the PIT counter for IRQ0 to emulate the interrupt. Don't forget that the ISR will have to resynchronize with the signal (it will be a bit off) and the counter subsequently will have to be reloaded manually. This method does not give extremely precise results so I suggest sampling maybe 5 times and averaging or even taking the lowest value within reason (too high of a countdown value will cause you to overshoot and waste many many precious CPU cycles).

    Depending on your application, you may also want to call the original timer interrupt handler at approximately the correct frequency. This requires a divide to figure out how many of your simulated vertical retrace interrupts must pass before you can call the original handler. There will of course be a remainder that will need to be handled, too. Really, implement this how you want it and have fun! I have used this in a few basic demo programs of my own as well as a useful little utility that tells you the vertical scanning frequency of your monitor. There may be errors however considering it is getting late and I am sleepy.

    (Edit: corrected a dumb error)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories