The Main -- Sasanka Chalivendra

Raw and Unedited


main proc far ; Author: Sasanka Chalivendra

mov ax,cseg ; Initialize Default Segment register
mov ds, ax
call KbdInstall ; install keyboard
call ModeGraph ; set in 320x200x256 mode

get_option:
mov ax, 0
call showMenu ; show main menu returs with
; bx = 0 if quit
; = 1 if controls
; = 2 if singleplayer
; = 3 if join network
; = 4 if view credits
call nooption
shl bx,1
jmp MainMenu[bx]

MainMenu dw offset leave_main, offset controls,offset player, offset get_option, offset wantcredits

wantcredits: mov ax, 3
call showMenu ; show credits and go back to main menu
jmp get_option

controls: mov ax, 2
call showMenu ; show the screen with all the key controls
jmp get_option ; go back to main menu

player:
call SB_Init ; intialize sound
mov cx,0
call PlayMid ; start playing MIDI
call Build_Tables
Invoke SetupGameData, 2
; call instTimer
call initplayers
mov al,0
mov ah,0
call newPlayer
mov dead,0
GameLoop: ; main loop, calls all gameplay and graphics functions
cli
; mov TimeOver,0
mov Pause_flag, 0
mov Key_flags,0
sti
;WaitForIt:
; cmp TimeOver,36
; jb waitforit
call Convert_Values
Invoke Ray_Caster, Player_X, Player_Y, Player_Angle
call ShowScreenBuffer
mov al, Key_flags
mov Flags_copy, al
call CalcCommand
call ProcessCommand
call UpdateMe
call PlayForComputer
call ComputeDamage
call UpdateMap
cmp Pause_Flag, 1
jne GameLoop
; call UnInstTimer

I_died_arg:

call StopMid
call SB_Stop
call SB_Clean
leave_main:
call ModeText
call KbdUninstall
DOSEXIT 0

main endp

cseg ends

END main