الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Pacman بلغة الاسمبلي

مغلق
بدأه درب الهدى في 30 ديسمبر 2007 · 7 رد · 2,486 مشاهدة · في لغة Assembly لأنظمة 16, 32, 64 بت
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله

اخواني لو سمحتوا بدي مساعدة في

عمل كود للعبة ال

pacman

بلغة الاسمبلي

لاني مبتدئة باللغة وتقريبا ما بعرف شي

:وهذا هو المطلوب بالضبط

اقتباس

Write a simple Pacman like game using x86 assembly language. Choose one ASCII character(C for example) to take the pcaman role. Using the arrows key you are required to move the pacman character right, left, up, and down. The pacman is supposed to keep moving in a reasonable configured speed in any direction. Draw a black bordered box on the screen with the size 15 rows and 40 cols. This will be the space that the pacman will move on.

Randomly place dots on the screen and when pacman move over these points add 1 point to the points shown on the right-bottom corner of the screen.

"الشكل مرفق"

شكرا جزيلا

والله يجزيكم كل خير

post-133653-1199002170_thumb.jpg

#2

وعليكم السلام ورحمة الله ,

مانوع المساعدة التي تريدنها ,,,

بالنسبة لفكرة اللعبة فهي سهلة .

- اذا كانت احداثيات pacman == احداثيات اي نقطة .. زودي العداد بمقدار واحد .

- اذا أردتي تحريك اللاعب لاي جهة .. اعملي كذا

x = x + 1 الاحداثي السيني
y= y +  1 الصادي

او اي قيمة مناسبة

هل المشكلة في فكرة اللعبة .. او في الاسمبلي ...؟

اعطينا المحاولة عشان نعرف نكمل عليها .. فانا لم اتعلم حتى الان اعمل لعبة بواجهة نصية

Text-Based Game

logo1.png تطبيق طمأنينة ، نسخة بيتا على أندرويد

عبدالله الشمّري - Al-Shammari

CodingAlone.com

twitter @abshammeri

abshammeri AT gmail.com

github : abshammeri

#3

السلام عليكم

شكرا الك اخي

المشكلة بالاسمبلي

ما بعرف اترجم افكاري باللغة لان معرفتي

باللغة شبه عدم

فكرة اللعبة بسيطة وبدائية

فقط المطلوب

حرف C

يتحرك عن طريق الاسهم من المستخدم

ونقاط عشوائية

لما يوصل لها الحرف تختفي

ويزيد العداد كل ما اختفت نقطة

و

timer

لحساب الزمن

وشكرا الك مرة اخرى

#4

اذا سأنقل الموضوع الى قسم الاسمبلي .. ممكن تجدي مساعدة هنا ...

logo1.png تطبيق طمأنينة ، نسخة بيتا على أندرويد

عبدالله الشمّري - Al-Shammari

CodingAlone.com

twitter @abshammeri

abshammeri AT gmail.com

github : abshammeri

#6

شكرا كتير غلبتكم

بس هون مكتوبة بالfasm

وانا بدي اياها tasm

والفكرة ابسط بكتير من الموجودة باللعبة

متل ما سبق وذكرت

يعطيكم الف عافية

#7

السلام عليكم

الكود المطلوب باستخدام Tasm :


.STACK 1000
.DATA
gname db "****PACMAN GAME**** $"
line db "______________________________________$"
instruct_1 db "1-use arrow keys$"
instruct_2 db "2- s:to start game$"
instruct_3 db "3- esc :to finish$"
instruct_4 db "Thank You For Playing$"
instruct_5 db "press 'esc' to exit$"
systemtime db "time$"
sensor db 30h
Scoremsg DB "Score:000 $"
holdscore db 30h,30h,30h
timemsg db "Time:$"

sms dw ?
p1 db ?
p2 db ?
char db ?

time db 30h,30h,3ah,30h,30h,"$"
vla db 03
vlb db 14
vlc db 07
vld db 30
vle db 03
vlf db 24
;score array for each row in the game
scorearray_1 db 40 dup (3)
scorearray_2 db 40 dup (3)
scorearray_3 db 40 dup (3)
scorearray_4 db 40 dup (3)
scorearray_5 db 40 dup (3)
scorearray_6 db 40 dup (3)
scorearray_7 db 40 dup (3)
scorearray_8 db 40 dup (3)
scorearray_9 db 40 dup (3)
scorearray_10 db 40 dup (3)
scorearray_11 db 40 dup (3)
scorearray_12 db 40 dup (3)
scorearray_13 db 40 dup (3)
scorearray_14 db 40 dup (3)
scorearray_15 db 40 dup (3)
player_score dw 0
max_score dw 599
hold db ?
boxscore db 30h,30h,30h,"$"
del db 10h


.code
.386
.startup
call clear
mov p1,7 ;row #
mov p2,30 ; column #
mov sms ,offset gname ;lood the message to print
call cout ;print procedure

mov p1,9 ;row #
mov p2,20 ; column #
mov sms,offset line
call cout

mov p1,15
mov p2,33
mov sms, offset instruct_1
call cout

mov p1,17
mov p2,33
mov sms,offset instruct_2
call cout

mov p1,19
mov p2,33
mov sms,offset instruct_3
call cout

soresc:
call input ;entr char procedure
cmp char ,73h ;if 'S' start game
je start
cmp char ,53h ;if 's' start game
je start
cmp char ,27 ;if 'esq' quit game
je endpro ;end program
jmp soresc

START:

call clear ;clear screan proc
;print score msg
mov p1,15 ;row #
mov p2,64 ; column #
mov sms,offset scoremsg
call cout
;print time msg
mov p1,16 ;row #
mov p2,65 ; column #
mov sms,offset timemsg
call cout
;here we want to draw borders of our game
MOV AX, 0600H
MOV BH, 33h
MOV CH, 2
MOV CL, 13
MOV DH, 18
MOV DL, 54
INT 10H
MOV AX, 0600H
MOV BH, 00Fh
MOV CH, 3
MOV CL, 14
MOV DH, 17
MOV DL, 53
INT 10H
mov ah,2
mov dh,[vla]
mov dl,[vlb]
mov bh,0 ;page #
int 10h ;call interupt

mov dl,2eh ;asci of pacman
mov cx ,0

;;here we wanna fill the game with dots in those two loops
myloopa:

inc cl
cmp cl, 41;# of dots per colmn
je myloopb
mov ah,2 ;set the curser position
mov dh,[vla] ;by using row
mov dl,[vlb] ;and column
mov bh,0 ;set the page 0
int 10h ;mov the curser
mov dl,02Eh
mov ah,06h
int 21h
add [vlb],1h
jmp myloopa

myloopb:
inc ch
sub cl,cl
add [vla],1h
mov [vlb],14
cmp ch,15
je pacmansta
jmp myloopa

;here we wanna start the game by setting the pacman at a position
;and taking the movement from the player
pacmansta:
call displaypac;setpacman position
mov si,16
mov [scorearray_5+si],2;to delete the point at the pacman place
moveit:
call pacmanst
jmp moveit


endpro:
mov AX,4c00h
int 21h
;________________________________________________________________________
;place to identefy proceduras
clear proc near
mov ax,0600h ;request clear screen
mov BH ,4Eh ;white bage with iue text
mov cx,0000h
mov dx,184fh
int 10h
ret
clear endp
;------------------------------------------------------------------------
cout proc near
mov ah,2
mov dh,p1
mov dl,p2
mov bh,0
int 10H
MOV DX,[SMS] ;set msg to be print
MOV AH, 9H ;request the print service
INT 21H ;call interrupt
ret
cout endp
;-----------------------------------------------------------------------
;input procedure to getacharacter from the user
input proc near
input8: mov ah,06
mov dl,0ffh
int 21h
jz input8
mov char,al
ret
input endp
;----------------------------------------------------------------------
pacmanst proc near

startpacman:
;get pacman move and go to its fuction plus show the time>
call timing
mov dl,0ffh
mov ah,06h
int 21h
jz startpacman ;get a char
cmp al,72 ;up to go up
je up
cmp al ,50h ;down to go down
je down
cmp al, 4dh ;right to go right
je right
cmp al,4bh ;left to go left
je left
cmp al ,1bh ;esc to end pro
je endpro
jmp startpacman


up:
call goup ;going up
ret
down:
call godn ;going down
ret
right:
call gort ;going right
ret
left:
call golt ;going left
ret
pacmanst endp
;----------------------------------------------------------------------
;go up procedure
goup proc near
call dissplay ;clear the place by space
sub[vlc],1h ;mov position to up
cmp [vlc],3 ;see if it is in boundaries or not
jl chekup ;if not go back to the previouse position
call displaypac ;if yeas then put pacman in the new position
call process_position;get the value of that position (the points if set or not)
cmp hold,3 ;if they are not set then there is no score and means no increase in the score
jne finish
call p_score ;if yes then increase score put that this place is visited
finish:
ret
chekup: ;here is the returning to old position
add[vlc],1h
call displaypac
ret
goup endp
;----------------------------------------------------------------------
;go down procedure
godn proc near
call dissplay ;clear the place by space
add[vlc],1h ;mov position to down
cmp [vlc],17 ;see if it is in boundaries or not
jg chekdn ;if not go back to the previouse position
call displaypac ;if yeas then put pacman in the new position
call process_position;get the value of that position (the points if set or not)
cmp hold,3 ;if they are not set then there is no score and means no increase in the score
jne finish1
call p_score ;if yes then increase score put that this place is visited
finish1:
ret
chekdn: ;here is the returning to old position
sub[vlc],1h
call displaypac
ret
godn endp
;----------------------------------------------------------------------
;go right procedure
gort proc near
call dissplay ;clear the place by space
add[vld],1h ;mov position to right
cmp [vld],53 ;see if it is in boundaries or not
jg chekrt ;if not go back to the previouse position
call displaypac ;if yeas then put pacman in the new position
call process_position;get the value of that position (the points if set or not)
cmp hold,3 ;if they are not set then there is no score and means no increase in the score
jne finish2
call p_score ;if yes then increase score put that this place is visited
finish2:
ret
chekrt: ;here is the returning to old position
sub[vld],1h
call displaypac
ret
gort endp
;------------------------------------------------------------------------
;go left procedure
golt proc near
call dissplay ;clear the place by space
sub[vld],1h ;mov position to left
cmp [vld],14 ;see if it is in boundaries or not
jl cheklt ;if not go back to the previouse position
call displaypac ;if yeas then put pacman in the new position
call process_position;get the value of that position (the points if set or not)
cmp hold,3 ;if they are not set then there is no score and means no increase in the score
jne finish3
call p_score ;if yes then increase score put that this place is visited
finish3:
ret
cheklt: ;here is the returning to old position
add[vld],1h
call displaypac
ret
golt endp

;----------------------------------------------------------------------
;clear position procedure
dissplay proc near
;setting the cursor
mov dh,[vlc]
mov dl,[vld]
mov ah,2
mov bh,0
int 10h
;putting ' ' to removeand clear the position
mov dl,20h
mov ah,06h
int 21h
ret
dissplay endp
;----------------------------------------------------------------------
;diplaying pacman face procedure
displaypac proc near
;set the position
mov dh,[vlc]
mov dl, [vld]
mov ah ,2
mov bh,0
int 10h
;print the pacman face
mov dl,1
mov ah,06h
int 21h
ret
displaypac endp
;-------------------------------------------------------------------------
;add score procedure
p_score proc near
MOV DI,3
incProcess:
DEC DI
CMP [boxscore+DI],'9' ;chking the last number if it is 9
JE putzero ;we wanna put zero and increase the other digit
JMP incrementscore ;if not increase it
putzero:
MOV [boxscore+DI],'0' ;PUTTING ZERO
JMP incProcess ;return to add the fisrt digit
incrementscore:
INC [boxscore+DI] ;here we increase the score
mov p1,15 ;and here we print it
mov p2,70
mov sms,offset boxscore
call cout
inc player_score ;inreasing the player score -it is a flag to nd the game-
mov dx,player_score
cmp max_score,dx ;chking if it is finished or not
je levelComplete ;if finish then finish it
RET
levelComplete:
;view the ending game messegs
mov p1,22
mov p2,30
mov sms,offset instruct_4
call cout
mov p1,23
mov p2,30
mov sms,offset instruct_5
call cout
;wait 'esc' to end the game
finish_it:
call input
cmp char ,27
je endpro
jmp finish_it
RET
p_score endp
;-------------------------------------------------------------------------
;process_position procedure
process_position proc near
;here we wanna chk the packman is in wich row to see what is te value of that position (if it had a point or not )
cmp [vlc],3
je row1
cmp [vlc],4
je row2
cmp [vlc],5
je row3
cmp [vlc],6
je row4
cmp [vlc],7
je row5
cmp [vlc],8
je row6
cmp [vlc],9
je row7
cmp [vlc],10
je row8
cmp [vlc],11
je row9
cmp [vlc],12
je row10
cmp [vlc],13
je row11
cmp [vlc],14
je row12
cmp [vlc],15
je row13
cmp [vlc],16
je row14
cmp [vlc],17
je row15
;for each row we will make the same steps which is
;accesing the point and takin its value and put it to hold which is use to do chk if we wanna increas the score or not
;then we will set the position to be used by changing the value of it to anything else 3 -which is used to detect a point-
row1:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_1+si]
mov hold,dl
mov [scorearray_1+si],2
jmp return
row2:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_2+si]
mov hold,dl
mov [scorearray_2+si],2
jmp return
row3:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_3+si]
mov hold,dl
mov [scorearray_3+si],2
jmp return
row4:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_4+si]
mov hold,dl
mov [scorearray_4+si],2
jmp return
row5:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_5+si]
mov hold,dl
mov [scorearray_5+si],2
jmp return
row6:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_6+si]
mov hold,dl
mov [scorearray_6+si],2
jmp return
row7:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_7+si]
mov hold,dl
mov [scorearray_7+si],2
jmp return
row8:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_8+si]
mov hold,dl
mov [scorearray_8+si],2
jmp return
row9:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_9+si]
mov hold,dl
mov [scorearray_9+si],2
jmp return
row10:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_10+si]
mov hold,dl
mov [scorearray_10+si],2
jmp return
row11:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_11+si]
mov hold,dl
mov [scorearray_11+si],2
jmp return
row12:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_12+si]
mov hold,dl
mov [scorearray_12+si],2
jmp return
row13:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_13+si]
mov hold,dl
mov [scorearray_13+si],2
jmp return
row14:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_14+si]
mov hold,dl
mov [scorearray_14+si],2
jmp return
row15:
mov al,[vld]
sub al,14
sub ah,ah
mov si,ax
mov dl,[scorearray_15+si]
mov hold,dl
mov [scorearray_15+si],2
return:
ret
process_position endp
;-------------------------------------------------------------------------
;timing procedure
timing proc near
MOV AH,2
MOV DH,17H
MOV DL,3BH
MOV BH,0
INT 10H
mov AH ,2Ch ;we want to take the system time
INT 21h
;we compare the seconds in this new time
;if the seconds changed we we wanna change our timing
cmp sensor , dh ;check the sensor if it has changed or not
je @@finish5 ;if not so end it
addcounter : ;if changed
mov sensor , dh ;save the new second
cmp [time+4],39h ;chk if the last digit is nine is 9
je chksec ;to chk the seconds if it is and to add 1 to it
inc [time+4] ;then add the seconds
jmp print ;print the time
chksec:
MOV [time+4],30h ;putting zero to it
cmp [time+3],35h;chking if the tens digit is 5 to make it zero and add 1 to min after checkin the whole sec
je chkmin
inc [time+3] ;if not go on and increase it
jmp print ;print the time
chkmin:
mov [time+3],48 ;putting zero to the tens digit of the seconds
inc [time+1] ;adding a min
print: ;then printing
mov p1,16 ;set row
mov p2 ,70 ;set column
mov sms,offset time ;save the time to be displayed.
CALL cout ;print the time at the row,column position
@@finish5:
ret
timing endp
end
.MODEL small

#8

السلام عليكم

كود بسيط وجميل سنستفيد منه الكثير :thumb_up:

:ty:

هذا الموضوع مغلق.

مواضيع مشابهة