Add initial source files for Tic-Tac-Toe game implementation

Signed-off-by: Elmar Kresse <elmar.kresse@stud.htwk-leipzig.de>
This commit is contained in:
Elmar Kresse
2025-07-03 15:53:46 +02:00
commit 2a94dfb8d5
10 changed files with 1121 additions and 0 deletions

133
main.asm Normal file
View File

@ -0,0 +1,133 @@
;****************************************
; Elmar Kresse 19-INB-1 (2021)
; main.asm
; file contains source code for the
; main operations
;
;****************************************
.model small
.STACK 100h
.486
esc_code = 1Bh ;esc key
video_seg = 0B800h
.data
INCLUDE data.asm
.code
INCLUDE draw.asm
INCLUDE game.asmn
INCLUDE sound.asm
INCLUDE logic.asm
ISR1Ch: push ds
push ax
mov ax, @DATA
mov ds, ax
pop ax
pop ds
iret
;start of the main program
;----------------------------------------------------------------------------------------------------------
Beginn:
mov ax, @DATA
mov ds, ax
mov ax, 3
int 10h
;read old VT entry
mov al, 1Ch
mov ah, 35h
int 21h
;es:bx address old ISR
;save
mov oldIOFF, bx
mov oldISeg, es
;store new ISR
push ds ; store ds
push cs
pop ds ; ds <- cs
mov dx, OFFSET ISR1Ch ; address in ds:dx
mov al, 1Ch ; <vn>
mov ah, 25h
int 21h
pop ds ; restore ds
call start_programm
;--------------------------------------------------------------------------------------------------------
;Endlosschleife
;--------------------------------------------------------------------------------------------------------
endlloop:
xor ax, ax ;delete ah
int 16h ;Keyboard query, waits for any key is pressed
cmp al, esc_code ;If esc is not pressed, the program remains in the endless loop
jne short endlloop ;jmp not equal
call reset_timerisr
mov cx, 0
call start_programm
;-------------------------------------------------------------------------------------------------------
;End of the program and return to DOS
;-----------------------------------------------------------------------------------------------------
ende:
PUSH DS
MOV AX, 251Ch ;Restore old user timer interrupt vector
MOV DX, [CS:old_timer]
MOV CX, [CS:old_segment]
MOV DS, CX
INT 21h
POP DS
mov ax, 0 ;reset mouse programm
int 33h ;mouse interrupt
MOV ax, 3 ;Reset screen mode
INT 10h
mov dx, oldIOFF ;order is important
mov ax, oldISeg
mov ds, ax
mov al, 1Ch
mov ah, 25h
int 21h
mov ah, 4Ch ;Backflow to DOS
int 21h
.stack 100h
end Beginn
;---------------------------------------------------------------------------------------------------
; Convert X: Y coordinates to fields
; Check whether the field is free
; if free field
; test whether the player has won
; 1 2 3 0 1 2
; 1|2 3 4 0|0 1 2
; 4|5 6 7 3|3 4 5
; 7|8 9 10 6|6 7 8
;8 test cases
; 0,3,6
; 1,4,7
; 2,5,8
; 0,1,2
; 3,4,5
; 6,7,8
; 0,4,8
; 6,4,2