简体   繁体   中英

Trying to make pong in assembly 8086 and the characters are out of line

Trying to make pong and the characters are out of line.

http://prntscr.com/69nyg8

; multi-segment executable file template.

data segment
    ; add your data here!
    game db        "±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±";0
         db 10,13, "                                           ";1
         db 10,13, "                                           ";2
         db 10,13, "                                           ";3
         db 10,13, "                                           ";4
         db 10,13, "                                           ";5
         db 10,13, "                                           ";6
         db 10,13, "                                           ";7
         db 10,13, "                                           ";8
         db 10,13, "                                           ";9
         db 10,13, "                                           ";A
         db 10,13, "                                           ";B
         db 10,13, "±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±";C
         db 10,13, "Player1:                         Player2: $";D 
                   ;0123456789ABCDEF        18   

     player1 db        ""       
             db 10,    ""
             db 10,    "$"

     player2 db        "" 
             db 10,    "" 
             db 10,    "$"

     ball db "*$"

      Menu db        "  _____                     " 
           db 10,13, " |  __ \                    " 
           db 10,13, " | |__) |___   _ __    __ _ " 
           db 10,13, " |  ___// _ \ | '_ \  / _` |" 
           db 10,13, " | |   | (_) || | | || (_| |" 
           db 10,13, " |_|    \___/ |_| |_| \__, |" 
           db 10,13, "                       __/ |" 
           db 10,13, "                      |___/ " 
           db 10,13, "Click HERE to start         "                             
           db 10,13, "Player1:W -UP               "
           db 10,13, "        S -DOWN             "
           db 10,13, "Player2: ON NUMPAD          "
           db 10,13, "        8 -UP               "
           db 10,13, "        2 -DOWB            $"







     player1Score db 0

     player2Score db 0

     ballx db 0Ch

     bally db 06h

     player1Y db 6

     player2Y db 6          

     xstart dw 2Fh          
     xFinal dw 4Dh
     ystart dw 40h
     yfinal dw 46h          



ends              


stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax
    mov ch,32;removes cursor
    mov ah,1h
    int 10h

    enu:
         mov ah,9
         lea dx,Menu
         int 21h
    mouse:
         mov ax,3
         int 33h
         cmp bx,1
         je checkPos
         jmp mouse     


    fresh:;prints new game


       mov al,3h
       mov ah,0
       int 10h

          mov ah,9
          lea dx,game
          int 21h 

          mov bh,0
          mov dh,player1Y
          mov dl,03h
          mov ah,2
          int 10h

          mov ah,9
          lea dx,player1
          int 21h

          mov bh,0
          mov dh,player2Y
          mov dl,25h
          mov ah,02h
          int 10h

          mov ah,9
          lea dx,player2
          int 21h







    mov ax, 4c00h ; exit to operating system.
    int 21h    


       mov al,12h
       mov ah,0
       int 10h


    ;  Input:
    ;  mov ah,7
    ;  int 21h
    ;  cmp al,'w'
    ;  je inc             
    ;  cmp al,'s'
    ;  je down
    ;  cmp al,'8'
    ;  je right
    ;  cmp al,'2'
    ;  je left
    ;  jmp firstInput 
    ;  
    ;  checkWall:
    ;
    ;  downRight:
    ;  inc ballY
    ;  inc ballX


    checkPos:
    mov ax,xstart
    cmp cx,ax
    jl mouse
    mov ax,xfinal
    cmp cx,ax
    jg mouse
    mov ax,yfinal
    cmp dx,ax
    jg Mouse
    mov ax,ystart
    cmp dx,ax
    jl mouse
    jmp fresh


ends

end start ; set entry point and stop the assembler.

The code is not finished yet so there is basically nothing.

player1 db        ""       
         db 10,    ""
         db 10,    "$"

causes the ladder view. putting backspace char after each line break may work:

player1 db        ""       
         db 10,8,    ""
         db 10,8,    "$"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM