hangman8086-devs team mailing list archive
-
hangman8086-devs team
-
Mailing list archive
-
Message #00012
[Merge] lp:~flozz/hangman8086/scores into lp:hangman8086
Fabien LOISON (FLOZz) has proposed merging lp:~flozz/hangman8086/scores into lp:hangman8086.
Requested reviews:
Vincent PEYROUSE (GodezInc) (godezinc)
For more details, see:
https://code.launchpad.net/~flozz/hangman8086/scores/+merge/65103
--
https://code.launchpad.net/~flozz/hangman8086/scores/+merge/65103
Your team Hangman 8086 Developers is subscribed to branch lp:hangman8086.
=== modified file 'README'
--- README 2011-05-16 14:31:51 +0000
+++ README 2011-06-18 21:26:31 +0000
@@ -39,6 +39,6 @@
WINDOWS:
Open the main.asm file with emu8086.exe <http://www.emu8086.com/>
- and clique on the build button on the GUI.
+ and click on the build button on the GUI.
=== modified file 'game.asm'
--- game.asm 2011-06-18 11:36:33 +0000
+++ game.asm 2011-06-18 21:26:31 +0000
@@ -42,6 +42,7 @@
;; _print_gword() -- Prints the guessed word (e.g. H _ _ _ _ _ N).
;; _print_tried_letters -- Prints the letters that the player have already
;; tried (e.g. A U I O W).
+;; _print_score() -- Print the score (in competition mode).
;; _game_anima() -- Displays an animation when the player loose
;; or win.
;;
@@ -478,7 +479,7 @@
;========================================================= _print_score() ====
-;; Print the score in competition mode).
+;; Print the score (in competition mode).
;; Usage:
;; call _print_tried_letters
=== modified file 'main.asm'
--- main.asm 2011-06-18 16:04:12 +0000
+++ main.asm 2011-06-18 21:26:31 +0000
@@ -69,6 +69,8 @@
include "twopl.asm" ;Contains the two player mode.
include "options.asm" ;Contains the options menu.
include "modesel.asm" ;Contains the mode selection menu.
+include "scores.asm" ;Contains the functions for displaying and managing
+ ;scores.
;RESOURCE
include "asciiart.res" ;Contains the ASCII art of the game.
=== modified file 'mainmenu.asm'
--- mainmenu.asm 2011-06-17 12:39:56 +0000
+++ mainmenu.asm 2011-06-18 21:26:31 +0000
@@ -147,6 +147,13 @@
jmp _main_menu
main_menu_option_end:
+ ;Scores
+ cmp main_menu_selected, MAIN_MENU_SCORES
+ jne main_menu_scores_end
+ call _scores
+ jmp _main_menu
+ main_menu_scores_end:
+
;Quit
cmp main_menu_selected, MAIN_MENU_QUIT
je main_menu_end
=== added file 'scores.asm'
--- scores.asm 1970-01-01 00:00:00 +0000
+++ scores.asm 2011-06-18 21:26:31 +0000
@@ -0,0 +1,360 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; __ __ _______ __ _ _______ __ __ _______ __ _ ;;
+;; | | | || _ || | | || || |_| || _ || | | | ;;
+;; | |_| || |_| || |_| || ___|| || |_| || |_| | ;;
+;; | || || || | __ | || || | ;;
+;; | || || _ || || || || || _ | ;;
+;; | _ || _ || | | || |_| || ||_|| || _ || | | | ;;
+;; |__| |__||__| |__||_| |__||_______||_| |_||__| |__||_| |__| ;;
+;; ;;
+;; ;;
+;; HANGMAN - An implementation of the Hang Man game in assembly (Emu8086) ;;
+;; ;;
+;; Copyright (C) 2011 Fabien LOISON ;;
+;; Copyright (C) 2011 Mathilde BOUTIGNY ;;
+;; Copyright (C) 2011 Vincent PEYROUSE ;;
+;; Copyright (C) 2011 Germain CARRÉ ;;
+;; Copyright (C) 2011 Matthis FRENAY ;;
+;; ;;
+;; HangMan is free software: you can redistribute it and/or modify ;;
+;; it under the terms of the GNU General Public License as published by ;;
+;; the Free Software Foundation, either version 3 of the License, or ;;
+;; (at your option) any later version. ;;
+;; ;;
+;; This program is distributed in the hope that it will be useful, ;;
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;
+;; GNU General Public License for more details. ;;
+;; ;;
+;; You should have received a copy of the GNU General Public License ;;
+;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;
+;; ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;
+;; Contains the functions for displaying and managing scores.
+;;
+;; Index:
+;; _scores -- Displays the best scores.
+;; _new_sp_score(NSPS_NAME, NSPS_SCORE) -- Insert the new score if
+;; necessary (single PLAYER
+;; mode).
+;;
+
+
+
+SP_SCORE_1N db "FLOZZ "
+SP_SCORE_1S dw 1000
+
+SP_SCORE_2N db "WILBER "
+SP_SCORE_2S dw 100
+
+SP_SCORE_3N db "THIERRY "
+SP_SCORE_3S dw 50
+
+
+TP_SCORE_1N db "TOMATE "
+TP_SCORE_1S dw 42
+
+TP_SCORE_2N db "WILBER "
+TP_SCORE_2S dw 20
+
+TP_SCORE_3N db "THIERRY "
+TP_SCORE_3S dw 10
+
+
+
+;============================================================== _scores() ====
+;; Contains the functions for displaying and managing scores.
+
+;; Usage:
+;; call _scores
+
+
+_scores:
+
+;Backup registers
+push ax
+push bx
+push cx
+push dx
+
+;Draw the UI
+call _draw_ui
+mov HELP_STR, offset scores_help
+call _print_help
+
+;SINGLE PLAYER
+ mov POS_X, 15
+ mov POS_Y, header_height + 6
+ call _move_cursor
+
+ ;TITLE
+ mov ah, 0x09
+ mov dx, offset scores_sp_title
+ int 0x21
+
+ add POS_Y, 2
+ call _move_cursor
+
+ ;ITEM 1
+ mov MEMCPY_SRC, offset SP_SCORE_1N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, SP_SCORE_1S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+ inc POS_Y
+ call _move_cursor
+
+ ;ITEM 2
+ mov MEMCPY_SRC, offset SP_SCORE_2N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, SP_SCORE_2S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+ inc POS_Y
+ call _move_cursor
+
+ ;ITEM 3
+ mov MEMCPY_SRC, offset SP_SCORE_3N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, SP_SCORE_3S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+;TWO PLAYER
+ mov POS_X, COLS - 15 - 19
+ mov POS_Y, header_height + 6
+ call _move_cursor
+
+ ;TITLE
+ mov ah, 0x09
+ mov dx, offset scores_tp_title
+ int 0x21
+
+ add POS_Y, 2
+ call _move_cursor
+
+ ;ITEM 1
+ mov MEMCPY_SRC, offset TP_SCORE_1N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, TP_SCORE_1S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+ inc POS_Y
+ call _move_cursor
+
+ ;ITEM 2
+ mov MEMCPY_SRC, offset TP_SCORE_2N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, TP_SCORE_2S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+ inc POS_Y
+ call _move_cursor
+
+ ;ITEM 3
+ mov MEMCPY_SRC, offset TP_SCORE_3N
+ mov MEMCPY_DEST, offset scores_disp_tpl
+ add MEMCPY_DEST, 3
+ mov MEMCPY_LEN, 8
+ call _memcpy
+ ;;
+ mov ax, TP_SCORE_3S
+ mov I2S_INT, ax
+ call _inttostr
+ mov MEMCPY_SRC, offset I2S_STR
+ add MEMCPY_DEST, 9
+ mov MEMCPY_LEN, 4
+ call _memcpy
+
+ mov ah, 0x09
+ mov dx, offset scores_disp_tpl
+ int 0x21
+
+;Wait
+mov ax, 0x0000
+int 0x16
+
+;Restore registers
+pop dx
+pop cx
+pop bx
+pop ax
+
+ret
+
+
+;Datas
+scores_help db "Press any key$"
+
+scores_sp_title db "-- SINGLE PLAYER --$"
+scores_tp_title db "--- TWO PLAYERS ---$"
+scores_disp_tpl db " > <PLAYER> <SC>$"
+
+
+
+;=================================== _new_sp_score(NSPS_NAME, NSPS_SCORE) ====
+;; Insert the new score if necessary (single player mode).
+
+;; Usage:
+;; mov NSPS_NAME, offset <playername>
+;; mov NSPS_SCORE, <score>
+;; call _scores
+
+;; Args:
+NSPS_NAME dw 0 ;Address of the player name
+NSPS_SCORE dw 0 ;The score
+
+
+_new_sp_score:
+
+;Backup registers
+push ax
+push bx
+push cx
+push dx
+
+;Check if the score is better than the best score
+ mov ax, NSPS_SCORE
+ cmp SP_SCORE_1S, ax
+ jge nsps_1s_end
+
+ mov ax, SP_SCORE_2S
+ mov SP_SCORE_3S, ax
+ mov MEMCPY_SRC, offset SP_SCORE_2N
+ mov MEMCPY_DEST, offset SP_SCORE_3N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+ mov ax, SP_SCORE_1S
+ mov SP_SCORE_2S, ax
+ mov MEMCPY_SRC, offset SP_SCORE_1N
+ mov MEMCPY_DEST, offset SP_SCORE_2N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+ mov ax, NSPS_SCORE
+ mov SP_SCORE_1S, ax
+ mov ax, NSPS_NAME
+ mov MEMCPY_SRC, ax
+ mov MEMCPY_DEST, offset SP_SCORE_1N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+ jmp nsps_end
+ nsps_1s_end:
+
+;Check if the score is better than the second score
+ mov ax, NSPS_SCORE
+ cmp SP_SCORE_2S, ax
+ jge nsps_2s_end
+
+ mov ax, SP_SCORE_2S
+ mov SP_SCORE_3S, ax
+ mov MEMCPY_SRC, offset SP_SCORE_2N
+ mov MEMCPY_DEST, offset SP_SCORE_3N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+ mov ax, NSPS_SCORE
+ mov SP_SCORE_2S, ax
+ mov ax, NSPS_NAME
+ mov MEMCPY_SRC, ax
+ mov MEMCPY_DEST, offset SP_SCORE_2N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+ jmp nsps_end
+ nsps_2s_end:
+
+;Check if the score is better than the third score
+ mov ax, NSPS_SCORE
+ cmp SP_SCORE_3S, ax
+ jge nsps_end
+
+ mov ax, NSPS_SCORE
+ mov SP_SCORE_3S, ax
+ mov ax, NSPS_NAME
+ mov MEMCPY_SRC, ax
+ mov MEMCPY_DEST, offset SP_SCORE_3N
+ mov MEMCPY_LEN, 8
+ call _memcpy
+
+
+nsps_end:
+
+;Restore registers
+pop dx
+pop cx
+pop bx
+pop ax
+
+ret
+
+
=== modified file 'singlepl.asm'
--- singlepl.asm 2011-06-18 14:23:09 +0000
+++ singlepl.asm 2011-06-18 21:26:31 +0000
@@ -36,7 +36,8 @@
;; Contains the single player mode.
;;
;; Index:
-;; _single_player() -- Play in single player mode.
+;; _single_player() -- Play in single player mode.
+;; _sp_gameover() -- Prints the game over screen
;;
@@ -135,6 +136,11 @@
cmp MODE, MODE_COMPETITION
jnz sp_start
+mov NSPS_NAME, offset PLAYER
+mov ax, SCORE
+mov NSPS_SCORE, ax
+call _new_sp_score
+
call _sp_gameover
sp_end:
=== modified file 'twopl.asm'
--- twopl.asm 2011-06-18 16:04:12 +0000
+++ twopl.asm 2011-06-18 21:26:31 +0000
@@ -57,6 +57,8 @@
push cx
push dx
+mov MODE, MODE_PRACTICE ;FIXME
+
;Ask the first player's name
mov IF_MSG, offset tp_msg_fplname
Follow ups