Added sources of the following games: bnc, checkers, fara, FindNumbers, gomoku, reversi, rforces, sq_game, sudoku, whowtbam, xonix.
git-svn-id: svn://kolibrios.org@1805 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
BIN
programs/games/bnc/trunk/bk100.png
Normal file
BIN
programs/games/bnc/trunk/bk100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
programs/games/bnc/trunk/bk5.PNG
Normal file
BIN
programs/games/bnc/trunk/bk5.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
22
programs/games/bnc/trunk/bnc.asm
Normal file
22
programs/games/bnc/trunk/bnc.asm
Normal file
@@ -0,0 +1,22 @@
|
||||
;************************************************
|
||||
;* Bulls-and-Cows */ Kolibri OS /*
|
||||
;************************* 25/10/2007 *********
|
||||
include 'main.inc' ; main.inc
|
||||
include 'data.inc' ; data.inc
|
||||
include 'code.inc' ; code.inc
|
||||
include 'macs.inc' ; macs.inc
|
||||
include 'macros.inc' ; standard macro definitions - mcall & all-all-all
|
||||
|
||||
BeginProgram
|
||||
call clears
|
||||
call rndseed
|
||||
call rnew
|
||||
|
||||
main_loop
|
||||
|
||||
CODE_SECTION
|
||||
|
||||
DATA_SECTION
|
||||
|
||||
EndProgram
|
||||
|
53
programs/games/bnc/trunk/bnc.txt
Normal file
53
programs/games/bnc/trunk/bnc.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
Bulls-and-Cows v0.01 --- bnc.bin --- http://kolibrios.org
|
||||
|
||||
Logical game. You must guess secret 4-digit number (Non-repeated).
|
||||
Input your move by keys from '0' to '9', edit it by 'BackSpace',
|
||||
and place into game by 'Enter'.
|
||||
|
||||
'Bull' stands for the digit is in right place.
|
||||
'Cow' means it is present, but is placed wrong.
|
||||
Program gives you total info from which you may deduce next move.
|
||||
Your aim is - 4 bulls. 9 moves is more then enought.
|
||||
|
||||
(* <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *)
|
||||
|
||||
<20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;))
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...
|
||||
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD> 0 <20><> 9, <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.
|
||||
|
||||
<20><><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <20><>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>. <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> 4 <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
|
||||
<20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
1234567890 <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ENTER.
|
||||
<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BackSpace.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>), <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>...
|
||||
<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
|
||||
|
||||
<20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bnc4.png, bnc6.png - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...
|
||||
|
||||
bk100.png - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 100 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 5-6 <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>. <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 95%
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD>. <20><> 7 <20><><EFBFBD><EFBFBD><EFBFBD> - 100%
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 7 <20><><EFBFBD><EFBFBD><EFBFBD>, <20><>
|
||||
100% <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
|
BIN
programs/games/bnc/trunk/bnc4.PNG
Normal file
BIN
programs/games/bnc/trunk/bnc4.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
programs/games/bnc/trunk/bnc6.PNG
Normal file
BIN
programs/games/bnc/trunk/bnc6.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
205
programs/games/bnc/trunk/code.inc
Normal file
205
programs/games/bnc/trunk/code.inc
Normal file
@@ -0,0 +1,205 @@
|
||||
macro CODE_SECTION
|
||||
|
||||
{
|
||||
;+-----------------------------------+ Uses:eax,ebx,edx
|
||||
;|-------Random Number Generator-----|---------------------------|
|
||||
;+-----------------------------------+
|
||||
rndseed: ;
|
||||
mov eax,26 ; func 26 subfunc 9
|
||||
mov ebx,9 ;
|
||||
int 0x40 ;
|
||||
mov dword[seed],eax ; system time from boot
|
||||
random9: ; RND=[0..9]
|
||||
mov eax,3 ;
|
||||
int 0x40 ; get current time
|
||||
shr eax,16 ; seconds in al
|
||||
add eax,dword[seed] ;
|
||||
imul eax,0x15a4e35 ; random formula rv=rv*0x15a4e35+1
|
||||
inc eax ; return (rv&0x7FFFFFFF)%N
|
||||
mov dword[seed],eax ;
|
||||
and eax,0x07FFFFFFF ;
|
||||
mov ebx,10 ; N=10
|
||||
xor edx,edx ;
|
||||
div bx ; eax/ebx= int[result]+rest
|
||||
add dl,'0' ; DL='0'..'9' - rest
|
||||
ret ;
|
||||
;=================================================
|
||||
rnew: ; New Random Secret Number
|
||||
xor esi,esi ;----------------------------
|
||||
LoopBegin lb1,0 ;
|
||||
rn: call random9 ; DL=RND('0'..'9')
|
||||
xor edi,edi ;
|
||||
lb2: cmp byte[nA+edi],dl ;
|
||||
je rn ;
|
||||
inc edi ;
|
||||
cmp edi,4 ; 4 digit
|
||||
jne lb2 ;
|
||||
mov byte[nA+esi],dl ;nA - secret number without double digits
|
||||
inc esi ;nA - 4 bytes of non-repeated digits '0'..'9'
|
||||
LoopEnd lb1,4 ;
|
||||
ret ;
|
||||
;-------------------------------------
|
||||
numStr: inc dword[turn] ; turn++
|
||||
mov ebx,dword[turn] ;
|
||||
push ebx ;
|
||||
pop ecx ; ebx=ecx=turn
|
||||
add cl,'0' ;
|
||||
add ch,':' ;
|
||||
dec ebx ; -1
|
||||
shl ebx,4 ; *16
|
||||
mov word[tStr+ebx],cx; begin string by turn number +':'
|
||||
ret
|
||||
;-------------------------------------
|
||||
paint_list:
|
||||
LoopBegin lbList,0
|
||||
mov ebx,ecx
|
||||
shl ebx,4 ; *16
|
||||
mov edx,tStr
|
||||
add edx,ebx
|
||||
add ebx,25*65536 ;x
|
||||
add ebx,45 ;y
|
||||
mov eax,4 ;func 4
|
||||
mov ecx,cTxt ;color
|
||||
mov esi,16 ;line length
|
||||
int 0x40
|
||||
LoopEnd lbList,9 ;
|
||||
ret
|
||||
;-INPUT------------------------------------ KEYBOARD INPUT -----------
|
||||
input: ;ah - key code
|
||||
mov byte[char],ah ;char<-ah
|
||||
cmp ah,13 ;13- enter
|
||||
jne @f
|
||||
jmp _enter
|
||||
@@:
|
||||
cmp ah,8 ;8 - del backSpace <=|
|
||||
jne @f
|
||||
jmp _back
|
||||
@@:
|
||||
|
||||
cmp ah,'0' ; '0'..'9'
|
||||
jae @f
|
||||
ret
|
||||
@@: cmp ah,'9'
|
||||
jbe @f
|
||||
ret ; if not - return subroutine
|
||||
@@:
|
||||
;------------------------pressed:0123456789-----------
|
||||
cmp byte[posn],4
|
||||
je @f ;full line - do nothing
|
||||
call ptrStr ;esi - pointer at tStr
|
||||
xor eax,eax
|
||||
add al,byte[posn]
|
||||
add esi,eax ;+posn
|
||||
mov al,byte[char]
|
||||
mov byte[esi+3],al ;esi+3 = place 4 digits
|
||||
inc byte[posn] ;next digit
|
||||
@@: ret
|
||||
;------------------------
|
||||
_enter:
|
||||
cmp byte[posn],4 ; Enter Turn
|
||||
je @f
|
||||
ret
|
||||
@@:
|
||||
call check ; check input for difference
|
||||
cmp eax,0
|
||||
je @f
|
||||
ret
|
||||
@@:
|
||||
call bcalculate ; calc b+c
|
||||
call numStr ; 'N:' next string number
|
||||
mov byte[posn],0 ; new line
|
||||
ret
|
||||
;------------------------
|
||||
_back: cmp byte[posn],0 ; empty input - do nothing
|
||||
je @f
|
||||
dec byte[posn]
|
||||
call ptrStr ;esi = pointer at tStr
|
||||
xor eax,eax
|
||||
add al,byte[posn] ; byte of esi +posn
|
||||
add esi,eax ;+posn
|
||||
mov byte[esi+3],' '
|
||||
@@: ret
|
||||
;===========================================--end - input -
|
||||
ptrStr: ; esi=tStr+turn*16
|
||||
mov esi,dword[turn]
|
||||
shl esi,4
|
||||
add esi,tStr
|
||||
ret
|
||||
;------------------------
|
||||
clears: mov ecx,160
|
||||
clr1: mov byte[tStr+ecx],0;' '
|
||||
loop clr1
|
||||
mov byte[tStr],0;' '
|
||||
mov byte[posn],0
|
||||
mov dword[turn],0
|
||||
ret
|
||||
;-------------------------CHECK---Input--[1234]-------
|
||||
check: ; check for similar digits (equal)
|
||||
call ptrStr ; esi ...pointer
|
||||
;mov esi,dword[turn]
|
||||
;shl esi,4
|
||||
;add esi,tStr
|
||||
xor eax,eax
|
||||
xor edi,edi ; edi - counter 0..3
|
||||
xor ecx,ecx
|
||||
lb4ch: mov dl,byte[esi+ecx+3]
|
||||
cmp byte[esi+edi+3],dl
|
||||
jne @f
|
||||
inc eax ; =equivalent +1
|
||||
@@:
|
||||
inc edi ;
|
||||
cmp edi,4 ; cycle ,4 digits
|
||||
jne lb4ch ;
|
||||
xor edi,edi ; edi - counter 0..3
|
||||
|
||||
inc ecx
|
||||
cmp ecx,4
|
||||
jne lb4ch
|
||||
|
||||
sub eax,4 ; must be 4, if more - doubles present
|
||||
ret
|
||||
|
||||
bcalculate: ;------------------; calc b:+c:
|
||||
call ptrStr ; esi ...
|
||||
add esi,3
|
||||
;inc esi
|
||||
;inc esi ;+3
|
||||
;inc esi ; ...- pointer to Line
|
||||
LoopBegin lbBu1,0 ;bull count cycle ecx=0..3
|
||||
mov bl,byte[nA+ecx]
|
||||
mov dl,byte[esi+ecx]
|
||||
cmp bl,dl
|
||||
jne @f
|
||||
inc byte[nBul]
|
||||
@@:
|
||||
LoopEnd lbBu1,4
|
||||
|
||||
mov ax,'B:' ; output Bulls
|
||||
mov word[esi+6],ax
|
||||
mov al,byte[nBul]
|
||||
add al,'0'
|
||||
mov byte[esi+8],al
|
||||
|
||||
LoopBegin lbCo2,0 ;Cows count cycle ecx=0..3
|
||||
mov dl,byte[esi+ecx]
|
||||
xor edi,edi ; cycle edi=0..3
|
||||
lb3: mov bl,byte[nA+edi]
|
||||
cmp bl,dl
|
||||
jne @f
|
||||
inc byte[nCow] ;Cows+Bulls
|
||||
@@: inc edi ;
|
||||
cmp edi,4 ;
|
||||
jne lb3 ;
|
||||
LoopEnd lbCo2,4 ;endcycle ecx
|
||||
|
||||
mov ax,'C:' ; output Cows
|
||||
mov word[esi+10],ax
|
||||
mov al,byte[nCow]
|
||||
sub al,byte[nBul]
|
||||
add al,'0'
|
||||
mov byte[esi+12],al
|
||||
mov dword[nBul],0 ;nCow=posn=char=0
|
||||
ret
|
||||
;--------------------------------------
|
||||
}
|
||||
|
35
programs/games/bnc/trunk/data.inc
Normal file
35
programs/games/bnc/trunk/data.inc
Normal file
@@ -0,0 +1,35 @@
|
||||
;#**************************
|
||||
;#* BNC-DATA *
|
||||
;#************************** 25/10/2007
|
||||
macro DATA_SECTION
|
||||
{
|
||||
;-----------------------------------------------------------------------------
|
||||
header: db 'Bulls-and-Cows v0.01 '
|
||||
new: db 'New'
|
||||
;---------------------------------
|
||||
nBul: db 0
|
||||
nCow: db 0
|
||||
;---------------------------------
|
||||
posn: db 0 ;position 0-4 : 4 - finish -enter
|
||||
char: db 0
|
||||
;
|
||||
nA: dd 0
|
||||
turn: dd 0
|
||||
seed: dd 0
|
||||
;
|
||||
tStr: ; table of Strings = 10*(16) bytes
|
||||
;-------------------------------------------
|
||||
rb 160
|
||||
;-- '0123456789ABCDEF'---
|
||||
;-- 1: 1234 B:4 C:0 ---
|
||||
;db ' ';1
|
||||
;db ' ';2
|
||||
;db ' ';3
|
||||
;db ' ';4
|
||||
;db ' ';5
|
||||
;db ' ';6
|
||||
;db ' ';7
|
||||
;db ' ';8
|
||||
;db ' ';9
|
||||
|
||||
}
|
595
programs/games/bnc/trunk/draw.inc
Normal file
595
programs/games/bnc/trunk/draw.inc
Normal file
@@ -0,0 +1,595 @@
|
||||
|
||||
DrawLine:
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[Line.x1]
|
||||
mov ecx,[Line.y1]
|
||||
mov edx,[Line.color]
|
||||
shl ebx,16
|
||||
shl ecx,16
|
||||
add ebx,[Line.x2]
|
||||
add ecx,[Line.y2]
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
DrawPixel:
|
||||
|
||||
xor eax,eax
|
||||
inc al
|
||||
mov ebx,[Pixel.x]
|
||||
mov ecx,[Pixel.y]
|
||||
mov edx,[Pixel.color]
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
RectangleContour:
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[Rectangle.x]
|
||||
mov ecx,[Rectangle.y]
|
||||
mov edx,[Rectangle.color]
|
||||
mov esi,ebx
|
||||
mov edi,ecx
|
||||
shl ebx,16
|
||||
shl ecx,16
|
||||
add ebx,esi
|
||||
add ecx,edi
|
||||
add ebx,[Rectangle.width]
|
||||
mcall
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[Rectangle.x]
|
||||
mov ecx,[Rectangle.y]
|
||||
mov edx,[Rectangle.color]
|
||||
add ecx,[Rectangle.height]
|
||||
mov esi,ebx
|
||||
mov edi,ecx
|
||||
shl ebx,16
|
||||
shl ecx,16
|
||||
add ebx,esi
|
||||
add ecx,edi
|
||||
add ebx,[Rectangle.width]
|
||||
mcall
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[Rectangle.x]
|
||||
mov ecx,[Rectangle.y]
|
||||
mov edx,[Rectangle.color]
|
||||
mov esi,ebx
|
||||
mov edi,ecx
|
||||
shl ebx,16
|
||||
shl ecx,16
|
||||
add ebx,esi
|
||||
add ecx,edi
|
||||
add ecx,[Rectangle.height]
|
||||
mcall
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[Rectangle.x]
|
||||
mov ecx,[Rectangle.y]
|
||||
mov edx,[Rectangle.color]
|
||||
add ebx,[Rectangle.width]
|
||||
mov esi,ebx
|
||||
mov edi,ecx
|
||||
shl ebx,16
|
||||
shl ecx,16
|
||||
add ebx,esi
|
||||
add ecx,edi
|
||||
add ecx,[Rectangle.height]
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;OUT
|
||||
;eax - averege color
|
||||
calculate_average_color:
|
||||
|
||||
and eax,0xffffff
|
||||
and ebx,0xffffff
|
||||
|
||||
mov [b_min],al
|
||||
mov [b_max],bl
|
||||
shr eax,8
|
||||
shr ebx,8
|
||||
mov [g_min],al
|
||||
mov [g_max],bl
|
||||
shr eax,8
|
||||
shr ebx,8
|
||||
mov [r_min],al
|
||||
mov [r_max],bl
|
||||
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
mov al,[r_max]
|
||||
mov bl,[r_min]
|
||||
add eax,ebx
|
||||
shr eax,1
|
||||
mov [r],al
|
||||
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
mov al,[g_max]
|
||||
mov bl,[g_min]
|
||||
add eax,ebx
|
||||
shr eax,1
|
||||
mov [g],al
|
||||
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
mov al,[b_max]
|
||||
mov bl,[b_min]
|
||||
add eax,ebx
|
||||
shr eax,1
|
||||
mov [b],al
|
||||
|
||||
xor eax,eax
|
||||
mov al,[r]
|
||||
shl eax,8
|
||||
mov al,[g]
|
||||
shl eax,8
|
||||
mov al,[b]
|
||||
|
||||
ret
|
||||
|
||||
;eax -color
|
||||
;ebx- sub value
|
||||
;OUT
|
||||
;eax - sabved color
|
||||
calculate_sabved_color:
|
||||
|
||||
and eax,0xffffff
|
||||
|
||||
mov [b],al
|
||||
shr eax,8
|
||||
mov [g],al
|
||||
shr eax,8
|
||||
mov [r],al
|
||||
|
||||
sub [r],bl
|
||||
sub [g],bl
|
||||
sub [b],bl
|
||||
|
||||
xor eax,eax
|
||||
mov al,[r]
|
||||
shl eax,8
|
||||
mov al,[g]
|
||||
shl eax,8
|
||||
mov al,[b]
|
||||
|
||||
ret
|
||||
|
||||
DrawString:
|
||||
|
||||
mov ebx,[Button.text]
|
||||
call GetLengthString
|
||||
mov esi,eax
|
||||
|
||||
mov eax,4
|
||||
mov ebx,[Font.x]
|
||||
shl ebx,16
|
||||
add ebx,[Font.y]
|
||||
mov ecx,[Button.textcolor]
|
||||
mov edx,[Button.text]
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;ecx- x coordinat of rectangle
|
||||
;edx- y coordinat of rectangle
|
||||
;esi- rectangle size x
|
||||
;edi- rectangle size y
|
||||
|
||||
rectangle_gradient_right:
|
||||
|
||||
mov [line_coordinat_x],ecx
|
||||
mov [line_coordinat_y],edx
|
||||
mov [line_size_x],esi
|
||||
mov [line_size_y],edi
|
||||
|
||||
mov ecx,esi
|
||||
mov edx,dword pointer
|
||||
call gradient
|
||||
|
||||
mov ecx,[line_coordinat_y]
|
||||
shl ecx,16
|
||||
add ecx,[line_coordinat_y]
|
||||
add ecx,[line_size_y]
|
||||
|
||||
mov eax,[line_size_x]
|
||||
add [line_coordinat_x],eax
|
||||
|
||||
mov esi,dword pointer
|
||||
mov edi,[line_size_x]
|
||||
|
||||
next_vertical_line_draw_right:
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[line_coordinat_x]
|
||||
shl ebx,16
|
||||
add ebx,[line_coordinat_x]
|
||||
mov edx,[esi]
|
||||
and edx,0xffffff
|
||||
mcall
|
||||
|
||||
add esi,3
|
||||
sub [line_coordinat_x],1
|
||||
|
||||
dec edi
|
||||
jnz next_vertical_line_draw_right
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;ecx- x coordinat of rectangle
|
||||
;edx- y coordinat of rectangle
|
||||
;esi- rectangle size x
|
||||
;edi- rectangle size y
|
||||
|
||||
rectangle_gradient_left:
|
||||
|
||||
mov [line_coordinat_x],ecx
|
||||
mov [line_coordinat_y],edx
|
||||
mov [line_size_x],esi
|
||||
mov [line_size_y],edi
|
||||
|
||||
mov ecx,esi
|
||||
mov edx,dword pointer
|
||||
call gradient
|
||||
|
||||
mov ecx,[line_coordinat_y]
|
||||
shl ecx,16
|
||||
add ecx,[line_coordinat_y]
|
||||
add ecx,[line_size_y]
|
||||
|
||||
mov esi,dword pointer
|
||||
mov edi,[line_size_x]
|
||||
|
||||
next_vertical_line_draw_left:
|
||||
|
||||
mov eax,38
|
||||
mov ebx,[line_coordinat_x]
|
||||
shl ebx,16
|
||||
add ebx,[line_coordinat_x]
|
||||
mov edx,[esi]
|
||||
and edx,0xffffff
|
||||
mcall
|
||||
|
||||
add esi,3
|
||||
add [line_coordinat_x],1
|
||||
|
||||
dec edi
|
||||
jnz next_vertical_line_draw_left
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;ecx- x coordinat of rectangle
|
||||
;edx- y coordinat of rectangle
|
||||
;esi- rectangle size x
|
||||
;edi- rectangle size y
|
||||
|
||||
rectangle_gradient_up:
|
||||
|
||||
mov [line_coordinat_x],ecx
|
||||
mov [line_coordinat_y],edx
|
||||
mov [line_size_x],esi
|
||||
mov [line_size_y],edi
|
||||
|
||||
mov ecx,edi
|
||||
mov edx,dword pointer
|
||||
call gradient
|
||||
|
||||
mov ebx,[line_coordinat_x]
|
||||
shl ebx,16
|
||||
add ebx,[line_coordinat_x]
|
||||
add ebx,[line_size_x]
|
||||
|
||||
mov eax,[line_size_y]
|
||||
add [line_coordinat_y],eax
|
||||
|
||||
mov esi,dword pointer
|
||||
mov edi,[line_size_y]
|
||||
|
||||
next_horizontal_line_draw_up:
|
||||
|
||||
mov eax,38
|
||||
mov ecx,[line_coordinat_y]
|
||||
shl ecx,16
|
||||
add ecx,[line_coordinat_y]
|
||||
mov edx,[esi]
|
||||
and edx,0xffffff
|
||||
mcall
|
||||
|
||||
add esi,3
|
||||
sub [line_coordinat_y],1
|
||||
|
||||
dec edi
|
||||
jnz next_horizontal_line_draw_up
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;ecx- x coordinat of rectangle
|
||||
;edx- y coordinat of rectangle
|
||||
;esi- rectangle size x
|
||||
;edi- rectangle size y
|
||||
|
||||
rectangle_gradient_down:
|
||||
|
||||
mov [line_coordinat_x],ecx
|
||||
mov [line_coordinat_y],edx
|
||||
mov [line_size_x],esi
|
||||
mov [line_size_y],edi
|
||||
|
||||
mov ecx,edi
|
||||
mov edx,dword pointer
|
||||
call gradient
|
||||
|
||||
mov ebx,[line_coordinat_x]
|
||||
shl ebx,16
|
||||
add ebx,[line_coordinat_x]
|
||||
add ebx,[line_size_x]
|
||||
|
||||
mov esi,dword pointer
|
||||
mov edi,[line_size_y]
|
||||
|
||||
next_horizontal_line_draw_down:
|
||||
|
||||
mov eax,38
|
||||
mov ecx,[line_coordinat_y]
|
||||
shl ecx,16
|
||||
add ecx,[line_coordinat_y]
|
||||
mov edx,[esi]
|
||||
and edx,0xffffff
|
||||
mcall
|
||||
|
||||
add esi,3
|
||||
add [line_coordinat_y],1
|
||||
|
||||
dec edi
|
||||
jnz next_horizontal_line_draw_down
|
||||
|
||||
ret
|
||||
|
||||
;eax -first color
|
||||
;ebx- second color
|
||||
;ecx- length of line
|
||||
;edx- pointer to memory for colors of gradient
|
||||
|
||||
gradient:
|
||||
|
||||
mov [length],ecx
|
||||
|
||||
and eax,0xffffff
|
||||
and eax,0xffffff
|
||||
|
||||
mov [b_min],al
|
||||
mov [b_max],bl
|
||||
shr eax,8
|
||||
shr ebx,8
|
||||
mov [g_min],al
|
||||
mov [g_max],bl
|
||||
shr eax,8
|
||||
shr ebx,8
|
||||
mov [r_min],al
|
||||
mov [r_max],bl
|
||||
|
||||
mov eax,[length]
|
||||
dec eax
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[r_max]
|
||||
sub al,[r_min]
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fdiv st0,st1
|
||||
fstp [step_r]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[g_max]
|
||||
sub al,[g_min]
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fdiv st0,st1
|
||||
fstp [step_g]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[b_max]
|
||||
sub al,[b_min]
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fdiv st0,st1
|
||||
fstp [step_b]
|
||||
|
||||
fstp [v]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[r_min]
|
||||
mov [r],al
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fstp [r_f]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[g_min]
|
||||
mov [g],al
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fstp [g_f]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[b_min]
|
||||
mov [b],al
|
||||
mov [v],eax
|
||||
fild [v]
|
||||
fstp [b_f]
|
||||
|
||||
next_gradient_color_save:
|
||||
|
||||
xor ebx,ebx
|
||||
xor eax,eax
|
||||
mov al,[r]
|
||||
mov bl,al
|
||||
shl eax,8
|
||||
mov al,[g]
|
||||
shl eax,8
|
||||
mov al,[b]
|
||||
|
||||
mov [edx],ax
|
||||
mov [edx+2],bl
|
||||
|
||||
fld [step_r]
|
||||
fld [r_f]
|
||||
fadd st0,st1
|
||||
fst [r_f]
|
||||
fistp [v]
|
||||
xor eax,eax
|
||||
mov eax,[v]
|
||||
mov [r],al
|
||||
fstp [v]
|
||||
|
||||
fld [step_g]
|
||||
fld [g_f]
|
||||
fadd st0,st1
|
||||
fst [g_f]
|
||||
fistp [v]
|
||||
xor eax,eax
|
||||
mov eax,[v]
|
||||
mov [g],al
|
||||
fstp [v]
|
||||
|
||||
fld [step_b]
|
||||
fld [b_f]
|
||||
fadd st0,st1
|
||||
fst [b_f]
|
||||
fistp [v]
|
||||
xor eax,eax
|
||||
mov eax,[v]
|
||||
mov [b],al
|
||||
fstp [v]
|
||||
|
||||
add edx,3
|
||||
|
||||
dec ecx
|
||||
jnz next_gradient_color_save
|
||||
|
||||
ret
|
||||
|
||||
;IN
|
||||
;NON
|
||||
;OUT
|
||||
;variable [skin_height]
|
||||
|
||||
get_skin_height:
|
||||
|
||||
pushad
|
||||
|
||||
mov eax,48
|
||||
mov ebx,4
|
||||
int 0x40
|
||||
|
||||
mov [skin_height],eax
|
||||
popad
|
||||
|
||||
ret
|
||||
;eax - x
|
||||
;ebx - y
|
||||
;ecx - size x
|
||||
;edx - size y
|
||||
;esi - pointer to memory for rectangle
|
||||
SaveFonForRectangle:
|
||||
|
||||
mov [Rectangle.x],eax
|
||||
mov [Rectangle.y],ebx
|
||||
mov [Rectangle.width],ecx
|
||||
mov [Rectangle.height],edx
|
||||
mov [PointerToMem],esi
|
||||
|
||||
;get bytes per string
|
||||
mov eax,61
|
||||
mov ebx,2
|
||||
mcall
|
||||
mov [BitsPerPixel],eax
|
||||
|
||||
mov eax,61
|
||||
mov ebx,3
|
||||
mcall
|
||||
mov [BytesPerString],eax
|
||||
|
||||
|
||||
;get window coordinats
|
||||
mov eax,9
|
||||
mov ebx,dword IPC_table
|
||||
or ecx,-1
|
||||
mcall
|
||||
|
||||
mov eax,dword[IPC_table+34]
|
||||
mov ebx,dword[IPC_table+38]
|
||||
;mov ecx,dword[IPC_table+42]
|
||||
;mov edx,dword[IPC_table+46]
|
||||
;mov [WindowCoordinatX],eax
|
||||
;mov [WindowCoordinatY],ebx
|
||||
;mov [WindowSizeX],ecx
|
||||
;mov [WindowSizeY],edx
|
||||
|
||||
add eax,[Rectangle.x]
|
||||
add ebx,[Rectangle.y]
|
||||
|
||||
imul ebx,[BytesPerString]
|
||||
mov esi,[Rectangle.width]
|
||||
|
||||
cmp [BitsPerPixel],24
|
||||
jne no_24
|
||||
|
||||
lea eax,[eax+eax*2]
|
||||
lea esi,[esi+esi*2]
|
||||
mov edi,3
|
||||
jmp exit_bits_per_pixel
|
||||
no_24:
|
||||
|
||||
shl eax,2
|
||||
shl esi,2
|
||||
mov edi,4
|
||||
exit_bits_per_pixel:
|
||||
|
||||
add eax,ebx
|
||||
|
||||
mov ebx,[BytesPerString]
|
||||
sub ebx,esi
|
||||
mov [offset],ebx
|
||||
|
||||
mov esi,[PointerToMem]
|
||||
mov edx,[Rectangle.height]
|
||||
next_string_pixels_save:
|
||||
|
||||
mov ecx,[Rectangle.width]
|
||||
next_pixel_save:
|
||||
|
||||
mov ebx,[gs:eax]
|
||||
and ebx,0xffffff
|
||||
mov [esi],bx
|
||||
shr ebx,16
|
||||
mov [esi+2],bl
|
||||
|
||||
add esi,3
|
||||
add eax,edi
|
||||
dec ecx
|
||||
jnz next_pixel_save
|
||||
|
||||
add eax,[offset]
|
||||
dec edx
|
||||
jnz next_string_pixels_save
|
||||
|
||||
exit_:
|
||||
ret
|
1
programs/games/bnc/trunk/lang.inc
Normal file
1
programs/games/bnc/trunk/lang.inc
Normal file
@@ -0,0 +1 @@
|
||||
lang fix ru
|
270
programs/games/bnc/trunk/macros.inc
Normal file
270
programs/games/bnc/trunk/macros.inc
Normal file
@@ -0,0 +1,270 @@
|
||||
; new application structure
|
||||
macro meos_app_start
|
||||
{
|
||||
use32
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd __start
|
||||
dd __end
|
||||
dd __memory
|
||||
dd __stack
|
||||
|
||||
if used __params & ~defined __params
|
||||
dd __params
|
||||
else
|
||||
dd 0x0
|
||||
end if
|
||||
|
||||
dd 0x0
|
||||
}
|
||||
MEOS_APP_START fix meos_app_start
|
||||
|
||||
macro code
|
||||
{
|
||||
__start:
|
||||
}
|
||||
CODE fix code
|
||||
|
||||
macro data
|
||||
{
|
||||
__data:
|
||||
}
|
||||
DATA fix data
|
||||
|
||||
macro udata
|
||||
{
|
||||
if used __params & ~defined __params
|
||||
__params:
|
||||
db 0
|
||||
__end:
|
||||
rb 255
|
||||
else
|
||||
__end:
|
||||
end if
|
||||
__udata:
|
||||
}
|
||||
UDATA fix udata
|
||||
|
||||
macro meos_app_end
|
||||
{
|
||||
align 32
|
||||
rb 2048
|
||||
__stack:
|
||||
__memory:
|
||||
__end:
|
||||
}
|
||||
MEOS_APP_END fix meos_app_end
|
||||
|
||||
|
||||
; macro for defining multiline text data
|
||||
struc mstr [sstring]
|
||||
{
|
||||
forward
|
||||
local ssize
|
||||
virtual at 0
|
||||
db sstring
|
||||
ssize = $
|
||||
end virtual
|
||||
dd ssize
|
||||
db sstring
|
||||
common
|
||||
dd -1
|
||||
}
|
||||
|
||||
|
||||
; strings
|
||||
macro sz name,[data] { ; from MFAR [mike.dld]
|
||||
common
|
||||
if used name
|
||||
label name
|
||||
end if
|
||||
forward
|
||||
if used name
|
||||
db data
|
||||
end if
|
||||
common
|
||||
if used name
|
||||
.size = $-name
|
||||
end if
|
||||
}
|
||||
|
||||
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
|
||||
common
|
||||
if used name
|
||||
label name
|
||||
end if
|
||||
forward
|
||||
if (used name)&(lang eq lng)
|
||||
db data
|
||||
end if
|
||||
common
|
||||
if used name
|
||||
.size = $-name
|
||||
end if
|
||||
}
|
||||
|
||||
|
||||
|
||||
; easy system call macro
|
||||
macro mpack dest, hsrc, lsrc
|
||||
{
|
||||
if (hsrc eqtype 0) & (lsrc eqtype 0)
|
||||
mov dest, (hsrc) shl 16 + lsrc
|
||||
else
|
||||
if (hsrc eqtype 0) & (~lsrc eqtype 0)
|
||||
mov dest, (hsrc) shl 16
|
||||
add dest, lsrc
|
||||
else
|
||||
mov dest, hsrc
|
||||
shl dest, 16
|
||||
add dest, lsrc
|
||||
end if
|
||||
end if
|
||||
}
|
||||
|
||||
macro __mov reg,a,b { ; mike.dld
|
||||
if (~a eq)&(~b eq)
|
||||
mpack reg,a,b
|
||||
else if (~a eq)&(b eq)
|
||||
mov reg,a
|
||||
end if
|
||||
}
|
||||
|
||||
macro mcall a,b,c,d,e,f { ; mike.dld
|
||||
__mov eax,a
|
||||
__mov ebx,b
|
||||
__mov ecx,c
|
||||
__mov edx,d
|
||||
__mov esi,e
|
||||
__mov edi,f
|
||||
int 0x40
|
||||
}
|
||||
|
||||
|
||||
|
||||
; optimize the code for size
|
||||
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
|
||||
macro add arg1,arg2
|
||||
{
|
||||
if (arg2 eqtype 0)
|
||||
if (arg2) = 1
|
||||
inc arg1
|
||||
else
|
||||
add arg1,arg2
|
||||
end if
|
||||
else
|
||||
add arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
macro sub arg1,arg2
|
||||
{
|
||||
if (arg2 eqtype 0)
|
||||
if (arg2) = 1
|
||||
dec arg1
|
||||
else
|
||||
sub arg1,arg2
|
||||
end if
|
||||
else
|
||||
sub arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
macro mov arg1,arg2
|
||||
{
|
||||
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
|
||||
if (arg2) = 0
|
||||
xor arg1,arg1
|
||||
else if (arg2) = 1
|
||||
xor arg1,arg1
|
||||
inc arg1
|
||||
else if (arg2) = -1
|
||||
or arg1,-1
|
||||
else if (arg2) > -128 & (arg2) < 128
|
||||
push arg2
|
||||
pop arg1
|
||||
else
|
||||
mov arg1,arg2
|
||||
end if
|
||||
else
|
||||
mov arg1,arg2
|
||||
end if
|
||||
}
|
||||
|
||||
|
||||
macro struct name
|
||||
{
|
||||
virtual at 0
|
||||
name name
|
||||
sizeof.#name = $ - name
|
||||
end virtual
|
||||
}
|
||||
|
||||
; structures used in MeOS
|
||||
struc process_information
|
||||
{
|
||||
.cpu_usage dd ? ; +0
|
||||
.window_stack_position dw ? ; +4
|
||||
.window_stack_value dw ? ; +6
|
||||
.not_used1 dw ? ; +8
|
||||
.process_name rb 12 ; +10
|
||||
.memory_start dd ? ; +22
|
||||
.used_memory dd ? ; +26
|
||||
.PID dd ? ; +30
|
||||
.x_start dd ? ; +34
|
||||
.y_start dd ? ; +38
|
||||
.x_size dd ? ; +42
|
||||
.y_size dd ? ; +46
|
||||
.slot_state dw ? ; +50
|
||||
dw ? ; +52 - reserved
|
||||
.client_left dd ? ; +54
|
||||
.client_top dd ? ; +58
|
||||
.client_width dd ? ; +62
|
||||
.client_height dd ? ; +66
|
||||
.wnd_state db ? ; +70
|
||||
rb (1024-71)
|
||||
}
|
||||
struct process_information
|
||||
|
||||
struc system_colors
|
||||
{
|
||||
.frame dd ?
|
||||
.grab dd ?
|
||||
.grab_button dd ?
|
||||
.grab_button_text dd ?
|
||||
.grab_text dd ?
|
||||
.work dd ?
|
||||
.work_button dd ?
|
||||
.work_button_text dd ?
|
||||
.work_text dd ?
|
||||
.work_graph dd ?
|
||||
}
|
||||
struct system_colors
|
||||
|
||||
|
||||
; constants
|
||||
|
||||
; events
|
||||
EV_IDLE = 0
|
||||
EV_TIMER = 0
|
||||
EV_REDRAW = 1
|
||||
EV_KEY = 2
|
||||
EV_BUTTON = 3
|
||||
EV_EXIT = 4
|
||||
EV_BACKGROUND = 5
|
||||
EV_MOUSE = 6
|
||||
EV_IPC = 7
|
||||
EV_STACK = 8
|
||||
|
||||
; event mask bits for function 40
|
||||
EVM_REDRAW = 1b
|
||||
EVM_KEY = 10b
|
||||
EVM_BUTTON = 100b
|
||||
EVM_EXIT = 1000b
|
||||
EVM_BACKGROUND = 10000b
|
||||
EVM_MOUSE = 100000b
|
||||
EVM_IPC = 1000000b
|
||||
EVM_STACK = 10000000b
|
86
programs/games/bnc/trunk/macs.inc
Normal file
86
programs/games/bnc/trunk/macs.inc
Normal file
@@ -0,0 +1,86 @@
|
||||
;************************************
|
||||
;******** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *******************
|
||||
;************************************
|
||||
; Constants= colors
|
||||
;-----------------------梥<EFBFBD>:0xRRGGBB
|
||||
cBLACK = 0x000000 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cRED = 0xFF0000 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cYELLOW = 0xFFFF00 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cGREEN = 0x00FF00 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cNAVY = 0x0000FF ; ᨭ<EFBFBD><EFBFBD>
|
||||
cMAGENTA = 0xFF00FF ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cBLUE = 0x00FFFF ; <EFBFBD><EFBFBD><EFBFBD>㡮<EFBFBD>
|
||||
cWHITE = 0xFFFFFF ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cBROWN = 0x554433 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>筥<EFBFBD><EFBFBD><EFBFBD>
|
||||
cB equ cBLACK
|
||||
cW equ cWHITE
|
||||
|
||||
macro BeginProgram
|
||||
{
|
||||
use32
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 0x01
|
||||
dd __start
|
||||
dd __end
|
||||
dd __memory ; 0x10000
|
||||
dd __stack ; 0x10000
|
||||
dd 0x0 ; dd __params
|
||||
dd 0x0
|
||||
__start:
|
||||
}
|
||||
|
||||
macro EndProgram
|
||||
{
|
||||
align 32
|
||||
rb 256 ;512
|
||||
__end:
|
||||
__stack:
|
||||
__memory:
|
||||
}
|
||||
|
||||
|
||||
macro LoopBegin lab,begi
|
||||
{
|
||||
push ecx ; ECX->STACK store old
|
||||
mov ecx,begi
|
||||
lab:
|
||||
push ecx ; ECX->STACK counter store
|
||||
}
|
||||
|
||||
macro LoopEnd lab,endi
|
||||
{
|
||||
pop ecx ;ECX<-STACK counter restore
|
||||
inc ecx
|
||||
cmp ecx,endi
|
||||
jne lab
|
||||
pop ecx ;ECX<-STACK restore old
|
||||
}
|
||||
|
||||
macro SetEventMask mmm
|
||||
{
|
||||
mov eax,40
|
||||
mov ebx,mmm
|
||||
int 0x40
|
||||
}
|
||||
|
||||
macro redraw_begin
|
||||
{
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
int 0x40
|
||||
}
|
||||
|
||||
macro redraw_end
|
||||
{
|
||||
mov eax,12
|
||||
mov ebx,2
|
||||
int 0x40
|
||||
}
|
||||
|
||||
macro EventIs eee,lll
|
||||
{
|
||||
cmp eax,eee
|
||||
je lll
|
||||
}
|
74
programs/games/bnc/trunk/main.inc
Normal file
74
programs/games/bnc/trunk/main.inc
Normal file
@@ -0,0 +1,74 @@
|
||||
;#***************
|
||||
;#* BNC.MAIN()
|
||||
;#***************
|
||||
cTxt equ 0x10000000
|
||||
cTxtW equ 0x10FFFFFF
|
||||
|
||||
macro main_loop
|
||||
{
|
||||
draw_window:
|
||||
redraw_begin
|
||||
;------------------------------
|
||||
;--- MainWindow
|
||||
mcall 0,100*65536+250,100*65536+250,0x02FFFFFF ,0x808899AA ,0xFFAAcc
|
||||
;--- MainWindow TitleBar
|
||||
mcall 4,8*65536+8,0x00224422,header,20
|
||||
;--- Button - Close MainWindow
|
||||
mcall 8,230*65536+12, 5*65536+12, 100 ,0xFF6611
|
||||
;--- Button - "New" ...
|
||||
mcall 8,190*65536+50,25*65536+15, 200 ,0xAA66CC
|
||||
mcall 4,205*65536+30,cTxtW,new,3
|
||||
;--- Button - "Turn" ...
|
||||
;mcall 8,190*65536+50,50*65536+15, 150 ,0x116611
|
||||
;-----------------------------1234-secret-number---show
|
||||
; mcall 4, 50*65536+30,cTxt ,nA,4
|
||||
;-----------------------------9-lines-
|
||||
call paint_list
|
||||
redraw_end
|
||||
;=============================
|
||||
event_wait:
|
||||
mcall 23,100
|
||||
;-------------------------------------------------------------------------------
|
||||
; event in eax - and what will happen
|
||||
;-------------------------------------------------------------------------------
|
||||
EventIs EV_REDRAW,draw_window ; redraw window
|
||||
EventIs EV_KEY,key ; pressed key
|
||||
EventIs EV_BUTTON,button ; one clicks button
|
||||
jmp event_wait ; returns at point of waiting for
|
||||
;-------------------------------------------------------------------------------
|
||||
; Events handler
|
||||
;-------------------------------------------------------------------------------
|
||||
key: ;
|
||||
mov eax,2 ; key code in ah.
|
||||
int 0x40 ;
|
||||
cmp ah,27 ; ESC?
|
||||
je close ; exit on ESC
|
||||
|
||||
call input ; input 0-9,Enter,<_BackSpace
|
||||
|
||||
jmp draw_window ; event_wait ;
|
||||
button: ;
|
||||
mov eax,17 ; button ID in ah
|
||||
int 0x40 ;
|
||||
;-------------------------------------------------------------------------------
|
||||
; Buttons handler
|
||||
;-------------------------------------------------------------------------------
|
||||
cmp ah,100 ; id=100("Close window")?
|
||||
jne noclose ;
|
||||
close: ;
|
||||
mov eax,-1 ; CLOSE all
|
||||
int 0x40 ;
|
||||
noclose: ;
|
||||
cmp ah,150 ; id=150 "Turn"
|
||||
je @F
|
||||
call rnew ; id=200 "New" ->nA
|
||||
|
||||
call clears
|
||||
jmp draw_window ;event_wait
|
||||
|
||||
@@:
|
||||
call paint_list
|
||||
jmp event_wait
|
||||
;
|
||||
}
|
||||
|
Reference in New Issue
Block a user