chibi-hime 0 Newbie Poster

Hi. I need help with the code for a fish race

The question I was given is as follows:

*You are asked to design a “Fish Race” game. Two fishes of different colors and shapes will race until one of them reaches the race’s end line. Your program should display a message at the end of the race showing which fish has won the race. To win the race, three fishes from the same type should reach the end line. When one of the fishes reaches the end line, another fish from the same type and color of the winning fish starts moving again towards the end line. Your program should display two counters at the top of the screen showing how many fishes have currently reached the end of line.
Note that each fish will be on a separate row (line) and each fish will move horizontally in random steps (each random step can only be between 1 and 4 steps).
*

My problem is that the fish aren't moving towards the finish line. Only the first fish moves and that too just one step.
Before one fish atleast was able to cross the finish line but then my VS crashed while I was making changes to the code and I can't figure out what I changed.
So below is the code. I hope somebody can help me please

INCLUDE Irvine32.inc

.data
headerRow BYTE 77 DUP ('-'), 0
Fishr BYTE "x=@",0
Fishy BYTE ">=>",0
Redfish BYTE "red = ",0
Yellowfish BYTE "yellow = ",0
countY DWORD 0 
countR DWORD 0  

.code

main PROC
    call Randomize
    call RepeatDesign

;Displaying yellow fish
    mov eax, 10011110b ;store the color in eax 
    call setTextcolor ;to make the foreground yellow and the background blue
    xor edx, edx    ; clearing edx
    mov dl, 0 
    mov dh, 12
    call Gotoxy 
    mov edx, OFFSET Fishy  ;store the address of fishy in edx to display it    
    call WriteString  ;display string
    call Crlf

;Displaying red fish
    xor edx, edx
    mov dl, 0 
    mov dh, 15
    mov ecx, edx    ; copying position of red fish to ecx
    push ecx        ; storing position of red fish in stack
    call Gotoxy 
    mov eax, 10010100b 
    call SetTextcolor ;to make the foreground red and the background blue
    mov edx, OFFSET Fishr
    call WriteString 
    call CRLF

;Moving fish 
;Fish moves randomly 1 to 4 steps

;StepY => steps for moving yellow fish
StepY: 
    mov eax, 1000
    call Delay
    call RepeatDesign

    mov eax, 4 
    call RandomRange ;chooses a random number from 0 to 3
    inc al  ; in-case RandomRange returned 0 so that fish always moves at least 1 step

;compare the value in dl with 78 
;if = or above bec. unsigned number then it means that the yellow fish reached the end line
;else move yellow fish
    xor edx, edx
    mov dl, bl 
    cmp dl, 4Eh
    jae YDone
    add dl, al 
    mov dh, 12 
    call Gotoxy
    mov eax, 10011110b 
    call setTextcolor
    mov ebx, edx    ; store position of yellow fish in ebx
    mov edx, OFFSET Fishy
    call WriteString
    pop ecx
    mov edx, ecx    ; restore position of red fish
    push ecx
    call GoToXY
    mov eax, 10010100b 
    call SetTextcolor ;to make the foreground red and the background blue
    mov edx, OFFSET Fishr
    call WriteString
    jmp StepR
YDone:
    mov eax, countY
    inc eax
    mov dh, 0
    mov dl, 61
    call GoToXY
    call WriteInt

; check #of wins of yellow fish
; if yellow fish has won 3 times then game ends
; else yellow fish begins racing again
    cmp countY, 3
    je Done
    mov eax, 10011110b 
    call setTextcolor
    mov dl, 0
    mov dh, 12
    call GoToXY
    mov edx, OFFSET Fishy
    call WriteString

; StepR => steps for moving red fish
StepR: 
    mov eax, 4 
    call RandomRange ;chooses a random number from 0 to 3
    inc al  ; in-case RandomRange returned 0 so that fish always moves at least 1 step

;compare the value in dl with 78 
;if = or above bec. unsigned number then it means that the red fish reached the end line
;else move red fish
    pop ecx
    mov ecx, edx
    cmp dl, 4Eh
    jae RDone
    add dl, al ; add the random number to the position of red fish so it can move that many steps
