how is textmode saved in memory???

sorry, my first manguage is french so i might have a little problems explaining what i'm looking for. I would like to know how the video memory is used under textmode...



i thought it might be similar to 13h mode since the ASCII table ranges from 0 to 255 but apparently that's not the answer.



for example, how can i know what character is at the position ( x, y ) of the screen by accessing the memory.



but what i'm really looking for is the layout of the information in the screen...



thxs for the help



Olivier


Comments

  • In videoRAM (address B800:0000 ---> B800:FFFF) is every char stored in two bytes... the first is ASCII of char, and the second is attribute... for example, if you want to write some pascal text, you can use this code :







    Program Try;

    Var test : String;



    Begin

    Test := 'Testing string';



    Asm

    Mov si, offset test

    mov ax,seg(test)

    mov ds,ax

    mov ax,0b800h

    mov es,ax

    xor di,di

    xor cx,cx

    mov cl,byte ptr ds:[si]

    inc si

    mov ah,07 {this is text attribute}

    @loop :

    lodsb

    stosw

    loop @loop

    End;



    End.


  • : sorry, my first manguage is french so i might have a little problems explaining what i'm looking for.



    i just wanted to say..

    quand votre premiere langue est francais vous parlez en francais...



    i'm not the best speaker but surely there are couple of people here who can understand you if you know how to describe your problem better in french eh.. so think about it 4 next time.. :)



    //נועם (for what you can see that's noam in hebrew..)


  • I'm not Backstabber but.

    Si j'avais su, j'aurais parler Franais! :) Moi jsuis Qubcois.



    The fact is that I don't know Pascal to that point. I mean what you guys are talking about is like Chinese for me. I'm just starting using Sound, File Handling, graphic mode, unit programming.



    I'm currently making a RPG, I first start to program it as a One Recursive Procedure.



    But then I learned how to use Goto Label.



    So now I could use other recursive Procedure.



    I've got one for each command, or almost. :)



    But I now changed for Graphic mode and got problems with OutText, that's why i made a unit where OutTextLn exists!!! and it works! :)



    But some other doesnt, like my OutTextBelow... I just can't understand Incrementing a variable.



    What does Incrementing means in French?



    Pour le text mode je saurais pas rpondre. Le mieux c'est d'essayer l'exemple.





    : In videoRAM (address B800:0000 ---> B800:FFFF) is every char stored in two bytes... the first is ASCII of char, and the second is attribute... for example, if you want to write some pascal text, you can use this code :

    :

    :

    :

    : Program Try;

    : Var test : String;

    :

    : Begin

    : Test := 'Testing string';

    :

    : Asm

    : Mov si, offset test

    : mov ax,seg(test)

    : mov ds,ax

    : mov ax,0b800h

    : mov es,ax

    : xor di,di

    : xor cx,cx

    : mov cl,byte ptr ds:[si]

    : inc si

    : mov ah,07 {this is text attribute}

    : @loop :

    : lodsb

    : stosw

    : loop @loop

    : End;

    :

    : End.

    :






  • : I'm not Backstabber but.

    : Si j'avais su, j'aurais parler Franais! :) Moi jsuis Qubcois.

    :

    : The fact is that I don't know Pascal to that point. I mean what you guys are talking about is like Chinese for me. I'm just starting using Sound, File Handling, graphic mode, unit programming.

    :

    : I'm currently making a RPG, I first start to program it as a One Recursive Procedure.

    :

    : But then I learned how to use Goto Label.

    :

    : So now I could use other recursive Procedure.

    :

    : I've got one for each command, or almost. :)

    :

    : But I now changed for Graphic mode and got problems with OutText, that's why i made a unit where OutTextLn exists!!! and it works! :)

    :

    : But some other doesnt, like my OutTextBelow... I just can't understand Incrementing a variable.

    :

    : What does Incrementing means in French?

    :

    : Pour le text mode je saurais pas rpondre. Le mieux c'est d'essayer l'exemple.

    :

    :

    : : In videoRAM (address B800:0000 ---> B800:FFFF) is every char stored in two bytes... the first is ASCII of char, and the second is attribute... for example, if you want to write some pascal text, you can use this code :

    : :

    : :

    : :

    : : Program Try;

    : : Var test : String;

    : :

    : : Begin

    : : Test := 'Testing string';

    : :

    : : Asm

    : : Mov si, offset test

    : : mov ax,seg(test)

    : : mov ds,ax

    : : mov ax,0b800h

    : : mov es,ax

    : : xor di,di

    : : xor cx,cx

    : : mov cl,byte ptr ds:[si]

    : : inc si

    : : mov ah,07 {this is text attribute}

    : : @loop :

    : : lodsb

    : : stosw

    : : loop @loop

    : : End;

    : :

    : : End.

    : :

    :

    :

    :



    This is simple... There are two bytes for each character on screen in text mode (one byte is char and other byte is attribute). The example above is written in assembler using lodsb (load byte) and stosw ( set word - which is two byte).

    Since we are reading from string (chars in sequence) and writing to screen (two byte per char) we must compensate because each lodsb increments index register by one and stosw by two.

    If you put some number in DI instead of clearing it (xor di,di) you can have message anywhere on the screen (and beyond visible area).



    Iby






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