diff --git a/Old/prem/c.cmd b/Old/prem/c.cmd deleted file mode 100644 index 83d3edd..0000000 --- a/Old/prem/c.cmd +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -for %%a in (*.asm) do ( - ..\tasm3\tasm /zi /m2 /l /c %%a - if errorlevel 1 goto :exit -) - -..\tasm3\tlink /v prem.obj util.obj - -:exit - diff --git a/Old/prem/d.cmd b/Old/prem/d.cmd deleted file mode 100644 index ab14619..0000000 --- a/Old/prem/d.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -..\tasm3\td %* diff --git a/Old/prem/header.inc b/Old/prem/header.inc deleted file mode 100644 index 3b37789..0000000 --- a/Old/prem/header.inc +++ /dev/null @@ -1,16 +0,0 @@ - - -word_bits equ 1 -dword_bits equ 2 - -pointer equ word -pointer_bits equ word_bits - -;; All functions preserve: bx, si, di - - -model small, pascal -locals - -program_params_len equ 80h -program_params_str equ 81h diff --git a/Old/prem/l.cmd b/Old/prem/l.cmd deleted file mode 100644 index 9a7483f..0000000 --- a/Old/prem/l.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -..\tasm3\tlink /t %~n1.obj \ No newline at end of file diff --git a/Old/prem/prem.asm b/Old/prem/prem.asm deleted file mode 100644 index 006239d..0000000 --- a/Old/prem/prem.asm +++ /dev/null @@ -1,95 +0,0 @@ -.486 -ideal -include "header.inc" -include "util.inc" - -macro SWAP_DS_ES - push ds - push es - pop ds - pop es -endm - - - - -segment _TEXTSEG public - - -; es:0000 and ds:0000 - points to PSP -; - assume cs:_TEXTSEG, ds:_DATASEG, es:NOTHING, ss: _STACKSEG - - -start_program: - mov ax, _DATASEG - mov ds, ax - - movzx cx, [es:program_params_len] - call parse_command_line, offset argv, cx, es, program_params_str - mov [argc], ax - - cmp ax, 3 - mov dx, offset msg_not_enough_params - jne @@error_exit - - mov bx, ax - - SWAP_DS_ES - -@@loop_by_params: - mov si, 3 - sub si, bx - shl si, 1 - - mov ax, [es:argv + si] - call convert_atou, ax - mov [es:param_numbers + si], ax - - dec bx - jnz @@loop_by_params - - SWAP_DS_ES - - call PartialRemainder , [param_numbers] , [param_numbers + 2] , [param_numbers + 4 ] - call intToString , ax , offset result - mov ah , 09h - lea dx , result - int 21h - jmp @@clean_exit - - -@@error_exit: - mov ah, 9 ; функц_я виводу на екран - int 21h ; вив_д на екран - - - - -@@clean_exit: - mov ax, 4c00h ; функц_я виходу з програми з кодом повернення 0 - int 21h ; вих_д з програми - -ends - - -segment _DATASEG -helloMsg db 'Hello in my program . You gave paramets : $' -argc dw 0 -argv dw 64 dup (0) -result db 10 dup (?) - -param_numbers dw 4 dup (0) - -msg_not_enough_params: - db 'Three parameters required$' - -ends - - -segment _STACKSEG private uninit stack - dw 256 dup (?) -ends - - -end start_program \ No newline at end of file diff --git a/Old/prem/util.asm b/Old/prem/util.asm deleted file mode 100644 index 5981ced..0000000 --- a/Old/prem/util.asm +++ /dev/null @@ -1,277 +0,0 @@ -.486 -ideal -include "header.inc" -include "util.inc" - -segment _TEXTSEG public -assume cs:_TEXTSEG, ds:NOTHING, ss:NOTHING - - - -proc parse_command_line -ARG @@argv_buffer:word, @@line_len: word, @@line_seg:word, @@command_line:word -; Returns ax = argc - push es - push bx - push si - push di - - mov ax, [@@line_seg] - mov es, ax - mov si, [word ptr @@command_line] - mov bx, [@@argv_buffer] - xor di, di - mov cx, [@@line_len] - - jcxz @@1 - -@@7: -; Search for word begin -@@3: - mov al, [es:si] - cmp al, ' ' - ja @@2 - - inc si - dec cx - jz @@1 - jmp @@3 - -@@2: - cmp al, '"' - jz @@4 - -; Store word pointer - mov [bx + di], si - add di, pointer - -; Look for end of the word -@@6: - mov al, [es:si] - cmp al, ' ' - jbe @@5 - - inc si - dec cx - jnz @@6 - -; if string ended, store 0 and exit - mov [byte ptr es:si], 0 - jmp @@1 - -; if word is in quotes "aaa bbb" -@@4: -; look for another '"' - inc si - dec cx - jz @@1 - - mov [bx + di], si - add di, pointer - -@@9: - mov al, [es:si] - cmp al, '"' - jz @@8 - - inc si - dec cx - jnz @@9 - -; if string ended, store 0 and exit - mov [byte ptr es:si], 0 - jmp @@1 - -@@8: -@@5: - mov [byte ptr es:si], 0 - inc si - dec cx - jnz @@7 - -@@1: - mov ax, di - shr ax, pointer_bits - - pop di - pop si - pop bx - pop es - ret -endp - - - -proc convert_atou -ARG @@number_string:word ; 0..65535 -; returns ax = unsigned integer result - push si - - xor cx, cx - xor ah, ah - mov si, [@@number_string] - -@@2: - movzx ax, [byte ptr si] - cmp al, '9' - ja @@1 - sub al, '0' - jb @@1 - xchg ax, cx - mov dx, 10 - mul dx - add cx, ax - inc si - jmp @@2 - - -@@1: - mov ax, cx - - pop si - ret -endp - - -proc convert_atoi -ARG @@number_string:word -; returns ax = signed integer result - push si - - mov si, [@@number_string] - mov al, [si] - - cmp al, '-' - pushf - jz @@2 - cmp al, '+' - jnz @@3 - -@@2: - inc si - -@@3: - call convert_atou, si - - popf - jnz @@1 - neg ax - -@@1: - pop si - ret -endp - -proc intToString -ARG @@number:word , @@mass:word - mov ax , [@@number] - mov di , 0 - mov si , 10 - mov bx , [@@mass] -@@first_step: - - xor dx , dx - div si - add dx , 30h - mov [byte ptr bx + di], dl - inc di - cmp ax , 1 - jc @@next_step - jmp @@first_step - -@@next_step: - - cmp di , 1 - jz @@oneParam - push di - mov si , 0 - mov cx , di - and cx , 11111110b - shr cx , 1 - dec di - - - - -@@for: - mov al , [byte ptr bx + si] - mov ah , [byte ptr bx + di] - mov [byte ptr bx + si] , ah - mov [byte ptr bx + di] , al - dec di - inc si - loop @@for - - -@@moreParam: - - - pop di - mov [byte ptr bx + di] , '$' - jmp @@exit - - - @@oneParam: - - mov [byte ptr bx + 1] , '$' - - - @@exit: - - ret - -endp - -proc PartialRemainder -Arg @@Base: word, @@Exponent: word, @@Modulo: word - - mov ax, [@@Exponent] - cmp ax, 1 - jb @@exponent_0 - je @@exponent_1 - - shr ax, 1 - jc @@odd_number - - call PartialRemainder, [@@Base], ax, [@@Modulo] - - mul ax - jmp @@div_and_exit - -@@odd_number: - push ax; sub sp, 2 - ; mov [sp], ax - - call PartialRemainder, [@@Base], ax, [@@Modulo] - pop dx ; get previous argument - push ax ; push result - - inc dx ; increment argument - call PartialRemainder, [@@Base], dx, [@@Modulo] - pop dx ; pop first result - ; mov dx, [sp] - ; add sp, 2 - - mul dx - jmp @@div_and_exit - -@@exponent_1: - mov ax, [@@Base] - xor dx, dx - -@@div_and_exit: - div [@@Modulo] - mov ax, dx - jmp @@exit - -@@exponent_0: - mov ax, 1 ; a^0 mod b == 1 for any b - -@@exit: - ret -endp - -ends - -end - \ No newline at end of file diff --git a/Old/prem/util.inc b/Old/prem/util.inc deleted file mode 100644 index e835b7c..0000000 --- a/Old/prem/util.inc +++ /dev/null @@ -1,8 +0,0 @@ -segment _TEXTSEG public - -global parse_command_line: proc -global convert_atoi: proc -global convert_atou: proc -global intToString:proc -global PartialRemainder:proc -ends diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..e67360d --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1 @@ +Educational project to develop a Python game in x86 assmbler for DOS with secondary school pupils. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 84a269e..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -ASM-PYTHON -====== -Educational project to develop a Python game in x86 assembler for DOS with secondary school pupils. diff --git a/Src/MAIN.EXE b/Src/MAIN.EXE deleted file mode 100644 index 9ae23b1..0000000 Binary files a/Src/MAIN.EXE and /dev/null differ diff --git a/Src/b.bat b/Src/b.bat deleted file mode 100644 index 8eb3a5b..0000000 --- a/Src/b.bat +++ /dev/null @@ -1,16 +0,0 @@ -@echo off - -tasm -m2 -v main.asm >errors.txt -if errorlevel 1 goto exit - -tasm -m2 -v util.asm >errors.txt -if errorlevel 1 goto exit - -tlink -v main.obj util.obj >errors.txt -if errorlevel 1 goto exit - -echo Compiled successfully -set /p x=debug? -if %x%==y start td main.exe - -:exit \ No newline at end of file diff --git a/Src/edit.sc b/Src/edit.sc deleted file mode 100644 index 1ebf318..0000000 --- a/Src/edit.sc +++ /dev/null @@ -1 +0,0 @@ -                                                                                                                                                                   How use editor ?                                                                F2 - Set wall                                                                   F3 - Cange wall color                                                           F4 - Save changes                                                               F5 - Get the previous wall                                                      F6 - Get the next wall                                                          F7 - Clear all                                                                  F8 - Set the start position                                                     Backspace - erase wall                                                                                                                                        \ No newline at end of file diff --git a/Src/globals.inc b/Src/globals.inc deleted file mode 100644 index 7c6c283..0000000 --- a/Src/globals.inc +++ /dev/null @@ -1,43 +0,0 @@ - - -word_bits equ 1 -dword_bits equ 2 - -pointer equ word -pointer_bits equ word_bits - - - -model tiny, pascal -locals - -program_params_len equ 80h -program_params_str equ 81h - - -macro PUSH_PROC_REGS - push bx - push si - push di -endm - -macro POP_PROC_REGS - pop di - pop si - pop bx -endm - - - -struc ScreenCoord -coordX db ? -coordY db ? -ends - -struc ScreenChar -charCode db ? -charAttr db ? -ends - - -;; All functions preserve: bx, si, di diff --git a/Src/levels/level1.inc b/Src/levels/level1.inc deleted file mode 100644 index d1f1142..0000000 --- a/Src/levels/level1.inc +++ /dev/null @@ -1 +0,0 @@ -b \ No newline at end of file diff --git a/Src/levels/level1.lv b/Src/levels/level1.lv deleted file mode 100644 index 7024f17..0000000 --- a/Src/levels/level1.lv +++ /dev/null @@ -1 +0,0 @@ -                                                                                                                                                                                                                                                                                                                                                    # #                                     # #                                     # #                                     # #                                     # #                                     # #                                     # #                                     # #                                     # #                                     # #                                                                                                                                                                                                                                                                                                          \ No newline at end of file diff --git a/Src/levels/level2.inc b/Src/levels/level2.inc deleted file mode 100644 index d3d4967..0000000 --- a/Src/levels/level2.inc +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Src/levels/level2.lv b/Src/levels/level2.lv deleted file mode 100644 index 488660d..0000000 --- a/Src/levels/level2.lv +++ /dev/null @@ -1 +0,0 @@ -                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            \ No newline at end of file diff --git a/Src/levels/level3.inc b/Src/levels/level3.inc deleted file mode 100644 index 62e77f8..0000000 --- a/Src/levels/level3.inc +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Src/levels/level3.lv b/Src/levels/level3.lv deleted file mode 100644 index 549280d..0000000 --- a/Src/levels/level3.lv +++ /dev/null @@ -1 +0,0 @@ -                                                                                !!                                            !!!!!!!!!!!!!!!!################        !     !!!!!!!!!!        #               !     !!!!!!!!!!        #       !!     !             !!    #   #       !!      !             !!    #   #      #!!      !             !!    #####      #!!      !             !!        #      #!!      !                      #      #!!                                    #!!                    !!   #    #      #!!                    !!   #    #      #!!                    !!   #    #      #!!                    !!   #    #      #!!                    !!   ######      #!!                    !!        #      #!!                    !!        #      #!!                    !!        #      #!!                    !!        #      #!!                   !!        #      #!!                    !!        #      #!!                    !!   #############!!!!!!!!!!!!!!!!!!!!!!!!               # \ No newline at end of file diff --git a/Src/levels/level4.inc b/Src/levels/level4.inc deleted file mode 100644 index 8972c02..0000000 --- a/Src/levels/level4.inc +++ /dev/null @@ -1,2 +0,0 @@ -" - \ No newline at end of file diff --git a/Src/levels/level4.lv b/Src/levels/level4.lv deleted file mode 100644 index bc61431..0000000 --- a/Src/levels/level4.lv +++ /dev/null @@ -1 +0,0 @@ -1010101010101010101010101010101010101010               0101010101010101010101010               0101010101010101010101010    101010     0101010101010101010101010                                                1     10                            101010101010      101010                101010101010      1010101               101010101010       0101010              101010101010         0101               101010101010          10101       10                          101010      1010  1010101010101         1010101     1010  1010101010101         1010101      010                   0 0101010101     10101     1  0101 101 1010101010101     1010     01010101 101 101010101010     010      101010101  0  101010101010     010    10010101101011001010     010    10010110110101001010    1010    1001011011111001010            100101011110010101           10110101101011001           101101011010110010     01010101010101010101010101010101010101010 \ No newline at end of file diff --git a/Src/main.asm b/Src/main.asm deleted file mode 100644 index 0828029..0000000 --- a/Src/main.asm +++ /dev/null @@ -1,843 +0,0 @@ -.486 -ideal -include "globals.inc" - -stack 256 - -include "util.inc" - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -LEVEL_COUNT EQU 9 -RABBITS_PER_LEVEL EQU 16 -INITIAL_GROWTH EQU 2 -GROWTH_PER_RABBIT EQU 1 - -TARGET_SYMBOL EQU 0cfh -TARGET_ATTR EQU 7 - -HEAD_SYMBOL EQU '@' -HEAD_ATTR EQU 7 -BODY_SYMBOL EQU 'O' -BODY_ATTR EQU 7 - -WALL_SYMBOL EQU '#' -WALL EQU WALL_SYMBOL - -EMPTY_SYMBOL EQU ' ' -EMPTY_ATTR EQU 7 - -START_X EQU screenWidth / 2 -START_Y EQU screenHeight - 1 - - -macro render - call OutputScreenImage , offset buf -endm - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -dataseg - -currentLevel db 0 ; Contains current game level -rabitsRemainder db 0 ; Contains number of rabbits to be eaten until level increment -growthRemainder db 0 ; Contains how many steps python has to grow yet - -headIndex dw 0 ; Index of HEAD_SYMBOL in array -tailIndex dw 0 ; Index of tail in array - -motionDelta ScreenCoord <0, -1> ; Direction of motion - -editFile db 'edit.sc',0 -max db 3 -inputBuf db 5 dup (?) -testf db '125',0 -sX db 'Enter start x :',0 -sy db 'Enter start y :',0 -enterSp db 'Enter Speed : ',0 -showSize db 'Size: ' , 0 -info db 'LEVEL EDITOR (c) 2012 LMPL',0 -enterX db 'Enter start x pos :',0 -enterY db 'Enter start y pos :',0 -enterS db 'Enter level speed :',0 -gover1 db 'Game Over',0 -gover2 db 'Press enter to restart',0 -gover3 db 'Press escape to exit the menu',0 -targ db 0 -msg db 'You eated the TARGET_CHAR !',0 -randSeed2 dd 0 -paramString db 'Start Game',0,'Select level',0,'Edit level',0,'Exit',0 -levelName db 'levels\\level1.lv',0 -levelInc db 'levels\\level1.inc',0 -levelLIsCharPendingt db 'Level 1',0,'Level 2',0,'Level 3',0,'Level 4',0 -buf db 2 * screenWidth * screenHeight dup (' ') , '$' -python db 2 * screenWidth * screenHeight dup (?) -fileName db 'menu.sc',0 -help db 3 dup (?) - - - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -codeseg - - -proc get_pos -ARG @@x:byte , @@y:byte - mov ax , screenWidth - mov ch , [@@y] - dec ch - mul ch - xor bx , bx - mov bl , [@@x] - inc bl - add ax , bx - shl ax , 1 - sub ax , 4 - mov si , ax - ret -endp - - -proc outputToBuf -Arg @@X: byte, @@Y: byte, @@SYM: byte, @@Attr: byte - push si - call outputChar, [@@x], [@@y], [@@sym], [@@attr] - mov ax , screenWidth - movzx cx , [@@y] - dec cx - mul cx - add ax , [@@x] - shl ax , 1 - mov si , ax - mov [byte ptr buf + si - 2] , HEAD_SYMBOL - mov [byte ptr buf + si - 1] , HEAD_ATTR - pop si - ret -endp - - - -; pos = ((y - 1) * width + x) * 2 - 2 -proc StartGame -ARG @@levelSpeed:byte , @@levelScreen:word , @@start_X:byte , @@start_Y:byte -local @@head:word , @@tail:word , @@direction:byte , @@size:byte , @@help:byte -@@start_game_l: - mov [@@size] , INITIAL_GROWTH - mov ax, [@@levelScreen] - mov ah , [@@start_Y] - mov al , [@@start_X] - mov [@@head] , ax - - call ReadScreen , ax , offset buf - call OutputScreenImage , offset buf - call outputToBuf , [@@start_X] , [@@start_Y] , HEAD_SYMBOL , HEAD_ATTR - - - mov [@@tail] , 2 - mov ax , [@@head] - inc ah - mov [word ptr python] , ax - inc ah - mov [word ptr python + 2] , ax - mov ax , [@@head] - add ah , 2 - movzx bx , al - movzx cx , ah - push bx - push cx - call outputChar , bx , cx , BODY_SYMBOL , BODY_ATTR - pop cx - pop bx - mov ax , screenWidth - dec cx - mul cx - add ax , bx - shl ax , 1 - mov si , ax - mov [buf + si - 2] , BODY_SYMBOL - mov [buf + si - 1] , BODY_ATTR -; 1 - up -; 2 - down -; 3 - left -; 4 - right - mov [@@direction] , 1 -@@for: - - mov al , [targ] - cmp al , 1 - je @@for2 - mov si , 0 - mov bx , offset buf - xor cx , cx -@@for_label1: - add si , 2 - mov al , [bx + si] - cmp al , 20h - jne @@for_label1 - inc cx - cmp si , 2000 - jb @@for_label1 - call GenerateRandomNumber , cx - xor cx , cx - xor si , si - mov bx , offset buf -@@for_label2: - add si , 2 - mov al , [bx + si] - cmp al , 20h - jne @@for_label2 - inc cx - cmp cx , ax - jne @@for_label2 - mov [byte ptr bx + si] , TARGET_SYMBOL - mov [byte ptr bx + si + 1] , TARGET_ATTR - render - mov al , 1 - mov [targ] , al -@@for2: - call Sleep , 15 - call IsCharPending - jz @@waiting - mov [@@help] , ah -@@from_waiting: - mov ax , [@@head] - movzx bx , al - movzx cx , ah - call get_pos, bx , cx - mov [buf + si ] , BODY_SYMBOL - mov [buf + si + 1] , BODY_ATTR - mov si , [@@tail] - mov ax , [@@head] - mov bx , [word ptr python + si] - mov [word ptr python + si] , ax - movzx ax , bl - movzx cx , bh - call get_pos , ax ,cx - mov [buf + si] , ' ' - mov [buf + si + 1] , 7 - - mov ah , [@@help] - cmp ah , KEY_UP - je @@up - cmp ah , KEY_DOWN - je @@down - cmp ah , KEY_LEFT - je @@left - cmp ah , KEY_RIGHT - je @@right - cmp ah , KEY_ESC - je @@fast_exit -@@for3: - - mov [@@head] , ax - movzx bx , al - movzx cx , ah - call get_pos , bx ,cx - mov [buf + si] , HEAD_SYMBOL - mov [buf + si + 1] , HEAD_ATTR - render - mov ax , [@@tail] - movzx bx , [@@size] - shl bx , 1 - add ax , 2 - cmp bx , ax - jne @@for2 - xor ax , ax - mov [@@tail] , ax - jmp @@for - -@@up: - mov ah , 1 - mov [@@direction] , ah - mov ax , [@@head] - dec ah - push ax - movzx bx , al - movzx cx , ah - call get_pos , bx , cx - mov ah , [buf + si] - cmp ah , TARGET_SYMBOL - je @@eat - cmp ah , ' ' - jne @@exit - pop ax - cmp ah , 0 - jne @@for3 - mov ah , screenHeight - jmp @@for3 - -@@down: - mov ah , 2 - mov [@@direction] , ah - mov ax , [@@head] - inc ah - push ax - movzx bx , al - movzx cx , ah - call get_pos , bx , cx - mov ah , [buf + si] - cmp ah , WALL_SYMBOL - je @@exit - cmp ah , BODY_SYMBOL - je @@exit - cmp ah , TARGET_SYMBOL - je @@eat - pop ax - cmp ah , screenHeight - jne @@for3 - mov ah , 0 - jmp @@for3 - -@@left: - mov ah , 3 - mov [@@direction] , ah - mov ax , [@@head] - dec al - push ax - movzx bx , al - movzx cx , ah - call get_pos , bx , cx - mov ah , [buf + si] - cmp ah , WALL_SYMBOL - je @@exit - cmp ah , BODY_SYMBOL - je @@exit - cmp ah , TARGET_SYMBOL - je @@eat - pop ax - cmp al , 0 - jne @@for3 - mov al , screenWidth - jmp @@for3 - -@@right: - mov ah , 4 - mov [@@direction] , ah - mov ax , [@@head] - inc al - push ax - movzx bx , al - movzx cx , ah - call get_pos , bx , cx - mov ah , [buf + si] - cmp ah , WALL_SYMBOL - je @@exit - cmp ah , BODY_SYMBOL - je @@exit - cmp ah , TARGET_SYMBOL - je @@eat - pop ax - cmp al , screenWidth - jne @@for3 - mov al , 0 - jmp @@for3 - -@@eat: - mov al , 0 - mov [targ] , al - pop ax - jmp @@for3 - -@@waiting: - - - - mov ah , [@@direction] - cmp ah , 1 - je @@d_up - cmp ah , 2 - je @@d_down - cmp ah , 3 - je @@d_left - cmp ah , 4 - jne @@for - mov ah , KEY_RIGHT - mov [@@help] , ah - jmp @@from_waiting - -@@d_up: - mov ah , KEY_UP - mov [@@help] , ah - jmp @@from_waiting - -@@d_down: - mov ah , KEY_DOWN - mov [@@help] , ah - jmp @@from_waiting - -@@d_left: - mov ah , KEY_LEFT - mov [@@help] , ah - jmp @@from_waiting - -@@exit: - call outputString , 15 , 12 , offset gover1 , 4 - call outputString , 0 , 0 , offset gover2 , 4 - call outputString , 0 , 1 , offset gover3 , 4 -@@cicl: - call IsCharPending - cmp ah , KEY_ESC - je @@fast_exit - cmp ah , KEY_ENTER - jne @@cicl - call ReadScreen , offset fileName , offset buf - call OutputScreenImage , offset buf - jmp @@start_game_l - -@@fast_exit: - ret - -endp - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -proc SelectLevel - xor si , si - mov cx , size buf -@@loop1: - mov [buf + si] , 20h - mov [buf + si + 1] , 7 - add si , 2 - loop @@loop1 -render - call GameMenu , 4 , offset levelLIsCharPendingt , 8 - cmp ax , 1 - je @@1 - cmp ax , 2 - je @@2 - cmp ax , 3 - je @@3 - mov ah , 34h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@exit -@@1: - mov ah , 31h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@exit -@@2: - mov ah , 32h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@exit -@@3: - mov ah , 33h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah -@@exit: - - ret -endp - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -proc EditLevel - local @@pos:word , @@color:byte , @@wall_char:byte , @@speed:byte , @@cords:word - call ReadScreen , offset fileName , offset buf - render - call GameMenu , 4 , offset levelLIsCharPendingt , 8 - cmp ax , 0ffffh - je @@exit - cmp ax , 1 - je @@1 - cmp ax , 2 - je @@2 - cmp ax , 3 - je @@3 - mov ah , 34h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@next -@@1: - mov ah , 31h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@next - @@2: - mov ah , 32h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - jmp @@next - @@3: - mov ah , 33h - mov [levelName + 13] , ah - mov [levelInc + 13] , ah - @@next: - call ReadScreen , offset editFile , offset buf - render - call outputString , 0, 0 , offset enterSp , 4 - mov cx,03h - mov ah,01h - int 10h - call SetCursorPos , 14 , 0 - mov ah , 0ah - lea dx , [max] - int 21h - movzx si , [max + 1] - mov [inputBuf + si + 1] , 0 - call StringToInt , offset inputBuf + 1 - mov bx , 100 - sub bx , ax - mov [@@speed] , bl - mov ax , 1015h - mov [@@cords] , ax - - - - - - call ReadScreen , offset levelName , offset buf - render - call outputString , 0, 0 , offset Info , 4 - xor ax ,ax - mov ah , 1 - mov [@@pos] , ax - mov ah , 1 - mov [@@color] , ah - mov ah , WALL - mov [@@wall_char] , ah - mov ax , [@@cords] - movzx bx , al - movzx cx , ah - call outputChar , bx , cx , 249 , 3 - mov cx,1fh - mov ah,01h - int 10h - call SetCursorPos , 0 , 1 - -@@for: - call ReadInputChar - cmp ah , KEY_UP - je @@up - cmp ah , KEY_DOWN - je @@down - cmp ah , KEY_LEFT - je @@left - cmp ah , KEY_RIGHT - je @@right - cmp ah , KEY_ESC - je @@exit - cmp ah , KEY_F2 - je @@wall - cmp ah , KEY_F4 - je @@save - cmp ah , KEY_F3 - je @@change_color - cmp ah , KEY_CLEAR - je @@delete - cmp ah , KEY_F6 - je @@add_wall_char - cmp ah , KEY_F5 - je @@sub_wall_char - cmp ah , KEY_F7 - je @@clear_screen - cmp ah , KEY_F8 - je @@set_start_cords - jmp @@for - - @@set_start_cords: - mov ax , [@@cords] - movzx bx , al - movzx cx , ah - call outputChar , bx , cx , 20h , 7 - mov ax , [@@pos] - mov [@@cords] , ax - movzx bx , al - movzx cx , ah - call outputChar , bx , cx , 249 , 3 - jmp @@for - - @@clear_screen: - mov cx , 1000 - xor si , si - @@some_loop_1: - mov [buf + si] , 20h - mov [buf + si + 1] , 7 - add si , 2 - loop @@some_loop_1 - render - call outputString , 0, 0 , offset Info , 4 - mov ax , [@@cords] - movzx bx , al - movzx cx , ah - call outputChar , bx , cx , 249 , 3 - mov ax , [@@pos] - movzx bx , al - movzx cx , ah - call SetCursorPos , bx ,cx - jmp @@for - - @@sub_wall_char: - mov ah , [@@wall_char] - dec ah - mov [@@wall_char] , ah - jmp @@for - - @@add_wall_char: - mov ah , [@@wall_char] - inc ah - mov [@@wall_char] , ah - jmp @@for - - @@delete: - mov ax , [@@pos] - movzx bx , al - movzx cx , ah - call outputChar , bx , cx , 20h , 7 - mov ax , [@@pos] - movzx bx , al - movzx cx , ah - inc cx - inc bx - call get_pos , bx , cx - mov [buf + si] , 20h - mov [buf + si + 1] , 7 - jmp @@for - - @@change_color: - movzx ax , [@@color] - inc ax - cmp ax , 7 - ja @@d - mov [@@color] , al - jmp @@for - @@d: - mov ah , 1 - mov [@@color] , ah - jmp @@for - - @@wall: - mov ax , [@@pos] - movzx bx , al - movzx cx , ah - movzx ax , [@@color] - movzx di , [@@wall_char] - call outputChar , bx , cx , di , ax - mov ax , [@@pos] - movzx bx , al - movzx cx , ah - inc bx - inc cx - call get_pos , bx , cx - mov dl , [@@wall_char] - mov [buf + si] , dl - mov ah , [@@color] - mov [buf + si + 1] , ah - jmp @@for - - @@save: - - mov ah , 3dh - mov dx , offset levelName - mov al , 1 - int 21h - jc @@exit - mov si , ax - push si - mov bx , ax - mov ah , 40h - mov dx , offset buf - mov cx , 2000 - int 21h - jc @@exit - mov ah , 3eh - pop bx - int 21h - mov ax , [@@cords] - mov [inputBuf] , ah - mov [inputBuf + 1] , al - mov ah , [@@speed] - mov [inputBuf + 2] , ah - mov ah , 3dh - mov dx , offset levelInc - mov al , 1 - int 21h - jc @@exit - mov si , ax - push si - mov bx , ax - mov ah , 40h - mov dx , offset inputBuf - mov cx , 3 - int 21h - jc @@exit - mov ah , 3eh - pop bx - int 21h - jmp @@exit - - @@up: - mov ax , [@@pos] - dec ah - cmp ah , 0 - je @@up_2 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - @@up_2: - mov ah , screenHeight - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - - - @@down: - mov ax , [@@pos] - inc ah - cmp ah , screenHeight - je @@down_2 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - @@down_2: - mov ah , 1 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - - - @@left: - mov ax , [@@pos] - dec al - cmp al , 0 - je @@left_2 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - @@left_2: - mov al , screenWidth - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - - @@right: - mov ax , [@@pos] - inc al - cmp al , screenWidth - je @@right_2 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - @@right_2: - mov al , 0 - mov [@@pos] , ax - movzx bx , al - movzx cx , ah - call SetCursorPos , bx , cx - jmp @@for - - - -@@exit: - call HideCursor - ret -endp - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -start: - mov ax , @data - mov ds , ax - call initVideo - call InitializeRandomGenerator - call HideCursor -@@again: - call ReadScreen , offset fileName , offset buf - call OutputScreenImage , offset buf - call GameMenu , 4 , offset paramString , 8 - cmp ax , 1 - je @@start - cmp ax , 4 - je @@exit - cmp ax , 2 - je @@selectLevel - cmp ax , 3 - je @@edit - jmp @@again -@@edit: - call EditLevel - jmp @@again -@@selectLevel: - call SelectLevel - jmp @@again -@@start: - mov ah , 3dh - mov dx , offset levelInc - mov al , 0 - int 21h - jc @@exit - mov si , ax - mov bx , ax - mov ah , 3fh - mov dx , offset help - mov cx , 3 - int 21h - jc @@exit - mov ah , 3eh - mov bx , si - int 21h - movzx ax , [help] - movzx bx , [help + 1] - movzx cx , [help + 2] - call StartGame , cx ,offset levelName , bx , ax - cmp ax , 1 - je @@start - jmp @@again - -@@exit: - call ClearScreen - call ShutdownVideo - call ExitProgram - - - - - - - - - - - -end start diff --git a/Src/menu.sc b/Src/menu.sc deleted file mode 100644 index a4ca8c9..0000000 --- a/Src/menu.sc +++ /dev/null @@ -1 +0,0 @@ -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                                                                                                                                                                                                                                                                                                                                @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(C) LPML 2012@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/Src/util.asm b/Src/util.asm deleted file mode 100644 index 8431a83..0000000 --- a/Src/util.asm +++ /dev/null @@ -1,801 +0,0 @@ -.486 -ideal -include "globals.inc" - - -dataseg - -startingVideoMode db ? -startingCursorShape dw ? - -randSeed2 dd 0 - - -codeseg - -include "util.inc" - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - - -proc StringToInt -arg @@str:word -local @@sum:word - push si - push di - push bx - mov bx , [@@str] - xor si , si - xor cx , cx -@@loop1: - mov ah , [bx + si] - cmp ah , 0 - je @@next_step - inc cx - inc si - jmp @@loop1 -@@next_step: - mov si , cx - dec si - mov di , 1 - xor ax , ax - mov [@@sum] , ax - - -@@loop2: - push cx - movzx ax , [bx + si] - sub ax , 48 - mul di - mov dx , [@@sum] - add ax , dx - mov [@@sum] , ax - mov ax , di - mov di , 10 - mul di - mov di , ax - dec si - pop cx - loop @@loop2 - mov ax , [@@sum] - pop bx - pop di - pop si - ret - -endp - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -proc intToString -ARG @@number:word , @@mass:word - push si - push di - push bx - mov ax , [@@number] - mov di , 0 - mov bx , 10 - -@@first_step: - - xor dx , dx - div bx - add dl , 30h - mov [byte ptr @@mass + di],dl - inc di - cmp ax , 1 - jc @@next_step - jmp @@first_step - -@@next_step: - - cmp di , 1 - jz @@oneParam - push di - mov cx , di - shr cx , 1 - mov si , 0 - dec di - - - -@@for: - mov bl , [byte ptr @@mass + si] - mov bh , [byte ptr @@mass + di] - mov [byte ptr @@mass + si] , bh - mov [byte ptr @@mass + di] , bl - dec di - inc si - cmp cx , si - je @@for - jmp @@moreParam - -@@moreParam: - - pop di - mov [byte ptr @@mass + di] , '$' - jmp @@exit - - - @@oneParam: - mov [byte ptr @@mass + di] , '$' - - - @@exit: - pop bx - pop di - pop si - ret - -endp - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; exitCode -; no results -proc ExitProgram -ARG @@Code:byte - mov al,[@@Code] - mov ah,4Ch - int 21h - ret -endp - -;####################################################################################### -;####################################################################################### -;####################################################################################### -proc Sleep -ARG @@time:word -local @@seconds:byte , @@hundseconds:byte -mov ah , 2ch -int 21h -mov ax , [@@time] -mov ch , 100 -div ch -add dl , ah -add dh , al -mov [@@seconds] , dh -mov [@@hundseconds] , dl -mov bh , [@@seconds] -mov bl , [@@hundseconds] -@@cicl: -push bx -mov ah , 2ch -int 21h -pop bx -cmp dh , bh -ja @@exit -cmp dl , bl -jb @@cicl -@@exit: -ret -endp - -;asm -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; al=success/fail -proc InitVideo - - PUSH_PROC_REGS - - ; Save initial video mode into starting_video_mode - mov ax, 0f00h - int 10h - mov [startingVideoMode],al - mov ax, 0001h - int 10h - POP_PROC_REGS - - ret -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; no results -proc ShutdownVideo - - - ; restore initial video mode from starting_video_mode - PUSH_PROC_REGS - mov al, [startingVideoMode] - mov ah, 00h - int 10h - POP_PROC_REGS - ret -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; no results -proc ClearScreen - - PUSH_PROC_REGS - - ; !!! This can be implemented with one interrupt call with CX=... - - mov dh , 0 - mov dl , 0 - -@@label: - - - mov ah , 02h - mov bh , 0 - int 10h - mov ah , 09h - mov bh , 0h - mov al , ' ' - ; mov cx , 1h - mov cx , screenWidth * screenHeight - mov bl , 7 - int 10h - ; inc dl - ; - ; cmp dl, screenWidth - ; jne @@label - ; - ;@@NextLine: - ; - ; inc dh - ; xor dl , dl - ; cmp dh , screenHeight - ; jne @@label - - - POP_PROC_REGS - ret -endp - -proc ReadScreen -ARG @@screenName:word , @@buffer:word - - PUSH_PROC_REGS - - mov ah , 3dh - mov dx , [@@screenName] - mov al , 0 - int 21h - jc @@error - mov si , ax - mov bx , ax - mov ah , 3fh - mov dx , [@@buffer] - mov cx , screenWidth * screenHeight * 2 - int 21h - jc @@error - mov ah , 3eh - mov bx , si - int 21h - jc @@error - -@@error: - POP_PROC_REGS - ret - -endp - - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; no results -proc HideCursor - PUSH_PROC_REGS - - ; Save cursor shape in starting_cursor_shape(C/D) - - mov ah,03h - mov bh,00h - int 10h - mov [startingCursorShape],cx - mov cx,2000h - mov ah,01h - int 10h - - POP_PROC_REGS - ret -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; no results -proc ShowCursor - PUSH_PROC_REGS - - mov cx,[startingCursorShape] - mov ah,01h - int 10h - - POP_PROC_REGS - ret - -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; x, y -; no results -proc SetCursorPos -ARG @@x:byte , @@y:byte - PUSH_PROC_REGS - - mov ah , 02h - mov bh , 0 - mov dh , [@@y] - mov dl , [@@x] - int 10h - - POP_PROC_REGS - ret - -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; x, y, char, color -; no results - -;COLOR TABLE ::: -;0 = black -;1 = blue -;2 = green -;4 = red -;6 = yellow -;7 = white -;8 = gray - - -proc OutputChar -ARG @@x:byte, @@y:byte , @@char:byte , @@color:byte - PUSH_PROC_REGS - - mov ah , 02h - mov bh , 0 - mov dh , [@@y] - mov dl , [@@x] - int 10h - mov ah , 09h - mov bh , 0h - mov al , [@@char] - mov cx , 1h - mov bl , [@@color] - int 10h - - POP_PROC_REGS - ret - -endp - - - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - - -; x, y, zero-terminated-line, color -; no results - - -proc OutputString -ARG @@x:byte , @@y:byte , @@str:word , @@color:byte - - PUSH_PROC_REGS - - ; This can be made with a singe callto int 10h fn 1300 - - mov si , [@@str] - cmp [byte ptr si] , 0 - je @@exit - mov dh , [@@y] - mov dl , [@@x] - cmp dl , screenHeight - ja @@exit - cmp dh , screenWidth - ja @@exit - mov ah , 02h - mov bh , 0 - int 10h - mov ah , 09h - mov bh , 0 - mov al , [si] - mov cx , 1 - mov bl , [@@color] - int 10h - -@@label: - - inc si - inc dl - mov bh , [si] - cmp bh , 1 - jc @@exit - cmp dl, screenWidth - je @@nextLine - -@@WriteChar: - - mov ah , 02h - mov bh , 0 - int 10h - mov ah , 09h - mov bh , 0 - mov al , [si] - mov cx , 1 - mov bl , [@@color] - int 10h - jmp @@label - -@@nextLine: - - xor dl , dl - inc dh ; DH may exceed the screen line count!!! - jmp @@WriteChar - -@@exit: - POP_PROC_REGS - ret -endp - - - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; pointerToImage (screenWidth*screenHeight), color - -proc OutputScreenImage -ARG @@buffer:word - PUSH_PROC_REGS - - ;Can be implemented with one call to int 10 fn 1303 - - mov si , [@@buffer] - mov dh , 0 - mov dl , 0 - -@@label: - - mov ah , 02h - mov bh , 0 - int 10h - mov ah , 09h - mov bh , 0h - mov al , [si] - mov cx , 1h - mov bl , [si + 1] - int 10h - add si , 2 - inc dl - cmp dl, screenWidth - jne @@label - -@@NextLine: - - inc dh - xor dl , dl - cmp dh , screenHeight - jne @@label - - -@@exit: - POP_PROC_REGS - ret -endp - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; ax=scan/ascii, cf=yes/no -proc IsCharPending - PUSH_PROC_REGS - - mov ah , 11h - int 16h - jnz @@yes - clc - jmp @@exit -@@yes: - mov ah , 10h - int 16h - stc -@@exit: - - POP_PROC_REGS - ret - -endp - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; no params -; ax=scan/ascii -proc ReadInputChar - PUSH_PROC_REGS - - xor ax , ax - int 16h - - POP_PROC_REGS - ret -endp - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; tickCount -; no results -proc DelayExecution - ARG @@tick:word - push es - - mov ax, 00040 - mov es, ax - mov cx, [@@tick] - mov ax, [es:0006ch] - -@@loop: - mov dx, ax - -@@wait_change: - mov ax, [es:0006ch] - cmp ax, dx - je @@wait_change - sub cx, 1 - jnc @@loop - - pop es - ret - -endp - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -proc GameMenu -ARG @@argc:word , @@argv:word , @@spos:word -local @@active:byte - -SELECT_CHAR = 16 -MENU_X = 8 -SELECT_X = MENU_X-2 - mov bx , [@@argv] - mov dx , [@@argc] - xor di , di - xor si , si - mov ax , bx - mov cx , [@@spos] -@@someLabel1: - - push cx - push dx - call outputString , MENU_X , cx , ax , 7 - pop dx - pop cx - -@@for: - mov ah , [bx + si] - inc si - cmp ah , 0 - jne @@for - mov ax , bx - add ax , si - add cx , 2 - dec dx - cmp dx , 0 - jne @@someLabel1 - - - mov al , 1 - mov [@@active] , al - - mov ax , [@@spos] - call outputChar , SELECT_X, ax , SELECT_CHAR , 5 - -@@q: - - call ReadInputChar - cmp ah , KEY_UP - je @@k_up - cmp ah , KEY_DOWN - je @@k_down - cmp ah , KEY_ENTER - je @@k_enter - cmp ah , KEY_ESC - je @@back - jmp @@q - -@@k_up: - - mov al , [@@active] - cmp al , 1 - je @@k_up_2 - movzx cx , al - shl cx , 1 - mov ax , [@@spos] - sub ax , 4 - add cx , ax - push cx - call outputChar , SELECT_X , cx , SELECT_CHAR , 5 - pop cx - add cx , 2 - call outputChar , SELECT_X , cx , ' ' , 7 - mov al , [@@active] - dec al - mov [@@active] , al - jmp @@q - - -@@k_up_2: - mov ax , [@@spos] - call outputChar , SELECT_X , ax , ' ' , 7 - - mov cx , [@@argc] - mov [@@active] , cl - - dec cx - shl cx , 1 - add cx , [@@spos] - call outputChar , SELECT_X , cx , SELECT_CHAR , 5 - jmp @@q - -@@k_down: - mov bx , [@@argc] - mov al , [@@active] - cmp bl , al - je @@k_down_2 - mov al , [@@active] - inc al - mov [@@active] , al - movzx cx , al - dec cx - shl cx ,1 - mov ax ,[@@spos] - add cx , ax - push cx - call outputChar , SELECT_X , cx , 16 , 5 - pop cx - sub cx , 2 - call outputChar , SELECT_X , cx , ' ' , 7 - - jmp @@q - -@@k_down_2: - mov al , 1 - mov [@@active] , al - - mov cx , [@@spos] - call outputChar , SELECT_X , cx , 16 , 5 - mov ax , [@@argc] - shl ax , 1 - add ax , SELECT_X - call outputChar , SELECT_X , ax , ' ' , 7 - jmp @@q - -@@k_enter: - call ClearScreen - xor ax , ax - mov al , [@@active] - ret - @@back: - mov ax , 0ffffh - ret -endp - - - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; -proc InitializeRandomGenerator - - push es - mov ax, 0040h - mov es, ax - mov ax, [es:006ch] - mov dx, [es:006eh] - mov [word ptr randSeed2 + 0], ax - mov [word ptr randSeed2 + 2], dx - pop es - ret -endp - -;####################################################################################### -;####################################################################################### -;####################################################################################### - -; maximum -; ax=random -proc GenerateRandomNumber -ARG @@max:word - -; _ptiddata ptd = _getptd(); -; -; return( ((ptd->_holdrand = ptd->_holdrand * 0x343fd -; + 0x269EC3) >> 16) & 0x7fff ); - -; srand(0); -; ((rand() * 2 * max) >> 16) - - push bx - push si - mov ax, [word ptr randSeed2] - mov si, 43fdh - mul si - mov cx, dx - mov bx, ax - mov ax, [word ptr randSeed2+2] - mul si - add cx, ax - mov ax, [word ptr randSeed2] - mov si, 3h - mul si - add cx, ax - add bx, 9ec3h - adc cx, 26h - mov [word ptr randSeed2], bx - mov ax, cx - mov [word ptr randSeed2], cx - shl ax, 1 - mul [@@max] - mov ax, dx - pop si - pop bx - ret -endp - - -end diff --git a/Src/util.inc b/Src/util.inc deleted file mode 100644 index 582adbe..0000000 --- a/Src/util.inc +++ /dev/null @@ -1,106 +0,0 @@ - - -screenWidth EQU 40 -screenHeight EQU 25 -KEY_ESC EQU 01h -KEY_ENTER EQU 1ch -KEY_ALT EQU 38h -KEY_UP EQU 48h -KEY_DOWN EQU 50h -KEY_LEFT EQU 4bh -KEY_RIGHT EQU 4dh -KEY_F1 EQU 3bh -KEY_F2 EQU 3ch -KEY_F3 EQU 3dh -KEY_F4 EQU 3eh -KEY_F5 EQU 3fh -KEY_F6 EQU 40h -KEY_F7 EQU 41h -KEY_F8 EQU 42h -KEY_CLEAR EQU 0eh - - -; exitCode -; no results -global ExitProgram: proc - -; no params -; al=success/fail -global InitVideo: proc - -;no params -;no results - -global GameMenu: proc - -global StringToInt: proc - -global intToString: proc - -; no params -; no results -global ShutdownVideo: proc - -;Program sleep some time in 10E-2 seconds -global Sleep: proc - -; no params -; no results -global ClearScreen: proc - -;params :Screen name and buffer -;result :Screen in buffer and cf = 0 if successfull or cf = 1 if error - -global ReadScreen: proc - - -; no params -; no results -global HideCursor: proc - - -; no params -; no results -global ShowCursor: proc - - -; x, y -; no results -global SetCursorPos: proc - - -; x, y, char, color -; no results -global OutputChar: proc - - -; x, y, zero-terminated-line, color -; no results -global OutputString: proc - -; pointerToImage (screenWidth*screenHeight), color -global OutputScreenImage: proc - - -; no params -; ax=scan/ascii, cf=yes/no -global IsCharPending: proc - - -; no params -; ax=scan/ascii -global ReadInputChar: proc - - -; tickCount -; no results -global DelayExecution: proc - - -; no params -; no results -global InitializeRandomGenerator: proc - -; maximum -; ax=random -global GenerateRandomNumber: proc