;   mov dh, 15
    call Gotoxy
    mov ecx, edx    ; store position of red fish in ecx
    push ecx
    mov eax, 10010100b 
    call setTextcolor
    mov edx, OFFSET Fishr
    call WriteString
    mov edx, ebx    ; restore position of yellow fish
    call GoToXY
    mov eax, 10011110b 
    call SetTextcolor ;to make the foreground yellow and the background blue
    mov edx, OFFSET Fishy
    call WriteString
    jmp StepY
RDone:
    mov eax, countR
    inc eax
    mov dh, 0
    mov dl, 16
    call GoToXY
    call WriteInt

; check #of wins of red fish
; if red fish has won 3 times then game ends
; else red fish begins racing again
    cmp countR, 3
;   je Done
    mov dl, 0
    mov dh, 16
    call GoToXY
    mov eax, 10010100b 
    call setTextcolor
    mov edx, OFFSET Fishr
    call WriteString

Done:
    mov dl, 0
    mov dh, 24
    call GoToXY
    mov ax, 10011111b
    call setTextColor
    exit
main ENDP

RepeatDesign PROC
    call Clrscr
; setting the bg to light blue
    mov eax, 10011111b ;store the color in eax 
    call setTextcolor ;to make the background light blue
    call Clrscr ;clear screen to make all the screen light blue

;displaying Redfish and countR in red and keeping bg color light blue
    mov eax, 10010100b ;store the color in eax 
    call SetTextcolor ;to make the fore-ground red and the background blue
    mov dh, 0
    mov dl, 10
    call GoToXY
    mov edx, OFFSET Redfish   ;store the address of Redfish in edx
    call WriteString ;Display string
    mov eax, countR
    mov dh, 0
    mov dl, 16
    call GoToXY
    call WriteInt

; displaying Yellowfish and countY in yellow and keeping bg light blue
    mov eax, 10011110b ;store the color in eax
    call setTextcolor ;to make the foreground yellow and the background blue
    mov dh, 0
    mov dl, 52
    call GoToXY
    mov edx, OFFSET Yellowfish  ;store the address of the yellowfish variable in edx
    call WriteString ;display string
    mov eax, countY
    mov dh, 0
    mov dl, 61
    call GoToXY
    call WriteInt

    call CRLF ;for a new line

;displaying the dashed horizontal line in green and keeping bg light blue
    mov eax, lightgreen + (lightblue*16)
    call SetTextColor
    mov dh,1 ;store two in dh it means go to row third 
    mov dl,0 ;store zero in dl it means go to column 0
    call Gotoxy ;locate cursor
    mov edx, OFFSET headerRow
    call WriteString
    call CRLF

;displaying the dashed vertical line 
    mov dl,77 ;store 77 in dl it means go to column 77
    mov dh,0 ;;store zero in dh it means go to row 0
    call Gotoxy ;locate cursor
    mov al, '|'
    call WriteChar ;display character
    mov ecx, 24 ;the loop will start from row 0 until row 24
    Label2:   ;second label
    inc dh ;increment dh registor (increment the row)
    mov dl,77 ;store 77 in dl (column will stay the same)
    call Gotoxy ;locate cursor
    mov al, '|'
    call WriteChar ;display character
    LOOP Label2 ;the loop ends
    call crlf

;displaying END spelled vertically
    mov dl, 78 ;store 78 in dl registor go to column number 78
    mov dh, 11 ;store 12 in dh registor go to row number 11 
    call Gotoxy ;locate cursor
    mov al, 'E' ;store the E character in al to display it 
    call WriteChar ;display character
    mov dl, 78 
    mov dh, 13 
    call Gotoxy ;locate cursor
    mov al, 'N'
    call WriteChar ;display character
    mov dl, 78 
    mov dh, 15 
    call Gotoxy 
    mov al, 'D'
    call WriteChar 
    call Crlf  ;new line
ret
RepeatDesign ENDP

END main

Also, I've attached my current output window. Again, somebody please help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.