在dosbox清屏中组装

问题描述 投票:0回答:1

我想清除显示屏上的屏幕,但当我尝试时,总是要么屏幕被清除,但随后它会放大,或者屏幕被清除,但我的光标消失了,所有代码详细信息都消失了。模型小

.stack 64
.data
    welcome     db  "Welcome to Penang Travel Bus System!: $"
    msg1        db  10,13, "Pick up destinations : $"
    msg2        db  10,13, "Drop up destinations : $"
    pickupTitle db  10,13, "---- Your Pickup Destination ---- $"
    dropoffTitle    db  10,13, "---- Your Drop-off Destination ---- $"
    destination1    db  10,13, "1. Spice Arena Bayan Lepas $"
    destination2    db  10,13, "2. Ayer Itam Bus Terminal $"
    destination3    db  10,13, "3. Komtar Sentral Georgetown $"
    destination4    db  10,13, "4. Balik Pulau Bus Terminal $"
    destination5    db  10,13, "5. Gurney Plaza Pulau Tikus $"
    destination6    db  10,13, "6. Vantage Point Bus Stop Tanjung Tokong $"
    pickupPrompt    db  10,13,10,13, "Enter the number of your pickup destination (1-6): $"
    dropoffPrompt   db  10,13,10,13, "Enter the number of your drop-off destination (1-6): $"
    pickupChoice    db  ?  
    dropoffChoice   db  ?
    pickupchosen    db  10,13, "You selected pickup destination: $"
    dropoffchosen   db  10,13,  "You selected drop-off destination: $"
    invalid_pickup  db  10,13, "Invalid pickup destination. Please select from (1-6): $"
    invalid_dropoff db  10,13, "Invalid drop-off destination. Please select from(1-6): $"
    invalid_destination db 10,13,"Your drop-off destination cannot be same as your pickup destination. Please select other destination: $"
    invalid_quantity db 10,13, "Invalid quantity. Minimum number of tickets is 0 and maximum is 9. Please select from (1-9): $"
    invalid_feature db 10,13, "Invalid feature. Enter from (1-4) or (0) for no features. $"
    quantityPrompt  db  10,13,10,13, "Enter the quantity of tickets (1-9): $"
    ticketQuantity  db ?
    features    db  10,13,10,13, "Would you like any of these extra features? $"
    snacks      db  10,13, "1. Snacks of your choice: (Twisties / Super Ring / Cheezels / Chips) - RM7.00 $"
    beverages   db  10,13, "2. Cold beverages (100Plus / Cola / 7UP / Sprite) - RM7.00 $"
    entertainment   db  10,13, "3. TV Entertainment (Smart TV) - RM10.00 $"
    wifi        db  10,13, "4. Onboard WiFi - RM8.00 $"
    featuresPrompt db 10,13, "Enter the features you want (1-4) Press (0) if no : $"
    featuresChoice db 0
    featuremessage  db  10,10, "Feature added. Would you like any more features? $"
    chosenfeatures db 10,13, "Feature chosen: $"


;==========================================================================

.code
    main    proc    far

    mov ax , @data
    mov ds , ax;

    call clear_screen

    mov ah , 09h
    lea dx , welcome
    int 21h
    
    mov ah , 09h
    lea dx , pickupTitle
    int 21h

    mov ah , 09h
    lea dx , msg1
    int 21h

    mov ah , 09h
    lea dx , destination1
    int 21h

    mov ah , 09h
    lea dx , destination2
    int 21h

    mov ah , 09h
    lea dx , destination3
    int 21h

    mov ah , 09h
    lea dx , destination4
    int 21h

    mov ah , 09h
    lea dx , destination5
    int 21h

    mov ah , 09h
    lea dx , destination6
    int 21h
    
    mov ah , 09h
    lea dx , pickupPrompt
    int 21h


    ;Read user input for pickup choice
get_pickup:
    mov ah , 01h            ; Please prepare I want to read a char
    int 21h
    sub al , 30h            ; Change it to integer
    
    cmp al , 1
    jl invalidpickup
    cmp al , 6
    jg invalidpickup
    
    mov pickupChoice, al
    jmp get_dropoff

