org 0x7c00
jmp _main
; _data:
playerPosition dw 0
; %1 == coluna (x)
; %2 == linha (y)
%macro drawRacket 2
mov ah, 0ch ; print pixels mode
mov dx, %2
for1:
mov bx, 32 ;racket height
add bx, %2
cmp dx, bx ; racket end (row)
je .fim1
mov cx, %1 ; racket beggining (column)
jmp .for2
jmp for1
.fim1:
jmp mainLoop
; loop to draw each line
.for2:
mov bx, 8 ;racket width
add bx, %1
cmp cx, bx ;
je .fim2
mov al, 0x0f
mov ah, 0ch
int 10h
inc cx
jmp .for2
.fim2:
inc dx
jmp for1
%endmacro
_main:
;
xor ax, ax
mov ds, ax
mov cx, ax
mov dx, ax
call setVideoMode
;racket initial position
mov word[playerPosition], 10
mainLoop:
mov ah, 01h
int 16h
cmp al, 115
je moveDown
jmp mainLoop
jmp $
;
setVideoMode:
mov ah, 0 ;
mov al, 13h ;
int 10h
ret
moveDown:
drawRacket 10, word[playerPosition]
mov ax, word[playerPosition]
inc ax
mov word[playerPosition], ax
jmp mainLoop
times 510-($-$$) db 0
dw 0xaa55
That's the assembly code. I am trying to make a "Pong game", and I am at the very beggining. I was trying to draw the 1st player's racket, but it is not working. When I press "s" (mainLoop function) on the keyboard, it actually works and jumps to the macro drawRacket and draws it. But, if I press "s" again nothing works.. I already tried to change a lot of things on the mainLoop function but nothing works, what makes me think that I have some problems with the macro drawRacket. I would appreciate any hints or answers.