print routine isnt working 
Author Message
 print routine isnt working

I've been sidetracked with a little Tic Tac Toe project i wanted to
accomplish for myself but it isnt really printing... It uses a virtual
board (in memory) and a physical board (on the screen...) the code is
rather self explanatory... Compile under NASM and see what happens...
when u input a position it wont print an "X" where it should (wont print
an X at all!)
    Sorry for the lack of comments ... i better get in the habit of not
leaving them for last!

; Tic Tac Toe

org 100h

section .text

main:
        call    draw_ui
        call    game
        call    exit

game:
        call    get_input
        call    refresh_virtual
        call    refresh_physical
        ret

get_input:
        mov     ah,     02
        xor     bh,     bh
        mov     dh,     12
        xor     dl,     dl
        int     10h

        mov     ah,     09
        mov     dx,     input_msg
        int     21h

        mov     ah,     01
        int     21h

        cmp     al,     '1'
        jb      get_input

        cmp     dl,     '9'
        ja      get_input

        sub     al,     49
        mov     [p1_move],         al

        ret

refresh_virtual:
        xor     bh,     bh
        mov     bl,     byte [p1_move]

        cmp     bl,     0FFh
        je      position_filled

        cmp     byte [board + bx],      0
        jne     position_filled

        mov     dl,     'X'

        mov     byte [board + bx],      dl

        ret

position_filled:
        mov     byte [p1_move], 0FFh

        ret

refresh_physical:
        xor     bx,     bx
        mov     bl,     byte [p1_move]

        ;cmp     bl,     0FFh
        ;je      position_filled

        mov     dx,     word [pos_chart + bx]

        xor     bx,     bx
        mov     ah,     02
        int     10h

        mov     ah,     02
        mov     dx,     [p1_fig]
        int     21h

        ret

draw_ui:
        xor     ah,     ah
        mov     al,     03
        int     10h

        mov     ah,     09
        mov     dx,     ui_map
        int     21h

        ret

exit:
        mov     ah,     4ch
        int     21h

section .data

        ui_map  db      " 1 | 2 | 3     |   |   ", 10, 13
                db      "---+---+--- ---+---+---", 10, 13
                db      " 4 | 5 | 6     |   |   ", 10, 13
                db      "---+---+--- ---+---+---", 10, 13
                db      " 7 | 8 | 9     |   |   ", 10, 13
                db      "$"

        board   db      0, 0, 0, 0, 0, 0, 0, 0

        p1_move db      0FFh
        p1_fig  db      0, "X"
        ai_fig  db      0, "O"

        pos_chart       db      0, 14, 0, 18, 0, 21
                        db      1, 14, 1, 18, 0, 21
                        db      2, 14, 2, 18, 2, 21

        input_msg       db      "Move:$"



Mon, 09 Jul 2001 03:00:00 GMT  
 print routine isnt working

Quote:
> I've been sidetracked with a little Tic Tac Toe project i wanted to
> accomplish for myself but it isnt really printing... It uses a virtual
> board (in memory) and a physical board (on the screen...) the code is
> rather self explanatory... Compile under NASM and see what happens...
> when u input a position it wont print an "X" where it should (wont print
> an X at all!)
>     Sorry for the lack of comments ... i better get in the habit of not
> leaving them for last!

> ; Tic Tac Toe

> org 100h

> section .text

> main:
>         call    draw_ui
>         call    game
>         call    exit

> game:
>         call    get_input
>         call    refresh_virtual
>         call    refresh_physical
>         ret

> get_input:
>         mov     ah,     02
>         xor     bh,     bh
>         mov     dh,     12
>         xor     dl,     dl
>         int     10h

>         mov     ah,     09
>         mov     dx,     input_msg
>         int     21h

>         mov     ah,     01
>         int     21h

>         cmp     al,     '1'
>         jb      get_input

>         cmp     dl,     '9'
>         ja      get_input

>         sub     al,     49
>         mov     [p1_move],         al

>         ret

> refresh_virtual:
>         xor     bh,     bh
>         mov     bl,     byte [p1_move]

