bgi alternative?

i know that bgi commands are very slow, so what's the alternative? is there anybody who has a unit or at least procedures and functions doing the same as the procedures and functions in the graph unit, only faster?

Comments

  • : i know that bgi commands are very slow, so what's the alternative? is there anybody who has a unit or at least procedures and functions doing the same as the procedures and functions in the graph unit, only faster?
    :
    You can do graphics directly. This piece of asm code will get you into the easiest graphics mode to work with (Mode 13h)

    asm
    mov ax,0013h
    int 10h
    end;

    After that, you can draw to the screen in many ways, but if you want to avoid assembly then you can use the Mem array to read and write pixels.

    Use this Pascal statement to draw a pixel to the screen

    Mem[$A000:offset] := colour;

    where colour is the number for the colour of the pixel (there are 256 colours in this mode, BTW) and offset is the offset of the pixel you want to write to. This is how the offsets work. Starting from the top-left corner of the screen, you have offset 0. Every pixel right of that has an offset of 1 more. There are 320 pixels in a row in this mode, so the last pixel in the first row is 319. When you get the first pixel on the second row is 320.

    In a nutshell, use this formula:
    Mem[$A000: x + (y*320)] := colour;
    where x and y are your x- and y-coordinates.

  • : i know that bgi commands are very slow, so what's the alternative? is there anybody who has a unit or at least procedures and functions doing the same as the procedures and functions in the graph unit, only faster?
    :
    Here's another way. Declare a variable like this:

    Var
    Screen: array[0..199,0..319] of byte absolute $A000:0;

    Now your screen is in an array. As long as you are in Mode 13h (see previous post) anything you do to this array will happen on the screen. It's worth pointing out that this is a [y,x] array, not a [x,y] one.

  • thanks!
    i've got a list of modes like the 13h one, now i know what to do with it.
    do you know where i can find a tutorial on how to code own graphic procedures like circles or lines? sinus and cosinus are too slow i think.
    thanks again, you were a big help

    chobo

  • : thanks!
    : i've got a list of modes like the 13h one, now i know what to do with it.
    : do you know where i can find a tutorial on how to code own graphic procedures like circles or lines? sinus and cosinus are too slow i think.
    : thanks again, you were a big help
    :
    : chobo

    i finally found a unit doing this myself. it's much faster, i'll only have to understand how exactly it works.

  • : : thanks!
    : : i've got a list of modes like the 13h one, now i know what to do with it.
    : : do you know where i can find a tutorial on how to code own graphic procedures like circles or lines? sinus and cosinus are too slow i think.
    : : thanks again, you were a big help
    : :
    : : chobo
    :
    : i finally found a unit doing this myself. it's much faster, i'll only have to understand how exactly it works.
    :
    Look around for theory on Bresenham algorithms. That could help you to understand.

    By the way, there are ways of speeding up trig functions. You could build yourself a lookup-table in an array when your program starts and thereafter look in the array instead of using functions.

    Var
    Sinus: array[0..359]of real;

    Procedure GenerateSinTable;
    Var
    c: word;
    Begin
    For c := 0 to 359 do Sinus[c] := Sin((pi*c)/360);
    end;

  • : Look around for theory on Bresenham algorithms. That could help you to understand.
    :
    : By the way, there are ways of speeding up trig functions. You could build yourself a lookup-table in an array when your program starts and thereafter look in the array instead of using functions.
    :
    : Var
    : Sinus: array[0..359]of real;
    :
    : Procedure GenerateSinTable;
    : Var
    : c: word;
    : Begin
    : For c := 0 to 359 do Sinus[c] := Sin((pi*c)/360);
    : end;

    thanks, i'll use that in my next program.
    btw: it'll be an ai robot contest. the competitorst program how their robots are designed (where the cannons are), how they move, when they shoot, things like that. if it dosn't begin to seem boring to me before it's finished i'll maybe even start a little internet competition. if i find more than 10 competitor, then i'll maybe even make it better.
    haha, me dreamer ;)

  • : thanks!
    : i've got a list of modes like the 13h one, now i know what to do with it.
    : do you know where i can find a tutorial on how to code own graphic procedures like circles or lines? sinus and cosinus are too slow i think.
    : thanks again, you were a big help
    :
    : chobo
    :

    sin and cos are slow indeed, so try to calculate them and program start, and store them in a table, then use this table to calculate.
    all you will have to do is multiply, so that wont be very slow

    and of course: it is always a good idea to do it in ASM

  • :
    : and of course: it is always a good idea to do it in ASM
    :

    yes, if you CAN do it in asm :(

    but thx anyway

  • : :
    : : and of course: it is always a good idea to do it in ASM
    : :
    :
    : yes, if you CAN do it in asm :(
    :
    : but thx anyway
    :

    Of course you can. everything you can do in any languges, you can do it in ASM. Make your SIN and COS tables in pascal (it would be a little bit more complicated in ASM), but for the rest, you can do it in ASM, its pretty easy.

    post a message on the X86 messageboard if you want more info on this, if I dont answer quick enough, someone else will!


  • : : :
    : : : and of course: it is always a good idea to do it in ASM
    : : :
    : :
    : : yes, if you CAN do it in asm :(
    : :
    : : but thx anyway
    : :
    :
    : Of course you can. everything you can do in any languges, you can do it in ASM. Make your SIN and COS tables in pascal (it would be a little bit more complicated in ASM), but for the rest, you can do it in ASM, its pretty easy.
    :
    : post a message on the X86 messageboard if you want more info on this, if I dont answer quick enough, someone else will!
    :

    it was more about that I can't do it in asm than that it's impossible to do it in asm


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