putpixel


Why this code doesn't work correctly in Windows?

void main(int x, int y, char color)
{
int offs;
offs = 320 * y + x;
asm mov ax, 13h
asm int 10h
asm mov ax, 0a000h
asm mov es, ax
asm mov di, offs
asm mov al, color
asm mov [es:di], al
}



Comments

  • That code is for real mode, not protected mode. To do that in Windows, you need to find the correct API to switch to mode 13h or equivalent and edit the screen buffer correctly.
  • : That code is for real mode, not protected mode. To do that in Windows, you need to find the correct API to switch to mode 13h or equivalent and edit the screen buffer correctly.

    So it's possible to use mode 13h in Windows?
    Where do I get information about this?


  • : : That code is for real mode, not protected mode. To do that in Windows, you need to find the correct API to switch to mode 13h or equivalent and edit the screen buffer correctly.
    :
    : So it's possible to use mode 13h in Windows?
    : Where do I get information about this?
    :
    :
    :

    I'd recommend using SDL (www.libsdl.org) which is a cross-platform low-level graphics library. It will quickly get you access to the framebuffer. It's obviously a C library, but that shouldn't be a problem. In fact, if the only reason you were using assembly was to get into and out of mode 13h and access the framebuffer, then this is a better solution all around and I'd recommend using a high-level language (C or C++ or whatever you feel like if you can get the bindings to work). Of course if you are using assembly for the fun of it, then by all means continue.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • [b][red]This message was edited by AsmGuru62 at 2002-10-29 7:45:43[/red][/b][hr]
    : : That code is for real mode, not protected mode. To do that in Windows, you need to find the correct API to switch to mode 13h or equivalent and edit the screen buffer correctly.
    :
    : So it's possible to use mode 13h in Windows?
    : Where do I get information about this?
    :
    :
    :
    [blue]If you build your code using 16-bit compiler (like Turbo C++) it will work fine in windows - it will be just working in DOS Prompt box. If you compiled this code with 32-bit compiler it is not supposed to work - you can't access the video RAM directly.

    Also, [b]main()[/b] does not take such parameters as yours and it returns [b]int[/b] by the later standards.[/blue]


  • [b][red]This message was edited by mr_biology at 2002-10-29 11:39:0[/red][/b][hr]
    : [blue]If you build your code using 16-bit compiler (like Turbo C++) it will work fine in windows - it will be just working in DOS Prompt box. If you compiled this code with 32-bit compiler it is not supposed to work - you can't access the video RAM directly.[/blue]

    Ok, now the code is working properly (I compiled it to 16-bit).
    But..

    For example in Windows XP there's no such thing as DOS. So, will the code work ok under XP as well (even if it's compiled to 16-bit)?



  • : [b][red]This message was edited by mr_biology at 2002-10-29 11:39:0[/red][/b][hr]
    : : [blue]If you build your code using 16-bit compiler (like Turbo C++) it will work fine in windows - it will be just working in DOS Prompt box. If you compiled this code with 32-bit compiler it is not supposed to work - you can't access the video RAM directly.[/blue]
    :
    : Ok, now the code is working properly (I compiled it to 16-bit).
    : But..
    :
    : For example in Windows XP there's no such thing as DOS. So, will the code work ok under XP as well (even if it's compiled to 16-bit)?
    :
    :
    :
    :
    [blue]I never tried it, but if XP is backward compatible (probably, not) the DOS code will execute on virtual machine.

    Can you try it?[/blue]

  • : [blue]I never tried it, but if XP is backward compatible (probably, not) the DOS code will execute on virtual machine.
    :
    : Can you try it?[/blue]

    I can try it under Windows 2000 but it's not the same as running
    it under XP. Or is it?

  • :
    : : [blue]I never tried it, but if XP is backward compatible (probably, not) the DOS code will execute on virtual machine.
    : :
    : : Can you try it?[/blue]
    :
    : I can try it under Windows 2000 but it's not the same as running
    : it under XP. Or is it?
    :
    :
    [blue]Maybe... I will try that at home.[/blue]
  • [b][red]This message was edited by mr_biology at 2002-10-31 0:20:5[/red][/b][hr]
    : : I can try it under Windows 2000 but it's not the same as running
    : : it under XP. Or is it?
    : :
    : :
    : [blue]Maybe... I will try that at home.[/blue]

    YES!! It works under Win2000. Is there DOS included in Windows 2000?



  • : [b][red]This message was edited by mr_biology at 2002-10-31 0:20:5[/red][/b][hr]
    : : : I can try it under Windows 2000 but it's not the same as running
    : : : it under XP. Or is it?
    : : :
    : : :
    : : [blue]Maybe... I will try that at home.[/blue]
    :
    : YES!! It works under Win2000. Is there DOS included in Windows 2000?
    :
    :
    :
    :
    [blue]There is a DOS Virtual Machine - a special task - you can run [b]some[/b] DOS code inside it, but not all DOS code - there are some restrictions... When running a DOS code open Task Manager (Right click on a task bar) and see the task list - it called NTVDM.[/blue]
  • [b][red]This message was edited by mr_biology at 2002-11-1 5:5:59[/red][/b][hr]
    : : [b][red]This message was edited by mr_biology at 2002-10-31 0:20:5[/red][/b][hr]
    : : : : I can try it under Windows 2000 but it's not the same as running
    : : : : it under XP. Or is it?
    : : : :
    : : : :
    : : : [blue]Maybe... I will try that at home.[/blue]
    : :
    : : YES!! It works under Win2000. Is there DOS included in Windows 2000?
    : :
    : :
    : :
    : :
    : [blue]There is a DOS Virtual Machine - a special task - you can run [b]some[/b] DOS code inside it, but not all DOS code - there are some restrictions... When running a DOS code open Task Manager (Right click on a task bar) and see the task list - it called NTVDM.[/blue]

    Could you tell me how it works after you've tried it under XP?



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