>         cmp     bl,     0FFh
>         je      position_filled

>         cmp     byte [board + bx],      0
>         jne     position_filled

>         mov     dl,     'X'

>         mov     byte [board + bx],      dl

>         ret

> position_filled:
>         mov     byte [p1_move], 0FFh

>         ret

> refresh_physical:
>         xor     bx,     bx
>         mov     bl,     byte [p1_move]

>         ;cmp     bl,     0FFh
>         ;je      position_filled

>         mov     dx,     word [pos_chart + bx]

>         xor     bx,     bx
>         mov     ah,     02
>         int     10h

>         mov     ah,     02
>         mov     dx,     [p1_fig]
>         int     21h

>         ret

> draw_ui:
>         xor     ah,     ah
>         mov     al,     03
>         int     10h

>         mov     ah,     09
>         mov     dx,     ui_map
>         int     21h

>         ret

> exit:
>         mov     ah,     4ch
>         int     21h

> section .data

>         ui_map  db      " 1 | 2 | 3     |   |   ", 10, 13
>                 db      "---+---+--- ---+---+---", 10, 13
>                 db      " 4 | 5 | 6     |   |   ", 10, 13
>                 db      "---+---+--- ---+---+---", 10, 13
>                 db      " 7 | 8 | 9     |   |   ", 10, 13
>                 db      "$"

>         board   db      0, 0, 0, 0, 0, 0, 0, 0

>         p1_move db      0FFh
>         p1_fig  db      0, "X"
>         ai_fig  db      0, "O"

>         pos_chart       db      0, 14, 0, 18, 0, 21
>                         db      1, 14, 1, 18, 0, 21
>                         db      2, 14, 2, 18, 2, 21

>         input_msg       db      "Move:$"

Just remember that words are stored reversed in memory!

So, when you use "mov dx, word [pos_chart + bx]" and "mov dx, [p1_fig]",
both in "refresh_physical" routine, registers DL and DH are inter-changed.

I tried...

    p1_fig  db    "X", 0
    ai_fig  db    "O", 0

    pos_chart    db      14, 0, 18, 0, 21, 0
                        db      14, 1, 18, 1, 21, 0
                        db      14, 2, 18, 2, 21, 2

... and printf routine now works, but not always in the right place.
Continue working.



Tue, 10 Jul 2001 03:00:00 GMT  
 print routine isnt working

Quote:
> I've been sidetracked with a little Tic Tac Toe project i wanted to
> accomplish for myself but it isnt really printing... It uses a virtual
> board (in memory) and a physical board (on the screen...) the code is
> rather self explanatory... Compile under NASM and see what happens...
> when u input a position it wont print an "X" where it should (wont print
> an X at all!)
>     Sorry for the lack of comments ... i better get in the habit of not
> leaving them for last!

> ; Tic Tac Toe

> org 100h

> section .text

> main:
>         call    draw_ui
>         call    game
>         call    exit

> game:
>         call    get_input
>         call    refresh_virtual
>         call    refresh_physical
>         ret

> get_input:
>         mov     ah,     02
>         xor     bh,     bh
>         mov     dh,     12
>         xor     dl,     dl
>         int     10h

>         mov     ah,     09
>         mov     dx,     input_msg
>         int     21h

>         mov     ah,     01
>         int     21h

>         cmp     al,     '1'
>         jb      get_input

>         cmp     dl,     '9'
>         ja      get_input

>         sub     al,     49
>         mov     [p1_move],         al

>         ret

> refresh_virtual:
>         xor     bh,     bh
>         mov     bl,     byte [p1_move]

>         cmp     bl,     0FFh
>         je      position_filled

>         cmp     byte [board + bx],      0
>         jne     position_filled

>         mov     dl,     'X'

>         mov     byte [board + bx],      dl

>         ret

> position_filled:
>         mov     byte [p1_move], 0FFh

>         ret

> refresh_physical:
>         xor     bx,     bx
>         mov     bl,     byte [p1_move]

>         ;cmp     bl,     0FFh
>         ;je      position_filled

