我正在尝试打印此分数以创建游戏,并且分数仅打印在一侧,(当我增加时分数,它仅在一侧打印分数,另一侧保持零。这是代码,谢谢。
proc print_score
; prints the points in the middle of the screen:
; set cursor to the middle:
mov dl, 170
mov dh, 45
mov bh, 0
mov ah, 02h
int 10h
; print scores, knowing it can be 0-9 (aka one char):
mov al, [Score1]
mov bl, 0Fh
mov bh, 0
mov ah, 0eh
add al, '0'
int 10h
; score1:score2
mov al, ':'
mov bl, 0Fh
mov bh, 0
mov ah, 0Eh
int 10h
mov al, [Score2]
mov bl, 0Fh
mov bh, 0
mov ah, 0eh
add al, '0'
int 10h
ret
endp print_score
proc check_goal
pusha
;如果玩家1得分高于玩家2,则得分check_goal_player1:cmp [ballX],315dja Goal_1
jmp check_goal_player2
目标_1:inc [score1]
call refrash
;call player_2_scored
jmp new_round
check_goal_player2:cmp [ballX],0djb目标_2
jmp no_update
goal_2:
inc [score2]
call refrash
;call player_1_scored
新回合:
call restore_ball_possition
jmp no_update
no_update:
popa
ret
endp check_goal
; prints the points in the middle of the screen: ; set cursor to the middle: mov dl, 170 mov dh, 45 mov bh, 0 mov ah, 02h int 10h
BIOS.SetCursor函数02h希望您为所需的光标位置传递字符单元格坐标。行上字符单元的数量不能超过255,并且行坐标使用相同的限制。如果您说您瞄准屏幕中间,并为列坐标传递170的值,那么您的屏幕将包含约340列!此BIOS调用无法实现。您在字符坐标和像素坐标之间感到困惑吗?
例如320x200 256色屏幕的中间具有光标坐标(20,12),因为只有40列和25行。
check_goal_player2: cmp [ballX],0d jb goal_2 jmp no_update goal_2: inc [score2]
将某个值与0进行比较时,您可以从不获取以下条件代码。因此,jb goal_2
指令将never跳转到您想增加score2的位置。
看到cmp [ballX], 315
ja goal_1
并考虑到对称性,我猜您正在使用320像素宽的屏幕。也许解决方法是写cmp [ballX], 4
jb goal_2
吗?