invalidpickup:              ; Display an invalid pickup message if user doesn't enter from 1 to 6
    mov ah , 09h
    lea dx , invalid_pickup
    int 21h
    jmp get_pickup

;Dropoff menu

get_dropoff:
    mov ah , 09h
    lea dx, dropoffTitle    ; Display the title
    int 21h

    mov ah , 09h
    lea dx, destination1    ; Display drop-off 1
    int 21h
        
    mov ah , 09h
    lea dx , destination2   ; Display drop-off 2
    int 21h

    mov ah, 09h
    lea dx , destination3   ; Display drop-off 3
    int 21h

    mov ah , 09h
    lea dx , destination4   ; Display drop-off 4
    int 21h

    mov ah , 09h
    lea dx , destination5   ; Display drop-off 5
    int 21h

    mov ah , 09h
    lea dx , destination6   ; Display drop-off 6
    int 21h
        
    mov ah , 09h
    lea dx , dropoffPrompt
    int 21h

    mov ah , 01h            ; Please prepare I want to read a char
    int 21h
    sub al , 30h            ; Change it to integer

    cmp al , 1              ; If user doesn't enter (1-6) it shows an error message
    jl invaliddropoff
    cmp al , 6
    jg invaliddropoff

    mov dropoffChoice , al  ; Protect the input

;We also need to check if the dropoff choice is the same as pickup
;Need to load to register to only use cmp

    mov al , pickupChoice
    cmp al , dropoffChoice
    je invaliddestination

    mov pickupChoice , al   ; Move it back to the variable

    jmp destination

invaliddropoff:             ; Error message and loop back to get user input
    mov ah , 09h
    lea dx , invalid_dropoff
    int 21h
    jmp get_dropoff

invaliddestination:         ; Error message if user enters same destination for pickup and dropoff
    mov ah , 09h
    lea dx , invalid_destination
    int 21h
    jmp get_dropoff

destination:
        call clear_screen       ; Clear the screen and then display the chosen destinations
        int 10h

        mov ah , 09h
        lea dx , pickupchosen
        int 21h


        mov dl , pickupChoice
        add dl , 30h
        mov ah , 02h
        int 21h

        mov ah , 09h
        lea dx , dropoffchosen
        int 21h

        mov dl , dropoffChoice
        add dl , 30h
        mov ah , 02h
        int 21h

; Prompt for the quantity of tickets

        mov al , 0          ; Clear the al register just in case

get_ticketquantity:
    mov ah , 09h
    lea dx , quantityPrompt
    int 21h

; Read user input for quantity

    mov ah , 01h
    int 21h
    sub al , 30h            ; Change to integer
    

; Check if the quantity is valid (between 1 and 9)

    cmp al , 1
    jl invalidquantity
    cmp al , 9
    jg invalidquantity

    mov ticketQuantity, al      ; Protect the value
    jmp extrafeatures

    invalidquantity:

    mov ah , 09h
    lea dx, invalid_quantity    ; Display error message for invalid quantity
    int 21h

    jmp get_ticketquantity      ; Repeat the loop to get a valid quantity