>         mov     dx,     word [pos_chart + bx]

>         xor     bx,     bx
>         mov     ah,     02
>         int     10h

>         mov     ah,     02
>         mov     dx,     [p1_fig]
>         int     21h

>         ret

> draw_ui:
>         xor     ah,     ah
>         mov     al,     03
>         int     10h

>         mov     ah,     09
>         mov     dx,     ui_map
>         int     21h

>         ret

> exit:
>         mov     ah,     4ch
>         int     21h

> section .data

>         ui_map  db      " 1 | 2 | 3     |   |   ", 10, 13
>                 db      "---+---+--- ---+---+---", 10, 13
>                 db      " 4 | 5 | 6     |   |   ", 10, 13
>                 db      "---+---+--- ---+---+---", 10, 13
>                 db      " 7 | 8 | 9     |   |   ", 10, 13
>                 db      "$"

>         board   db      0, 0, 0, 0, 0, 0, 0, 0

>         p1_move db      0FFh
>         p1_fig  db      0, "X"
>         ai_fig  db      0, "O"

>         pos_chart       db      0, 14, 0, 18, 0, 21
>                         db      1, 14, 1, 18, 0, 21
>                         db      2, 14, 2, 18, 2, 21

>         input_msg       db      "Move:$"

*
* Posted on Friday. As it didn't arrive, re-posted on Monday.
* Sorry if you get the two copies.
*

Just remember that words are stored reversed in memory!

So, when you use "mov dx, word [pos_chart + bx]" and "mov dx, [p1_fig]",
both in "refresh_physical", registers DL and DH are inter-changed.

I tried...

    p1_fig    db    "X", 0
    ai_fig    db    "O", 0

    pos_chart    db    14, 0, 18, 0, 21, 0
                        db    14, 1, 18, 1, 21, 1
                        db    14, 2, 18, 2, 21, 2

... and print routine now works, but not always in the right place.
Continue working.



Fri, 13 Jul 2001 03:00:00 GMT  
 print routine isnt working

Quote:

> > I've been sidetracked with a little Tic Tac Toe project i wanted to
> > accomplish for myself but it isnt really printing... It uses a virtual
> > board (in memory) and a physical board (on the screen...) the code is
> > rather self explanatory... Compile under NASM and see what happens...
> > when u input a position it wont print an "X" where it should (wont print
> > an X at all!)
> >     Sorry for the lack of comments ... i better get in the habit of not
> > leaving them for last!

> > ; Tic Tac Toe

> > org 100h

> > section .text

> > main:
> >         call    draw_ui
> >         call    game
> >         call    exit

> > game:
> >         call    get_input
> >         call    refresh_virtual
> >         call    refresh_physical
> >         ret

*
* Posted on Friday. As it didn't arrive, re-posted on Monday.
* Sorry if you get the two copies.
*
* Re-reposted on Tuesday as it did incomplete...
*

Just remember that words are stored reversed in memory!

So, when you use "mov dx, word [pos_chart + bx]" and "mov dx, [p1_fig]",
both in "refresh_physical", registers DL and DH are inter-changed.

I tried...

    p1_fig    db    "X", 0
    ai_fig    db    "O", 0

    pos_chart    db    14, 0, 18, 0, 21, 0
                        db    14, 1, 18, 1, 21, 1
                        db    14, 2, 18, 2, 21, 2

... and print routine now works, but not always in the right place.
Continue working.



Sat, 14 Jul 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Automation ActiveX for msGraph isnt working

2. Bootsec dump isnt WORKING!

3. My Object pool isnt working

4. CW4 isnt like CPD for DOS - help!

5. event:tabchanging isnt executed in a translated ABC template

6. Operand Types...Isnt this right

7. Printing routine for APL+WIN Forms

8. c4a: --break label-- doesn't work inside of a routine

9. Print routine delay using Pagescript

10. Print routines to a laser

11. Non working scrollthumb after set() in locaterecord routine ???

12. Label Printing Routine

 

 
Powered by phpBB® Forum Software