I am trying to move a 6x6 pixel object in 8086 assembly, but with no luck. I would like it to move 4 pixels a second, but currently it isn't moving at all.
I would be very glad if someone could help me, because it is a for a substantial project for my computer studies finals in high school and I have got until the end of the weekend
Here is the code itself
IDEAL
MODEL medium
DATASEG
STACK 100h
segment extra para public use16 ;Create Extra Segment that is 16 bits;
;(Removed the data segment for your sake, its very long pixel lists)
CODESEG
; -------------------------------
; change screen mode to text mode
; -------------------------------
proc DrawPix
ContLines:
mov cx, [LineLength] ; How many times should the "rep movsb" should iterate
push di ; Save in stack the calculated position indicating the begining of the current line
rep movsb ; copies bytes from si(image) to di (screen)
pop di ; di was changed during the movesb. I change it back to pint to the begin of the line
add di, ScreenWidth ; by adding ScreenWidth (320)' I am moving the di to point to the next line
dec [NumOfLines] ; Check if I wrote all the lines of the image
jnz ContLines ; IF there are still pixcells to print on the screen(image not ended), loop to next line
ret
endp
proc keycontrol
;check for arrow keys, and go to check arrow removed;
jmp Shoot
checkarrow:
removed, irrelevant (supposed to change direction of turret)
Exit:
ret
endp
proc Shoot
cmp [turretstate],1 ;turret facing up
je bulletup
cmp [turretstate],2;turret facing down
je bulletdown
cmp [turretstate],3;turret facing left
je bulletleft
cmp [turretstate],4;turret facing right
je bulletright
ret
bulletup:
not relevant for testing left movement
bulletdown:
not relevant for testing left movement
bulletright:
not relevant for testing left movement
bulletleft:
mov di,320*87+133
lea si, [bullet]
mov [LineLength],6
mov [numOFLines],6
call DrawPix
ret
endp
proc leftbull
pop dx
dec dx
mov di,320*84
add di,dx
lea si, [bullet]
mov [LineLength],6
mov [NumOfLines],6
call DrawPix
ret
endp
proc progbullets
mov dx,0
checkleft:
inc dx
cmp dx,136
je exit1
mov cx,87
mov ah,0Dh
int 10h
cmp al,4
jne checkleft
push dx
call leftbull
exit1:
ret
endp
;---------------------------------------------;
;---------------------------------------------;
start:
Main_Loop:
mov [sectimer], 0
mov ah,00H
int 1Ah
mov [sectimer],dx
call keycontrol
func_Loop:
call progbullets
mov ah,00H
int 1Ah
sub dx,18
cmp dx,[sectimer]
jge Main_Loop
;call moveGame
jmp func_Loop
; call the operating system to terminate this program
mov ah,1
int 21h
mov ax, 4C00H
int 21h
ends
end start
The program has a starting screen, can move the turret around, and place the "bullets", but I wasn't able to make them move and it also has some odd pixels here and there. The Shoot proc is the main concern, it is supposed to go one by one on the x value (the bullet stays on the same y value), and check if the pixel is red (bullet color), and if so move it one left.
EDIT: Thanks so much for the help, I am new here and really need it. I don't have a proper debugger for gui tasm which is the system I am using, so I wasent able to do that I removed most of the unecessary stuff, but wasen't sure what else isn't necessary, since I am not sure what is the thing that dosen't work. I guess the "shoot" proc is the most relevant. The shoot only works for the left bullet, because I wanted to test it first, but it didnt work for that either