extrafeatures:
;Code to display any extra features the user may input
    mov ah , 09h
    lea dx , features
    int 21h

    mov ah , 09h
    lea dx , snacks
    int 21h

    mov ah , 09h
    lea dx , beverages
    int 21h

    mov ah , 09h
    lea dx , entertainment
    int 21h

    mov ah , 09h
    lea dx , wifi
    int 21h

    mov ah , 09h
    lea dx , featuresprompt
    int 21h

    mov ah , 01h
    int 21h
    sub al , 30h                    ; Protect the input

    cmp al , 0
    je displayfeatures              ; Jump to displayfeatures if user enters 0
    cmp al , 1
    je addsnacks
    cmp al , 2
    je addbeverages
    cmp al , 3
    je addentertainment
    cmp al , 4
    je addwifi

    jmp invalidfeature

    addsnacks:
    or featuresChoice, 1            ; If user chooses snacks, the corresponding bit is set (bit 1)
    call clear_screen                   ; Clear screen and let user to choose anymore extra features
    int 10h
    mov ah , 09h
    lea dx , featuremessage
    int 21h
    jmp extrafeatures

    addbeverages:
    or featuresChoice, 2            ; If user chooses beverages, the corresponding bit is set (bit 2)
    call clear_screen                       ; Clear screen and let user to choose anymore extra features
    int 10h
    mov ah , 09h
    lea dx , featuremessage
    int 21h
    jmp extrafeatures

    addentertainment:
    or featuresChoice, 4            ; If user chooses entertainment, the corresponding bit is set (bit 3)
    call clear_screen                   ; Clear screen and let user to choose anymore extra features
    int 10h
    mov ah , 09h
    lea dx , featuremessage
    int 21h
    jmp extrafeatures

    addwifi:
    or featuresChoice, 8            ; If user chooses wifi, the corresponding bit is set (bit 4)
    call clear_screen                       ; Clear screen and let user to choose anymore extra features
    int 10h
    mov ah , 09h
    lea dx , featuremessage
    int 21h
    jmp extrafeatures

    invalidfeature:
    cmp al , 1
    jne validfeature                ; If true , jump to valid feature option that 
                                    ; repeats without showing invalid feature message
    call clear_screen                   ; Clear screen and let user to choose anymore extra features
    int 10h

    mov ah , 09h                    ; If it didn't jump , this error message will appear
    lea dx , invalid_feature
    int 21h
    jmp extrafeatures

    validfeature:                   ; If the jump occured it will just loop back as normal
    jmp extrafeatures

displayfeatures:
    jmp finaldisplay                ; Jump to final display

finaldisplay:
    call clear_screen                   ; Clear screen and summarize the user order
    int 10h 
        
    mov ah , 09h
    lea dx , pickupchosen
    int 21h

    mov dl , pickupChoice
    add dl , 30h
    mov ah , 02h
    int 21h

    mov ah , 09h
    lea dx , dropoffchosen
    int 21h

    mov dl , dropoffChoice
    add dl , 30h
    mov ah , 02h
    int 21h

    mov ah  , 09h
    lea dx , quantityPrompt
    int 21h

    mov dl , ticketQuantity
    add dl , 30h
    mov ah , 02h
    int 21h

    mov ah , 09h
    lea dx , chosenfeatures
    int 21h

    ; Check snacks
    mov ah , 0
    mov al , featuresChoice
    and al , 1    ; Check the least significant bit (snacks)
    cmp al , 1
    je snacks_chosen
    jmp beverages_check

snacks_chosen:
    mov ah , 09h
    lea dx , snacks
    int 21h
    jmp beverages_check

beverages_check:
    ; Check beverages (bit 1)
    mov ah , 0
    mov al , featuresChoice
    and al , 2    ; Check bit 1 (beverages)
    cmp al , 2
    je beverages_chosen
    jmp entertainment_check

beverages_chosen:
    mov ah , 09h
    lea dx , beverages
    int 21h
    jmp entertainment_check

entertainment_check:
    ; Check entertainment (bit 2)
    mov ah , 0
    mov al , featuresChoice
    and al , 4    ; Check bit 2 (entertainment)
    cmp al , 4
    je entertainment_chosen
    jmp wifi_check

entertainment_chosen:
    mov ah , 09h
    lea dx , entertainment
    int 21h
    jmp wifi_check

wifi_check:
    ; Check WiFi (bit 3)
    mov ah , 0
    mov al , featuresChoice
    and al , 8    ; Check bit 3 (WiFi)
    cmp al , 8
    je wifi_chosen
    jmp final

wifi_chosen:
    mov ah , 09h
    lea dx , wifi
    int 21h
    jmp final

final:
    mov ax , 4c00h
    int 21h


    main    endp
    clear_screen:
    mov ax,0b800h
    mov es,ax
    mov ax,0
    mov di,ax
    mov ax,160
    mov si,ax
    cld
    mov cx,24*80
    rep movsw
end main

我期望清晰的屏幕,然后转到下一个显示屏

assembly video-processing dosbox
1个回答
0
投票

我认为问题出在最后一部分。这会将字节从

ds:si
复制到
es:di
,从
ds:160
开始,并在内存中向上移动,因为方向标志已清除
cld

clear_screen:
    mov ax,0b800h
    mov es,ax
    mov ax,0
    mov di,ax
    mov ax,160
    mov si,ax
    cld
    mov cx,24*80
    rep movsw
© www.soinside.com 2019 - 2024. All rights reserved.