I need to make a small game in assembly for school. For now, I just have a green rectangle that moves on the screen inside a white outline. The thing is, I want to draw a heart on the screen (using a function that paints 1's in a mat) but if I draw the heart I can't move the rectangle. Can anyone please help me? (Also, I am new to the site so sorry for making all of this question messy.)
The code: by using this mat:
heart db 1,1,0,1,1
db 1,1,0,1,1
db 0,1,1,1,0
db 0,0,1,0,0
And this function:
proc Sprite_Figure
push bp
mov bp, sp
push ax
push bx
push cx
push dx
push si
push es
push di
mov ax, 0a000h
mov es, ax
xor ax, ax
sub [byte ptr bp+6], 7
sub [byte ptr bp+8], 8 ; result is 8 up and 7 left. Given cord is middle of the card
mov di, [bp+6]
mov si, [bp+4] ; sprite offset
mov cx, [bp+14] ; number of lines
loop1:
mov dx, [bp+12] ; size of one line
loop2:
push dx
xor dx, dx
cmp [byte ptr si], 0
je continue
print:
mov bx, [bp+8] ; current row
mov ax, 320
mul bx
mov bx, ax ; calculation to get location of pixel on screen
add bx, [bp+6] ; x
mov ax, [bp+10] ; color
mov [es:bx], al ; color location, es val is 0A000h
continue:
pop dx
inc si ; next element in array
dec dx
inc [byte ptr bp+6] ; right by one
cmp dx, 0
jne loop2
inc [byte ptr bp+8] ; one line down
mov [bp+6], di ; reset x
dec cx
cmp cx, 0
jne loop1
pop di
pop es
pop si
pop dx
pop cx
pop bx
pop ax
pop bp
ret 12
endp Sprite_Figure
I make the heart.
In order to make the cube, I use this code:
proc DisplayDot
mov al, [color]
mov bl, 0
mov cx, [x]
mov dx, [y]
mov ah, 0Ch
int 10h
ret
endp DisplayDot
proc DisplayLine
mov cx, [startX]
mov [x], cx
DisplayDotLoop:
call DisplayDot
inc [x]
mov cx, [endX]
inc cx
cmp [x], cx
jne DisplayDotLoop
ret
endp DisplayLine
proc DisplayRect
mov dx, [startY]
mov [y], dx
DisplayLineLoop:
call DisplayLine
inc [y]
mov dx, [endY]
inc dx
cmp [y], dx
jne DisplayLineLoop
ret
endp DisplayRect
And this is one of the four move procedures for the cube:
proc MoveUp
cmp [startY], 15
je EndMoveUp
mov [color], 0
call DisplayRect
sub [startY], 10
sub [endY], 10
mov [color], 0Ah
call DisplayRect
EndMoveUp:
ret
endp MoveUp