i want to make a start screen for my game and an end screen. when i start it shows my start screen for a second and than immidiately changes to the lose screen, the button are still working to start the game but it just showing the lose screen. if the apple touches the floor it should go to the lose screen(proc GamePlay). the start screen is called in the start section(call Startscreen)and whatPress is for the play button.(theres a few more things that dont work in the code but this is my main concern right now)
IDEAL
MODEL small
STACK 100h
P186
;————————————
include “Display.asm”
DATASEG
checkcolor db ?
ballspeed dw 05FFFh;0-0FFFF|0-faster FFFF-slower
x0 dw 163
y0 dw 187
x dw 163
y dw 187
xgreen dw 190
ygreen dw 190
color db 15 ; 15 = white 5 = pink
w dw 17 ; width of the rectangle
h dw 9 ; height of the rectangle
;===============
floorh dw 4
floorw dw 320
floorx0 dw 0
floory dw 197
floorx dw 0
floorcolor db 33
;==============
blackcolor db 0
appleh dw 6
applew dw 5
applex0 dw ?
appley dw 5
applex dw ?
applecolor db 4
;=================
ten db 10
RandomNumber db 0
;================
startcolor db 0
num0 Bitmap {ImagePath=”num0.bmp”}
num2 Bitmap {ImagePath=”num2.bmp”}
;————-
mousePress db 0;0=nothing preseed, 1= white pressed(15), 2 rules pressed (5)
appleHit db 0 ; 0 = no hit, 1 = hit the paddle, 2 = hit the floor
keyboardStatus db 0
Hero db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,255,255,255,255,255,255,255,255,255,255,255,255,255,00,00
db 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
;—————————
apple db 00,00,00,00,00
db 14,14,14,14,14
db 14,14,14,14,14
db 14,14,14,14,14
db 14,14,14,14,14
db 14,14,14,14,14
;—————————
appleblack db 00,00,00,00,00
db 00,00,00,00,00
db 00,00,00,00,00
db 00,00,00,00,00
db 00,00,00,00,00
db 00,00,00,00,00
;—————————-
CODESEG
;———————————–
proc clean
pusha
mov cx, 64000 ; 320×200 pixels / 2 bytes per pixel
xor al, al ; Color to fill (black)
rep stosb ; Fill video memory with AL (black)
popa
ret
endp clean
;——————-
proc Startscreen
pusha
mov ax, 2h
int 33h
mov si, offset num0
display_BMP si,0,0 ; 0,0 מיקום התמונה x y
mov ax, 1h
int 33h
popa
endp Startscreen
proc LoseScreen
pusha
mov ax, 2h
int 33h
mov si, offset num2
display_BMP si,0,0 ; 0,0 מיקום התמונה x y
mov ax, 1h
int 33h
popa
endp LoseScreen
;————————————
proc delay
pusha
mov cx, 1h
mov dx, 10h ; [ballspeed]
mov al,0
mov ah,86h
int 15h
popa
ret
endp delay
;=============================
proc printHero
pusha
mov si, offset Hero
mov cx, [h]
printCol:
push cx
push [x]
mov cx, [w]
printRow:
mov dl, [byte ptr si]
mov [color], dl
call one_dot
inc [x]
inc si
loop printRow
inc [y]
pop [x]
pop cx
loop printCol
popa
ret
endp printHero
;——
proc printApple
pusha
mov si, offset apple
mov cx, [appleh]
applePrintCol:
push cx
push [applex]
mov cx, [applew]
applePrintRow:
mov dl, [byte ptr si]
mov [applecolor], dl
call apple_dot
inc [applex]
inc si
loop applePrintRow
inc [appley]
pop [applex]
pop cx
loop applePrintCol
popa
ret
endp printApple
;——–
proc printBlackApple
pusha
mov si, offset appleblack
mov cx, [appleh]
blackapplePrintCol:
push cx
push [applex]
mov cx, [applew]
blackapplePrintRow:
mov dl, [byte ptr si]
mov [blackcolor], dl
call apple_dot
inc [applex]
inc si
loop blackapplePrintRow
inc [appley]
pop [applex]
pop cx
loop blackapplePrintCol
popa
ret
endp printBlackApple
;——–
proc one_dot
pusha
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
mov ah,0ch
int 10h
popa
ret
endp one_dot
;=====================
proc floor_rec
pusha
mov cx,[floorh] ; גובה המלבן
rectangle:
push cx
mov cx, [floorw] ; רוחב המלבן
mov dx, [floorx0] ; מיקום התחלתי
mov [floorx] , dx
call one_line
inc [floory]
pop cx
loop rectangle
popa
ret
;drawLine:
; push cx
; call floor_dot
endp floor_rec
;——————————-
proc floor_dot
pusha
mov bh,0h
mov cx,[floorx]
mov dx,[floory]
mov al,[floorcolor]
mov ah,0ch
int 10h
popa
ret
endp floor_dot
;———————–
proc one_line
pusha
Line:
push cx
call floor_dot
inc [floorx]
pop cx
loop Line
popa
ret
endp one_line
;===================
proc apple_rec
pusha
mov cx,[appleh] ; גובה המלבן
applerec:
push cx
mov cx, [applew] ; רוחב המלבן
mov dx, [applex0] ; מיקום התחלתי
mov [applex] , dx
call apple_line
inc [appley]
pop cx
loop applerec
popa
ret
endp apple_rec
;——————————
proc apple_dot
pusha
mov bh,0h
mov cx,[applex]
mov dx,[appley]
mov al,[applecolor]
mov ah,0ch
int 10h
popa
ret
endp apple_dot
;———————
proc apple_line
pusha
AppleLine:
push cx
call apple_dot
inc [applex]
pop cx
loop AppleLine
popa
ret
endp apple_line
;————————-
proc randomApplex
pusha
mov bx,100
mov ax, 40h
mov es, ax
mov ax, [es: 6Ch]
xor ax, [bx]
and ax, 000Fh
mov [applex],ax
popa
ret
endP RandomApplex
;———————
;===================
;——————————
;==========================
;==========================
proc setUpMagicNumbers
pusha
call randomApplex
popa
ret
endp setUpMagicNumbers
;==========================
proc checkHit
pusha
mov cx,[applex]
mov dx,[appley]
add dx, 5
;
mov bh,0h
mov ah,0Dh
int 10h
cmp al,[floorcolor]
je floorHit
cmp al, 255
je boardHit
jmp noHit
floorHit:
mov [appleHit], 2
jmp noHit
boardHit:
mov [appleHit], 1
noHit:
popa
ret
endp checkHit
;==========================
proc reactKeyboardInput
pusha
; Wait for key press
mov ah,01h
int 16h
cmp al,27 ; ESC
je escPress
mov [keyboardStatus], 0 ; esc wasnt pressed
jmp escNPress
escPress:
mov [keyboardStatus], 1 ; esc was pressed
escNPress:
cmp ah, 75 ; Left
jne skip1
dec [x]
skip1:
cmp ah, 77 ; Right
jne skip2
inc [x]
skip2:
push [y0]
pop [y]
xor ax, ax ; מנקה את הבאפר במידה והייתה לחיצה על מקש ה אסקייפ במקלדת
mov ah, 0ch
xor al, al
int 21h
popa
ret
endp reactKeyboardInput
;==========================
proc appleWasHit
pusha
mov ax, 10
popa
ret
endp appleWasHit
;==========================
proc lowerApple
pusha
mov ax, [appley]
sub ax, [appleh]
mov [appley], ax
inc [appley]
popa
ret
endp lowerApple
;==========================
proc resetApple
pusha
mov [appley],5
call randomApplex
popa
ret
endp resetApple
;==========================
proc Lose
pusha
call clean
call LoseScreen
mov ax,00
int 33h
mov ax,01
int 33h
waitforpress2:
;call Esc_end
mov ax, 3
int 33h
cmp cx, 418
jb waitforpress2
cmp cx, 622
ja waitforpress2
cmp dx, 23
jb waitforpress2
cmp dx, 121
ja waitforpress2
cmp bx, 1h
je startt2
jmp waitforpress2
startt2:
mov ax,02
int 33h
call clean
call whatPress
popa
endp Lose
;=========================
proc MousePressChange
pusha
waitMS:
mov ax,3h
int 33h
cmp bx,01h
jne waitMS
popa
ret
endp MousePressChange
;===========
proc whatPress
pusha
mov ax,00
int 33h
mov ax,01
int 33h
waitforpress:
;call Esc_end
mov ax, 3
int 33h
cmp cx, 112
jb waitforpress
cmp cx, 452
ja waitforpress
cmp dx, 81
jb waitforpress
cmp dx, 153
ja waitforpress
cmp bx, 1h
je startt
jmp waitforpress
startt:
mov ax,02
int 33h
call clean
call GamePlay
endp whatPress
;============================
;================
proc GamePlay
pusha
call setUpMagicNumbers
call floor_rec
call printHero
again:
call reactKeyboardInput
call printApple
call lowerApple
call printHero
call delay
call checkHit
mov al, [appleHit]
cmp al, 0
je appleWasntHit
cmp al, 1
je appleHeroHit
cmp al, 2
je appleHitFloor
appleWasntHit:
jmp again
appleHeroHit:
call resetApple
mov [appleHit],0
jmp again
appleHitFloor:
call Lose
popa
endp GamePlay
START:
mov ax, @data
mov ds, ax
; Graphic mode
mov ax, 13h
int 10h
;===================
call Startscreen
call whatPress
;=================
;===========
; Return to text mode
mov ah, 0
mov al, 2
int 10h
exit:
mov ax, 4c00h
int 21h
END start
at start i just called the lose screen and it didnt work then i tried putting it in a proc and it still didnt work i really dont know why it shows both of the screens together.
steven FM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1