include GLOBALS.INC

; ===========================================================================
code segment para public 'CODE' use16
        assume cs:code

; =============== S U B R O U T I N E =======================================

; Attributes: noreturn

        public start
start       proc near

; FUNCTION CHUNK AT 027F SIZE 00000217 BYTES

        mov dx, seg data
        mov ds, dx
        assume ds:data

programStart:               ; CODE XREF: runMainMenu+28Fp
                    ; DATA XREF: data:000Ao
        ;db 26h, 8Ah, 0Eh, 80h, 00h
        mov cl, [es:80h]        ; Length of command line arguments
        mov cbCommandLine, cl
        cmp cl, 2
        jnb short hasCommandLine
        jmp doesNotHaveCommandLine
; ---------------------------------------------------------------------------

hasCommandLine:             ; CODE XREF: start+11j
        cld
        xor ch, ch      ; cx = nr command line bytes
        mov di, 81h ; '?'   ; start of command line args in PSP
        push    di
        push    cx

readAndProcessCommandLine:
        mov si, offset commandLine

copyNextCmdLineByte:            ; CODE XREF: start+28j
        mov al, es:[di]
        mov [si], al
        inc si
        inc di
        loop    copyNextCmdLineByte
        pop cx
        pop di
        mov di, ds
        mov es, di
        assume es:data
        mov di, offset commandLine
        push    di
        push    cx

processCommandLine:         ; CODE XREF: start+F7j
        mov al, 3Ah ; ':'
        repne scasb
        jz  short hascolon
        jmp nohascolon
; ---------------------------------------------------------------------------

hascolon:                ; CODE XREF: start+39j
        mov al, 20h 
        mov si, offset demoFileName

copyArgument:              ; CODE XREF: start+52j
        or  cx, cx
        jz  short loc_46C74
        mov ah, es:[di]
        cmp ah, al
        jz  short loc_46C74
        mov [si], ah
        inc si
        inc di
        loop    copyArgument

loc_46C74:              ; CODE XREF: start+45j start+4Cj
        xor al, al
        mov [si], al
        pop cx
        pop di
        push    di
        push    cx
        mov al, 3Ah ; ':'
        repne scasb
        dec di
        inc cx
        mov al, 20h ; ' '

loc_46C84:              ; CODE XREF: start+6Aj
        cmp es:[di], al
        jz  short loc_46C8C
        stosb
        loop    loc_46C84

loc_46C8C:              ; CODE XREF: start+67j
        mov ax, 3D00h
        mov dx, offset demoFileName
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jb  short loc_46D09
        mov bx, ax
        push    bx

loc_46C99:
        mov ax, 4202h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from end of file
        pop bx
        pushf
        jb  short loc_46CAF
        or  dx, dx
        jnz short loc_46CAF

loc_46CAA:
        cmp ax, levelDataLength

loc_46CAD:
        jb  short loc_46CB7

loc_46CAF:              ; CODE XREF: start+84j start+88j
        push    ax
        push    dx
        mov ah, 3Eh
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        pop dx
        pop ax

loc_46CB7:              ; CODE XREF: start:loc_46CADj
		db 8Dh, 36h, 65h, 9Fh
        ;lea si, [aFileDemo] ; "!! File >> Demo: "
        mov word_599DA, 0
        popf
        jb  short loc_46D09
        or  dx, dx
        jnz short loc_46CE4
        cmp ax, 0C60Ah
        ja  short loc_46CE4
        lea si, aFileLevel    ; "!! File < Level: "

loc_46CD1:
        cmp ax, levelDataLength
        jnb short loc_46CF4
        call    fileReadUnk1
        mov word_599DA, ax
        pushf
        mov ah, 3Eh
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        popf
        jnb short loc_46CF6

loc_46CE4:              ; CODE XREF: start+A6j start+ABj
        pop cx
        pop di
        push    di
        push    cx
        mov al, 40h ; '@'
        repne scasb
        jnz short loc_46D09
        call    conprintln
        jmp immediateexit
; ---------------------------------------------------------------------------

loc_46CF4:              ; CODE XREF: start+B4j
        jz  short loc_46CFB

loc_46CF6:              ; CODE XREF: start+C2j
        mov byte_599D5, 1

loc_46CFB:              ; CODE XREF: start:loc_46CF4j
        cmp demoFileName, 0
        jz  short loc_46D09
        mov byte_599D4, 2
        jmp short loc_46D13
; ---------------------------------------------------------------------------

loc_46D09:              ; CODE XREF: start+74j start+A2j ...
        mov demoFileName, 0
        mov byte_599D4, 0

loc_46D13:              ; CODE XREF: start+E7j
        pop cx
        pop di
        push    di
        push    cx
        jmp processCommandLine
; ---------------------------------------------------------------------------

nohascolon:               ; CODE XREF: start+3Bj
        pop cx
        pop di
        push    di
        push    cx
        mov al, 40h ; '@'
        repne scasb
        pop cx
        pop di
        jnz short runSpFile
        ; When @ is specd we need a valid file
        cmp demoFileName, 0
        jnz short demoFileNotMissing
        lea si, a@ErrorBadOrMis ; "\"@\"-ERROR: Bad or missing \":filename"...
        call    conprint
        jmp immediateexit
; ---------------------------------------------------------------------------

demoFileNotMissing:              ; CODE XREF: start+10Bj
        cmp byte_599D5, 1
        jz  short spHasAtAndDemo
        lea si, aSpWithoutDemo ; "SP without demo: "
        call    conprintln
        jmp immediateexit
; ---------------------------------------------------------------------------

spHasAtAndDemo:              ; CODE XREF: start+11Cj
        mov fastMode, 1
        mov speed?, 0

runSpFile:              ; CODE XREF: start+104j
        push    di
        push    cx
        mov al, 41h ; 'A'
        jmp short loc_46D5A
; ---------------------------------------------------------------------------

loc_46D58:              ; CODE XREF: start+14Fj
        mov al, 61h ; 'a'

loc_46D5A:              ; CODE XREF: start+136j
        lea bx, word_59B60

loc_46D5E:              ; CODE XREF: start+14Dj start+153j
        repne scasb
        jnz short loc_46D64
        or  [bx], al

loc_46D64:              ; CODE XREF: start+140j
        pop cx
        pop di
        push    di
        push    cx
        inc bx
        inc al
        cmp al, 5Bh ; '['
        jb  short loc_46D5E
        jz  short loc_46D58
        cmp al, 7Bh ; '{'
        jb  short loc_46D5E
        cmp byte_59B63, 0
        jz  short loc_46D82
        mov word_51970, 1

loc_46D82:              ; CODE XREF: start+15Aj
        mov al, 21h ; '!'
        repne scasb
        jnz short loc_46DBF
        cmp cx, 1
        jb  short loc_46DBF
        mov ax, es:[di]
        cmp al, 30h ; '0'
        jb  short loc_46DBF
        cmp al, 39h ; '9'
        ja  short loc_46DBF
        cmp ah, 30h ; '0'
        jb  short loc_46DA2
        cmp ah, 39h ; '9'
        jbe short modifysetfns

loc_46DA2:              ; CODE XREF: start+17Bj
        mov ah, al
        mov al, 30h ; '0'

modifysetfns:              ; CODE XREF: start+180j
        mov word ptr aLevels_dat_0+8, ax ; "AT"
        mov word ptr aLevel_lst+7, ax ; "ST"
        mov word ptr aDemo0_bin+7, ax ; "IN"
        mov word ptr aPlayer_lst+8, ax ; "ST"
        mov word ptr aHallfame_lst+0Ah, ax ; "ST"
        cmp byte ptr dword_59B76, 0
        jnz short loc_46DBF
        mov word ptr aSavegame_sav+0Ah, ax ; "AV"

loc_46DBF:              ; CODE XREF: start+166j start+16Bj ...
        pop cx
        pop di
        push    di
        push    cx
        mov al, 23h ; '#'
        repne scasb
        jnz short loc_46E18
        mov byte_59B85, 0FFh
        mov word_58DAC, 4628h
        mov word_58DAE, 524Fh
        mov word_58DB0, 4543h
        mov word_58DB2, 2944h
        mov di, 8AA8h
        mov cx, 6Fh ; 'o'
        mov al, 2
        push    es
        push    ds
        pop es
        rep stosb
        mov al, 20h ; ' '
        mov cx, 8
        mov di, 8B1Ch
        rep stosb
        mov cx, 8
        mov di, 8B9Ch
        rep stosb
        mov cx, 16h
        mov di, 8853h
        rep stosb
        mov cx, 16h
        mov di, 886Ah
        rep stosb
        pop es
        assume es:nothing
        jmp short loc_46E39
; ---------------------------------------------------------------------------

loc_46E18:              ; CODE XREF: start+1A7j
        pop cx
        pop di
        push    di
        push    cx
        mov al, 26h ; '&'
        repne scasb
        jnz short loc_46E39
        call    atoi        ; reset ax
        cmp al, 1
        jnb short loc_46E2B
        inc al

loc_46E2B:              ; CODE XREF: start+207j
        cmp al, 14h
        jbe short loc_46E31
        mov al, 14h

loc_46E31:              ; CODE XREF: start+20Dj
        dec al
        mov byte_5981F, al
        mov byte_58D46, al

loc_46E39:              ; CODE XREF: start+1F6j start+200j
        pop cx
        pop di
        push    di
        push    cx
        mov al, 2Ah ; '*'
        repne scasb
        jnz short loc_46E59
        call    atoi        ; reset ax
        cmp al, 0Ah
        jbe short loc_46E4C
        mov al, 0Ah

loc_46E4C:              ; CODE XREF: start+228j
        mov ah, 0Ah
        sub ah, al
        jb  short loc_46E59
        or  ah, 0C0h
        mov speed?3, ah

loc_46E59:              ; CODE XREF: start+221j start+230j
        pop cx
        pop di
        mov al, 2Fh ; '/'
        repne scasb
        jnz short doesNotHaveCommandLine
        mov byte_59B84, 0FFh
        call    atoi        ; reset ax
        cmp al, 1
        jnb short loc_46E6F
        inc al

loc_46E6F:              ; CODE XREF: start+24Bj
        cmp al, 6Fh ; 'o'
        jbe short loc_46E75
        mov al, 6Fh ; 'o'

loc_46E75:              ; CODE XREF: start+251j
        mov byte_59B84, al

doesNotHaveCommandLine:         ; CODE XREF: start+13j start+23Fj ...
        call    getTime
        call    checkVideo
        cmp byte_59B64, 0
        jz  short leaveVideoStatus
        mov videoStatusUnk, 2

leaveVideoStatus:           ; CODE XREF: start+28Aj
        mov ax, 0A000h
        mov es, ax
        assume es:nothing
        call    sub_4D2BF
        call    sub_4D2E9
        call    setint8
        call    setint24
        call    setint9
        call    sub_4D8B0
        cmp fastMode, 0
        jnz short isFastMode
        call    sub_4D517
        call    sub_4D4E4
        mov si, 60D5h
        call    sub_4D836
        call    readTitleDatAndGraphics?
        mov si, 5F15h
        call    fade

isFastMode:              ; CODE XREF: start+2ADj
        call    readMoving
        call    sub_4D4E4
        mov al, byte_59B6B
        or  al, byte_59B84
        or  al, byte_599D4
        or  al, fastMode
        jz  short openingSequence
        call    readEverything
        jmp short afterOpeningSequence
; ---------------------------------------------------------------------------

openingSequence:
        call    loadScreen2
        call    readEverything
        call    sub_502CF
        call    openCreditsBlock
        call    showNewCredits

afterOpeningSequence:              ; CODE XREF: start+2DEj
        call    readConfig
        cmp byte_50946, 0
        jz  short loc_46F20
        mov byte_50940, 1
        jmp short loc_46F25
; ---------------------------------------------------------------------------

loc_46F20:              ; CODE XREF: start+2F7j
        mov byte_50940, 0

loc_46F25:              ; CODE XREF: start+2FEj
        cmp fastMode, 0
        jz  short isNotFastMode
        jmp loc_46FBE
; ---------------------------------------------------------------------------

isNotFastMode:              ; CODE XREF: start+30Aj
        mov si, 60D5h
        call    fade
        mov word_58467, 1
        jmp loc_46FBE
; ---------------------------------------------------------------------------

loc_46F3E:              ; CODE XREF: start+428j start+444j
        call    readLevels
        mov si, 60D5h
        call    fade
        mov byte_5A33F, 0
        call    sub_4C293
        call    sub_48A20
        call    sub_4D464
        call    sub_48F6D
        call    sub_501C0
        call    sub_4A2E6
        call    sub_4A3BB
        call    enableFloppy?
        call    findMurphy
        mov si, 6015h
        call    fade
        cmp byte_59886, 0
        jnz short loc_46F77
        call    sound?3

loc_46F77:              ; CODE XREF: start+352j
        mov byte_5A33F, 1
        call    runLevel
        mov byte_599D4, 0
        cmp word_5197A, 0
        jz  short loc_46F8E
        jmp loc_47067
; ---------------------------------------------------------------------------

loc_46F8E:              ; CODE XREF: start+369j
        cmp fastMode, 1
        jnz short isNotFastMode2
        jmp doneWithDemoPlayback
; ---------------------------------------------------------------------------

isNotFastMode2:              ; CODE XREF: start+373j
        call    slideDownGameDash
        cmp byte_59B71, 0
        jz  short loc_46FA5
        call    readMoving

loc_46FA5:              ; CODE XREF: start+380j
        mov byte_5A33F, 0
        cmp word_5197A, 0
        jz  short loc_46FB4
        jmp loc_47067
; ---------------------------------------------------------------------------

loc_46FB4:              ; CODE XREF: start+38Fj
        cmp byte_59886, 0
        jnz short loc_46FBE
        call    sound?2

loc_46FBE:              ; CODE XREF: start+30Cj start+31Bj ...
        call    enableFloppy?
        call    sub_49544
        cmp byte_599D4, 2
        jnz short loc_46FFF
        mov byte_599D4, 1
        cmp byte_599D5, 1
        jnz short loc_46FDF
        mov ax, 0
        call    demoSomething?
        jmp short loc_46FE4
; ---------------------------------------------------------------------------

loc_46FDF:              ; CODE XREF: start+3B5j
        mov byte_510DE, 0

loc_46FE4:              ; CODE XREF: start+3BDj
        mov ax, 1
        mov byte_510B3, 0
        mov byte_5A2F9, 1
        mov byte ptr a00s0010_sp+3, 2Dh ; '-' ; "001$0.SP"
        mov word ptr a00s0010_sp+4, 2D2Dh ; "01$0.SP"
        push    ax
        jmp short loc_4701A
; ---------------------------------------------------------------------------

loc_46FFF:              ; CODE XREF: start+3A9j
        mov al, byte_59B84
        mov byte_59B84, 0
        mov byte_510DE, 0
        inc al
        jz  short loc_4704B
        dec al
        jz  short loc_4704B
        xor ah, ah
        push    ax
        call    sub_4BF4A

loc_4701A:              ; CODE XREF: start+3DDj start+433j
        mov byte_5A33F, 1
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        mov word_58467, 0
        call    sound?2
        pop ax
        mov word_51ABC, ax
        call    sub_4B899
        call    sub_4C141
        mov word_5196C, 0
        mov byte_5A19B, 0
        jmp loc_46F3E
; ---------------------------------------------------------------------------

loc_4704B:              ; CODE XREF: start+3EEj start+3F2j
        mov ax, 1
        cmp byte_59B6B, 0
        jnz short loc_4701A
        mov byte_5A2F9, 0
        call    runMainMenu
        cmp word_5197A, 0
        jnz short loc_47067
        jmp loc_46F3E
; ---------------------------------------------------------------------------

loc_47067:              ; CODE XREF: start+36Bj start+391j ...
        mov si, 60D5h
        call    fade

doneWithDemoPlayback:           ; CODE XREF: start+375j
        call    resetint9
        call    sub_4D2E1
        cmp fastMode, 1
        jnz short isNotFastMode3
        cmp byte_5A19C, 0
        jz  short loc_47094
        cmp byte_5A19B, 0
        jz  short loc_4708E
        lea si, aDemoSuccessful ; "Demo successful: "
        jmp short printMessageAfterward
; ---------------------------------------------------------------------------

loc_4708E:              ; CODE XREF: start+466j
        lea si, aDemoFailed ; "Demo failed:     "
        jmp short printMessageAfterward
; ---------------------------------------------------------------------------

loc_47094:              ; CODE XREF: start+45Fj
        cmp byte_5A19B, 0
        jz  short loc_470A1
        lea si, a@ErrorLevel?Su ; "\"@\"-ERROR: Level(?) successful: "
        jmp short printMessageAfterward
; ---------------------------------------------------------------------------

loc_470A1:              ; CODE XREF: start+479j
        lea si, a@ErrorLevel?Fa ; "\"@\"-ERROR: Level(?) failed:     "

printMessageAfterward:          ; CODE XREF: start+46Cj start+472j ...
        call    conprintln

isNotFastMode3:              ; CODE XREF: start+458j
        call    resetint24
        call    resetint8
        call    soundShutdown?

immediateexit:              ; CODE XREF: start+D1j start+114j ...
        mov ax, 4C00h
        int 21h     ; DOS - 2+ - QUIT WITH EXIT CODE (EXIT)
; END OF FUNCTION CHUNK FOR start   ; AL = exit code
start       endp ; sp-analysis failed

; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR loadScreen2

exit:                   ; CODE XREF: readConfig:loc_474BBj
                    ; readConfig+3Bj ...
        push    ax
        call    resetint9
        call    resetint24
        call    soundShutdown?
        call    sub_4D2E1
        call    resetint8
        pop ax
        push    ax
        call    writeexitmessage
        pop ax
        or  al, al
        jnz short exitnow
        dec al

exitnow:                ; CODE XREF: loadScreen2-7C9j
        mov ah, 4Ch
        int 21h     ; DOS - 2+ - QUIT WITH EXIT CODE (EXIT)
; END OF FUNCTION CHUNK FOR loadScreen2 ; AL = exit code

; =============== S U B R O U T I N E =======================================


fileReadUnk1    proc near       ; CODE XREF: start+B6p readDemo+81p
        push    bx
        lea bx, word_599DC
        mov cx, 0Ah     ; cx = 10

loop_:                  ; CODE XREF: fileReadUnk1+Fj
        cmp [bx], ax
        jz  short loc_47105
        add bx, 2
        loop    loop_
        jmp short bail
; ---------------------------------------------------------------------------

loc_47105:              ; CODE XREF: fileReadUnk1+Aj
        pop bx
        push    bx
        push    cx
        mov ax, 4200h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        pop ax
        jb  short bail
        pop bx
        push    bx
        push    ax
        mov cx, 4
        lea dx, fileLevelData
        mov ax, 3F00h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        pop bx
        jb  short bail
        sub bx, 0Ah
        neg bx
        shl bx, 1
        shl bx, 1
        mov si, offset fileLevelData
        mov ax, [bx-691Eh]
        cmp ax, word_50A7A
        jnz short bail
        mov ax, [bx-6920h]
        cmp ax, fileLevelData
        jnz short bail
        xor ah, ah
        clc
        jmp short done
; ---------------------------------------------------------------------------

bail:                   ; CODE XREF: fileReadUnk1+11j
                    ; fileReadUnk1+20j ...
        xor ax, ax
        stc

done:                   ; CODE XREF: fileReadUnk1+57j
        pop bx
        retn
fileReadUnk1    endp


; =============== S U B R O U T I N E =======================================


crt?2       proc near       ; CODE XREF: slideDownGameDash:loc_4720Cp
        cmp byte ptr word_510C1, 0
        jz  short loc_4715C
        mov cx, 5Fh ; '_'
        jmp short loc_4715F
; ---------------------------------------------------------------------------

loc_4715C:              ; CODE XREF: crt?2+5j
        mov cx, 90h ; '?'

loc_4715F:              ; CODE XREF: crt?2+Aj crt?2+5Fj
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 7
        out dx, al      ; Video: CRT cntrlr addr
                    ; bit 8 for certain CRTC regs. Data bits:
                    ; 0: vertical total (Reg 06)
                    ; 1: vert disp'd enable end (Reg 12H)
                    ; 2: vert retrace start (Reg 10H)
                    ; 3: start vert blanking (Reg 15H)
                    ; 4: line compare (Reg 18H)
                    ; 5: cursor location (Reg 0aH)
        inc dx
        mov al, 3Fh ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 9
        out dx, al      ; Video: CRT cntrlr addr
                    ; maximum scan line
        inc dx
        mov al, 80h ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov bx, word_51967
        cmp bx, 4DAEh
        jbe short loc_4718E
        sub bx, 7Ah ; 'z'
        mov word_51967, bx

loc_4718E:              ; CODE XREF: crt?2+35j
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        call    sub_4D457
        add cx, 1
        cmp cx, 90h ; '?'
        jbe short loc_4715F
        retn
crt?2       endp


; =============== S U B R O U T I N E =======================================


crt?1       proc near       ; CODE XREF: slideDownGameDash+7p
        cmp byte ptr word_510C1, 0
        jz  short loc_471BE
        mov cx, 0B0h ; '?'
        jmp short loc_471C1
; ---------------------------------------------------------------------------

loc_471BE:              ; CODE XREF: crt?1+5j
        mov cx, 0C8h ; '?'

loc_471C1:              ; CODE XREF: crt?1+Aj crt?1+4Bj
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers
        mov bx, word_51967
        cmp bx, 4DAEh
        jbe short loc_471DC
        sub bx, 7Ah ; 'z'
        mov word_51967, bx

loc_471DC:              ; CODE XREF: crt?1+21j
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        call    sub_4D457
        add cx, 1
        cmp cx, 0C8h ; '?'
        jbe short loc_471C1
        retn
crt?1       endp


; =============== S U B R O U T I N E =======================================


slideDownGameDash proc near     ; CODE XREF: start:isNotFastMode2p
        cmp videoStatusUnk, 2
        jnz short loc_4720C
        call    crt?1
        jmp short locret_4720F
; ---------------------------------------------------------------------------

loc_4720C:              ; CODE XREF: slideDownGameDash+5j
        call    crt?2

locret_4720F:               ; CODE XREF: slideDownGameDash+Aj
        retn
slideDownGameDash endp


; =============== S U B R O U T I N E =======================================


setint9     proc near       ; CODE XREF: start+2A2p

; waits for shift, ctrl, alt, system, and suspend to NOT be pressed
        push    ds
        mov ax, 0040h;
        mov ds, ax
        assume ds:nothing

keysstillpressed:
        ; test keyboard state flags at 0040:0017
        test    word ptr [ds:0017h], 0F70Fh 
        jnz short keysstillpressed 

; keys no longer pressed, we can continue
        pop ds
        assume ds:data
        push    ds
        push    es
        mov ah, 35h ; '5'
        mov al, 9
        int 21h     ; DOS - 2+ - GET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; Return: ES:BX = value of interrupt vector
        mov int9seg, es
        mov int9off, bx
        mov dx, offset int9handler
        mov ax, seg code
        mov ds, ax
        assume ds:code
        mov ah, 25h ; '%'
        mov al, 9
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        pop es
        assume es:nothing
        pop ds
        assume ds:data
        retn
setint9     endp


; =============== S U B R O U T I N E =======================================


resetint9   proc near       ; CODE XREF: start:doneWithDemoPlaybackp
                    ; loadScreen2-7E0p ...
        cmp byte_5199A, 0
        jnz short resetint9
        cmp byte ptr word_519A7, 0
        jnz short resetint9
        cmp byte ptr word_519B3, 0
        jnz short resetint9
        cmp byte_519B5, 0
        jnz short resetint9
        cmp byte_519B7, 0
        jnz short resetint9
        cmp byte_519C2, 0
        jnz short resetint9
        cmp byte_519C3, 0
        jnz short resetint9
        cmp byte_519CF, 0
        jnz short resetint9
        cmp byte_519D1, 0
        jnz short resetint9
        push    ds
        push    es
        mov dx, int9off
        mov ax, int9seg
        mov ds, ax
        mov ah, 25h ; '%'
        mov al, 9
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        pop es
        pop ds
        retn
resetint9   endp

; ---------------------------------------------------------------------------
        nop

; =============== S U B R O U T I N E =======================================


int9handler proc far        ; DATA XREF: setint9+1Fo
        push    ax
        push    bx
        push    cx
        push    ds
        mov ax, seg data
        mov ds, ax
        in  al, 60h     ; 8042 keyboard input buffer
        mov cl, al
        mov bl, al
        in  al, 61h     ; PC/XT PPI port B bits:
                    ; 0: Tmr 2 gate ??? OR 03H=spkr ON
                    ; 1: Tmr 2 data ?  AND  0fcH=spkr OFF
                    ; 3: 1=read high switches
                    ; 4: 0=enable RAM parity checking
                    ; 5: 0=enable I/O channel check
                    ; 6: 0=hold keyboard clock low
                    ; 7: 0=enable kbrd
        or  al, 10000000b
        out 61h, al     ; enable keyboard
        and al, 1111111b
        out 61h, al     ; disable keyboard
        xor al, al
        xor bh, bh
        shl bl, 1
        cmc
        rcl al, 1
        shr bl, 1
        mov [bx+166Dh], al
        test    cl, 80h     ; think key up
        jz  short storeKey
        jmp storeNoKeyPressed
; ---------------------------------------------------------------------------

storeKey:               ; CODE XREF: int9handler+2Bj
        mov keyPressed, cl
        cmp speed?3, 0
        jl  short checkX
        cmp cl, 37h ; '7'   ; Grey *
        jnz short checkSlash
        cmp speed?3, 0
        jl  short checkSlash
        mov cl, speed?3
        mov gameSpeed, cl
        jmp short loc_47320
; ---------------------------------------------------------------------------

checkSlash:             ; CODE XREF: int9handler+3Ej
                    ; int9handler+45j
        cmp cl, 35h ; '5'   ; /
        jnz short checkPlus
        mov speed?, 0
        mov gameSpeed, 0Ah
        jmp short checkX
; ---------------------------------------------------------------------------

checkPlus:              ; CODE XREF: int9handler+54j
        cmp cl, 4Eh ; 'N'   ; Grey +
        jnz short checkMinus
        mov speed?, 0
        cmp gameSpeed, 0Ah
        jnb short checkMinus
        inc gameSpeed

checkMinus:             ; CODE XREF: int9handler+65j
                    ; int9handler+71j
        cmp cl, 4Ah ; 'J'   ; Grey -
        jnz short checkX
        mov speed?, 0
        cmp gameSpeed, 0
        jz  short checkX
        dec gameSpeed

loc_47320:              ; CODE XREF: int9handler+4Fj
        push    cx
        mov cl, speed?2
        and cl, 0F0h
        or  cl, gameSpeed
        cmp speed?2, cl
        jbe short dontUpdateSpeed?2
        mov speed?2, cl

dontUpdateSpeed?2:          ; CODE XREF: int9handler+9Cj
        pop cx

checkX:                 ; CODE XREF: int9handler+39j
                    ; int9handler+60j ...
        cmp cl, 2Dh ; '-'   ; X
        jnz short doneexit
        cmp byte_519B5, 0
        jz  short doneexit
        mov word_51974, 1
        mov word_5197A, 1
        jmp short doneexit
; ---------------------------------------------------------------------------

storeNoKeyPressed:          ; CODE XREF: int9handler+2Dj
        mov keyPressed, 0

doneexit:                   ; CODE XREF: int9handler+A6j
                    ; int9handler+ADj ...
        mov al, 100000b ; nonspecific EOI
        out 20h, al     ; Interrupt controller, 8259A.
        pop ds
        pop cx
        pop bx
        pop ax
        iret
int9handler endp

; ---------------------------------------------------------------------------
        nop

; =============== S U B R O U T I N E =======================================


int8handler proc far        ; DATA XREF: setint8+10o
        push    ds
        push    dx
        push    ax
        mov ax, seg data
        mov ds, ax
        inc byte_59B96
        cmp byte_510AE, 0
        jz  short loc_473AA
        mov al, byte_510AF
        inc al
        mov byte_510AF, al
        cmp al, 32h ; '2'
        jl  short loc_473AA
        mov byte_510AF, 0
        mov al, byte_510B0
        inc al
        mov byte_510B0, al
        cmp al, 3Ch ; '<'
        jl  short loc_473AA
        mov byte_510B0, 0
        mov al, byte_510B1
        inc al
        mov byte_510B1, al
        cmp al, 3Ch ; '<'
        jl  short loc_473AA
        mov byte_510B1, 0
        inc byte_510B2

loc_473AA:              ; CODE XREF: int8handler+11j
                    ; int8handler+1Dj ...
        cmp soundEnabled?, 0
        jz  short loc_473B4
        call    sound?11

loc_473B4:              ; CODE XREF: int8handler+4Fj
        cmp byte_5988B, 0
        jz  short loc_473C6
        dec byte_5988B
        jnz short loc_473C6
        mov byte_59889, 0

loc_473C6:              ; CODE XREF: int8handler+59j
                    ; int8handler+5Fj
        cmp byte_5988C, 0
        jz  short loc_473D8
        dec byte_5988C
        jnz short loc_473D8
        mov byte_5988A, 0

loc_473D8:              ; CODE XREF: int8handler+6Bj
                    ; int8handler+71j
        inc byte_5A320
        inc byte_5A321
        cmp byte_5A320, 3
        jnz short loc_473F0
        inc byte_5A322
        mov byte_5A320, 0

loc_473F0:              ; CODE XREF: int8handler+85j
        cmp byte_5A321, 21h ; '!'
        jnz short loc_47400
        inc byte_5A322
        mov byte_5A321, 0

loc_47400:              ; CODE XREF: int8handler+95j
        cmp byte_5A322, 0
        jz  short loc_47414
        dec byte_5A322
        pop ax
        pop dx
        pushf
        call   [int8loc]
        pop ds
        iret
; ---------------------------------------------------------------------------

loc_47414:              ; CODE XREF: int8handler+A5j
        mov al, 20h ; ' '
        out 20h, al     ; Interrupt controller, 8259A.
        pop ax
        pop dx
        pop ds
        iret
int8handler endp


; =============== S U B R O U T I N E =======================================


setint8     proc near       ; CODE XREF: start+29Cp
        push    ds
        push    es
        mov ah, 35h ; '5'
        mov al, 8
        int 21h     ; DOS - 2+ - GET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; Return: ES:BX = value of interrupt vector
        mov word ptr int8loc+2, es
        mov word ptr int8loc, bx
        mov dx, offset int8handler
        mov ax, seg code
        mov ds, ax
        assume ds:code
        mov ah, 25h ; '%'
        mov al, 8
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        mov al, 36h ; '6'
        out 43h, al     ; Timer 8253-5 (AT: 8254.2).
        mov al, 38h ; '8'
        out 40h, al     ; Timer 8253-5 (AT: 8254.2).
        mov al, 5Dh ; ']'
        out 40h, al     ; Timer 8253-5 (AT: 8254.2).
        pop es
        pop ds
        assume ds:data
        retn
setint8     endp


; =============== S U B R O U T I N E =======================================


resetint8   proc near       ; CODE XREF: start+48Bp
                    ; loadScreen2-7D4p
        push    ds
        push    es
        mov dx, word ptr int8loc
        mov ax, word ptr int8loc+2
        mov ds, ax
        mov ah, 25h ; '%'
        mov al, 8
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        mov al, 36h ; '6'
        out 43h, al     ; Timer 8253-5 (AT: 8254.2).
        mov al, 0FFh
        out 40h, al     ; Timer 8253-5 (AT: 8254.2).
        mov al, 0FFh
        out 40h, al     ; Timer 8253-5 (AT: 8254.2).
        pop es
        pop ds
        retn
resetint8   endp


; =============== S U B R O U T I N E =======================================


setint24    proc near       ; CODE XREF: start+29Fp
        push    ds
        push    es
        mov ah, 35h ; '5'
        mov al, 24h ; '$'
        int 21h     ; DOS - 2+ - GET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; Return: ES:BX = value of interrupt vector
        mov word_510A9, es
        mov word_510A7, bx
        mov dx, offset int24handler
        mov ax, seg code
        mov ds, ax
        assume ds:code
        mov ah, 25h ; '%'
        mov al, 24h ; '$'
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        pop es
        pop ds
        assume ds:data
        retn
setint24    endp


; =============== S U B R O U T I N E =======================================


resetint24  proc near       ; CODE XREF: start:isNotFastMode3p
                    ; loadScreen2-7DDp
        push    ds
        push    es
        mov dx, word_510A7
        mov ax, word_510A9
        mov ds, ax
        mov ah, 25h ; '%'
        mov al, 24h ; '$'
        int 21h     ; DOS - SET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; DS:DX = new vector to be used for specified interrupt
        pop es
        pop ds
        retn
resetint24  endp


; =============== S U B R O U T I N E =======================================


int24handler    proc far        ; DATA XREF: setint24+10o
        mov al, 1
        iret
int24handler    endp


; =============== S U B R O U T I N E =======================================


readConfig  proc near       ; CODE XREF: start:loc_46F0Fp
        mov ax, 3D00h
        mov dx, offset aSupaplex_cfg ; "SUPAPLEX.CFG"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_474BE
        cmp ax, 2
        jnz short loc_474B3
        jmp loc_47551
; ---------------------------------------------------------------------------

loc_474B3:              ; CODE XREF: readConfig+Dj
        cmp ax, 3
        jnz short loc_474BB
        jmp loc_47551
; ---------------------------------------------------------------------------

loc_474BB:              ; CODE XREF: readConfig+15j
        jmp exit
; ---------------------------------------------------------------------------

loc_474BE:              ; CODE XREF: readConfig+8j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        mov ax, 3F00h
        mov cx, 4
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        pushf
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_474DF
        jmp exit
; ---------------------------------------------------------------------------

loc_474DF:              ; CODE XREF: readConfig+39j
        popf
        jnb short loc_474E5
        jmp exit
; ---------------------------------------------------------------------------

loc_474E5:              ; CODE XREF: readConfig+3Fj
        mov si, offset fileLevelData
        cmp byte ptr [si], 73h ; 's'
        jnz short loc_474F2
        call    loadBeep2
        jmp short loc_4751D
; ---------------------------------------------------------------------------

loc_474F2:              ; CODE XREF: readConfig+4Aj
        cmp byte ptr [si], 61h ; 'a'
        jnz short loc_474FC
        call    loadAdlib
        jmp short loc_4751D
; ---------------------------------------------------------------------------

loc_474FC:              ; CODE XREF: readConfig+54j
        cmp byte ptr [si], 62h ; 'b'
        jnz short loc_47506
        call    loadBlaster
        jmp short loc_4751D
; ---------------------------------------------------------------------------

loc_47506:              ; CODE XREF: readConfig+5Ej
        cmp byte ptr [si], 72h ; 'r'
        jnz short loc_47510
        call    loadRoland
        jmp short loc_4751D
; ---------------------------------------------------------------------------

loc_47510:              ; CODE XREF: readConfig+68j
        cmp byte ptr [si], 63h ; 'c'
        jnz short loc_4751A
        call    loadCombined
        jmp short loc_4751D
; ---------------------------------------------------------------------------

loc_4751A:              ; CODE XREF: readConfig+72j
        call    loadBeep

loc_4751D:              ; CODE XREF: readConfig+4Fj
                    ; readConfig+59j ...
        inc si
        mov byte_50940, 0
        cmp byte ptr [si], 6Ah ; 'j'
        jnz short loc_47530
        mov byte_50940, 1
        call    sub_4921B

loc_47530:              ; CODE XREF: readConfig+85j
        inc si
        mov byte_59886, 0
        cmp byte ptr [si], 6Dh ; 'm'
        jnz short loc_47540
        mov byte_59886, 1

loc_47540:              ; CODE XREF: readConfig+98j
        inc si
        mov byte_59885, 0
        cmp byte ptr [si], 78h ; 'x'
        jnz short locret_47550
        mov byte_59885, 1

locret_47550:               ; CODE XREF: readConfig+A8j
        retn
; ---------------------------------------------------------------------------

loc_47551:              ; CODE XREF: readConfig+Fj
                    ; readConfig+17j
        call    loadBeep
        mov byte_50940, 0
        retn
readConfig  endp

; ---------------------------------------------------------------------------
sub_4755A       proc near               ; CODE XREF: code:loc_4CAECp
                mov     ax, 3C00h
                mov     cx, 0
                mov     dx, 371Dh
                int     21h             ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                                        ; CX = attributes for file
                                        ; DS:DX -> ASCIZ filename (may include drive and path)
                jnb     short loc_4756A
                jmp     exit
; ---------------------------------------------------------------------------

loc_4756A:                              ; CODE XREF: sub_4755A+Bj
                mov     lastFileHandle, ax
                mov     si, offset fileLevelData
                cmp     sndType, 2
                jnz     short loc_4757C
                mov     byte ptr [si], 73h ; 's'
                jmp     short loc_475AF
; ---------------------------------------------------------------------------

loc_4757C:                              ; CODE XREF: sub_4755A+1Bj
                cmp     sndType, 1
                jnz     short loc_47588
                mov     byte ptr [si], 69h ; 'i'
                jmp     short loc_475AF
; ---------------------------------------------------------------------------

loc_47588:                              ; CODE XREF: sub_4755A+27j
                cmp     sndType, 3
                jnz     short loc_47594
                mov     byte ptr [si], 61h ; 'a'
                jmp     short loc_475AF
; ---------------------------------------------------------------------------

loc_47594:                              ; CODE XREF: sub_4755A+33j
                cmp     sndType, 5
                jnz     short loc_475A0
                mov     byte ptr [si], 72h ; 'r'
                jmp     short loc_475AF
; ---------------------------------------------------------------------------

loc_475A0:                              ; CODE XREF: sub_4755A+3Fj
                cmp     musType, 5
                jnz     short loc_475AC
                mov     byte ptr [si], 63h ; 'c'
                jmp     short loc_475AF
; ---------------------------------------------------------------------------

loc_475AC:                              ; CODE XREF: sub_4755A+4Bj
                mov     byte ptr [si], 62h ; 'b'

loc_475AF:                              ; CODE XREF: sub_4755A+20j
                                        ; sub_4755A+2Cj ...
                inc     si
                cmp     byte_50940, 0
                jnz     short loc_475BC
                mov     byte ptr [si], 6Bh ; 'k'
                jmp     short loc_475BF
; ---------------------------------------------------------------------------

loc_475BC:                              ; CODE XREF: sub_4755A+5Bj
                mov     byte ptr [si], 6Ah ; 'j'

loc_475BF:                              ; CODE XREF: sub_4755A+60j
                inc     si
                cmp     byte_59886, 0
                jz      short loc_475CC
                mov     byte ptr [si], 6Dh ; 'm'
                jmp     short loc_475CF
; ---------------------------------------------------------------------------

loc_475CC:                              ; CODE XREF: sub_4755A+6Bj
                mov     byte ptr [si], 6Eh ; 'n'

loc_475CF:                              ; CODE XREF: sub_4755A+70j
                inc     si
                cmp     byte_59885, 0
                jz      short loc_475DC
                mov     byte ptr [si], 78h ; 'x'
                jmp     short loc_475DF
; ---------------------------------------------------------------------------

loc_475DC:                              ; CODE XREF: sub_4755A+7Bj
                mov     byte ptr [si], 79h ; 'y'

loc_475DF:                              ; CODE XREF: sub_4755A+80j
                mov     bx, lastFileHandle
                mov     ax, 4000h
                mov     cx, 4
                mov     dx, offset fileLevelData
                int     21h             ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                                        ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
                jnb     short loc_475F3
                jmp     exit
; ---------------------------------------------------------------------------

loc_475F3:                              ; CODE XREF: sub_4755A+94j
                mov     ax, 3E00h
                mov     bx, lastFileHandle
                int     21h             ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                                        ; BX = file handle
                jnb     short locret_47601
                jmp     exit
; ---------------------------------------------------------------------------

locret_47601:                           ; CODE XREF: sub_4755A+A2j
                retn
sub_4755A       endp

; =============== S U B R O U T I N E =======================================


enableFloppy?   proc near       ; CODE XREF: start+341p
                    ; start:loc_46FBEp ...
        mov dx, 3F2h
        mov al, 1111b
        out dx, al      ; Floppy: digital output reg bits:
                    ; 0-1: Drive to select 0-3 (AT: bit 1 not used)
                    ; 2:   0=reset diskette controller; 1=enable controller
                    ; 3:   1=enable diskette DMA and interrupts
                    ; 4-7: drive motor enable.  Set bits to turn drive ON.
                    ;
        retn
enableFloppy?   endp


; =============== S U B R O U T I N E =======================================


readDemo    proc near       ; CODE XREF: readEverything+12p
                    ; sub_4B159p ...
        push    es
        mov ax, seg demoseg
        mov es, ax
        assume es:demoseg
        mov bx, 16h
        mov word_510DF, bx
        mov word_5A33C, bx
        mov ax, 0FFFFh
        mov di, 0
        mov cx, 0Bh
        cld
        rep stosw
        mov cx, 0

loc_47629:              ; CODE XREF: readDemo+175j
        push    cx
        mov word_599D8, 0
        cmp byte_599D4, 1
        jnz short loc_4763C
        mov dx, offset demoFileName
        jmp short loc_47647
; ---------------------------------------------------------------------------

loc_4763C:              ; CODE XREF: readDemo+2Cj
        mov bx, offset aDemo0_bin ; "DEMO0.BIN"
        add cl, 30h ; '0'
        mov [bx+4], cl
        mov dx, bx

loc_47647:              ; CODE XREF: readDemo+31j
        mov ax, 3D00h
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47651
        jmp loc_47783
; ---------------------------------------------------------------------------

loc_47651:              ; CODE XREF: readDemo+43j
        mov lastFileHandle, ax
        mov bx, ax
        cmp byte_599D4, 1
        jnz short loc_47674
        cmp word_599DA, 0
        jnz short loc_476DB
        mov ax, 4200h
        xor cx, cx
        mov dx, levelDataLength
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        mov bx, lastFileHandle
        jmp short loc_476DB
; ---------------------------------------------------------------------------

loc_47674:              ; CODE XREF: readDemo+52j
        push    bx
        mov ax, 4202h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from end of file
        pop bx
        jb  short loc_47690
        or  dx, dx
        jnz short loc_47690
        cmp ax, levelDataLength
        jnb short loc_47690
        call    fileReadUnk1
        mov word_599D8, ax

loc_47690:              ; CODE XREF: readDemo+76j readDemo+7Aj ...
        mov ax, 4200h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        cmp word_599D8, 0
        jnz short loc_476DB
        mov ax, 3F00h
        mov bx, lastFileHandle
        pop cx
        push    cx
        mov dx, cx
        shl cx, 1
        add dx, cx
        mov cl, 9
        shl dx, cl
        add dx, 0BE20h
        mov cx, levelDataLength
        push    ds
        push    dx
        push    es
        pop ds
        assume ds:demoseg
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        pop bx
        mov dx, [bx+5FEh]
        pop ds
        assume ds:data
        jnb short loc_476CB
        jmp loc_47783
; ---------------------------------------------------------------------------

loc_476CB:              ; CODE XREF: readDemo+BDj
        cmp ax, levelDataLength
        jz  short loc_476D3
        jmp loc_47783
; ---------------------------------------------------------------------------

loc_476D3:              ; CODE XREF: readDemo+C5j
        pop bx
        push    bx
        shl bx, 1
        mov [bx-67CAh], dx

loc_476DB:              ; CODE XREF: readDemo+59j readDemo+69j ...
        mov cx, 0BE09h
        sub cx, word_510DF
        cmp cx, 0BE09h
        jbe short loc_476EA
        xor cx, cx

loc_476EA:              ; CODE XREF: readDemo+DDj
        cmp cx, 0
        jnz short loc_476F3
        xor ax, ax
        jmp short loc_4771A
; ---------------------------------------------------------------------------

loc_476F3:              ; CODE XREF: readDemo+E4j
        mov dx, word_510DF
        mov bx, lastFileHandle
        push    ds
        mov ax, es
        mov ds, ax
        assume ds:nothing
        mov ax, 3F00h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47719
        pop ds
        assume ds:data
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        mov ax, 0
        jnb short loc_47783
        jmp exit
; ---------------------------------------------------------------------------

loc_47719:              ; CODE XREF: readDemo+FCj
        pop ds

loc_4771A:              ; CODE XREF: readDemo+E8j
        push    ax
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47729
        jmp exit
; ---------------------------------------------------------------------------

loc_47729:              ; CODE XREF: readDemo+11Bj
        pop ax
        mov bx, word_510DF
        and byte ptr es:[bx], 7Fh
        cmp word_599D8, 0
        mov word_599D8, 0
        jnz short loc_47743
        or  byte ptr es:[bx], 80h

loc_47743:              ; CODE XREF: readDemo+134j
        mov cx, bx
        add bx, ax
        push    ds
        push    es
        pop ds
        assume ds:nothing
        dec bx
        cmp bx, 0FFFFh
        jz  short loc_4775A
        cmp ax, 1
        jbe short loc_4775A
        cmp byte ptr [bx], 0FFh
        jz  short loc_47765

loc_4775A:              ; CODE XREF: readDemo+145j
                    ; readDemo+14Aj
        cmp bx, maxdemolength
        jnb short loc_47765
        inc bx
        inc ax
        mov byte ptr [bx], 0FFh

loc_47765:              ; CODE XREF: readDemo+14Fj
                    ; readDemo+155j
        pop ds
        assume ds:data
        pop cx
        mov bx, cx
        shl bx, 1
        mov dx, word_510DF
        db 26h, 89h, 97h, 00h, 00h; mov es:[bx+0], dx
        add word_510DF, ax
        inc cx
        cmp cx, 0Ah
        jz  short loc_47781
        jmp loc_47629
; ---------------------------------------------------------------------------

loc_47781:              ; CODE XREF: readDemo+173j
        pop es
        assume es:nothing
        retn
; ---------------------------------------------------------------------------

loc_47783:              ; CODE XREF: readDemo+45j readDemo+BFj ...
        pop cx
        pop es
        retn
readDemo    endp


; =============== S U B R O U T I N E =======================================


readPallettes   proc near       ; CODE XREF: readEverythingp
        mov ax, 3D00h
        mov dx, offset aPalettes_dat ; "PALETTES.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4779F
        cmp ax, 2
        jnz short loc_4779C
        call    sub_47F39
        jb  short loc_4779C
        jmp short loc_4779F
; ---------------------------------------------------------------------------

loc_4779C:              ; CODE XREF: readPallettes+Dj
                    ; readPallettes+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_4779F:              ; CODE XREF: readPallettes+8j
                    ; readPallettes+14j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        mov ax, 3F00h
        mov cx, 100h
        mov dx, 5FD5h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_477B6
        jmp exit
; ---------------------------------------------------------------------------

loc_477B6:              ; CODE XREF: readPallettes+2Bj
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_477C4
        jmp exit
; ---------------------------------------------------------------------------

locret_477C4:               ; CODE XREF: readPallettes+39j
        retn
readPallettes   endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

openCreditsBlock proc near      ; CODE XREF: start+2E9p

var_6       = word ptr -6
var_4       = word ptr -4
var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFFAh
        push    ds
        mov ax, ds
        mov [bp+var_6], ax
        mov ax, es
        mov ds, ax
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov [bp+var_2], 5A23h
        mov [bp+var_4], 5A24h
        mov dx, 0Fh

loc_47800:              ; CODE XREF: openCreditsBlock+AFj
        push    dx
        mov ax, [bp+var_6]
        mov ds, ax
        mov cx, 2

loc_47809:              ; CODE XREF: openCreditsBlock+4Cj
        push    cx
        call    videoloop
        call    sub_4D457
        pop cx
        loop    loc_47809
        mov ax, es
        mov ds, ax
        pop dx
        mov cx, 94h ; '?'
        mov si, [bp+var_2]
        dec si
        mov di, si
        dec di

loc_47822:              ; CODE XREF: openCreditsBlock+65j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_47822
        mov cx, 94h ; '?'
        mov si, [bp+var_2]
        mov di, si
        add si, 28h ; '('

loc_47837:              ; CODE XREF: openCreditsBlock+79j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_47837
        std
        mov cx, 94h ; '?'
        mov si, [bp+var_4]
        add si, 4689h
        mov di, si
        inc di

loc_4784E:              ; CODE XREF: openCreditsBlock+91j
        movsb
        movsb
        sub si, 78h ; 'x'
        sub di, 78h ; 'x'
        loop    loc_4784E
        cld
        mov cx, 94h ; '?'
        mov si, [bp+var_4]
        mov di, si
        add si, 28h ; '('

loc_47864:              ; CODE XREF: openCreditsBlock+A6j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_47864
        dec [bp+var_2]
        inc [bp+var_4]
        dec dx
        jnz short loc_47800
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        pop ds
        mov cx, 1

loc_47884:              ; CODE XREF: openCreditsBlock+C7j
        push    cx
        call    videoloop
        call    sub_4D457
        pop cx
        loop    loc_47884
        mov bx, 4DD4h
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 5F55h
        call    fade
        mov sp, bp
        pop bp
        retn
openCreditsBlock endp


; =============== S U B R O U T I N E =======================================


loadScreen2 proc near       ; CODE XREF: start:loc_46F00p

; FUNCTION CHUNK AT 04B2 SIZE 00000020 BYTES

        mov ax, 3D00h
        mov dx, 375Ch
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_478C0
        jmp exit
; ---------------------------------------------------------------------------

loc_478C0:              ; CODE XREF: loadScreen2+8j
        mov lastFileHandle, ax
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register

loc_478CD:
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0C8h ; '?'
        mov di, 4DACh

loc_478E7:              ; CODE XREF: loadScreen2+6Bj
        push    cx
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 0A0h ; '?'
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_478FC
        jmp exit
; ---------------------------------------------------------------------------

loc_478FC:              ; CODE XREF: loadScreen2+44j
        mov si, offset fileLevelData
        mov ah, 1

loc_47901:              ; CODE XREF: loadScreen2+65j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_47901
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_478E7
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_4792E
        jmp exit
; ---------------------------------------------------------------------------

loc_4792E:              ; CODE XREF: loadScreen2+76j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov bx, 4DACh
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        mov byte_510A6, 0
        mov si, 5F95h
        call    sub_4D836
        mov ax, 3D00h
        mov dx, 3767h
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47978
        jmp exit
; ---------------------------------------------------------------------------

loc_47978:              ; CODE XREF: loadScreen2+C0j
        mov lastFileHandle, ax
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0C8h ; '?'
        mov di, 4DD4h

loc_47995:              ; CODE XREF: loadScreen2+119j
        push    cx
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 0A0h ; '?'
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_479AA
        jmp exit
; ---------------------------------------------------------------------------

loc_479AA:              ; CODE XREF: loadScreen2+F2j
        mov si, offset fileLevelData
        mov ah, 1

loc_479AF:              ; CODE XREF: loadScreen2+113j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_479AF
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_47995
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_479DC
        jmp exit
; ---------------------------------------------------------------------------

loc_479DC:              ; CODE XREF: loadScreen2+124j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        retn
loadScreen2 endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

readMoving  proc near       ; CODE XREF: start:isFastModep
                    ; start+382p ...

var_6       = word ptr -6
var_4       = word ptr -4
var_1       = byte ptr -1

        push    bp
        mov bp, sp
        add sp, 0FFFAh

loc_479ED:              ; CODE XREF: readMoving+27j
        mov ax, 3D00h
        mov dx, offset aMoving_dat ; "MOVING.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47A13
        cmp ax, 2
        jnz short loc_47A10
        call    sub_47F39
        pushf
        cmp byte_59B86, 0FFh
        jnz short loc_47A0B
        popf
        jmp loc_47AE3
; ---------------------------------------------------------------------------

loc_47A0B:              ; CODE XREF: readMoving+1Ej
        popf
        jb  short loc_47A10
        jmp short loc_479ED
; ---------------------------------------------------------------------------

loc_47A10:              ; CODE XREF: readMoving+13j
                    ; readMoving+25j
        jmp exit
; ---------------------------------------------------------------------------

loc_47A13:              ; CODE XREF: readMoving+Ej
        mov lastFileHandle, ax
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ax, 0B72h
        mov [bp+var_6], ax
        mov ax, 0
        mov [bp+var_4], ax

loc_47A40:              ; CODE XREF: readMoving+BAj
        mov al, 0
        mov [bp+var_1], al

loc_47A45:              ; CODE XREF: readMoving+AEj
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 28h ; '('
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47A59
        jmp exit
; ---------------------------------------------------------------------------

loc_47A59:              ; CODE XREF: readMoving+6Dj
        mov si, offset fileLevelData
        mov ax, [bp+var_4]
        mov bx, 7Ah ; 'z'
        mul bx
        mov di, ax
        add di, [bp+var_6]

loc_47A69:              ; CODE XREF: readMoving+8Cj
        cmp di, 4D34h
        jb  short loc_47A75
        sub di, 4D0Ch
        jmp short loc_47A69
; ---------------------------------------------------------------------------

loc_47A75:              ; CODE XREF: readMoving+86j
        mov cl, [bp+var_1]
        mov ah, 1
        shl ah, cl
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 14h
        rep movsw
        mov al, [bp+var_1]
        inc al
        mov [bp+var_1], al
        cmp al, 4
        jl  short loc_47A45
        mov ax, [bp+var_4]
        inc ax
        mov [bp+var_4], ax
        cmp ax, 1D0h
        jl  short loc_47A40
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47AB1
        jmp exit
; ---------------------------------------------------------------------------

loc_47AB1:              ; CODE XREF: readMoving+C5j
        mov ax, 3D00h
        mov dx, offset aFixed_dat ; "FIXED.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47ABE
        jmp exit
; ---------------------------------------------------------------------------

loc_47ABE:              ; CODE XREF: readMoving+D2j
        mov lastFileHandle, ax
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 1400h
        mov dx, 3815h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47AD5
        jmp exit
; ---------------------------------------------------------------------------

loc_47AD5:              ; CODE XREF: readMoving+E9j
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47AE3
        jmp exit
; ---------------------------------------------------------------------------

loc_47AE3:              ; CODE XREF: readMoving+21j
                    ; readMoving+F7j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: sequencer data register
        mov sp, bp
        pop bp
        retn
readMoving  endp


; =============== S U B R O U T I N E =======================================


readPanelDat    proc near       ; CODE XREF: readPanelDat+14j
                    ; readEverything+6p
        mov ax, 3D00h
        mov dx, offset aPanel_dat ; "PANEL.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47B0A
        cmp ax, 2
        jnz short loc_47B07
        call    sub_47F39
        jb  short loc_47B07
        jmp short readPanelDat
; ---------------------------------------------------------------------------

loc_47B07:              ; CODE XREF: readPanelDat+Dj
                    ; readPanelDat+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_47B0A:              ; CODE XREF: readPanelDat+8j
        mov lastFileHandle, ax
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 0F00h
        mov dx, 4C15h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47B21
        jmp exit
; ---------------------------------------------------------------------------

loc_47B21:              ; CODE XREF: readPanelDat+2Bj
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47B2F
        jmp exit
; ---------------------------------------------------------------------------

locret_47B2F:               ; CODE XREF: readPanelDat+39j
        retn
readPanelDat    endp


; =============== S U B R O U T I N E =======================================


readBackDat proc near       ; CODE XREF: readBackDat+14j
                    ; readEverything+15p
        mov ax, 3D00h
        mov dx, offset aBack_dat ; "BACK.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47B49
        cmp ax, 2
        jnz short loc_47B46
        call    sub_47F39
        jb  short loc_47B46
        jmp short readBackDat
; ---------------------------------------------------------------------------

loc_47B46:              ; CODE XREF: readBackDat+Dj
                    ; readBackDat+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_47B49:              ; CODE XREF: readBackDat+8j
        mov lastFileHandle, ax
        push    ds
        mov ax, seg backseg
        mov bx, lastFileHandle
        mov ds, ax
        assume ds:nothing
        mov ax, 3F00h
        mov cx, 7D00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47B67
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_47B67:              ; CODE XREF: readBackDat+31j
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47B76
        jmp exit
; ---------------------------------------------------------------------------

locret_47B76:               ; CODE XREF: readBackDat+41j
        retn
readBackDat endp


; =============== S U B R O U T I N E =======================================


readChars6Dat   proc near       ; CODE XREF: readChars6Dat+14j
                    ; readEverything+3p
        mov ax, 3D00h
        mov dx, offset aChars6_dat ; "CHARS6.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47B90
        cmp ax, 2
        jnz short loc_47B8D
        call    sub_47F39
        jb  short loc_47B8D
        jmp short readChars6Dat
; ---------------------------------------------------------------------------

loc_47B8D:              ; CODE XREF: readChars6Dat+Dj
                    ; readChars6Dat+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_47B90:              ; CODE XREF: readChars6Dat+8j
        mov lastFileHandle, ax
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 200h
        mov dx, 5B15h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47BA7
        jmp exit
; ---------------------------------------------------------------------------

loc_47BA7:              ; CODE XREF: readChars6Dat+2Bj
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47BB5
        jmp exit
; ---------------------------------------------------------------------------

loc_47BB5:              ; CODE XREF: readChars6Dat+39j
        mov ax, 3D00h
        mov dx, 378Eh
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47BC2
        jmp exit
; ---------------------------------------------------------------------------

loc_47BC2:              ; CODE XREF: readChars6Dat+46j
        mov lastFileHandle, ax
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 200h
        mov dx, 5D15h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47BD9
        jmp exit
; ---------------------------------------------------------------------------

loc_47BD9:              ; CODE XREF: readChars6Dat+5Dj
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47BE7
        jmp exit
; ---------------------------------------------------------------------------

locret_47BE7:               ; CODE XREF: readChars6Dat+6Bj
        retn
readChars6Dat   endp


; =============== S U B R O U T I N E =======================================


readTitleDatAndGraphics? proc near  ; CODE XREF: start+2BBp
        mov bx, 4D84h
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        mov byte_510A6, 0
        mov ax, 3D00h
        mov dx, offset aTitle_dat ; "TITLE.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47C18
        jmp exit
; ---------------------------------------------------------------------------

loc_47C18:              ; CODE XREF: readTitleDatAndGraphics?+2Bj
        mov lastFileHandle, ax
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0C8h ; '?'
        mov di, (offset videoStatusUnk+1570h)

loc_47C3F:              ; CODE XREF: readTitleDatAndGraphics?+8Ej
        push    cx
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, 0A0h ; '?'
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47C54
        jmp exit
; ---------------------------------------------------------------------------

loc_47C54:              ; CODE XREF: readTitleDatAndGraphics?+67j
        mov si, offset fileLevelData
        mov ah, 1

loc_47C59:              ; CODE XREF: readTitleDatAndGraphics?+88j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_47C59
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_47C3F
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47C86
        jmp exit
; ---------------------------------------------------------------------------

loc_47C86:              ; CODE XREF: readTitleDatAndGraphics?+99j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        retn
readTitleDatAndGraphics? endp


; =============== S U B R O U T I N E =======================================


readLevelsLst   proc near       ; CODE XREF: readLevelsLst+CCj
                    ; readEverything+Fp ...
        mov ax, 3D00h
        mov dx, offset aLevel_lst ; "LEVEL.LST"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jb  short loc_47CA8
        jmp loc_47D6D
; ---------------------------------------------------------------------------

loc_47CA8:              ; CODE XREF: readLevelsLst+8j
        mov ax, 3D00h
        mov dx, 17AFh
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47CB5
        jmp loc_47D5D
; ---------------------------------------------------------------------------

loc_47CB5:              ; CODE XREF: readLevelsLst+15j
        mov lastFileHandle, ax
        mov bx, 2A6Ch
        mov ax, 3030h
        mov dx, 2031h
        mov cx, 6Fh ; 'o'

loc_47CC4:              ; CODE XREF: readLevelsLst:loc_47CE4j
        mov [bx], ax
        mov [bx+2], dx
        add bx, 1Ch
        mov byte ptr [bx-1], 0Ah
        inc dl
        cmp dl, 39h ; '9'
        jbe short loc_47CE4
        mov dl, 30h ; '0'
        inc ah
        cmp ah, 39h ; '9'
        jbe short loc_47CE4
        mov ah, 30h ; '0'
        inc al

loc_47CE4:              ; CODE XREF: readLevelsLst+3Aj
                    ; readLevelsLst+43j
        loop    loc_47CC4
        mov cx, 6Fh ; 'o'
        mov dx, 5A6h
        xor ax, ax
        mov bx, 2A70h

loc_47CF1:              ; CODE XREF: readLevelsLst+83j
        push    cx
        push    dx
        push    ax
        push    bx
        mov cx, ax
        mov bx, lastFileHandle
        mov ax, 4200h
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        pop dx
        push    dx
        mov cx, 17h
        mov bx, lastFileHandle
        mov ax, 3F00h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        pop bx
        pop ax
        pop dx
        pop cx
        jb  short loc_47D81
        add dx, levelDataLength
        adc ax, 0
        add bx, 1Ch
        loop    loc_47CF1
        cmp byte_59B62, 0
        jz  short loc_47D8D
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_47D35
        jmp exit
; ---------------------------------------------------------------------------

loc_47D35:              ; CODE XREF: readLevelsLst+95j
        mov ax, 3C00h
        mov cx, 0
        mov dx, offset aLevel_lst ; "LEVEL.LST"
        int 21h     ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                    ; CX = attributes for file
                    ; DS:DX -> ASCIZ filename (may include drive and path)
        jnb short loc_47D45
        jmp exit
; ---------------------------------------------------------------------------

loc_47D45:              ; CODE XREF: readLevelsLst+A5j
        mov bx, ax
        mov lastFileHandle, bx
        mov cx, 0C24h
        mov dx, 2A6Ch
        mov ax, 4000h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        jnb short loc_47D5B
        jmp exit
; ---------------------------------------------------------------------------

loc_47D5B:              ; CODE XREF: readLevelsLst+BBj
        jmp short loc_47D8D
; ---------------------------------------------------------------------------

loc_47D5D:              ; CODE XREF: readLevelsLst+17j
        cmp ax, 2
        jnz short loc_47D6A
        call    sub_47F39
        jb  short loc_47D6A
        jmp readLevelsLst
; ---------------------------------------------------------------------------

loc_47D6A:              ; CODE XREF: readLevelsLst+C5j
                    ; readLevelsLst+CAj
        jmp exit
; ---------------------------------------------------------------------------

loc_47D6D:              ; CODE XREF: readLevelsLst+Aj
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        mov ax, 3F00h
        mov cx, 0C24h
        mov dx, 2A6Ch
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47D8D

loc_47D81:              ; CODE XREF: readLevelsLst+77j
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jmp exit
; ---------------------------------------------------------------------------

loc_47D8D:              ; CODE XREF: readLevelsLst+8Aj
                    ; readLevelsLst:loc_47D5Bj ...
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47D9B
        jmp exit
; ---------------------------------------------------------------------------

locret_47D9B:               ; CODE XREF: readLevelsLst+FBj
        retn
readLevelsLst   endp


; =============== S U B R O U T I N E =======================================


readGfxDat  proc near       ; CODE XREF: readGfxDat+14j
                    ; readEverything+1Ep
        mov ax, 3D00h
        mov dx, offset aGfx_dat ; "GFX.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47DB5
        cmp ax, 2
        jnz short loc_47DB2
        call    sub_47F39
        jb  short loc_47DB2
        jmp short readGfxDat
; ---------------------------------------------------------------------------

loc_47DB2:              ; CODE XREF: readGfxDat+Dj
                    ; readGfxDat+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_47DB5:              ; CODE XREF: readGfxDat+8j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        push    ds
        mov ax, seg gfxseg
        mov ds, ax
        assume ds:nothing
        mov ax, 3F00h
        mov cx, 7D00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47DD3
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_47DD3:              ; CODE XREF: readGfxDat+31j
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47DE2
        jmp exit
; ---------------------------------------------------------------------------

locret_47DE2:               ; CODE XREF: readGfxDat+41j
        retn
readGfxDat  endp


; =============== S U B R O U T I N E =======================================


readControlsDat proc near       ; CODE XREF: readControlsDat+14j
                    ; readEverything+Cp
        mov ax, 3D00h
        mov dx, offset aControls_dat ; "CONTROLS.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_47DFC
        cmp ax, 2
        jnz short loc_47DF9
        call    sub_47F39
        jb  short loc_47DF9
        jmp short readControlsDat
; ---------------------------------------------------------------------------

loc_47DF9:              ; CODE XREF: readControlsDat+Dj
                    ; readControlsDat+12j
        jmp exit
; ---------------------------------------------------------------------------

loc_47DFC:              ; CODE XREF: readControlsDat+8j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        push    ds
        mov ax, seg controlsseg
        mov ds, ax
        assume ds:controlsseg
        mov ax, 3F00h
        mov cx, 7D00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_47E1A
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_47E1A:              ; CODE XREF: readControlsDat+31j
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_47E29
        jmp exit
; ---------------------------------------------------------------------------

locret_47E29:               ; CODE XREF: readControlsDat+41j
        retn
readControlsDat endp


; =============== S U B R O U T I N E =======================================


readPlayersLst  proc near       ; CODE XREF: readEverything+1Bp
                    ; sub_4B419+149p
        cmp byte_59B85, 0
        jnz short locret_47E4F
        mov ax, 3D00h
        mov dx, offset aPlayer_lst ; "PLAYER.LST"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jb  short locret_47E4F
        mov bx, ax
        mov ax, 3F00h
        mov cx, 0A00h
        mov dx, 8A9Ch
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jb  short locret_47E4F
        mov ax, 3E00h
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

locret_47E4F:               ; CODE XREF: readPlayersLst+5j
                    ; readPlayersLst+Fj ...
        retn
readPlayersLst  endp


; =============== S U B R O U T I N E =======================================


readHallfameLst proc near       ; CODE XREF: readEverything+18p
                    ; sub_4B419+146p
        cmp byte_59B85, 0
        jnz short locret_47E75
        mov ax, 3D00h
        mov dx, offset aHallfame_lst ; "HALLFAME.LST"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jb  short locret_47E75
        mov bx, ax
        mov ax, 3F00h
        mov cx, 24h ; '$'
        mov dx, 9514h
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jb  short locret_47E75
        mov ax, 3E00h
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

locret_47E75:               ; CODE XREF: readHallfameLst+5j
                    ; readHallfameLst+Fj ...
        retn
readHallfameLst endp


; =============== S U B R O U T I N E =======================================


readEverything  proc near       ; CODE XREF: start+2DBp start+2E3p ...
        call    readPallettes
        call    readChars6Dat
        call    readPanelDat
        call    readMenuDat
        call    readControlsDat
        call    readLevelsLst
        call    readDemo
        call    readBackDat
        call    readHallfameLst
        call    readPlayersLst
        call    readGfxDat
        retn
readEverything  endp


; =============== S U B R O U T I N E =======================================


sub_47E98   proc near       ; CODE XREF: sub_47F39+4Ap
                    ; sub_4AF0C+216p ...
        mov byte_59B86, 0

keyIsPressed:               ; CODE XREF: sub_47E98+16j
        cmp byte_5197E, 0
        jz  short loc_47EA9
        mov byte_59B86, 0FFh

loc_47EA9:              ; CODE XREF: sub_47E98+Aj
        cmp keyPressed, 0
        jnz short keyIsPressed

mouseIsClicked:              ; CODE XREF: sub_47E98+1Ej
        call    getMouseStatus
        cmp bx, 0
        jnz short mouseIsClicked     ; wait for mouse to not be clicked

loc_47EB8:              ; CODE XREF: sub_47E98+28j
        call    sub_48E59
        cmp byte_50941, 4
        jg  short loc_47EB8
        mov cx, 1068h
        push    cx

loc_47EC6:              ; CODE XREF: sub_47E98+57j
        pop cx
        dec cx
        push    cx
        call    videoloop
        call    sub_4D457
        pop cx
        push    cx
        cmp cx, 0
        jz  short loc_47EF1
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_47F02
        cmp keyPressed, 0
        jnz short loc_47F0C
        call    sub_48E59
        cmp byte_50941, 4
        jg  short loc_47F21
        jmp short loc_47EC6
; ---------------------------------------------------------------------------

loc_47EF1:              ; CODE XREF: sub_47E98+3Cj
                    ; sub_47E98+72j ...
        pop cx
        mov word_510A2, 0
        cmp byte_59B86, 0
        clc
        jz  short locret_47F01
        stc

locret_47F01:               ; CODE XREF: sub_47E98+66j
        retn
; ---------------------------------------------------------------------------

loc_47F02:              ; CODE XREF: sub_47E98+44j
                    ; sub_47E98+70j
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_47F02
        jmp short loc_47EF1
; ---------------------------------------------------------------------------

loc_47F0C:              ; CODE XREF: sub_47E98+4Bj
                    ; sub_47E98+85j
        cmp byte_5197E, 0
        jz  short loc_47F18
        mov byte_59B86, 0FFh

loc_47F18:              ; CODE XREF: sub_47E98+79j
        cmp keyPressed, 0
        jnz short loc_47F0C
        jmp short loc_47EF1
; ---------------------------------------------------------------------------

loc_47F21:              ; CODE XREF: sub_47E98+55j
                    ; sub_47E98+9Dj
        cmp byte_5197E, 0
        jz  short loc_47F2D
        mov byte_59B86, 0FFh

loc_47F2D:              ; CODE XREF: sub_47E98+8Ej
        call    sub_48E59
        cmp byte_50941, 4
        jg  short loc_47F21
        jmp short loc_47EF1
sub_47E98   endp


; =============== S U B R O U T I N E =======================================


sub_47F39   proc near       ; CODE XREF: readPallettes+Fp
                    ; readMoving+15p ...
        call    enableFloppy?
        mov si, 60D5h
        call    sub_4D836
        call    vgaloadbackseg
        cmp byte_53A10, 1
        jnz short loc_47F56
        mov si, 370Fh
        mov byte_53A10, 2
        jmp short loc_47F5E
; ---------------------------------------------------------------------------

loc_47F56:              ; CODE XREF: sub_47F39+11j
        mov si, 3701h
        mov byte_53A10, 1

loc_47F5E:              ; CODE XREF: sub_47F39+1Bj
        mov di, 7D3Bh
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 5FD5h
        call    sub_4D836
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    sub_47E98
        pushf
        mov si, 60D5h
        call    sub_4D836
        popf
        retn
sub_47F39   endp

; ---------------------------------------------------------------------------
        nop

; =============== S U B R O U T I N E =======================================


movefun   proc near       ; DATA XREF: data:160Co
        cmp byte ptr leveldata[si], 1
        jz  short loc_47F98
        retn
; ---------------------------------------------------------------------------

loc_47F98:              ; CODE XREF: movefun+5j
        mov ax, leveldata[si]
        cmp ax, 1
        jz  short loc_47FA4
        jmp loc_48035
; ---------------------------------------------------------------------------

loc_47FA4:              ; CODE XREF: movefun+Fj
        cmp byte_51035, 2
        jnz short loc_47FAC
        retn
; ---------------------------------------------------------------------------

loc_47FAC:              ; CODE XREF: movefun+19j
        mov ax, leveldata[si+78h]
        cmp ax, 0
        jz  short loc_47FF4
        cmp ax, 1
        jz  short loc_47FC5
        cmp ax, 4
        jz  short loc_47FC5
        cmp ax, 5
        jz  short loc_47FC5
        retn
; ---------------------------------------------------------------------------

loc_47FC5:              ; CODE XREF: movefun+28j
                    ; movefun+2Dj ...
        cmp leveldata[si+78h-2], 0
        jz  short loc_47FFB
        cmp leveldata[si+78h-2], 8888h
        jz  short loc_47FFB
        cmp leveldata[si+78h-2], 0AAAAh
        jz  short loc_47FFB

loc_47FDC:              ; CODE XREF: movefun+72j
                    ; movefun+1F1j
        cmp leveldata[si+78h+2], 0
        jz  short loc_48011
        cmp leveldata[si+78h+2], 8888h
        jz  short loc_48011
        cmp leveldata[si+78h+2], 0AAAAh
        jz  short loc_48011
        retn
; ---------------------------------------------------------------------------

loc_47FF4:              ; CODE XREF: movefun+23j
        mov byte ptr leveldata[si+1], 40h ; '@'
        jmp short loc_48035
; ---------------------------------------------------------------------------

loc_47FFB:              ; CODE XREF: movefun+3Aj
                    ; movefun+42j ...
        cmp leveldata[si-2], 0
        jz  short loc_48004
        jmp short loc_47FDC
; ---------------------------------------------------------------------------

loc_48004:              ; CODE XREF: movefun+70j
        mov byte ptr leveldata[si+1], 50h ; 'P'
        mov leveldata[si-2], 8888h
        jmp short loc_48035
; ---------------------------------------------------------------------------

loc_48011:              ; CODE XREF: movefun+51j
                    ; movefun+59j ...
        cmp leveldata[si+2], 0
        jz  short loc_48028
        cmp leveldata[si+2], 9999h
        jnz short locret_48027
        cmp leveldata[si-78h+2h], 1
        jz  short loc_48028

locret_48027:               ; CODE XREF: movefun+8Ej
        retn
; ---------------------------------------------------------------------------

loc_48028:              ; CODE XREF: movefun+86j
                    ; movefun+95j
        mov byte ptr leveldata[si+1], 60h ; '`'
        mov leveldata[si+2], 8888h
        jmp short $+2
; ---------------------------------------------------------------------------

loc_48035:              ; CODE XREF: movefun+11j
                    ; movefun+69j ...
        mov bl, byte ptr leveldata[si+1]
        xor bh, bh
        mov al, bl
        and al, 0F0h
        cmp al, 10h
        jnz short loc_48045
        jmp short loc_48078
; ---------------------------------------------------------------------------

loc_48045:              ; CODE XREF: movefun+B1j
        cmp al, 20h ; ' '
        jnz short loc_4804C
        jmp loc_48212
; ---------------------------------------------------------------------------

loc_4804C:              ; CODE XREF: movefun+B7j
        cmp al, 30h ; '0'
        jnz short loc_48053
        jmp loc_48277
; ---------------------------------------------------------------------------

loc_48053:              ; CODE XREF: movefun+BEj
        cmp byte_51035, 2
        jnz short loc_4805B
        retn
; ---------------------------------------------------------------------------

loc_4805B:              ; CODE XREF: movefun+C8j
        cmp al, 40h ; '@'
        jnz short loc_48062
        jmp loc_482DC
; ---------------------------------------------------------------------------

loc_48062:              ; CODE XREF: movefun+CDj
        cmp al, 50h ; 'P'
        jnz short loc_48069
        jmp loc_4830A
; ---------------------------------------------------------------------------

loc_48069:              ; CODE XREF: movefun+D4j
        cmp al, 60h ; '`'
        jnz short loc_48070
        jmp loc_48378
; ---------------------------------------------------------------------------

loc_48070:              ; CODE XREF: movefun+DBj
        cmp al, 70h ; 'p'
        jnz short locret_48077
        jmp loc_483E6
; ---------------------------------------------------------------------------

locret_48077:               ; CODE XREF: movefun+E2j
        retn
; ---------------------------------------------------------------------------

loc_48078:              ; CODE XREF: movefun+B3j
                    ; movefun+475j
        xor bh, bh
        shl bl, 1
        shl bl, 1
        and bl, 1Fh
        mov di, [si+60DDh]
        add di, [bx+6C95h]
        push    si
        mov si, word_515A2
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_48096:              ; CODE XREF: movefun+10Ej
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_48096
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 16h
        jnz short loc_480BB
        mov [si+1835h], bl
        sub si, 78h ; 'x'
        call    sub_488DC
        add si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_480BB:              ; CODE XREF: movefun+11Bj
        cmp bl, 18h
        jge short loc_480C5
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_480C5:              ; CODE XREF: movefun+12Ej
        mov byte ptr [si+1835h], 0
        cmp byte_51035, 2
        jnz short loc_480D2
        retn
; ---------------------------------------------------------------------------

loc_480D2:              ; CODE XREF: movefun+13Fj
        cmp word ptr [si+18ACh], 0
        jnz short loc_480DC
        jmp loc_4816D
; ---------------------------------------------------------------------------

loc_480DC:              ; CODE XREF: movefun+147j
        cmp word ptr [si+18ACh], 9999h
        jnz short loc_480E7
        jmp loc_4816D
; ---------------------------------------------------------------------------

loc_480E7:              ; CODE XREF: movefun+152j
        cmp byte ptr [si+18ACh], 3
        jnz short loc_480F1
        jmp loc_481A4
; ---------------------------------------------------------------------------

loc_480F1:              ; CODE XREF: movefun+15Cj
        cmp byte ptr [si+18ACh], 11h
        jnz short loc_480FB
        jmp loc_481FE
; ---------------------------------------------------------------------------

loc_480FB:              ; CODE XREF: movefun+166j
        cmp word ptr [si+18ACh], 2BBh
        jnz short loc_48106
        jmp loc_481C6
; ---------------------------------------------------------------------------

loc_48106:              ; CODE XREF: movefun+171j
        cmp word ptr [si+18ACh], 4BBh
        jnz short loc_48111
        jmp loc_481E2
; ---------------------------------------------------------------------------

loc_48111:              ; CODE XREF: movefun+17Cj
        cmp byte ptr [si+18ACh], 18h
        jnz short loc_4811B
        jmp loc_481FE
; ---------------------------------------------------------------------------

loc_4811B:              ; CODE XREF: movefun+186j
        cmp word ptr [si+18ACh], 8
        jnz short loc_48125
        jmp loc_48205
; ---------------------------------------------------------------------------

loc_48125:              ; CODE XREF: movefun+190j
        call    sound?7
        cmp word ptr [si+18ACh], 1
        jz  short loc_4813E
        cmp word ptr [si+18ACh], 4
        jz  short loc_4813E
        cmp word ptr [si+18ACh], 5
        jz  short loc_4813E
        retn
; ---------------------------------------------------------------------------

loc_4813E:              ; CODE XREF: movefun+19Dj
                    ; movefun+1A4j ...
        cmp word ptr [si+18AAh], 0
        jz  short loc_4817A
        cmp word ptr [si+18AAh], 8888h
        jz  short loc_4817A
        cmp word ptr [si+18AAh], 0AAAAh
        jz  short loc_4817A
        cmp word ptr [si+18AEh], 0
        jz  short loc_48190
        cmp word ptr [si+18AEh], 8888h
        jz  short loc_48190
        cmp word ptr [si+18AEh], 0AAAAh

loc_4816A:
        jz  short loc_48190
        retn
; ---------------------------------------------------------------------------

loc_4816D:              ; CODE XREF: movefun+149j
                    ; movefun+154j
        mov word ptr leveldata[si], 7001h
        mov word ptr [si+18ACh], 9999h
        retn
; ---------------------------------------------------------------------------

loc_4817A:              ; CODE XREF: movefun+1B3j
                    ; movefun+1BBj ...
        cmp word ptr [si+1832h], 0
        jz  short loc_48184
        jmp loc_47FDC
; ---------------------------------------------------------------------------

loc_48184:              ; CODE XREF: movefun+1EFj
        mov byte ptr [si+1835h], 50h ; 'P'
        mov word ptr [si+1832h], 8888h
        retn
; ---------------------------------------------------------------------------

loc_48190:              ; CODE XREF: movefun+1CAj
                    ; movefun+1D2j ...
        cmp word ptr [si+1836h], 0
        jz  short loc_48198
        retn
; ---------------------------------------------------------------------------

loc_48198:              ; CODE XREF: movefun+205j
        mov byte ptr [si+1835h], 60h ; '`'
        mov word ptr [si+1836h], 8888h
        retn
; ---------------------------------------------------------------------------

loc_481A4:              ; CODE XREF: movefun+15Ej
        mov bl, [si+18ADh]
        cmp bl, 0Eh
        jz  short locret_48211
        cmp bl, 0Fh
        jz  short locret_48211
        cmp bl, 28h ; '('
        jz  short locret_48211
        cmp bl, 29h ; ')'
        jz  short locret_48211
        cmp bl, 25h ; '%'
        jz  short locret_48211
        cmp bl, 26h ; '&'
        jz  short locret_48211

loc_481C6:              ; CODE XREF: movefun+173j
        cmp byte ptr [si+18AAh], 18h
        jnz short loc_481D3
        mov word ptr [si+18ACh], 18h

loc_481D3:              ; CODE XREF: movefun+23Bj
        cmp byte ptr [si+18AAh], 1Fh
        jz  short loc_481E0
        mov word ptr [si+18AAh], 0

loc_481E0:              ; CODE XREF: movefun+248j
        jmp short loc_481FE
; ---------------------------------------------------------------------------

loc_481E2:              ; CODE XREF: movefun+17Ej
        cmp byte ptr [si+18AEh], 18h
        jnz short loc_481EF
        mov word ptr [si+18ACh], 18h

loc_481EF:              ; CODE XREF: movefun+257j
        cmp byte ptr [si+18AEh], 1Fh
        jz  short loc_481FC
        mov word ptr [si+18AEh], 0

loc_481FC:              ; CODE XREF: movefun+264j
        jmp short $+2
; ---------------------------------------------------------------------------

loc_481FE:              ; CODE XREF: movefun+168j
                    ; movefun+188j ...
        add si, 78h ; 'x'
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_48205:              ; CODE XREF: movefun+192j
        add si, 78h ; 'x'
        mov bx, si
        shr bx, 1
        mov byte ptr [bx+2434h], 6

locret_48211:               ; CODE XREF: movefun+21Bj
                    ; movefun+220j ...
        retn
; ---------------------------------------------------------------------------

loc_48212:              ; CODE XREF: movefun+B9j
        and bl, 7
        shl bl, 1
        xor bh, bh
        mov di, [si+6155h]
        push    si
        mov si, 1294h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax

loc_48228:
        mov cx, 10h

loc_4822B:              ; CODE XREF: movefun+2A5j
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_4822B
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 24h ; '$'
        jnz short loc_4824A
        mov word ptr [si+1836h], 0AAAAh

loc_4824A:              ; CODE XREF: movefun+2B2j
        cmp bl, 26h ; '&'
        jnz short loc_4825D
        mov [si+1835h], bl
        add si, 2
        call    sub_488DC
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_4825D:              ; CODE XREF: movefun+2BDj
        cmp bl, 28h ; '('
        jge short loc_48267
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_48267:              ; CODE XREF: movefun+2D0j
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 1001h
        retn
; ---------------------------------------------------------------------------

loc_48277:              ; CODE XREF: movefun+C0j
        and bl, 7
        shl bl, 1
        xor bh, bh
        mov di, [si+6153h]
        push    si
        mov si, 12A4h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax

loc_4828D:
        mov cx, 10h

loc_48290:              ; CODE XREF: movefun+30Aj
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48290
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 34h ; '4'
        jnz short loc_482AF
        mov word ptr [si+1832h], 0AAAAh

loc_482AF:              ; CODE XREF: movefun+317j
        cmp bl, 36h ; '6'
        jnz short loc_482C2
        mov [si+1835h], bl
        sub si, 2
        call    sub_488DC
        add si, 2
        retn
; ---------------------------------------------------------------------------

loc_482C2:              ; CODE XREF: movefun+322j
        cmp bl, 38h ; '8'
        jge short loc_482CC
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_482CC:              ; CODE XREF: movefun+335j
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 1001h
        retn
; ---------------------------------------------------------------------------

loc_482DC:              ; CODE XREF: movefun+CFj
        inc bl
        cmp bl, 42h ; 'B'
        jge short loc_482E8
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_482E8:              ; CODE XREF: movefun+351j
        cmp word ptr [si+18ACh], 0
        jz  short loc_482F6
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_482F6:              ; CODE XREF: movefun+35Dj
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov byte ptr leveldata[si], 1
        mov byte ptr [si+1835h], 10h
        retn
; ---------------------------------------------------------------------------

loc_4830A:              ; CODE XREF: movefun+D6j
        xor bh, bh
        and bl, 0Fh
        shl bl, 1
        mov di, [si+6153h]
        push    si
        mov si, 1294h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48323:              ; CODE XREF: movefun+39Dj
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48323
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 52h ; 'R'
        jge short loc_48341
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_48341:              ; CODE XREF: movefun+3AAj
        cmp word ptr [si+18AAh], 0
        jnz short loc_48371
        cmp word ptr [si+1832h], 0
        jz  short loc_48357
        cmp word ptr [si+1832h], 8888h
        jnz short loc_48371

loc_48357:              ; CODE XREF: movefun+3BDj
        mov leveldata[si], 0FFFFh
        sub si, 2
        mov byte ptr leveldata[si], 1
        mov byte ptr [si+1835h], 22h ; '"'
        mov word ptr [si+18ACh], 0FFFFh
        retn
; ---------------------------------------------------------------------------

loc_48371:              ; CODE XREF: movefun+3B6j
                    ; movefun+3C5j
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_48378:              ; CODE XREF: movefun+DDj
        xor bh, bh
        and bl, 7
        shl bl, 1
        mov di, [si+6155h]
        push    si
        mov si, 12A4h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48391:              ; CODE XREF: movefun+40Bj
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48391
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 62h ; 'b'
        jge short loc_483AF
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_483AF:              ; CODE XREF: movefun+418j
        cmp word ptr [si+18AEh], 0
        jnz short loc_483DF
        cmp word ptr [si+1836h], 0
        jz  short loc_483C5
        cmp word ptr [si+1836h], 8888h
        jnz short loc_483DF

loc_483C5:              ; CODE XREF: movefun+42Bj
        mov word ptr leveldata[si], 0FFFFh
        add si, 2
        mov byte ptr leveldata[si], 1
        mov byte ptr [si+1835h], 32h ; '2'

loc_483D8:
        mov word ptr [si+18ACh], 0FFFFh

locret_483DE:
        retn
; ---------------------------------------------------------------------------

loc_483DF:              ; CODE XREF: movefun+424j
                    ; movefun+433j
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_483E6:              ; CODE XREF: movefun+E4j
        cmp word ptr [si+18ACh], 0
        jz  short loc_483F6
        cmp word ptr [si+18ACh], 9999h
        jz  short loc_483F6
        retn
; ---------------------------------------------------------------------------

loc_483F6:              ; CODE XREF: movefun+45Bj
                    ; movefun+463j
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 1001h
        jmp loc_48078
movefun   endp


; =============== S U B R O U T I N E =======================================


movefun2  proc near       ; DATA XREF: data:1612o
        cmp byte ptr leveldata[si], 4
        jz  short loc_48410
        retn
; ---------------------------------------------------------------------------

loc_48410:              ; CODE XREF: movefun2+5j
        mov ax, [si+1834h]
        cmp ax, 4
        jz  short loc_4841B
        jmp short loc_48495
; ---------------------------------------------------------------------------

loc_4841B:              ; CODE XREF: movefun2+Fj
        mov ax, [si+18ACh]
        cmp ax, 0
        jz  short loc_48463
        cmp ax, 1
        jz  short loc_48434
        cmp ax, 4
        jz  short loc_48434
        cmp ax, 5
        jz  short loc_48434
        retn
; ---------------------------------------------------------------------------

loc_48434:              ; CODE XREF: movefun2+1Fj
                    ; movefun2+24j ...
        cmp word ptr [si+18AAh], 0
        jz  short loc_4846A
        cmp word ptr [si+18AAh], 8888h
        jz  short loc_4846A
        cmp word ptr [si+18AAh], 0AAAAh
        jz  short loc_4846A

loc_4844B:              ; CODE XREF: movefun2+69j
                    ; movefun2+1C7j
        cmp word ptr [si+18AEh], 0
        jz  short loc_48480

loc_48452:
        cmp word ptr [si+18AEh], 8888h
        jz  short loc_48480
        cmp word ptr [si+18AEh], 0AAAAh
        jz  short loc_48480
        retn
; ---------------------------------------------------------------------------

loc_48463:              ; CODE XREF: movefun2+1Aj
        mov byte ptr [si+1835h], 40h ; '@'
        jmp short loc_48495
; ---------------------------------------------------------------------------

loc_4846A:              ; CODE XREF: movefun2+31j
                    ; movefun2+39j ...
        cmp word ptr [si+1832h], 0
        jz  short loc_48473
        jmp short loc_4844B
; ---------------------------------------------------------------------------

loc_48473:              ; CODE XREF: movefun2+67j
        mov byte ptr [si+1835h], 50h ; 'P'
        mov word ptr [si+1832h], 8888h
        jmp short loc_48495
; ---------------------------------------------------------------------------

loc_48480:              ; CODE XREF: movefun2+48j
                    ; movefun2+50j ...
        cmp word ptr [si+1836h], 0
        jz  short loc_48488
        retn
; ---------------------------------------------------------------------------

loc_48488:              ; CODE XREF: movefun2+7Dj
        mov byte ptr [si+1835h], 60h ; '`'
        mov word ptr [si+1836h], 8888h
        jmp short $+2
; ---------------------------------------------------------------------------

loc_48495:              ; CODE XREF: movefun2+11j
                    ; movefun2+60j ...
        mov bl, [si+1835h]
        xor bh, bh
        mov al, bl
        and al, 0F0h
        cmp al, 10h
        jnz short loc_484A5
        jmp short loc_484D0
; ---------------------------------------------------------------------------

loc_484A5:              ; CODE XREF: movefun2+99j
        cmp al, 20h ; ' '
        jnz short loc_484AC
        jmp loc_4861B
; ---------------------------------------------------------------------------

loc_484AC:              ; CODE XREF: movefun2+9Fj
        cmp al, 30h ; '0'
        jnz short loc_484B3
        jmp loc_48677
; ---------------------------------------------------------------------------

loc_484B3:              ; CODE XREF: movefun2+A6j
        cmp al, 40h ; '@'
        jnz short loc_484BA
        jmp loc_486D2
; ---------------------------------------------------------------------------

loc_484BA:              ; CODE XREF: movefun2+ADj
        cmp al, 50h ; 'P'
        jnz short loc_484C1
        jmp loc_48700
; ---------------------------------------------------------------------------

loc_484C1:              ; CODE XREF: movefun2+B4j
        cmp al, 60h ; '`'
        jnz short loc_484C8
        jmp loc_4876E
; ---------------------------------------------------------------------------

loc_484C8:              ; CODE XREF: movefun2+BBj
        cmp al, 70h ; 'p'

loc_484CA:
        jnz short locret_484CF

loc_484CC:
        jmp loc_487DC
; ---------------------------------------------------------------------------

locret_484CF:               ; CODE XREF: movefun2:loc_484CAj
        retn
; ---------------------------------------------------------------------------

loc_484D0:              ; CODE XREF: movefun2+9Bj
                    ; movefun2+3F3j
        xor bh, bh
        shl bl, 1
        shl bl, 1
        and bl, 1Fh
        mov di, [si+60DDh]
        add di, [bx+6C95h]
        push    si
        mov si, word_515C4
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_484EE:              ; CODE XREF: movefun2+EEj
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_484EE
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 16h
        jnz short loc_48513
        mov [si+1835h], bl
        sub si, 78h ; 'x'
        call    sub_48957
        add si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_48513:              ; CODE XREF: movefun2+FBj
        cmp bl, 18h
        jge short loc_4851D
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4851D:              ; CODE XREF: movefun2+10Ej
        mov byte ptr [si+1835h], 0
        cmp word ptr [si+18ACh], 0
        jnz short loc_4852C
        jmp loc_485BB
; ---------------------------------------------------------------------------

loc_4852C:              ; CODE XREF: movefun2+11Fj
        cmp word ptr [si+18ACh], 9999h
        jnz short loc_48537
        jmp loc_485BB
; ---------------------------------------------------------------------------

loc_48537:              ; CODE XREF: movefun2+12Aj
        cmp byte ptr [si+18ACh], 3
        jnz short loc_48541
        jmp loc_485F2
; ---------------------------------------------------------------------------

loc_48541:              ; CODE XREF: movefun2+134j
        cmp word ptr [si+18ACh], 14h
        jnz short loc_4854B
        jmp loc_48614
; ---------------------------------------------------------------------------

loc_4854B:              ; CODE XREF: movefun2+13Ej
        cmp byte ptr [si+18ACh], 11h
        jnz short loc_48555
        jmp loc_48614
; ---------------------------------------------------------------------------

loc_48555:              ; CODE XREF: movefun2+148j
        cmp byte ptr [si+18ACh], 18h
        jnz short loc_4855F
        jmp loc_48614
; ---------------------------------------------------------------------------

loc_4855F:              ; CODE XREF: movefun2+152j
        cmp word ptr [si+18ACh], 12h
        jnz short loc_48569
        jmp loc_48614
; ---------------------------------------------------------------------------

loc_48569:              ; CODE XREF: movefun2+15Cj
        cmp word ptr [si+18ACh], 8
        jnz short loc_48573
        jmp loc_48614
; ---------------------------------------------------------------------------

loc_48573:              ; CODE XREF: movefun2+166j
        call    sound?7
        cmp word ptr [si+18ACh], 1
        jz  short loc_4858C
        cmp word ptr [si+18ACh], 4
        jz  short loc_4858C
        cmp word ptr [si+18ACh], 5
        jz  short loc_4858C
        retn
; ---------------------------------------------------------------------------

loc_4858C:              ; CODE XREF: movefun2+173j
                    ; movefun2+17Aj ...
        cmp word ptr [si+18AAh], 0
        jz  short loc_485C8
        cmp word ptr [si+18AAh], 8888h
        jz  short loc_485C8
        cmp word ptr [si+18AAh], 0AAAAh
        jz  short loc_485C8
        cmp word ptr [si+18AEh], 0
        jz  short loc_485DE
        cmp word ptr [si+18AEh], 8888h
        jz  short loc_485DE
        cmp word ptr [si+18AEh], 0AAAAh
        jz  short loc_485DE
        retn
; ---------------------------------------------------------------------------

loc_485BB:              ; CODE XREF: movefun2+121j
                    ; movefun2+12Cj
        mov word ptr leveldata[si], 7004h
        mov word ptr [si+18ACh], 9999h
        retn
; ---------------------------------------------------------------------------

loc_485C8:              ; CODE XREF: movefun2+189j
                    ; movefun2+191j ...
        cmp word ptr [si+1832h], 0
        jz  short loc_485D2
        jmp loc_4844B
; ---------------------------------------------------------------------------

loc_485D2:              ; CODE XREF: movefun2+1C5j
        mov byte ptr [si+1835h], 50h ; 'P'
        mov word ptr [si+1832h], 8888h
        retn
; ---------------------------------------------------------------------------

loc_485DE:              ; CODE XREF: movefun2+1A0j
                    ; movefun2+1A8j ...
        cmp word ptr [si+1836h], 0
        jz  short loc_485E6
        retn
; ---------------------------------------------------------------------------

loc_485E6:              ; CODE XREF: movefun2+1DBj
        mov byte ptr [si+1835h], 60h ; '`'
        mov word ptr [si+1836h], 8888h
        retn
; ---------------------------------------------------------------------------

loc_485F2:              ; CODE XREF: movefun2+136j
        mov bl, [si+18ADh]
        cmp bl, 0Eh
        jz  short locret_4861A
        cmp bl, 0Fh
        jz  short locret_4861A
        cmp bl, 28h ; '('
        jz  short locret_4861A
        cmp bl, 29h ; ')'
        jz  short locret_4861A
        cmp bl, 25h ; '%'
        jz  short locret_4861A
        cmp bl, 26h ; '&'
        jz  short locret_4861A

loc_48614:              ; CODE XREF: movefun2+140j
                    ; movefun2+14Aj ...
        add si, 78h ; 'x'
        call    sub_4A61F

locret_4861A:               ; CODE XREF: movefun2+1F1j
                    ; movefun2+1F6j ...
        retn
; ---------------------------------------------------------------------------

loc_4861B:              ; CODE XREF: movefun2+A1j
        and bl, 7
        shl bl, 1
        xor bh, bh
        mov di, [si+6155h]
        push    si
        mov si, 12B6h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48634:              ; CODE XREF: movefun2+236j
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48634
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 24h ; '$'
        jnz short loc_48653
        mov word ptr [si+1836h], 0AAAAh

loc_48653:              ; CODE XREF: movefun2+243j
        cmp bl, 26h ; '&'
        jnz short loc_48666
        mov [si+1835h], bl
        add si, 2
        call    sub_48957
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_48666:              ; CODE XREF: movefun2+24Ej
        cmp bl, 28h ; '('
        jge short loc_48670
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_48670:              ; CODE XREF: movefun2+261j
        mov word ptr leveldata[si], 7004h
        retn
; ---------------------------------------------------------------------------

loc_48677:              ; CODE XREF: movefun2+A8j
        and bl, 7
        shl bl, 1
        xor bh, bh
        mov di, [si+6153h]
        push    si
        mov si, 12C6h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48690:              ; CODE XREF: movefun2+292j
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48690
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 34h ; '4'
        jnz short loc_486AF
        mov word ptr [si+1832h], 0AAAAh

loc_486AF:              ; CODE XREF: movefun2+29Fj
        cmp bl, 36h ; '6'
        jnz short loc_486C1
        mov [si+1835h], bl
        sub si, 2
        call    sub_48957
        add si, 2

loc_486C1:              ; CODE XREF: movefun2+2AAj
        cmp bl, 38h ; '8'
        jge short loc_486CB
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_486CB:              ; CODE XREF: movefun2+2BCj
        mov word ptr leveldata[si], 7004h
        retn
; ---------------------------------------------------------------------------

loc_486D2:              ; CODE XREF: movefun2+AFj
        inc bl
        cmp bl, 42h ; 'B'
        jge short loc_486DE
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_486DE:              ; CODE XREF: movefun2+2CFj
        cmp word ptr [si+18ACh], 0
        jz  short loc_486EC
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_486EC:              ; CODE XREF: movefun2+2DBj
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov byte ptr leveldata[si], 4
        mov byte ptr [si+1835h], 10h
        retn
; ---------------------------------------------------------------------------

loc_48700:              ; CODE XREF: movefun2+B6j
        xor bh, bh
        and bl, 0Fh
        shl bl, 1
        mov di, [si+6153h]
        push    si
        mov si, 12B6h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48719:              ; CODE XREF: movefun2+31Bj
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48719
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 52h ; 'R'
        jge short loc_48737
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_48737:              ; CODE XREF: movefun2+328j
        cmp word ptr [si+18AAh], 0
        jnz short loc_48767
        cmp word ptr [si+1832h], 0
        jz  short loc_4874D
        cmp word ptr [si+1832h], 8888h
        jnz short loc_48767

loc_4874D:              ; CODE XREF: movefun2+33Bj
        mov word ptr leveldata[si], 0FFFFh
        sub si, 2
        mov byte ptr leveldata[si], 4
        mov byte ptr [si+1835h], 22h ; '"'
        mov word ptr [si+18ACh], 9999h
        retn
; ---------------------------------------------------------------------------

loc_48767:              ; CODE XREF: movefun2+334j
                    ; movefun2+343j
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4876E:              ; CODE XREF: movefun2+BDj
        xor bh, bh
        and bl, 7
        shl bl, 1
        mov di, [si+6155h]
        push    si
        mov si, 12C6h
        mov si, [bx+si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_48787:              ; CODE XREF: movefun2+389j
        movsb
        movsb
        movsb
        movsb
        add si, 76h ; 'v'
        add di, 76h ; 'v'
        loop    loc_48787
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        cmp bl, 62h ; 'b'
        jge short loc_487A5
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_487A5:              ; CODE XREF: movefun2+396j
        cmp word ptr [si+18AEh], 0
        jnz short loc_487D5
        cmp word ptr [si+1836h], 0
        jz  short loc_487BB
        cmp word ptr [si+1836h], 8888h
        jnz short loc_487D5

loc_487BB:              ; CODE XREF: movefun2+3A9j
        mov word ptr leveldata[si], 0FFFFh
        add si, 2
        mov byte ptr leveldata[si], 4
        mov byte ptr [si+1835h], 32h ; '2'
        mov word ptr [si+18ACh], 9999h
        retn
; ---------------------------------------------------------------------------

loc_487D5:              ; CODE XREF: movefun2+3A2j
                    ; movefun2+3B1j
        dec bl
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_487DC:              ; CODE XREF: movefun2:loc_484CCj
        cmp word ptr [si+18ACh], 0
        jz  short loc_487EC
        cmp word ptr [si+18ACh], 9999h
        jz  short loc_487EC
        retn
; ---------------------------------------------------------------------------

loc_487EC:              ; CODE XREF: movefun2+3D9j
                    ; movefun2+3E1j
        mov word ptr leveldata[si], 0FFFFh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 1004h
        jmp loc_484D0
movefun2  endp


; =============== S U B R O U T I N E =======================================


sub_487FE   proc near       ; CODE XREF: update?+E0Cp update?+E2Ap ...
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4880B
        mov word ptr leveldata[si], 0

loc_4880B:              ; CODE XREF: sub_487FE+5j
        cmp word ptr [si+17BCh], 0
        jz  short loc_48835
        cmp word ptr [si+17BCh], 9999h
        jz  short loc_48835
        cmp word ptr [si+17BCh], 1
        jz  short loc_48829
        cmp word ptr [si+17BCh], 4
        jz  short loc_4882F
        retn
; ---------------------------------------------------------------------------

loc_48829:              ; CODE XREF: sub_487FE+21j
        mov byte ptr [si+17BDh], 40h ; '@'
        retn
; ---------------------------------------------------------------------------

loc_4882F:              ; CODE XREF: sub_487FE+28j
        mov byte ptr [si+17BDh], 40h ; '@'
        retn
; ---------------------------------------------------------------------------

loc_48835:              ; CODE XREF: sub_487FE+12j
                    ; sub_487FE+1Aj
        cmp word ptr [si+17BAh], 1
        jz  short loc_48852
        cmp word ptr [si+17BAh], 4
        jz  short loc_48897

loc_48843:              ; CODE XREF: sub_487FE+69j
                    ; sub_487FE+AEj
        cmp word ptr [si+17BEh], 1
        jz  short loc_48875
        cmp word ptr [si+17BEh], 4
        jz  short loc_488BA
        retn
; ---------------------------------------------------------------------------

loc_48852:              ; CODE XREF: sub_487FE+3Cj
        cmp word ptr [si+1832h], 1
        jz  short loc_48869
        cmp word ptr [si+1832h], 4
        jz  short loc_48869
        cmp word ptr [si+1832h], 5
        jz  short loc_48869
        jmp short loc_48843
; ---------------------------------------------------------------------------

loc_48869:              ; CODE XREF: sub_487FE+59j
                    ; sub_487FE+60j ...
        mov byte ptr [si+17BBh], 60h ; '`'
        mov word ptr [si+17BCh], 8888h
        retn
; ---------------------------------------------------------------------------

loc_48875:              ; CODE XREF: sub_487FE+4Aj
        cmp word ptr [si+1836h], 1
        jz  short loc_4888B
        cmp word ptr [si+1836h], 4
        jz  short loc_4888B
        cmp word ptr [si+1836h], 5
        jz  short loc_4888B
        retn
; ---------------------------------------------------------------------------

loc_4888B:              ; CODE XREF: sub_487FE+7Cj
                    ; sub_487FE+83j ...
        mov byte ptr [si+17BFh], 50h ; 'P'
        mov word ptr [si+17BCh], 8888h
        retn
; ---------------------------------------------------------------------------

loc_48897:              ; CODE XREF: sub_487FE+43j
        cmp word ptr [si+1832h], 1
        jz  short loc_488AE
        cmp word ptr [si+1832h], 4
        jz  short loc_488AE
        cmp word ptr [si+1832h], 5
        jz  short loc_488AE
        jmp short loc_48843
; ---------------------------------------------------------------------------

loc_488AE:              ; CODE XREF: sub_487FE+9Ej
                    ; sub_487FE+A5j ...
        mov byte ptr [si+17BBh], 60h ; '`'
        mov word ptr [si+17BCh], 8888h
        retn
; ---------------------------------------------------------------------------

loc_488BA:              ; CODE XREF: sub_487FE+51j
        cmp word ptr [si+1836h], 1
        jz  short loc_488D0
        cmp word ptr [si+1836h], 4
        jz  short loc_488D0
        cmp word ptr [si+1836h], 5
        jz  short loc_488D0
        retn
; ---------------------------------------------------------------------------

loc_488D0:              ; CODE XREF: sub_487FE+C1j
                    ; sub_487FE+C8j ...
        mov byte ptr [si+17BFh], 50h ; 'P'
        mov word ptr [si+17BCh], 8888h
        retn
sub_487FE   endp


; =============== S U B R O U T I N E =======================================


sub_488DC   proc near       ; CODE XREF: movefun+124p
                    ; movefun+2C6p ...
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_488E9
        mov word ptr leveldata[si], 0

loc_488E9:              ; CODE XREF: sub_488DC+5j
        cmp word ptr [si+17BCh], 0
        jz  short loc_48901
        cmp word ptr [si+17BCh], 9999h
        jz  short loc_488F9
        retn
; ---------------------------------------------------------------------------

loc_488F9:              ; CODE XREF: sub_488DC+1Aj
        cmp byte ptr [si+1744h], 4
        jz  short loc_48901
        retn
; ---------------------------------------------------------------------------

loc_48901:              ; CODE XREF: sub_488DC+12j
                    ; sub_488DC+22j
        cmp word ptr [si+17BAh], 1
        jz  short loc_48910

loc_48908:              ; CODE XREF: sub_488DC+49j
        cmp word ptr [si+17BEh], 1
        jz  short loc_48934
        retn
; ---------------------------------------------------------------------------

loc_48910:              ; CODE XREF: sub_488DC+2Aj
        cmp word ptr [si+1832h], 1
        jz  short loc_48927
        cmp word ptr [si+1832h], 4
        jz  short loc_48927
        cmp word ptr [si+1832h], 5
        jz  short loc_48927
        jmp short loc_48908
; ---------------------------------------------------------------------------

loc_48927:              ; CODE XREF: sub_488DC+39j
                    ; sub_488DC+40j ...
        mov word ptr [si+17BAh], 6001h
        mov word ptr [si+17BCh], 8888h
        retn
; ---------------------------------------------------------------------------

loc_48934:              ; CODE XREF: sub_488DC+31j
        cmp word ptr [si+1836h], 1
        jz  short loc_4894A
        cmp word ptr [si+1836h], 4
        jz  short loc_4894A
        cmp word ptr [si+1836h], 5
        jz  short loc_4894A
        retn
; ---------------------------------------------------------------------------

loc_4894A:              ; CODE XREF: sub_488DC+5Dj
                    ; sub_488DC+64j ...
        mov word ptr [si+17BEh], 5001h
        mov word ptr [si+17BCh], 8888h
        retn
sub_488DC   endp


; =============== S U B R O U T I N E =======================================


sub_48957   proc near       ; CODE XREF: movefun2+104p
                    ; movefun2+257p ...
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_48964
        mov word ptr leveldata[si], 0

loc_48964:              ; CODE XREF: sub_48957+5j
        cmp word ptr [si+17BCh], 0
        jz  short loc_4897C
        cmp word ptr [si+17BCh], 9999h
        jz  short loc_48974
        retn
; ---------------------------------------------------------------------------

loc_48974:              ; CODE XREF: sub_48957+1Aj
        cmp byte ptr [si+1744h], 1
        jz  short loc_4897C
        retn
; ---------------------------------------------------------------------------

loc_4897C:              ; CODE XREF: sub_48957+12j
                    ; sub_48957+22j
        cmp word ptr [si+17BAh], 4
        jz  short loc_4898B

loc_48983:              ; CODE XREF: sub_48957+49j
        cmp word ptr [si+17BEh], 4
        jz  short loc_489AF
        retn
; ---------------------------------------------------------------------------

loc_4898B:              ; CODE XREF: sub_48957+2Aj
        cmp word ptr [si+1832h], 1
        jz  short loc_489A2
        cmp word ptr [si+1832h], 4
        jz  short loc_489A2
        cmp word ptr [si+1832h], 5
        jz  short loc_489A2
        jmp short loc_48983
; ---------------------------------------------------------------------------

loc_489A2:              ; CODE XREF: sub_48957+39j
                    ; sub_48957+40j ...
        mov word ptr [si+17BAh], 6004h
        mov word ptr [si+17BCh], 8888h
        retn
; ---------------------------------------------------------------------------

loc_489AF:              ; CODE XREF: sub_48957+31j
        cmp word ptr [si+1836h], 1
        jz  short loc_489C5
        cmp word ptr [si+1836h], 4
        jz  short loc_489C5
        cmp word ptr [si+1836h], 5
        jz  short loc_489C5
        retn
; ---------------------------------------------------------------------------

loc_489C5:              ; CODE XREF: sub_48957+5Dj
                    ; sub_48957+64j ...
        mov word ptr [si+17BEh], 5004h
        mov word ptr [si+17BCh], 8888h
        retn
sub_48957   endp

; ---------------------------------------------------------------------------
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  8Bh ; ?
        db 0C0h ; +

; =============== S U B R O U T I N E =======================================

; ax contains a status code if a DOS function fails.
writeexitmessage    proc near       ; CODE XREF: loadScreen2-7CFp
        push    es
        mov bx, ax
        mov ax, seg doserrors
        mov es, ax
        assume es:doserrors
        mov di, 0
        mov al, 0

        ; find message #bx
keeplooking:              ; CODE XREF: writeexitmessage+13j
        mov cx, 1000
        repne scasb             ; look for zero term
        dec bx
        jnz short keeplooking

writechar:              ; CODE XREF: writeexitmessage+23j
        mov ah, 0Eh
        mov al, es:[di]
        cmp al, 0
        jz  short write_crlf
        inc di
        mov bh, 0
        int 10h     ; - VIDEO - WRITE CHARACTER AND ADVANCE CURSOR (TTY WRITE)
                    ; AL = character, BH = display page (alpha modes)
                    ; BL = foreground color (graphics modes)
        jmp short writechar
; ---------------------------------------------------------------------------

write_crlf:              ; CODE XREF: writeexitmessage+1Cj
        mov ah, 0Eh
        mov al, 0Ah
        mov bh, 0
        int 10h     ; - VIDEO - WRITE CHARACTER AND ADVANCE CURSOR (TTY WRITE)
                    ; AL = character, BH = display page (alpha modes)
                    ; BL = foreground color (graphics modes)
        mov ah, 0Eh
        mov al, 0Dh
        mov bh, 0
        int 10h     ; - VIDEO - WRITE CHARACTER AND ADVANCE CURSOR (TTY WRITE)
                    ; AL = character, BH = display page (alpha modes)
                    ; BL = foreground color (graphics modes)
        pop es
        assume es:nothing
        retn
writeexitmessage    endp

; ---------------------------------------------------------------------------
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +

; =============== S U B R O U T I N E =======================================


sub_48A20   proc near       ; CODE XREF: start+32Fp
                    ; runLevel:notFunctionKeyp ...
        mov ax, word_510C3
        mov word_510BC, ax
        mov ax, word_510C5
        mov word_510BE, ax
        xor ax, ax
        mov word_510CB, ax
        mov word_510D1, ax
        mov word_51974, ax
        mov word_51978, ax
        mov byte_5195C, 0
        mov byte_5197C, 0
        mov word_510CD, 0
        mov byte ptr word_510B7, 0FFh
        mov byte ptr word_510B7+1, 0FFh
        mov byte_510B9, 0FFh
        mov byte_510AE, 1
        mov byte_510AF, 0
        mov byte_510B0, 0
        mov byte_510B1, 0
        mov byte_510B2, 0
        mov byte_510B4, 0
        mov byte_510B5, 0
        mov byte_510B6, 0
        mov byte_510C0, 0
        mov byte_5196A, 7Fh ; ''
        mov byte_5196B, 0
        mov word_5195D, 0
        mov byte ptr word_510C1, 1
        mov byte ptr word_510C1+1, 0
        mov byte_510D7, 0
        mov byte_510A6, 0
        mov byte ptr word_510D9, 0
        mov byte_510DB, 0
        mov word_510DC, 0
        retn
sub_48A20   endp


; =============== S U B R O U T I N E =======================================


runLevel    proc near       ; CODE XREF: start+35Cp
        cmp byte_510DE, 0
        jz  short loc_48ACE
        mov byte_5A19C, 1
        mov byte_510BA, 0
        jmp short loc_48AD8
; ---------------------------------------------------------------------------

loc_48ACE:              ; CODE XREF: runLevel+5j
        mov byte_5A19C, 0
        mov byte_510BA, 1

loc_48AD8:              ; CODE XREF: runLevel+11j
        cmp byte_5A2F8, 1
        jnz short loc_48B09

loc_48ADF:              ; CODE XREF: runLevel+BAj
        mov byte_5A2F8, 0
        call    sub_4FDFD

isFunctionKey:              ; CODE XREF: runLevel+35j
        mov al, keyPressed
        cmp al, 3Bh ; ';'   ; F1
        jb  short notFunctionKey
        cmp al, 44h ; 'D'   ; F10
        jbe short isFunctionKey

notFunctionKey:             ; CODE XREF: runLevel+31j
        call    sub_48A20
        cmp byte_59886, 0
        jnz short loc_48AFF
        call    sound?3

loc_48AFF:              ; CODE XREF: runLevel+3Fj
        mov byte_5A19C, 0
        mov byte_510BA, 1

loc_48B09:              ; CODE XREF: runLevel+22j
        mov byte_510DB, 0
        mov byte_5A323, 0
        mov word_510A2, 1

gamelooprep:                ; CODE XREF: runLevel+33Cj
                    ; runLevel+345j
        cmp byte_510DE, 0
        jnz short loc_48B23
        call    sub_48E59

loc_48B23:              ; CODE XREF: runLevel+63j
        call    getMouseStatus
        cmp bx, 2
        jnz short loc_48B38
        cmp word_51978, 0
        jg  short loc_48B38
        mov word_510D1, 1

loc_48B38:              ; CODE XREF: runLevel+6Ej runLevel+75j
        cmp word_51970, 0
        jz  short loc_48B6B
        cmp byte_59B7A, 0
        jz  short loc_48B4A
        dec byte_59B7A

loc_48B4A:              ; CODE XREF: runLevel+89j
        cmp byte_51999, 0
        jnz short loc_48B6B
        cmp bx, 1
        jnz short loc_48B6B
        cmp byte_59B7A, 0
        jnz short loc_48B6B
        mov byte_59B7A, 0Ah
        call    levelScanThing
        call    sub_48F6D
        call    sub_4A2E6

loc_48B6B:              ; CODE XREF: runLevel+82j runLevel+94j ...
        call    sub_4955B
        cmp byte_5A2F8, 1
        jnz short loc_48B78
        jmp loc_48ADF
; ---------------------------------------------------------------------------

loc_48B78:              ; CODE XREF: runLevel+B8j
        cmp word ptr flashingbackgroundon, 0
        jz  short noFlashing
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 35h ; '5'
        out dx, al
        out dx, al
        out dx, al

noFlashing:              ; CODE XREF: runLevel+C2j
        call    gameloop?
        cmp word ptr flashingbackgroundon, 0
        jz  short noFlashing2
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 21h ; '!'
        out dx, al
        out dx, al
        out dx, al

noFlashing2:              ; CODE XREF: runLevel+D8j
        call    sub_4FDFD
        call    sub_4FD65
        cmp word ptr flashingbackgroundon, 0
        jz  short noFlashing3
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 2Dh ; '-'
        out dx, al
        mov al, 21h ; '!'
        out dx, al
        mov al, 0Fh
        out dx, al

noFlashing3:              ; CODE XREF: runLevel+F1j
        call    sub_4A910
        call    sub_4A5E0
        call    sub_49EBE
        mov ax, word_5195F
        and al, 7
        mov byte_510A6, al
        test    speed?3, 40h
        jnz short loc_48BED
        test    speed?3, 80h
        jz  short loc_48BED
        mov al, gameSpeed
        xchg    al, speed?3
        cmp al, 0BFh ; '?'
        jz  short loc_48BED
        and al, 0Fh
        mov gameSpeed, al

loc_48BED:              ; CODE XREF: runLevel+119j
                    ; runLevel+120j ...
        cmp speed?, 0
        jnz short loc_48BF7
        jmp loc_48C86
; ---------------------------------------------------------------------------

loc_48BF7:              ; CODE XREF: runLevel+137j
        inc byte_59B94
        cmp byte_59B96, 0Ah
        jnb short loc_48C05
        jmp loc_48C86
; ---------------------------------------------------------------------------

loc_48C05:              ; CODE XREF: runLevel+145j
        mov byte_59B96, 0
        cmp byte_59B94, 8
        ja  short loc_48C1A
        cmp byte_59B94, 6
        jb  short loc_48C1A
        cmp al, al

loc_48C1A:              ; CODE XREF: runLevel+154j
                    ; runLevel+15Bj
        mov byte_59B94, 0
        ja  short loc_48C79
        jb  short loc_48C5F
        dec speed?
        cmp speed?, 0FEh ; '?'
        ja  short loc_48C86
        and speed?3, 0BFh
        mov speed?, 0
        cmp gameSpeed, 4
        jz  short loc_48C4F
        cmp gameSpeed, 6
        jz  short loc_48C6C
        cmp gameSpeed, 9
        jz  short loc_48C4F
        jmp short loc_48C86
; ---------------------------------------------------------------------------

loc_48C4F:              ; CODE XREF: runLevel+182j
                    ; runLevel+190j
        cmp gameSpeed, 0Ah
        jb  short loc_48C59
        jmp loc_48D59
; ---------------------------------------------------------------------------

loc_48C59:              ; CODE XREF: runLevel+199j
                    ; runLevel+1A9j
        inc gameSpeed
        jmp short loc_48C86
; ---------------------------------------------------------------------------

loc_48C5F:              ; CODE XREF: runLevel+166j
        cmp gameSpeed, 0Ah
        jb  short loc_48C59
        dec speed?
        jmp short loc_48C86
; ---------------------------------------------------------------------------

loc_48C6C:              ; CODE XREF: runLevel+189j
        cmp gameSpeed, 0
        jz  short loc_48C86

loc_48C73:              ; CODE XREF: runLevel+1C3j
        dec gameSpeed
        jmp short loc_48C86
; ---------------------------------------------------------------------------

loc_48C79:              ; CODE XREF: runLevel+164j
        cmp gameSpeed, 0
        ja  short loc_48C73
        dec speed?
        jmp short $+2
; ---------------------------------------------------------------------------

loc_48C86:              ; CODE XREF: runLevel+139j
                    ; runLevel+147j ...
        cmp fastMode, 1
        jnz short isNotFastMode4
        jmp loc_48D59
; ---------------------------------------------------------------------------

isNotFastMode4:              ; CODE XREF: runLevel+1D0j
        cmp gameSpeed, 0Ah
        jb  short loc_48C9A
        jmp loc_48D59
; ---------------------------------------------------------------------------

loc_48C9A:              ; CODE XREF: runLevel+1DAj
        mov cx, 6
        sub cl, gameSpeed
        jg  short loc_48CBD
        mov al, gameSpeed
        inc byte_59B95
        sub al, 5
        cmp al, byte_59B95
        jb  short loc_48CB5
        jmp loc_48D59
; ---------------------------------------------------------------------------

loc_48CB5:              ; CODE XREF: runLevel+1F5j
        mov byte_59B95, 0
        mov cx, 1

loc_48CBD:              ; CODE XREF: runLevel+1E6j
        push    bx

loc_48CBE:              ; CODE XREF: runLevel+29Aj
        mov dx, word_5195F
        sub dx, word_59B90
        cmp dx, 10h
        jg  short loc_48D38
        cmp dx, 0FFF0h
        jl  short loc_48D38
        mov ax, word_51961
        sub ax, word_59B92
        cmp ax, 10h
        jg  short loc_48D38
        cmp ax, 0FFF0h
        jl  short loc_48D38
        push    cx
        inc cx
        idiv    cl
        shl ah, 1
        jnb short loc_48CF3
        neg ah
        cmp ah, cl
        jb  short loc_48CF9
        dec al
        jmp short loc_48CF9
; ---------------------------------------------------------------------------

loc_48CF3:              ; CODE XREF: runLevel+22Cj
        cmp ah, cl
        jb  short loc_48CF9
        inc al

loc_48CF9:              ; CODE XREF: runLevel+232j
                    ; runLevel+236j ...
        cbw
        add word_59B92, ax
        mov ax, dx
        idiv    cl
        shl ah, 1
        jnb short loc_48D10
        neg ah
        cmp ah, cl
        jb  short loc_48D16
        dec al
        jmp short loc_48D16
; ---------------------------------------------------------------------------

loc_48D10:              ; CODE XREF: runLevel+249j
        cmp ah, cl
        jb  short loc_48D16
        inc al

loc_48D16:              ; CODE XREF: runLevel+24Fj
                    ; runLevel+253j ...
        cbw
        add word_59B90, ax
        mov ax, word_59B90
        mov bx, ax
        and al, 7
        mov byte_510A6, al
        mov cl, 3
        shr bx, cl
        mov ax, word_59B92
        mov cx, 7Ah ; 'z'
        mul cx
        add bx, ax
        add bx, 4D34h
        pop cx

loc_48D38:              ; CODE XREF: runLevel+20Ej
                    ; runLevel+213j ...
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        call    sub_4D457
        dec cx
        jz  short loc_48D58
        jmp loc_48CBE
; ---------------------------------------------------------------------------

loc_48D58:              ; CODE XREF: runLevel+298j
        pop bx

loc_48D59:              ; CODE XREF: runLevel+19Bj
                    ; runLevel+1D2j ...
        mov ax, word_51961
        mov word_59B92, ax
        mov ax, word_5195F
        mov word_59B90, ax
        and al, 7
        mov byte_510A6, al
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov cx, word_5195F
        mov ah, cl
        and ah, 7
        cmp word ptr flashingbackgroundon, 0
        jz  short noFlashing4
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 3Fh ; '?'
        out dx, al
        out dx, al
        out dx, al

noFlashing4:              ; CODE XREF: runLevel+2D1j
        mov byte_510A6, ah
        cmp fastMode, 1
        jz  short isFastMode2
        call    videoloop

isFastMode2:              ; CODE XREF: runLevel+2E8j
        cmp word_51A07, 1
        jbe short loc_48DB2
        call    sound?9

loc_48DB2:              ; CODE XREF: runLevel+2F2j
        mov cx, word_51A07

loc_48DB6:              ; CODE XREF: runLevel+310j
        dec cx
        jz  short loc_48DCD
        cmp fastMode, 1
        jz  short isFastMode3
        call    sub_4D457
        call    videoloop

isFastMode3:              ; CODE XREF: runLevel+303j
        push    cx
        call    sub_4955B
        pop cx
        jmp short loc_48DB6
; ---------------------------------------------------------------------------

loc_48DCD:              ; CODE XREF: runLevel+2FCj
        cmp word ptr flashingbackgroundon, 0
        jz  short noFlashing5
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al

noFlashing5:              ; CODE XREF: runLevel+317j
        cmp word_5197A, 0
        jnz short loc_48E03
        inc word_5195D
        cmp word_51974, 1
        jz  short loc_48E03
        cmp word_51978, 0
        jnz short loc_48DFA
        jmp gamelooprep
; ---------------------------------------------------------------------------

loc_48DFA:              ; CODE XREF: runLevel+33Aj
        dec word_51978
        jz  short loc_48E03
        jmp gamelooprep
; ---------------------------------------------------------------------------

loc_48E03:              ; CODE XREF: runLevel+328j
                    ; runLevel+333j ...
        mov word_510A2, 0
        cmp byte_510E3, 0
        jz  short loc_48E13
        call    somethingspsig

loc_48E13:              ; CODE XREF: runLevel+353j
        cmp byte_5A2F9, 0
        mov byte_5A2F9, 0
        jnz short loc_48E30
        cmp byte_510B3, 0
        jz  short loc_48E30
        cmp byte_5A323, 0
        jnz short loc_48E30
        call    sub_4A95F

loc_48E30:              ; CODE XREF: runLevel+362j
                    ; runLevel+369j ...
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0
        mov word_51A07, 1
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al
        retn
runLevel    endp


; =============== S U B R O U T I N E =======================================


sub_48E59   proc near       ; CODE XREF: sub_47E98:loc_47EB8p
                    ; sub_47E98+4Dp ...
        xor ax, ax
        xor bl, bl
        cmp byte_50940, 0
        jnz short loc_48E67
        jmp loc_48F68
; ---------------------------------------------------------------------------

loc_48E67:              ; CODE XREF: sub_48E59+9j
        mov word_50942, ax
        mov word_50944, ax
        mov word_5094F, ax
        mov word_50951, ax
        mov byte_50953, al
        mov byte_50954, al
        mov al, byte_50946
        test    al, al
        jnz short loc_48E83
        jmp loc_48F68
; ---------------------------------------------------------------------------

loc_48E83:              ; CODE XREF: sub_48E59+25j
        mov ah, 1
        call    sub_49FED
        jnb short loc_48E8D
        jmp loc_48F68
; ---------------------------------------------------------------------------

loc_48E8D:              ; CODE XREF: sub_48E59+2Fj
        mov word_50942, ax
        mov dx, word_5094B
        mul dx
        shl ax, 1
        adc dx, 0
        mov ax, dx
        cmp ax, 10h
        jbe short loc_48EA5
        mov ax, 10h

loc_48EA5:              ; CODE XREF: sub_48E59+47j
        cmp byte_519F7, 0
        jz  short loc_48EB1
        mov ax, 1
        jmp short loc_48EBB
; ---------------------------------------------------------------------------

loc_48EB1:              ; CODE XREF: sub_48E59+51j
        cmp byte_519F6, 0
        jz  short loc_48EBB
        mov ax, 10h

loc_48EBB:              ; CODE XREF: sub_48E59+56j
                    ; sub_48E59+5Dj
        mov word_5094F, ax
        mov ah, 2
        call    sub_49FED
        jnb short loc_48EC8
        jmp loc_48F68
; ---------------------------------------------------------------------------

loc_48EC8:              ; CODE XREF: sub_48E59+6Aj
        mov word_50944, ax
        mov dx, word_5094D
        mul dx
        shl ax, 1
        adc dx, 0
        mov ax, dx
        cmp ax, 10h
        jbe short loc_48EE0
        mov ax, 10h

loc_48EE0:              ; CODE XREF: sub_48E59+82j
        cmp byte_519F9, 0
        jz  short loc_48EEC
        mov ax, 1
        jmp short loc_48EF6
; ---------------------------------------------------------------------------

loc_48EEC:              ; CODE XREF: sub_48E59+8Cj
        cmp byte_519F8, 0
        jz  short loc_48EF6
        mov ax, 10h

loc_48EF6:              ; CODE XREF: sub_48E59+91j
                    ; sub_48E59+98j
        mov word_50951, ax
        mov ax, word_50951
        mov cx, 11h
        mul cx
        mov si, word_5094F
        add si, ax
        add si, 645h
        mov bl, [si]
        cmp bl, 0
        jz  short loc_48F40
        mov dx, 201h
        in  al, dx      ; Game I/O port
                    ; bits 0-3: Coordinates (resistive, time-dependent inputs)
                    ; bits 4-7: Buttons/Triggers (digital inputs)
        test    al, 10h
        jnz short loc_48F1F
        add bl, 4
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F1F:              ; CODE XREF: sub_48E59+BFj
        test    al, 20h
        jnz short loc_48F28
        add bl, 4
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F28:              ; CODE XREF: sub_48E59+C8j
        cmp byte_519F5, 0
        jz  short loc_48F34
        add bl, 4
        jmp short loc_48F3E
; ---------------------------------------------------------------------------

loc_48F34:              ; CODE XREF: sub_48E59+D4j
        cmp byte_519F4, 0
        jz  short loc_48F3E
        add bl, 4

loc_48F3E:              ; CODE XREF: sub_48E59+D9j
                    ; sub_48E59+E0j
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F40:              ; CODE XREF: sub_48E59+B7j
        mov dx, 201h
        in  al, dx      ; Game I/O port
                    ; bits 0-3: Coordinates (resistive, time-dependent inputs)
                    ; bits 4-7: Buttons/Triggers (digital inputs)
        test    al, 10h
        jnz short loc_48F4C
        mov bl, 9
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F4C:              ; CODE XREF: sub_48E59+EDj
        test    al, 20h
        jnz short loc_48F54
        mov bl, 9
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F54:              ; CODE XREF: sub_48E59+F5j
        cmp byte_519F5, 0
        jz  short loc_48F5F
        mov bl, 9
        jmp short loc_48F68
; ---------------------------------------------------------------------------

loc_48F5F:              ; CODE XREF: sub_48E59+100j
        cmp byte_519F4, 0
        jz  short loc_48F68
        mov bl, 9

loc_48F68:              ; CODE XREF: sub_48E59+Bj
                    ; sub_48E59+27j ...
        mov byte_50941, bl
        retn
sub_48E59   endp


; =============== S U B R O U T I N E =======================================


sub_48F6D   proc near       ; CODE XREF: start+335p runLevel+AAp ...
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        push    ds
        mov si, word_5184A
        mov ax, es
        mov ds, ax
        mov di, 4D35h
        mov cx, 8

loc_48F86:              ; CODE XREF: sub_48F6D+20j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_48F86
        sub di, 3CFh
        pop ds
        mov si, word_51856
        push    ds
        mov ax, es
        mov ds, ax
        mov dx, 7

loc_48FA0:              ; CODE XREF: sub_48F6D+41j
        mov cx, 74h ; 't'

loc_48FA3:              ; CODE XREF: sub_48F6D+38j
        movsb
        dec si
        loop    loc_48FA3
        add si, 7Ah ; 'z'
        add di, 6
        dec dx
        jnz short loc_48FA0
        mov cx, 74h ; 't'

loc_48FB3:              ; CODE XREF: sub_48F6D+48j
        movsb
        dec si
        loop    loc_48FB3
        sub di, 356h
        pop ds
        mov si, word_5184C
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 8

loc_48FC8:              ; CODE XREF: sub_48F6D+62j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_48FC8
        pop ds
        mov si, word_51854
        push    ds
        mov ax, es
        mov ds, ax
        mov dx, 2Ch ; ','

loc_48FDE:              ; CODE XREF: sub_48F6D+82j
        mov cx, 8

loc_48FE1:              ; CODE XREF: sub_48F6D+7Bj
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_48FE1
        sub si, 3D0h
        dec dx
        jnz short loc_48FDE
        pop ds
        mov si, word_51850
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 8

loc_48FFE:              ; CODE XREF: sub_48F6D+98j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_48FFE
        sub si, 3CEh
        pop ds
        mov si, word_51858
        sub di, 444h
        push    ds
        mov ax, es
        mov ds, ax
        mov dx, 8

loc_4901C:              ; CODE XREF: sub_48F6D+BDj
        mov cx, 74h ; 't'

loc_4901F:              ; CODE XREF: sub_48F6D+B4j
        movsb
        dec si
        loop    loc_4901F
        add si, 7Ah ; 'z'
        add di, 6
        dec dx
        jnz short loc_4901C
        mov cx, 74h ; 't'

loc_4902F:              ; CODE XREF: sub_48F6D+C4j
        movsb
        dec si
        loop    loc_4902F
        sub di, 356h
        pop ds
        mov si, word_51852
        mov di, 5105h
        push    ds
        mov ax, es
        mov ds, ax
        mov dx, 2Ch ; ','

loc_49047:              ; CODE XREF: sub_48F6D+EBj
        mov cx, 8

loc_4904A:              ; CODE XREF: sub_48F6D+E4j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_4904A
        sub si, 3D0h
        dec dx
        jnz short loc_49047
        pop ds
        mov si, word_5184E
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 8

loc_49067:              ; CODE XREF: sub_48F6D+101j
        movsb
        add si, 79h ; 'y'
        add di, 79h ; 'y'
        loop    loc_49067
        pop ds
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov bx, offset leveldata
        mov di, 4D34h
        mov cx, 16h
        add bx, 76h ; 'v'
        add di, 3CEh

loc_4909F:              ; CODE XREF: sub_48F6D+18Ej
        push    cx
        mov cx, 3Ah ; ':'
        add bx, 4
        add di, 4

loc_490A9:              ; CODE XREF: sub_48F6D+184j
        mov al, [bx]
        cmp al, 28h ; '('
        jbe short loc_490B1
        xor al, al

loc_490B1:              ; CODE XREF: sub_48F6D+140j
        add bx, 2
        xor ah, ah
        shl ax, 1
        mov si, ax
        add si, 3815h
        push    cx
        mov cx, 10h

loc_490C2:              ; CODE XREF: sub_48F6D+17Aj
        mov ah, 1

loc_490C4:              ; CODE XREF: sub_48F6D+175j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov al, [si]
        mov es:[di], al
        inc si
        mov al, [si]
        mov es:[di+1], al
        shl ah, 1
        add si, 4Fh ; 'O'
        test    ah, 0Fh
        jnz short loc_490C4
        add di, 7Ah ; 'z'
        loop    loc_490C2
        pop cx
        sub di, 79Eh
        dec cx
        jz  short loc_490F3
        jmp short loc_490A9
; ---------------------------------------------------------------------------

loc_490F3:              ; CODE XREF: sub_48F6D+182j
        pop cx
        add di, 728h
        dec cx
        jz  short loc_490FD
        jmp short loc_4909F
; ---------------------------------------------------------------------------

loc_490FD:              ; CODE XREF: sub_48F6D+18Cj
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov bx, word_5195F
        mov cl, 3
        shr bx, cl
        mov ax, word_51961
        mov cx, 7Ah ; 'z'
        mul cx
        add bx, ax
        add bx, 4D34h
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_48F6D   endp


; =============== S U B R O U T I N E =======================================


sub_4914A   proc near       ; CODE XREF: sub_4955B+7p
        cmp byte_519C8, 0
        jz  short loc_49159
        dec word_51963
        dec word_51963

loc_49159:              ; CODE XREF: sub_4914A+5j
        cmp byte_519CA, 0
        jz  short loc_49168
        inc word_51963
        inc word_51963

loc_49168:              ; CODE XREF: sub_4914A+14j
        cmp byte_519C5, 0
        jz  short loc_49177
        dec word_51965
        dec word_51965

loc_49177:              ; CODE XREF: sub_4914A+23j
        cmp byte_519CD, 0
        jz  short loc_49186
        inc word_51965
        inc word_51965

loc_49186:              ; CODE XREF: sub_4914A+32j
        cmp byte_519C9, 0
        jz  short loc_49199
        mov word_51963, 0
        mov word_51965, 0

loc_49199:              ; CODE XREF: sub_4914A+41j
        mov bx, 8
        sub bx, word_59B88
        mov ax, word_59B8A
        neg ax
        cmp byte_519CF, 0
        jz  short loc_491B3
        mov word_51963, bx
        mov word_51965, ax

loc_491B3:              ; CODE XREF: sub_4914A+60j
        add bx, 138h
        cmp byte_519C4, 0
        jz  short loc_491C5
        mov word_51963, bx
        mov word_51965, ax

loc_491C5:              ; CODE XREF: sub_4914A+72j
        add bx, 138h
        cmp byte_519C6, 0
        jz  short loc_491D7
        mov word_51963, bx
        mov word_51965, ax

loc_491D7:              ; CODE XREF: sub_4914A+84j
        sub bx, 270h
        add ax, 0A8h ; '?'
        cmp byte ptr word_510C1, 0
        jz  short loc_491E8
        add ax, 18h

loc_491E8:              ; CODE XREF: sub_4914A+99j
        cmp byte_519D0, 0
        jz  short loc_491F6
        mov word_51963, bx
        mov word_51965, ax

loc_491F6:              ; CODE XREF: sub_4914A+A3j
        add bx, 138h
        cmp byte_519CC, 0
        jz  short loc_49208
        mov word_51963, bx
        mov word_51965, ax

loc_49208:              ; CODE XREF: sub_4914A+B5j
        add bx, 138h
        cmp byte_519CE, 0
        jz  short locret_4921A
        mov word_51963, bx
        mov word_51965, ax

locret_4921A:               ; CODE XREF: sub_4914A+C7j
        retn
sub_4914A   endp


; =============== S U B R O U T I N E =======================================


sub_4921B   proc near       ; CODE XREF: readConfig+8Cp
                    ; sub_4955B+31p ...
        push    bp
        xor ax, ax
        mov byte_50946, al
        mov word_50947, ax
        mov word_50949, ax
        mov word_5094B, ax
        mov word_5094D, ax
        xor bp, bp
        mov ah, 1
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 1
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 1
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 1
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        shr bp, 1
        mov word_50947, bp
        mov dx, 10h
        xor ax, ax
        cmp bp, dx
        jbe short loc_492A6
        div bp
        mov word_5094B, ax
        xor bp, bp
        mov ah, 2
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 2
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 2
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        mov ah, 2
        call    sub_49FED
        jb  short loc_492A6
        add bp, ax
        shr bp, 1
        mov word_50949, bp
        mov dx, 10h
        xor ax, ax
        cmp bp, dx
        jbe short loc_492A6
        div bp
        mov word_5094D, ax
        mov al, 1
        mov byte_50946, al

loc_492A6:              ; CODE XREF: sub_4921B+19j
                    ; sub_4921B+22j ...
        pop bp
        retn
sub_4921B   endp


; =============== S U B R O U T I N E =======================================


sub_492A8   proc near       ; CODE XREF: sub_4955B+27p
                    ; sub_4A3E9+76p
        mov al, byte_510E2
        dec al
        jz  short loc_492B3
        mov byte_510E2, al
        retn
; ---------------------------------------------------------------------------

loc_492B3:              ; CODE XREF: sub_492A8+5j
        push    es
        mov ax, seg demoseg
        mov es, ax
        assume es:demoseg
        mov bx, word_510DF
        mov al, es:[bx]
        inc bx
        pop es
        assume es:nothing
        cmp al, 0FFh
        jz  short loc_492E3
        mov word_510DF, bx

loc_492CA:              ; CODE XREF: sub_492A8+47j
        mov ah, al
        and ah, 0Fh
        mov byte_50941, ah
        and al, 0F0h
        shr al, 1
        shr al, 1
        shr al, 1
        shr al, 1
        inc al
        mov byte_510E2, al
        retn
; ---------------------------------------------------------------------------

loc_492E3:              ; CODE XREF: sub_492A8+1Cj
        mov word_51978, 64h ; 'd'
        mov word_51974, 1
        jmp short loc_492CA
sub_492A8   endp


; =============== S U B R O U T I N E =======================================


sub_492F1   proc near       ; CODE XREF: sub_4955B+1Dp
        inc byte_510E2
        mov bl, byte_50941
        cmp byte_510E2, 0FFh
        jnz short loc_49311
        mov byte_510E1, bl
        mov ax, timeOfDay
        mov word_5A199, ax
        mov byte_59B5F, ah
        mov byte_59B5C, al

loc_49311:              ; CODE XREF: sub_492F1+Dj
        cmp byte_510E1, bl
        jnz short loc_4931E
        cmp byte_510E2, 0Fh
        jnz short locret_49359

loc_4931E:              ; CODE XREF: sub_492F1+24j
        mov al, byte_510E1
        mov ah, byte_510E2
        shl ah, 1
        shl ah, 1
        shl ah, 1
        shl ah, 1
        or  al, ah
        mov byte_510E1, al
        mov al, byte_510E2
        add byte_59B5C, al
        inc byte_59B5C
        mov ax, 4000h
        mov bx, word_510E4
        mov cx, 1
        mov dx, 0DD1h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        mov byte_510E2, 0FFh
        mov bl, byte_50941
        mov byte_510E1, bl

locret_49359:               ; CODE XREF: sub_492F1+2Bj
        retn
sub_492F1   endp


; =============== S U B R O U T I N E =======================================


somethingspsig  proc near       ; CODE XREF: runLevel+355p
                    ; sub_4945D+30p ...
        mov al, speed?2
        xor al, byte_59B5F
        mov byte_59B5D, al
        xor al, byte_59B5C
        mov byte_59B5E, al
        mov ah, 42h ; 'B'
        mov bx, word_510E4
        xor cx, cx
        xor al, al
        mov dx, 5FCh
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        mov ax, 4000h
        mov bx, word_510E4
        mov cx, 2
        mov dx, 984Dh
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        mov ax, 4000h
        mov bx, word_510E4
        mov cx, 2
        mov dx, 9E89h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        mov ah, 42h ; 'B'
        mov bx, word_510E4
        xor cx, cx
        xor dx, dx
        mov al, 2
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from end of file
        mov byte_510E1, 0FFh
        mov ax, 4000h
        mov bx, word_510E4
        mov cx, 1
        mov dx, 0DD1h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        cmp byte_5A19B, 0
        jz  short loc_49435
        mov ax, 3D00h
        mov dx, offset aMyspsig_txt ; "MYSPSIG.TXT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jb  short loc_49435
        mov bx, ax
        push    bx
        mov ax, 4202h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from end of file
        pop bx
        jb  short loc_49430
        mov cx, 1FFh
        or  dx, dx
        jnz short loc_493EB
        or  ax, ax
        jz  short loc_49430
        cmp ax, cx
        ja  short loc_493EB
        mov cx, ax

loc_493EB:              ; CODE XREF: somethingspsig+85j
                    ; somethingspsig+8Dj
        push    bx
        push    cx
        mov ax, 4200h
        xor cx, cx
        mov dx, cx
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        pop cx
        pop bx
        jb  short loc_49430
        push    bx
        push    cx
        mov ax, 3F00h
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        pop cx
        pop bx
        jb  short loc_49430
        push    bx
        push    es
        push    ds
        pop es
        assume es:data
        push    di
        push    cx
        mov di, offset fileLevelData
        mov al, 0FFh
        cld
        repne scasb
        jz  short loc_4941C
        dec cx
        mov byte ptr [di], 0FFh

loc_4941C:              ; CODE XREF: somethingspsig+BCj
        pop ax
        pop di
        pop es
        assume es:nothing
        sub cx, ax
        neg cx
        mov ax, 4000h
        mov bx, word_510E4
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        pop bx

loc_49430:              ; CODE XREF: somethingspsig+7Ej
                    ; somethingspsig+89j ...
        mov ax, 3E00h
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

loc_49435:              ; CODE XREF: somethingspsig+65j
                    ; somethingspsig+6Fj
        mov ax, 3E00h
        mov bx, word_510E4
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        mov byte_510E3, 0
        cmp byte_5A33E, 0
        jz  short loc_4944F
        mov byte_510DE, 1

loc_4944F:              ; CODE XREF: somethingspsig+EEj
        call    sub_4FC20
        mov byte_5A33F, 1
        mov byte_510DE, 0
        retn
somethingspsig  endp


; =============== S U B R O U T I N E =======================================


sub_4945D   proc near       ; CODE XREF: sub_4955B+294p
                    ; sub_4955B+2A4p ...
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0
        mov word_51A07, 1
        push    ax
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al
        cmp byte_510E3, 0
        jz  short loc_49490
        call    somethingspsig

loc_49490:              ; CODE XREF: sub_4945D+2Ej
        pop ax
        mov bx, 380Ah
        add al, 30h ; '0'
        mov [bx+4], al
        cmp byte ptr word_59B6E, 0
        jnz short loc_494A6
        mov bx, 0A014h
        mov [bx+7], al

loc_494A6:              ; CODE XREF: sub_4945D+41j
        mov byte ptr aRecordingDemo0+12h, al ; "0 ---"
        mov cx, 0
        mov dx, bx
        mov ax, 3C00h
        int 21h     ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                    ; CX = attributes for file
                    ; DS:DX -> ASCIZ filename (may include drive and path)
        jnb short loc_494B8
        jmp locret_49543
; ---------------------------------------------------------------------------

loc_494B8:              ; CODE XREF: sub_4945D+56j
        mov word_510E4, ax
        mov byte_5A140, 83h ; '?'
        mov bl, speed?3
        mov cl, 4
        shl bl, cl
        or  bl, gameSpeed
        mov speed?2, bl
        mov bx, word_510E4
        mov ax, 4000h
        mov cx, levelDataLength
        mov dx, offset levelBuffer
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        jb  short locret_49543
        mov ax, word_51ABC
        or  al, 80h
        mov byte_510E2, al
        mov ax, 4000h
        mov bx, word_510E4
        mov cx, 1
        mov dx, 0DD2h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        jb  short locret_49543
        mov byte_510E1, 0
        mov byte_5A2F8, 1
        mov byte_510DE, 0
        mov byte_510E2, 0FEh ; '?'
        mov word_51A07, 1
        cmp byte_599D4, 0
        jnz short loc_4952A
        mov ax, word_58AB8
        mov word_58AEA, ax
        mov ax, word_58ABA
        and ax, 0FFh
        mov word_58AEC, ax

loc_4952A:              ; CODE XREF: sub_4945D+BCj
        mov byte_510E3, 1
        cmp byte_5A33E, 0
        jz  short loc_4953B
        mov byte_510DE, 1

loc_4953B:              ; CODE XREF: sub_4945D+D7j
        call    sub_4A463
        mov byte_510DE, 0

locret_49543:               ; CODE XREF: sub_4945D+58j
                    ; sub_4945D+82j ...
        retn
sub_4945D   endp


; =============== S U B R O U T I N E =======================================


sub_49544   proc near       ; CODE XREF: start+3A1p
                    ; sub_4B375:loc_4B40Fp ...
        mov ax, word ptr aLevels_dat_0+8 ; "AT"
        cmp ax, 3030h
        jnz short loc_4954F
        mov ax, 2D2Dh

loc_4954F:              ; CODE XREF: sub_49544+6j
        cmp ax, 5441h
        jnz short loc_49557
        mov ax, 3030h

loc_49557:              ; CODE XREF: sub_49544+Ej
        mov word ptr a00s0010_sp, ax ; "00S001$0.SP"
        retn
sub_49544   endp


; =============== S U B R O U T I N E =======================================


sub_4955B   proc near       ; CODE XREF: runLevel:loc_48B6Bp
                    ; runLevel+30Cp

; FUNCTION CHUNK AT 2DA8 SIZE 0000038B BYTES

        cmp word_51A01, 0
        jz  short loc_49567
        call    sub_4914A
        jmp short loc_4957B
; ---------------------------------------------------------------------------

loc_49567:              ; CODE XREF: sub_4955B+5j
        cmp byte_510DE, 0
        jnz short loc_4957B
        call    sub_4A1BF
        cmp byte_510E3, 0
        jz  short loc_4957B
        call    sub_492F1

loc_4957B:              ; CODE XREF: sub_4955B+Aj
                    ; sub_4955B+11j ...
        cmp byte_510DE, 0
        jz  short loc_49585
        call    sub_492A8

loc_49585:              ; CODE XREF: sub_4955B+25j
        cmp byte_519A1, 0
        jz  short loc_4958F
        call    sub_4921B

loc_4958F:              ; CODE XREF: sub_4955B+2Fj
        cmp byte ptr word_510C1+1, 0
        jz  short loc_4959A
        dec byte ptr word_510C1+1

loc_4959A:              ; CODE XREF: sub_4955B+39j
        cmp byte_51999, 0
        jnz short loc_495A9
        mov byte ptr word_510C1+1, 0
        jmp loc_49635
; ---------------------------------------------------------------------------

loc_495A9:              ; CODE XREF: sub_4955B+44j
        cmp byte ptr word_510C1+1, 0
        jz  short loc_495B3
        jmp loc_49635
; ---------------------------------------------------------------------------

loc_495B3:              ; CODE XREF: sub_4955B+53j
        mov byte ptr word_510C1+1, 20h ; ' '
        cmp byte ptr word_510C1, 0
        jz  short loc_495FB
        mov byte ptr word_510C1, 0
        cmp videoStatusUnk, 1
        jnz short loc_495ED
        mov cl, 90h ; '?'
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 7
        out dx, al      ; Video: CRT cntrlr addr
                    ; bit 8 for certain CRTC regs. Data bits:
                    ; 0: vertical total (Reg 06)
                    ; 1: vert disp'd enable end (Reg 12H)
                    ; 2: vert retrace start (Reg 10H)
                    ; 3: start vert blanking (Reg 15H)
                    ; 4: line compare (Reg 18H)
                    ; 5: cursor location (Reg 0aH)
        inc dx
        mov al, 3Fh ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 9
        out dx, al      ; Video: CRT cntrlr addr
                    ; maximum scan line
        inc dx
        mov al, 80h ; '?'
        out dx, al      ; Video: CRT controller internal registers
        jmp short loc_49635
; ---------------------------------------------------------------------------

loc_495ED:              ; CODE XREF: sub_4955B+6Ej
        mov cl, 0C8h ; '?'
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers
        jmp short loc_49635
; ---------------------------------------------------------------------------

loc_495FB:              ; CODE XREF: sub_4955B+62j
        mov byte ptr word_510C1, 1
        cmp videoStatusUnk, 1
        jnz short loc_49629
        mov cl, 5Fh ; '_'
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 7
        out dx, al      ; Video: CRT cntrlr addr
                    ; bit 8 for certain CRTC regs. Data bits:
                    ; 0: vertical total (Reg 06)
                    ; 1: vert disp'd enable end (Reg 12H)
                    ; 2: vert retrace start (Reg 10H)
                    ; 3: start vert blanking (Reg 15H)
                    ; 4: line compare (Reg 18H)
                    ; 5: cursor location (Reg 0aH)
        inc dx
        mov al, 3Fh ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 9
        out dx, al      ; Video: CRT cntrlr addr
                    ; maximum scan line
        inc dx
        mov al, 80h ; '?'
        out dx, al      ; Video: CRT controller internal registers
        jmp short loc_49635
; ---------------------------------------------------------------------------

loc_49629:              ; CODE XREF: sub_4955B+AAj
        mov cl, 0B0h ; '?'
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, cl
        out dx, al      ; Video: CRT controller internal registers

loc_49635:              ; CODE XREF: sub_4955B+4Bj
                    ; sub_4955B+55j ...
        cmp word_51970, 1
        jz  short loc_4963F
        jmp loc_49949
; ---------------------------------------------------------------------------

loc_4963F:              ; CODE XREF: sub_4955B+DFj
        cmp byte_510E3, 0
        jz  short loc_49649
        jmp loc_49742
; ---------------------------------------------------------------------------

loc_49649:              ; CODE XREF: sub_4955B+E9j
        cmp byte ptr dword_519AF, 0
        jz  short loc_49656
        mov word_51A01, 1

loc_49656:              ; CODE XREF: sub_4955B+F3j
        cmp byte_5199D, 0
        jz  short loc_49663
        mov word ptr flashingbackgroundon, 1

loc_49663:              ; CODE XREF: sub_4955B+100j
        cmp byte ptr word_519A9, 0
        jz  short loc_4966F
        mov ah, 1
        call    sub_4A23C

loc_4966F:              ; CODE XREF: sub_4955B+10Dj
        cmp byte ptr word_519AD, 0
        jz  short loc_4967B
        mov ah, 2
        call    sub_4A23C

loc_4967B:              ; CODE XREF: sub_4955B+119j
        cmp byte_519A0, 0
        jz  short loc_49687
        mov ah, 6
        call    sub_4A23C

loc_49687:              ; CODE XREF: sub_4955B+125j
        cmp byte ptr word_519AB, 0
        jz  short loc_49693
        mov ah, 5
        call    sub_4A23C

loc_49693:              ; CODE XREF: sub_4955B+131j
        cmp byte_5199C, 0
        jz  short loc_4969F
        mov ah, 11h
        call    sub_4A23C

loc_4969F:              ; CODE XREF: sub_4955B+13Dj
        cmp byte_51990, 0
        jz  short loc_496AC
        call    videoloop
        call    sub_4A3E9

loc_496AC:              ; CODE XREF: sub_4955B+149j
        cmp byte_510DE, 0
        jz  short loc_496B6
        jmp loc_49742
; ---------------------------------------------------------------------------

loc_496B6:              ; CODE XREF: sub_4955B+156j
        cmp speed?3, 0
        jge short loc_496C0
        jmp loc_49742
; ---------------------------------------------------------------------------

loc_496C0:              ; CODE XREF: sub_4955B+160j
        cmp byte_5197F, 0
        jz  short loc_496CD
        mov word_51A07, 1

loc_496CD:              ; CODE XREF: sub_4955B+16Aj
        cmp byte_51980, 0
        jz  short loc_496DA
        mov word_51A07, 2

loc_496DA:              ; CODE XREF: sub_4955B+177j
        cmp byte_51981, 0
        jz  short loc_496E7
        mov word_51A07, 3

loc_496E7:              ; CODE XREF: sub_4955B+184j
        cmp byte_51982, 0
        jz  short loc_496F4
        mov word_51A07, 4

loc_496F4:              ; CODE XREF: sub_4955B+191j
        cmp byte_51983, 0
        jz  short loc_49701
        mov word_51A07, 6

loc_49701:              ; CODE XREF: sub_4955B+19Ej
        cmp byte_51984, 0
        jz  short loc_4970E
        mov word_51A07, 8

loc_4970E:              ; CODE XREF: sub_4955B+1ABj
        cmp byte_51985, 0
        jz  short loc_4971B
        mov word_51A07, 0Ch

loc_4971B:              ; CODE XREF: sub_4955B+1B8j
        cmp byte_51986, 0
        jz  short loc_49728
        mov word_51A07, 10h

loc_49728:              ; CODE XREF: sub_4955B+1C5j
        cmp byte_51987, 0
        jz  short loc_49735
        mov word_51A07, 18h

loc_49735:              ; CODE XREF: sub_4955B+1D2j
        cmp byte_51988, 0
        jz  short loc_49742
        mov word_51A07, 20h ; ' '

loc_49742:              ; CODE XREF: sub_4955B+EBj
                    ; sub_4955B+158j ...
        cmp byte_5199A, 1
        jnz short loc_4974C
        jmp loc_497D1
; ---------------------------------------------------------------------------

loc_4974C:              ; CODE XREF: sub_4955B+1ECj
        mov ax, word_5195D
        and ax, 7
        jz  short loc_49757
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_49757:              ; CODE XREF: sub_4955B+1F7j
        cmp byte_510E3, 0
        jz  short loc_49761
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_49761:              ; CODE XREF: sub_4955B+201j
        cmp byte_519B8, 0
        jnz short loc_4976F
        mov byte_59B7C, 0
        jmp short loc_49786
; ---------------------------------------------------------------------------

loc_4976F:              ; CODE XREF: sub_4955B+20Bj
        cmp byte_59B7C, 0
        jnz short loc_49786
        dec byte_59B7C
        and byte_5101C, 1
        xor byte_5101C, 1
        jmp short loc_497CE
; ---------------------------------------------------------------------------

loc_49786:              ; CODE XREF: sub_4955B+212j
                    ; sub_4955B+219j
        cmp byte_519B9, 0
        jnz short loc_49794
        mov byte_59B7D, 0
        jmp short loc_497AB
; ---------------------------------------------------------------------------

loc_49794:              ; CODE XREF: sub_4955B+230j
        cmp byte_59B7D, 0
        jnz short loc_497AB
        dec byte_59B7D
        and byte_51035, 2
        xor byte_51035, 2
        jmp short loc_497CE
; ---------------------------------------------------------------------------

loc_497AB:              ; CODE XREF: sub_4955B+237j
                    ; sub_4955B+23Ej
        cmp byte_519BA, 0
        jnz short loc_497B9
        mov byte_59B7E, 0
        jmp short loc_497CE
; ---------------------------------------------------------------------------

loc_497B9:              ; CODE XREF: sub_4955B+255j
        cmp byte_59B7E, 0
        jnz short loc_497CE
        dec byte_59B7E
        and byte_510D7, 1
        xor byte_510D7, 1

loc_497CE:              ; CODE XREF: sub_4955B+229j
                    ; sub_4955B+24Ej ...
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_497D1:              ; CODE XREF: sub_4955B+1EEj
        cmp byte_510DE, 0
        jz  short loc_497DB
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_497DB:              ; CODE XREF: sub_4955B+27Bj
        cmp speed?3, 0
        jge short loc_497E5
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_497E5:              ; CODE XREF: sub_4955B+285j
        cmp byte_519B8, 1
        jnz short loc_497F5
        mov ax, 0
        call    sub_4945D
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_497F5:              ; CODE XREF: sub_4955B+28Fj
        cmp byte_519B9, 1
        jnz short loc_49805
        mov ax, 1
        call    sub_4945D
        jmp loc_4988E
; ---------------------------------------------------------------------------

loc_49805:              ; CODE XREF: sub_4955B+29Fj
        cmp byte_519BA, 1
        jnz short loc_49814
        mov ax, 2
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_49814:              ; CODE XREF: sub_4955B+2AFj
        cmp byte_519BB, 1
        jnz short loc_49823
        mov ax, 3
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_49823:              ; CODE XREF: sub_4955B+2BEj
        cmp byte_519BC, 1
        jnz short loc_49832
        mov ax, 4
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_49832:              ; CODE XREF: sub_4955B+2CDj
        cmp byte_519BD, 1
        jnz short loc_49841
        mov ax, 5
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_49841:              ; CODE XREF: sub_4955B+2DCj
        cmp byte_519BE, 1
        jnz short loc_49850
        mov ax, 6
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_49850:              ; CODE XREF: sub_4955B+2EBj
        cmp byte_519BF, 1
        jnz short loc_4985F
        mov ax, 7
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_4985F:              ; CODE XREF: sub_4955B+2FAj
        cmp byte_519C0, 1
        jnz short loc_4986E
        mov ax, 8
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_4986E:              ; CODE XREF: sub_4955B+309j
        cmp byte_519C1, 1
        jnz short loc_4987D
        mov ax, 9
        call    sub_4945D
        jmp short loc_4988E
; ---------------------------------------------------------------------------

loc_4987D:              ; CODE XREF: sub_4955B+318j
        cmp byte_519D5, 1
        jnz short loc_4988E
        cmp byte_510E3, 0
        jz  short loc_4988E
        call    somethingspsig

loc_4988E:              ; CODE XREF: sub_4955B+1F9j
                    ; sub_4955B+203j ...
        cmp byte_510E3, 0
        jz  short loc_49898
        jmp loc_49949
; ---------------------------------------------------------------------------

loc_49898:              ; CODE XREF: sub_4955B+338j
        cmp byte_510DE, 0
        jz  short loc_498A2
        jmp loc_49949
; ---------------------------------------------------------------------------

loc_498A2:              ; CODE XREF: sub_4955B+342j
        cmp byte_51989, 0
        jnz short loc_498B5
        mov byte_59B7F, 0
        mov byte_59B80, 5
        jmp short loc_498FC
; ---------------------------------------------------------------------------

loc_498B5:              ; CODE XREF: sub_4955B+34Cj
        cmp byte_59B7F, 0
        jz  short loc_498C2
        dec byte_59B7F
        jmp short loc_498FC
; ---------------------------------------------------------------------------

loc_498C2:              ; CODE XREF: sub_4955B+35Fj
        cmp byte_59B80, 0
        jz  short loc_498D2
        dec byte_59B80
        mov byte_59B7F, 10h

loc_498D2:              ; CODE XREF: sub_4955B+36Cj
        cmp word_51ABC, 1
        ja  short loc_498DF
        mov word_51ABC, 2

loc_498DF:              ; CODE XREF: sub_4955B+37Cj
        dec word_51ABC
        cmp word_51ABC, 6Fh ; 'o'
        jbe short loc_498F0
        mov word_51ABC, 6Fh ; 'o'

loc_498F0:              ; CODE XREF: sub_4955B+38Dj
        mov ax, word_51ABC
        call    sub_4BF4A
        call    sub_4C141
        call    sub_4A3D2

loc_498FC:              ; CODE XREF: sub_4955B+358j
                    ; sub_4955B+365j
        cmp byte_5198A, 0
        jnz short loc_4990F
        mov byte_59B81, 0
        mov byte_59B82, 5
        jmp short loc_49949
; ---------------------------------------------------------------------------

loc_4990F:              ; CODE XREF: sub_4955B+3A6j
        cmp byte_59B81, 0
        jz  short loc_4991C
        dec byte_59B81
        jmp short loc_49949
; ---------------------------------------------------------------------------

loc_4991C:              ; CODE XREF: sub_4955B+3B9j
        cmp byte_59B82, 0
        jz  short loc_4992C
        dec byte_59B82
        mov byte_59B81, 10h

loc_4992C:              ; CODE XREF: sub_4955B+3C6j
        cmp word_51ABC, 6Fh ; 'o'
        jb  short loc_49939
        mov word_51ABC, 6Eh ; 'n'

loc_49939:              ; CODE XREF: sub_4955B+3D6j
        inc word_51ABC
        mov ax, word_51ABC
        call    sub_4BF4A
        call    sub_4C141
        call    sub_4A3D2

loc_49949:              ; CODE XREF: sub_4955B+E1j
                    ; sub_4955B+33Aj ...
        cmp byte_59B6B, 0
        mov byte_59B6B, 0
        jz  short loc_49958
        jmp loc_49A89
; ---------------------------------------------------------------------------

loc_49958:              ; CODE XREF: sub_4955B+3F8j
        cmp byte_5199A, 1
        jz  short loc_49962
        jmp loc_49C41
; ---------------------------------------------------------------------------

loc_49962:              ; CODE XREF: sub_4955B+402j
        cmp byte_519D5, 1
        jnz short loc_49984
        cmp byte_510DE, 0
        jz  short loc_49984
        mov byte_510DE, 0
        mov byte_510B3, 0
        mov byte_5A2F9, 1
        mov byte_5A33E, 1

loc_49984:              ; CODE XREF: sub_4955B+40Cj
                    ; sub_4955B+413j
        cmp byte_519C3, 1
        jnz short loc_499AA
        mov word_51970, 1
        cmp videoStatusUnk, 1
        jnz short loc_499AA
        mov di, 6D2h
        mov ah, 6
        push    si
        mov si, 0A00Ah
        call    sub_500F3
        pop si
        mov byte_5197C, 46h ; 'F'

loc_499AA:              ; CODE XREF: sub_4955B+42Ej
                    ; sub_4955B+43Bj
        cmp byte_5198E, 1
        jz  short loc_499C8
        jmp loc_49A7F
sub_4955B   endp


; =============== S U B R O U T I N E =======================================


readFromFh1 proc near       ; CODE XREF: sub_4955B+54Ep
                    ; sub_4955B+57Cp ...
        mov ax, 3F00h
        mov bx, fh1
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        retn
readFromFh1 endp


; =============== S U B R O U T I N E =======================================


writeToFh1  proc near       ; CODE XREF: sub_4955B+486p
                    ; sub_4955B+494p ...
        mov ax, 4000h
        mov bx, fh1
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        retn
writeToFh1  endp

; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR sub_4955B

loc_499C8:              ; CODE XREF: sub_4955B+454j
        mov cx, 0
        mov dx, offset aSavegame_sav ; "SAVEGAME.SAV"
        mov ax, 3C00h
        int 21h     ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                    ; CX = attributes for file
                    ; DS:DX -> ASCIZ filename (may include drive and path)
        jnb short loc_499D8
        jmp loc_49C28
; ---------------------------------------------------------------------------

loc_499D8:              ; CODE XREF: sub_4955B+478j
        mov fh1, ax
        mov cx, 4
        mov dx, 9FF9h
        call    writeToFh1
        jnb short loc_499E9
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_499E9:              ; CODE XREF: sub_4955B+489j
        mov cx, 1238h
        mov dx, offset leveldata
        call    writeToFh1
        jnb short loc_499F7
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_499F7:              ; CODE XREF: sub_4955B+497j
        cmp byte_510DE, 0
        jnz short loc_49A03
        mov dx, 87A8h
        jmp short loc_49A06
; ---------------------------------------------------------------------------

loc_49A03:              ; CODE XREF: sub_4955B+4A1j
        mov dx, 87DAh

loc_49A06:              ; CODE XREF: sub_4955B+4A6j
        mov cx, 1Ch
        push    dx
        call    writeToFh1
        pop bx
        jnb short loc_49A13
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_49A13:              ; CODE XREF: sub_4955B+4B3j
        mov cx, 6
        mov byte_5988D, 63h ; 'c'
        mov ax, word ptr aLevels_dat_0+8 ; "AT"
        mov word_5988E, ax
        mov al, [bx]
        cmp byte_510DE, 0
        jz  short loc_49A2C
        or  al, 80h

loc_49A2C:              ; CODE XREF: sub_4955B+4CDj
        mov byte_59890, al
        mov ax, [bx+1]
        mov word_59891, ax
        mov dx, 957Dh
        call    writeToFh1
        jnb short loc_49A40
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_49A40:              ; CODE XREF: sub_4955B+4E0j
        mov cx, 0E6h ; '?'
        mov dx, 0D08h
        call    writeToFh1
        jnb short loc_49A4E
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_49A4E:              ; CODE XREF: sub_4955B+4EEj
        mov cx, 23h ; '#'
        mov dx, 164Ah
        call    writeToFh1
        jnb short loc_49A5C
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_49A5C:              ; CODE XREF: sub_4955B+4FCj
        mov cx, levelDataLength
        mov dx, offset levelBuffer
        call    writeToFh1
        jnb short loc_49A6A
        jmp loc_49C1F
; ---------------------------------------------------------------------------

loc_49A6A:              ; CODE XREF: sub_4955B+50Aj
        mov ax, 3E00h
        mov bx, fh1
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_49A78
        jmp loc_49C28
; ---------------------------------------------------------------------------

loc_49A78:              ; CODE XREF: sub_4955B+518j
        push    si
        mov si, 0A001h
        jmp loc_49C2C
; ---------------------------------------------------------------------------

loc_49A7F:              ; CODE XREF: sub_4955B+456j
        cmp byte ptr dword_519A3, 1
        jz  short loc_49A89
        jmp loc_49C41
; ---------------------------------------------------------------------------

loc_49A89:              ; CODE XREF: sub_4955B+3FAj
                    ; sub_4955B+529j
        mov ax, 3D00h
        mov dx, offset aSavegame_sav ; "SAVEGAME.SAV"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_49A96
        jmp loc_49C28
; ---------------------------------------------------------------------------

loc_49A96:              ; CODE XREF: sub_4955B+536j
        mov fh1, ax
        cmp byte_510E3, 0
        jz  short loc_49AA3
        call    somethingspsig

loc_49AA3:              ; CODE XREF: sub_4955B+543j
        mov cx, 4
        mov dx, 9FFDh
        call    readFromFh1
        jnb short loc_49AB1
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49AB1:              ; CODE XREF: sub_4955B+551j
        mov cx, word_5A30D
        cmp cx, word_5A309
        jnz short loc_49AC5
        mov cx, word_5A30F
        cmp cx, word_5A30B
        jz  short loc_49AD1

loc_49AC5:              ; CODE XREF: sub_4955B+55Ej
        mov ax, 3E00h
        mov bx, fh1
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jmp loc_49C28
; ---------------------------------------------------------------------------

loc_49AD1:              ; CODE XREF: sub_4955B+568j
        mov cx, 1238h
        mov dx, offset leveldata
        call    readFromFh1
        jnb short loc_49ADF
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49ADF:              ; CODE XREF: sub_4955B+57Fj
        mov cx, 1Ch
        mov dx, 87A8h
        call    readFromFh1
        jnb short loc_49AED
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49AED:              ; CODE XREF: sub_4955B+58Dj
        mov cx, 6
        mov dx, 957Dh
        call    readFromFh1
        jnb short loc_49AFB
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49AFB:              ; CODE XREF: sub_4955B+59Bj
        mov cx, 84h ; '?'
        mov dx, 0D08h
        call    readFromFh1
        jnb short loc_49B09
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B09:              ; CODE XREF: sub_4955B+5A9j
        mov cx, 4
        mov dx, 0D9Bh
        call    readFromFh1
        jnb short loc_49B17
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B17:              ; CODE XREF: sub_4955B+5B7j
        mov cx, 7
        mov dx, 0D90h
        call    readFromFh1
        jnb short loc_49B25
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B25:              ; CODE XREF: sub_4955B+5C5j
        mov cx, 4
        mov dx, 0D9Bh
        call    readFromFh1
        jnb short loc_49B33
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B33:              ; CODE XREF: sub_4955B+5D3j
        mov cx, 53h ; 'S'
        mov dx, 0D9Bh
        push    word_510C1
        call    readFromFh1
        pop word_510C1
        jnb short loc_49B49
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B49:              ; CODE XREF: sub_4955B+5E9j
        mov cx, 23h ; '#'
        mov dx, 164Ah
        push    word_51961
        push    word_51967
        push    word_51970
        call    readFromFh1
        pop word_51970
        pop word_51967
        pop word_51961
        jnb short loc_49B6F
        jmp loc_49C1A
; ---------------------------------------------------------------------------

loc_49B6F:              ; CODE XREF: sub_4955B+60Fj
        cmp byte_5988D, 0
        jz  short loc_49B84
        mov cx, levelDataLength
        mov dx, offset levelBuffer
        call    readFromFh1
        jb  short loc_49B84
        call    sub_49D53

loc_49B84:              ; CODE XREF: sub_4955B+619j
                    ; sub_4955B+624j
        mov ax, 3E00h
        mov bx, fh1
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        mov byte_510DE, 0
        mov byte_510E3, 0
        mov byte_50941, 0
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0
        mov word_51A07, 1
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al
        call    getTime
        call    sub_4A1AE
        mov si, 60D5h
        call    sub_4D836
        call    sub_48F6D
        call    sub_501C0
        call    sub_4A2E6
        mov si, murphyloc
        mov ax, si
        shr ax, 1
        call    sub_4A291
        mov ax, 0FFFFh
        mov word_510B7, ax
        mov byte_510B9, al
        call    sub_4FDFD
        mov byte_5A2F9, 1
        mov byte_510E3, 0
        push    si
        mov si, 0A004h
        cmp videoStatusUnk, 1
        jnz short loc_49C12
        mov di, 6D2h
        mov ah, 6
        call    sub_500F3
        mov byte_5197C, 46h ; 'F'

loc_49C12:              ; CODE XREF: sub_4955B+6A8j
        mov si, 6015h
        call    fade
        jmp short loc_49C40
; ---------------------------------------------------------------------------

loc_49C1A:              ; CODE XREF: sub_4955B+553j
                    ; sub_4955B+581j ...
        mov byte_510E3, 0

loc_49C1F:              ; CODE XREF: sub_4955B+48Bj
                    ; sub_4955B+499j ...
        mov ax, 3E00h
        mov bx, fh1
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

loc_49C28:              ; CODE XREF: sub_4955B+47Aj
                    ; sub_4955B+51Aj ...
        push    si
        mov si, 0A007h

loc_49C2C:              ; CODE XREF: sub_4955B+521j
        cmp videoStatusUnk, 1
        jnz short loc_49C40
        mov di, 6D2h
        mov ah, 6
        call    sub_500F3
        mov byte_5197C, 46h ; 'F'

loc_49C40:              ; CODE XREF: sub_4955B+6BDj
                    ; sub_4955B+6D6j
        pop si

loc_49C41:              ; CODE XREF: sub_4955B+404j
                    ; sub_4955B+52Bj
        cmp byte_519B5, 1
        jnz short loc_49C96
        cmp byte_519C3, 1
        jnz short loc_49C96
        mov word_51970, 0
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0
        mov word_51A07, 1
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al
        cmp videoStatusUnk, 1
        jnz short loc_49C96
        mov di, 6D2h
        mov ah, 6
        push    si
        mov si, 0A00Dh
        call    sub_500F3
        pop si
        mov byte_5197C, 46h ; 'F'

loc_49C96:              ; CODE XREF: sub_4955B+6EBj
                    ; sub_4955B+6F2j ...
        cmp byte_51996, 0
        jz  short loc_49CC8
        mov byte_510AE, 0
        mov si, 6095h
        call    fade

loc_49CA8:              ; CODE XREF: sub_4955B+752j
        cmp byte_51996, 1
        jz  short loc_49CA8

loc_49CAF:              ; CODE XREF: sub_4955B+759j
        cmp byte_51996, 0
        jz  short loc_49CAF

loc_49CB6:              ; CODE XREF: sub_4955B+760j
        cmp byte_51996, 1
        jz  short loc_49CB6
        mov si, 6015h
        call    fade
        mov byte_510AE, 1

loc_49CC8:              ; CODE XREF: sub_4955B+740j
        cmp byte_519C2, 0
        jz  short loc_49D15
        mov byte_510AE, 0
        mov si, 6095h
        call    fade

loc_49CDA:              ; CODE XREF: sub_4955B+784j
        cmp byte_519C2, 1
        jz  short loc_49CDA
        mov si, 179Ah

loc_49CE4:              ; CODE XREF: sub_4955B+7A6j
        mov bx, [si]
        cmp bx, 0FFFFh
        jnz short loc_49CF3
        mov word_51970, 0
        jmp short loc_49D03
; ---------------------------------------------------------------------------

loc_49CF3:              ; CODE XREF: sub_4955B+78Ej
        cmp byte ptr [bx+166Dh], 0
        jz  short loc_49CFC
        inc si
        inc si

loc_49CFC:              ; CODE XREF: sub_4955B+79Dj
        cmp byte_519C2, 0
        jz  short loc_49CE4

loc_49D03:              ; CODE XREF: sub_4955B+796j
                    ; sub_4955B+7ADj
        cmp byte_519C2, 1
        jz  short loc_49D03
        mov si, 6015h
        call    fade
        mov byte_510AE, 1

loc_49D15:              ; CODE XREF: sub_4955B+772j
        cmp byte_5197E, 0
        jz  short loc_49D29
        cmp word_51978, 0
        jg  short loc_49D29
        mov word_510D1, 1

loc_49D29:              ; CODE XREF: sub_4955B+7BFj
                    ; sub_4955B+7C6j
        cmp byte_5198D, 0
        jz  short loc_49D48
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0

loc_49D48:              ; CODE XREF: sub_4955B+7D3j
        cmp byte ptr word_519B3, 0
        jz  short locret_49D52
        call    sub_4FDCE

locret_49D52:               ; CODE XREF: sub_4955B+7F2j
        retn
; END OF FUNCTION CHUNK FOR sub_4955B

; =============== S U B R O U T I N E =======================================


sub_49D53   proc near       ; CODE XREF: sub_4955B+626p
                    ; sub_4A23C+21p
        mov byte_59B7B, 0
sub_49D53   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


levelScanThing   proc near       ; CODE XREF: runLevel+A7p
        push    es
        push    ds
        pop es
        assume es:data
        cld
        mov cx, 5A0h
        mov di, offset leveldata
        mov ax, 0F11Fh

loc_49D65:              ; CODE XREF: levelScanThing+18j
        cmp es:[di], al
        jnz short loc_49D6D
        mov es:[di], ah

loc_49D6D:              ; CODE XREF: levelScanThing+10j
        inc di
        inc di
        dec cx
        jnz short loc_49D65
        cmp byte_59B7B, 0
        mov byte_59B7B, 0
        jnz short loc_49DDE
        mov cx, 5A0h
        mov di, offset leveldata

loc_49D84:              ; CODE XREF: levelScanThing+4Cj
        mov ax, 6
        repne scasw
        jnz short loc_49DA6
        mov bx, 59Fh
        sub bx, cx
        mov al, [bx-6775h]
        cmp ax, 1Ch
        jb  short loc_49DA2
        cmp ax, 25h ; '%'
        ja  short loc_49DA2
        mov es:[di-2], ax

loc_49DA2:              ; CODE XREF: levelScanThing+3Fj
                    ; levelScanThing+44j
        or  cx, cx
        jnz short loc_49D84

loc_49DA6:              ; CODE XREF: levelScanThing+31j
        mov cx, 5A0h
        mov di, offset leveldata

loc_49DAC:              ; CODE XREF: levelScanThing+7Fj
        mov ax, 5
        repne scasw
        jnz short loc_49DD9
        mov bx, 59Fh
        sub bx, cx
        mov al, [bx-6775h]
        cmp ax, 1Ah
        jb  short loc_49DD5
        cmp ax, 27h ; '''
        ja  short loc_49DD5
        sub ax, 1Ch
        cmp ax, 0Ah
        jb  short loc_49DD5
        add ax, 1Ch
        mov es:[di-2], ax

loc_49DD5:              ; CODE XREF: levelScanThing+67j
                    ; levelScanThing+6Cj ...
        or  cx, cx
        jnz short loc_49DAC

loc_49DD9:              ; CODE XREF: levelScanThing+59j
        mov byte_59B7B, 1

loc_49DDE:              ; CODE XREF: levelScanThing+24j
        pop es
        assume es:nothing
        retn
levelScanThing   endp


; =============== S U B R O U T I N E =======================================


gameloop?   proc near       ; CODE XREF: runLevel:noFlashingp

        ; set graphics write mode = 1
        mov dx, 3CEh
        mov al, 5
        out dx, al
        inc dx
        mov al, 1
        out dx, al

        mov si, murphyloc
        call    update?
        mov murphyloc, si

        cmp word ptr flashingbackgroundon, 0
        jz  short loc_49E0A

        ; flashes background
        ; set palette ix 0 = #3f2121 (maroon)
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 3Fh
        out dx, al
        out dx, al
        mov al, 21h
        out dx, al

loc_49E0A:
        cmp byte ptr word_510C1, 0
        jz  short loc_49E14
        call    sub_5024B

loc_49E14:
        ; set graphics write mode = 1
        mov dx, 3CEh
        mov al, 5
        out dx, al
        inc dx
        mov al, 1
        out dx, al

        cmp word ptr flashingbackgroundon, 0
        jz  short loc_49E33
        
        ; flashes background
        ; set palette ix 0 = #3f2121 (maroon)
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        mov al, 3Fh
        out dx, al
        mov al, 21h
        out dx, al
        out dx, al

loc_49E33:
        mov di, offset movingObjects?
        mov si, 7Ah ; level width in words + 2 (index of first gamefiled cell)
        mov cx, 526h ; unsure count
        xor dx, dx
        xor bh, bh

checkCellForMovingObject:              ; CODE XREF: gameloop?+84j
        mov bl, byte ptr leveldata[si]

        test    bl, 0Dh
        jz  short moveToNextCell

        cmp bl, 20h
        jnb short moveToNextCell

        ; multiply by 2 to go from byte to word
        shl bx, 1
        mov ax, movingFunctions[bx]
        or  ax, ax
        jz  short moveToNextCell

        ; log moving object for call
        ; each index has 2 bytes for index and 2 bytes as fn ptr to call
        inc dx
        mov [di], si
        mov [di+2], ax
        add di, 4

moveToNextCell:

        add si, 2
        loop    checkCellForMovingObject

        cmp dx, 0
        jz  short doneWithGameLoop ; not a single moving object
        mov cx, dx ; cx = number of moving objects
        mov di, offset movingObjects?

; call moving functions one by one
callNextMovingFunction:
        push    di
        push    cx
        mov si, [di]    ; the cell for the moving object
        mov ax, [di+2]  ; the function to call
        call    ax
        pop cx
        pop di
        add di, 4
        loop    callNextMovingFunction

doneWithGameLoop:
        ; set graphics write mode = 0
        mov dx, 3CEh
        mov al, 5
        out dx, al
        inc dx
        mov al, 0
        out dx, al

        cmp word_510D1, 1
        jz  short loc_49E99
        cmp word_510CF, 0
        jz  short loc_49E99
        retn
; ---------------------------------------------------------------------------

loc_49E99:              ; CODE XREF: gameloop?+AFj
                    ; gameloop?+B6j
        cmp word_51978, 0
        jnz short loc_49EB3
        mov word_510D1, 0
        mov si, word_510C7
        call    sub_4A61F
        mov word_51978, 40h ; '@'

loc_49EB3:
        ; set graphics write mode = 0
        mov dx, 3CEh
        mov al, 5
        out dx, al
        inc dx
        mov al, 1
        out dx, al

        retn
gameloop?   endp


; =============== S U B R O U T I N E =======================================


sub_49EBE   proc near       ; CODE XREF: runLevel+109p
                    ; sub_4A291+29p
        xor dx, dx
        cmp byte_510C0, 0
        jz  short loc_49ECC
        call    sub_4A1AE
        mov dx, ax

loc_49ECC:              ; CODE XREF: sub_49EBE+7j
        mov bx, word_510E8
        mov ax, word_510EA
        sub bx, 98h ; '?'
        cmp bx, 8
        jge short loc_49EDF
        mov bx, 8

loc_49EDF:              ; CODE XREF: sub_49EBE+1Cj
        cmp bx, 278h
        jbe short loc_49EE8
        mov bx, 278h

loc_49EE8:              ; CODE XREF: sub_49EBE+25j
        cmp byte ptr word_510C1, 0
        jz  short loc_49EF4
        sub ax, 58h ; 'X'
        jmp short loc_49EF7
; ---------------------------------------------------------------------------

loc_49EF4:              ; CODE XREF: sub_49EBE+2Fj
        sub ax, 64h ; 'd'

loc_49EF7:              ; CODE XREF: sub_49EBE+34j
        cmp ax, 0
        jge short loc_49EFE
        xor ax, ax

loc_49EFE:              ; CODE XREF: sub_49EBE+3Cj
        cmp byte ptr word_510C1, 0
        jz  short loc_49F0F
        cmp ax, 0C0h ; '?'
        jle short loc_49F0D
        mov ax, 0C0h ; '?'

loc_49F0D:              ; CODE XREF: sub_49EBE+4Aj
        jmp short loc_49F17
; ---------------------------------------------------------------------------

loc_49F0F:              ; CODE XREF: sub_49EBE+45j
        cmp ax, 0A8h ; '?'
        jle short loc_49F17
        mov ax, 0A8h ; '?'

loc_49F17:              ; CODE XREF: sub_49EBE:loc_49F0Dj
                    ; sub_49EBE+54j
        cmp word_51A01, 0
        jz  short loc_49F25
        cmp byte_519C9, 0
        jz  short loc_49F2E

loc_49F25:              ; CODE XREF: sub_49EBE+5Ej
        mov word_59B88, bx
        mov word_59B8A, ax
        jmp short loc_49FA9
; ---------------------------------------------------------------------------

loc_49F2E:              ; CODE XREF: sub_49EBE+65j
        mov bx, word_59B88
        mov ax, word_59B8A
        mov cx, bx
        add bx, word_51963
        cmp bx, 8
        jge short loc_49F56
        cmp byte_59B6C, 0
        jnz short loc_49F4C
        mov bx, 8
        jmp short loc_49F66
; ---------------------------------------------------------------------------

loc_49F4C:              ; CODE XREF: sub_49EBE+87j
        add bx, 3D0h
        dec word_51965
        jmp short loc_49F66
; ---------------------------------------------------------------------------

loc_49F56:              ; CODE XREF: sub_49EBE+80j
        cmp byte_59B6C, 0
        jnz short loc_49F6E
        cmp bx, 278h
        jbe short loc_49F6E
        mov bx, 278h

loc_49F66:              ; CODE XREF: sub_49EBE+8Cj
                    ; sub_49EBE+96j
        sub cx, bx
        neg cx
        mov word_51963, cx

loc_49F6E:              ; CODE XREF: sub_49EBE+9Dj
                    ; sub_49EBE+A3j
        mov cx, ax
        add ax, word_51965
        jge short loc_49F81
        cmp byte_59B6C, 0
        jnz short loc_49FA9
        xor ax, ax
        jmp short loc_49FA1
; ---------------------------------------------------------------------------

loc_49F81:              ; CODE XREF: sub_49EBE+B6j
        cmp byte_59B6C, 0
        jnz short loc_49FA9
        cmp byte ptr word_510C1, 0
        jz  short loc_49F99
        cmp ax, 0C0h ; '?'
        jbe short loc_49FA9
        mov ax, 0C0h ; '?'
        jmp short loc_49FA1
; ---------------------------------------------------------------------------

loc_49F99:              ; CODE XREF: sub_49EBE+CFj
        cmp ax, 0A8h ; '?'
        jbe short loc_49FA9
        mov ax, 0A8h ; '?'

loc_49FA1:              ; CODE XREF: sub_49EBE+C1j
                    ; sub_49EBE+D9j
        sub cx, ax
        neg cx
        mov word_51965, cx

loc_49FA9:              ; CODE XREF: sub_49EBE+6Ej
                    ; sub_49EBE+BDj ...
        cmp byte_59B72, 0
        jnz short loc_49FBE
        cmp byte_59B6D, 0
        jnz short loc_49FD2
        cmp byte ptr word_51978, 0
        jz  short loc_49FD2

loc_49FBE:              ; CODE XREF: sub_49EBE+F0j
        xor cx, cx
        and dx, 101h
        xchg    cl, dh
        add ax, cx
        cmp bx, 13Ch
        jbe short loc_49FD0
        neg dx

loc_49FD0:              ; CODE XREF: sub_49EBE+10Ej
        add bx, dx

loc_49FD2:              ; CODE XREF: sub_49EBE+F7j
                    ; sub_49EBE+FEj
        mov word_5195F, bx
        mov word_51961, ax
        mov cl, 3
        shr bx, cl
        mov cx, 7Ah ; 'z'
        mul cx
        add bx, ax
        add bx, 4D34h
        mov word_51967, bx
        retn
sub_49EBE   endp


; =============== S U B R O U T I N E =======================================


sub_49FED   proc near       ; CODE XREF: sub_48E59+2Cp
                    ; sub_48E59+67p ...
        mov al, byte_50940
        cmp al, 0
        jnz short loc_49FF8
        xor ax, ax
        stc
        retn
; ---------------------------------------------------------------------------

loc_49FF8:              ; CODE XREF: sub_49FED+5j
        mov dx, 201h
        cli
        mov cx, 0

loc_49FFF:              ; CODE XREF: sub_49FED+21j
        in  al, dx      ; Game I/O port
                    ; bits 0-3: Coordinates (resistive, time-dependent inputs)
                    ; bits 4-7: Buttons/Triggers (digital inputs)
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        test    al, ah
        jz  short loc_4A013
        loop    loc_49FFF
        stc
        jmp short loc_4A03B
; ---------------------------------------------------------------------------

loc_4A013:              ; CODE XREF: sub_49FED+1Fj
        out dx, al      ; Game I/O port
                    ; bits 0-3: Coordinates (resistive, time-dependent inputs)
                    ; bits 4-7: Buttons/Triggers (digital inputs)
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        mov cx, 0

loc_4A021:              ; CODE XREF: sub_49FED+44j
        nop
        in  al, dx      ; Game I/O port
                    ; bits 0-3: Coordinates (resistive, time-dependent inputs)
                    ; bits 4-7: Buttons/Triggers (digital inputs)
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        test    al, ah
        jz  short loc_4A036
        loop    loc_4A021
        stc
        jmp short loc_4A03B
; ---------------------------------------------------------------------------

loc_4A036:              ; CODE XREF: sub_49FED+42j
        neg cx
        mov ax, cx
        clc

loc_4A03B:              ; CODE XREF: sub_49FED+24j
                    ; sub_49FED+47j
        sti
        retn
sub_49FED   endp


; =============== S U B R O U T I N E =======================================


movefun7  proc near       ; DATA XREF: data:163Co
        cmp byte ptr leveldata[si], 19h
        jz  short loc_4A045
        retn
; ---------------------------------------------------------------------------

loc_4A045:              ; CODE XREF: movefun7+5j
        mov ax, word_5195D
        and ax, 3
        cmp ax, 0
        jz  short loc_4A051
        retn
; ---------------------------------------------------------------------------

loc_4A051:              ; CODE XREF: movefun7+11j
        mov bl, [si+1835h]
        inc bl
        cmp bl, 0Eh
        jl  short loc_4A067
        call    sub_4A1AE
        and al, 3Fh
        add al, 20h ; ' '
        neg al
        mov bl, al

loc_4A067:              ; CODE XREF: movefun7+1Dj
        mov [si+1835h], bl
        cmp bl, 0
        jge short loc_4A071
        retn
; ---------------------------------------------------------------------------

loc_4A071:              ; CODE XREF: movefun7+31j
        cmp byte ptr [si+17BAh], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+17BCh], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+17BEh], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+1832h], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+1836h], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+18AAh], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+18ACh], 3
        jz  short loc_4A0AB
        cmp byte ptr [si+18AEh], 3
        jz  short loc_4A0AB
        jmp short loc_4A0AE
; ---------------------------------------------------------------------------

loc_4A0AB:              ; CODE XREF: movefun7+39j
                    ; movefun7+40j ...
        call    sound?8

loc_4A0AE:              ; CODE XREF: movefun7+6Cj
        xor bh, bh
        mov di, [si+6155h]
        mov si, bx
        shl si, 1
        add si, 1272h
        mov si, [si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4A0C6:              ; CODE XREF: movefun7+91j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4A0C6
        pop ds
        retn
movefun7  endp


; =============== S U B R O U T I N E =======================================


movefun5  proc near       ; DATA XREF: data:1630o
        cmp byte ptr leveldata[si], 13h
        jz  short loc_4A0DA
        retn
; ---------------------------------------------------------------------------

loc_4A0DA:              ; CODE XREF: movefun5+5j
        mov bl, [si+1835h]
        inc bl
        cmp bl, 0
        jg  short loc_4A0EA
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4A0EA:              ; CODE XREF: movefun5+11j
        call    sub_4A1AE
        and al, byte_5196A
        neg al
        mov bl, al
        mov [si+1835h], bl
        mov di, [si+6155h]
        mov si, di
        add di, 4C4h
        add si, 0F4h ; '?'
        push    ds
        mov ax, es
        mov ds, ax
        push    si
        push    di
        movsb
        add di, 0FC2Fh
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        pop di
        pop si
        inc si
        inc di
        movsb
        add di, 0FC2Fh
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        movsb
        add di, 79h ; 'y'
        add si, 79h ; 'y'
        pop ds
        retn
movefun5  endp


; =============== S U B R O U T I N E =======================================


getTime     proc near       ; CODE XREF: start:doesNotHaveCommandLinep
                    ; sub_4955B+669p ...
        mov ax, 0
        int 1Ah     ; CLOCK - GET TIME OF DAY
                    ; Return: CX:DX = clock count
                    ; AL = 00h if clock was read or written (via AH=0,1) since the previous
                    ; midnight
                    ; Otherwise, AL > 0
        xor cx, dx
        mov timeOfDay, cx
        retn
getTime     endp


; =============== S U B R O U T I N E =======================================


sub_4A1AE   proc near       ; CODE XREF: sub_4955B+66Cp
                    ; sub_49EBE+9p ...
        mov ax, timeOfDay
        mov bx, 5E5h
        mul bx
        add ax, 31h ; '1'
        mov timeOfDay, ax
        shr ax, 1
        retn
sub_4A1AE   endp


; =============== S U B R O U T I N E =======================================


sub_4A1BF   proc near       ; CODE XREF: sub_4955B+13p
                    ; runMainMenu+BDp ...
        xor ah, ah
        cmp byte_519C5, 0
        jnz short loc_4A1CF
        cmp byte_519F9, 0
        jz  short loc_4A1D6

loc_4A1CF:              ; CODE XREF: sub_4A1BF+7j
        mov byte_50941, 1
        mov ah, 1

loc_4A1D6:              ; CODE XREF: sub_4A1BF+Ej
        cmp byte_519C8, 0
        jnz short loc_4A1E4
        cmp byte_519F7, 0
        jz  short loc_4A1EB

loc_4A1E4:              ; CODE XREF: sub_4A1BF+1Cj
        mov byte_50941, 2
        mov ah, 1

loc_4A1EB:              ; CODE XREF: sub_4A1BF+23j
        cmp byte_519CD, 0
        jnz short loc_4A1F9
        cmp byte_519F8, 0
        jz  short loc_4A200

loc_4A1F9:              ; CODE XREF: sub_4A1BF+31j
        mov byte_50941, 3
        mov ah, 1

loc_4A200:              ; CODE XREF: sub_4A1BF+38j
        cmp byte_519CA, 0
        jnz short loc_4A20E
        cmp byte_519F6, 0
        jz  short loc_4A215

loc_4A20E:              ; CODE XREF: sub_4A1BF+46j
        mov byte_50941, 4
        mov ah, 1

loc_4A215:              ; CODE XREF: sub_4A1BF+4Dj
        cmp byte_519B6, 0
        jnz short loc_4A22A
        cmp byte_519F5, 0
        jnz short loc_4A22A
        cmp byte_519F4, 0
        jz  short locret_4A23B

loc_4A22A:              ; CODE XREF: sub_4A1BF+5Bj
                    ; sub_4A1BF+62j
        cmp ah, 1
        jnz short loc_4A236
        add byte_50941, 4
        jmp short locret_4A23B
; ---------------------------------------------------------------------------

loc_4A236:              ; CODE XREF: sub_4A1BF+6Ej
        mov byte_50941, 9

locret_4A23B:               ; CODE XREF: sub_4A1BF+69j
                    ; sub_4A1BF+75j
        retn
sub_4A1BF   endp


; =============== S U B R O U T I N E =======================================


sub_4A23C   proc near       ; CODE XREF: sub_4955B+111p
                    ; sub_4955B+11Dp ...
        mov si, 0
        mov cx, 5A0h

loc_4A242:              ; CODE XREF: sub_4A23C+1Fj
        mov al, [si+1834h]
        cmp al, ah
        jz  short loc_4A253
        cmp ah, 11h
        jnz short loc_4A259
        cmp al, 0BBh ; '?'
        jnz short loc_4A259

loc_4A253:              ; CODE XREF: sub_4A23C+Cj
        mov word ptr leveldata[si], 0

loc_4A259:              ; CODE XREF: sub_4A23C+11j
                    ; sub_4A23C+15j
        inc si
        inc si
        loop    loc_4A242
        call    sub_49D53
        call    sub_48F6D
        call    sub_4A2E6
        mov byte_510B3, 0
        mov byte_5A2F9, 1
        retn
sub_4A23C   endp


; =============== S U B R O U T I N E =======================================


findMurphy   proc near       ; CODE XREF: start+344p sub_4A463+22p
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov di, offset leveldata
        mov cx, levelcells
        mov ax, murphy
        repne scasw
        pop es
        assume es:nothing
        mov ax, levelcells-1
        sub ax, cx
        mov cx, ax
        shl cx, 1
        mov murphyloc, cx
        mov si, cx
findMurphy   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4A291   proc near       ; CODE XREF: sub_4955B+686p
        mov bl, 3Ch ; '<'
        div bl
        mov bl, ah
        xor bh, bh
        mov word_510C3, bx
        xor ah, ah
        mov word_510C5, ax
        mov cl, 4
        shl ax, cl
        shl bx, cl
        mov word_510E8, bx
        mov word_510EA, ax
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        call    sub_49EBE
        mov ax, word_51961
        mov word_59B92, ax
        mov ax, word_5195F
        mov word_59B90, ax
        and al, 7
        mov byte_510A6, al
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        retn
sub_4A291   endp


; =============== S U B R O U T I N E =======================================


sub_4A2E6   proc near       ; CODE XREF: start+33Bp runLevel+ADp ...
        xor bx, bx
        xor dx, dx
        mov cx, 5A0h
        mov si, offset leveldata

loc_4A2F0:              ; CODE XREF: sub_4A2E6+D1j
        mov ax, [si]
        cmp al, 0F1h ; '?'
        jnz short loc_4A2FC
        mov byte ptr [si], 1Fh
        jmp loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A2FC:              ; CODE XREF: sub_4A2E6+Ej
        cmp byte_5A33F, 1
        jz  short loc_4A312
        cmp ax, 4
        jz  short loc_4A33C
        cmp ax, 11h
        jz  short loc_4A34B
        cmp ax, 18h
        jz  short loc_4A379

loc_4A312:              ; CODE XREF: sub_4A2E6+1Bj
        cmp ax, 1Ah
        jz  short loc_4A33F
        cmp ax, 1Bh
        jz  short loc_4A33F
        cmp ax, 26h ; '&'
        jz  short loc_4A33F
        cmp ax, 27h ; '''
        jz  short loc_4A33F
        cmp ax, 1Ch
        jl  short loc_4A330
        cmp ax, 26h ; '&'
        jl  short loc_4A345

loc_4A330:              ; CODE XREF: sub_4A2E6+43j
        cmp ax, 0Dh
        jl  short loc_4A33A
        cmp ax, 11h
        jl  short loc_4A3A7

loc_4A33A:              ; CODE XREF: sub_4A2E6+4Dj
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A33C:              ; CODE XREF: sub_4A2E6+20j
        inc dx
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A33F:              ; CODE XREF: sub_4A2E6+2Fj
                    ; sub_4A2E6+34j ...
        mov word ptr [si], 5
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A345:              ; CODE XREF: sub_4A2E6+48j
        mov word ptr [si], 6
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A34B:              ; CODE XREF: sub_4A2E6+25j
        cmp word ptr [si-2], 0
        jnz short loc_4A357
        mov byte ptr [si+1], 1
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A357:              ; CODE XREF: sub_4A2E6+69j
        cmp word ptr [si-78h], 0
        jnz short loc_4A368
        mov word ptr [si-78h], 1011h
        mov word ptr [si], 0FFFFh
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A368:              ; CODE XREF: sub_4A2E6+75j
        cmp word ptr [si+2], 0
        jnz short loc_4A3B0
        mov word ptr [si+2], 2811h
        mov word ptr [si], 0FFFFh
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A379:              ; CODE XREF: sub_4A2E6+2Aj
        cmp word ptr [si-2], 0
        jnz short loc_4A385
        mov byte ptr [si+1], 1
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A385:              ; CODE XREF: sub_4A2E6+97j
        cmp word ptr [si-78h], 0
        jnz short loc_4A396
        mov word ptr [si-78h], 1018h
        mov word ptr [si], 0FFFFh
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A396:              ; CODE XREF: sub_4A2E6+A3j
        cmp word ptr [si+2], 0
        jnz short loc_4A3B0
        mov word ptr [si+2], 2818h
        mov word ptr [si], 0FFFFh
        jmp short loc_4A3B0
; ---------------------------------------------------------------------------

loc_4A3A7:              ; CODE XREF: sub_4A2E6+52j
        sub byte ptr [si], 4
        mov byte ptr [si+1], 1
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A3B0:              ; CODE XREF: sub_4A2E6+13j
                    ; sub_4A2E6:loc_4A33Aj ...
        add si, 2
        inc bx
        dec cx
        jz  short locret_4A3BA
        jmp loc_4A2F0
; ---------------------------------------------------------------------------

locret_4A3BA:               ; CODE XREF: sub_4A2E6+CFj
        retn
sub_4A2E6   endp


; =============== S U B R O U T I N E =======================================


sub_4A3BB   proc near       ; CODE XREF: start+33Ep sub_4A463+17p
        cmp byte_51036, 0
        jz  short loc_4A3C6
        mov dl, byte_51036

loc_4A3C6:              ; CODE XREF: sub_4A3BB+5j
        mov byte_5195A, dl
        mov byte_5195B, dl
        call    sub_4FD21
        retn
sub_4A3BB   endp


; =============== S U B R O U T I N E =======================================


sub_4A3D2   proc near       ; CODE XREF: sub_4955B+39Ep
                    ; sub_4955B+3EBp
        mov byte_599D4, 0
        mov word_599D8, 0
        cmp byte_5A33E, 0
        mov byte_5A33E, 0
        jnz short $+12
sub_4A3D2   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4A3E9   proc near       ; CODE XREF: sub_4955B+14Ep
        cmp byte_5A33E, 0
        jnz short loc_4A3F3
        call    sub_4A95F

loc_4A3F3:              ; CODE XREF: sub_4A3D2+15j
                    ; sub_4A3E9+5j
        mov word_51A01, 0
        mov word_51963, 0
        mov word_51965, 0
        mov word ptr flashingbackgroundon, 0
        mov word_51A07, 1
        mov dx, 3C8h
        xor al, al
        out dx, al
        inc dx
        out dx, al
        out dx, al
        out dx, al
        cmp byte_5A33E, 0
        jz  short loc_4A427
        mov byte_510DE, 1

loc_4A427:              ; CODE XREF: sub_4A3E9+37j
        mov byte_5A33F, 0
        call    sub_4A463
        mov byte_5A33F, 1
        cmp byte_5A33E, 1
        jb  short loc_4A446
        mov byte_510DE, 0
        jnz short loc_4A446
        inc byte_5A33E

loc_4A446:              ; CODE XREF: sub_4A3E9+50j
                    ; sub_4A3E9+57j
        mov byte_50941, 0
        cmp byte_510DE, 0
        jz  short locret_4A462
        mov bx, word_5A33C
        mov word_510DF, bx
        mov byte_510E2, 1
        call    sub_492A8

locret_4A462:               ; CODE XREF: sub_4A3E9+67j
        retn
sub_4A3E9   endp


; =============== S U B R O U T I N E =======================================


sub_4A463   proc near       ; CODE XREF: sub_4945D:loc_4953Bp
                    ; sub_4A3E9+43p
        call    readLevels
        call    sub_4D464
        call    sub_48F6D
        call    sub_501C0
        neg byte_5A33F
        call    sub_4A2E6
        neg byte_5A33F
        call    sub_4A3BB
        mov byte_59B7B, 1
        call    sub_48A20
        call    findMurphy
        retn
sub_4A463   endp


; =============== S U B R O U T I N E =======================================


movefun3  proc near       ; DATA XREF: data:161Ao
        cmp byte ptr leveldata[si], 8
        jz  short loc_4A491
        retn
; ---------------------------------------------------------------------------

loc_4A491:              ; CODE XREF: movefun3+5j
        mov ax, [si+1834h]
        cmp ax, 3008h
        jge short loc_4A4D4
        cmp ax, 2008h
        jge short loc_4A4B4
        mov ax, [si+18ACh]
        cmp ax, 0
        jz  short loc_4A4A9
        retn
; ---------------------------------------------------------------------------

loc_4A4A9:              ; CODE XREF: movefun3+1Dj
        mov byte ptr [si+1835h], 20h ; ' '
        mov byte ptr [si+18ADh], 8
        retn
; ---------------------------------------------------------------------------

loc_4A4B4:              ; CODE XREF: movefun3+14j
        cmp word ptr [si+18ACh], 0
        jnz short loc_4A4C2
        mov word ptr leveldata[si], 8
        retn
; ---------------------------------------------------------------------------

loc_4A4C2:              ; CODE XREF: movefun3+30j
        mov bl, [si+1835h]
        inc bl
        cmp bl, 22h ; '"'
        jnz short loc_4A4CF
        mov bl, 30h ; '0'

loc_4A4CF:              ; CODE XREF: movefun3+42j
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4A4D4:              ; CODE XREF: movefun3+Fj
        push    si
        mov bl, [si+1835h]
        xor bh, bh
        mov al, bl
        shl bx, 1
        ;and bx, byte ptr 0Fh
		db 83h, 0E3h, 0Fh
        mov di, [si+6155h]
        shl bx, 1
        add di, [bx+6C95h]
        mov si, 12F6h
        mov si, [si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_4A4F9:              ; CODE XREF: movefun3+78j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4A4F9
        pop ds
        pop si
        mov bl, [si+1835h]
        inc bl
        mov al, bl
        and al, 7
        jz  short loc_4A516
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4A516:              ; CODE XREF: movefun3+86j
        mov word ptr leveldata[si], 0
        mov word ptr [si+18ACh], 8
        add si, 78h ; 'x'
        cmp word ptr [si+18ACh], 0
        jnz short loc_4A537
        mov byte ptr [si+1835h], 30h ; '0'
        mov byte ptr [si+18ADh], 8
        retn
; ---------------------------------------------------------------------------

loc_4A537:              ; CODE XREF: movefun3+A1j
        cmp byte ptr [si+18ACh], 1Fh
        jnz short loc_4A53F
        retn
; ---------------------------------------------------------------------------

loc_4A53F:              ; CODE XREF: movefun3+B3j
        call    sub_4A61F
        retn
movefun3  endp

; ---------------------------------------------------------------------------

loc_4A543:              ; DATA XREF: data:1648o
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4A54B
        retn
; ---------------------------------------------------------------------------

loc_4A54B:              ; CODE XREF: code:3928j
        mov ax, word_5195D
        and ax, 3
        cmp ax, 0
        jz  short loc_4A557
        retn
; ---------------------------------------------------------------------------

loc_4A557:              ; CODE XREF: code:3934j
        mov bl, [si+1835h]
        test    bl, 80h
        jnz short loc_4A5A0
        inc bl
        mov [si+1835h], bl
        push    si
        push    bx
        xor bh, bh
        dec bl
        mov di, [si+6155h]
        mov si, bx
        shl si, 1
        add si, 12D6h
        mov si, [si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4A582:              ; CODE XREF: code:396Aj
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4A582
        pop ds
        pop bx
        pop si
        cmp bl, 8
        jnz short locret_4A59F
        mov word ptr leveldata[si], 0
        mov byte_510C0, 0

locret_4A59F:               ; CODE XREF: code:3972j
        retn
; ---------------------------------------------------------------------------

loc_4A5A0:              ; CODE XREF: code:393Ej
        inc bl
        cmp bl, 89h ; '?'
        jnz short loc_4A5B3
        mov word ptr leveldata[si], 4
        mov byte_510C0, 0
        retn
; ---------------------------------------------------------------------------

loc_4A5B3:              ; CODE XREF: code:3985j
        mov [si+1835h], bl
        xor bh, bh
        dec bl
        and bl, 0Fh
        mov di, [si+6155h]
        mov si, bx
        shl si, 1
        add si, 12E6h
        mov si, [si]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4A5D4:              ; CODE XREF: code:39BCj
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4A5D4
        pop ds
        retn

; =============== S U B R O U T I N E =======================================


sub_4A5E0   proc near       ; CODE XREF: runLevel+106p
        mov si, 0
        mov bx, 0
        mov cx, 5A0h

loc_4A5E9:              ; CODE XREF: sub_4A5E0+25j
        cmp byte ptr [bx+2434h], 0
        jz  short loc_4A601
        jl  short loc_4A608
        dec byte ptr [bx+2434h]
        jnz short loc_4A601
        push    si
        push    cx
        push    bx
        call    sub_4A61F
        pop bx
        pop cx
        pop si

loc_4A601:              ; CODE XREF: sub_4A5E0+Ej
                    ; sub_4A5E0+16j ...
        add si, 2
        inc bx
        loop    loc_4A5E9
        retn
; ---------------------------------------------------------------------------

loc_4A608:              ; CODE XREF: sub_4A5E0+10j
        inc byte ptr [bx+2434h]
        jnz short loc_4A601
        push    si
        push    cx
        push    bx
        mov word ptr leveldata[si], 0FF18h
        call    sub_4A61F
        pop bx
        pop cx
        pop si
        jmp short loc_4A601
sub_4A5E0   endp


; =============== S U B R O U T I N E =======================================


sub_4A61F   proc near       ; CODE XREF: movefun+271p
                    ; movefun2+20Fp ...
        cmp byte ptr leveldata[si], 6
        jnz short loc_4A627
        retn
; ---------------------------------------------------------------------------

loc_4A627:              ; CODE XREF: sub_4A61F+5j
        mov byte_510C0, 1
        cmp byte ptr leveldata[si], 3
        jnz short loc_4A639
        mov word_510D1, 1

loc_4A639:              ; CODE XREF: sub_4A61F+12j
        cmp byte ptr leveldata[si], 18h
        jnz short loc_4A647
        mov cx, 801Fh
        mov dl, 0F3h ; '?'
        jmp short loc_4A64C
; ---------------------------------------------------------------------------

loc_4A647:              ; CODE XREF: sub_4A61F+1Fj
        mov cx, 1Fh
        mov dl, 0Dh

loc_4A64C:              ; CODE XREF: sub_4A61F+26j
        mov bx, si
        shr bx, 1
        mov dh, dl
        push    cx
        mov ax, leveldata[si-78h-2h]
        cmp al, 8
        jz  short loc_4A680
        cmp al, 12h
        jz  short loc_4A680
        cmp al, 11h
        jz  short loc_4A680
        cmp al, 1
        jz  short loc_4A69C
        cmp al, 4
        jz  short loc_4A692
        cmp al, 18h
        jnz short loc_4A676
        neg dh
        mov cx, 801Fh
        jmp short loc_4A680
; ---------------------------------------------------------------------------

loc_4A676:              ; CODE XREF: sub_4A61F+4Ej
        cmp al, 3
        jnz short loc_4A688
        mov word_510D1, 1

loc_4A680:              ; CODE XREF: sub_4A61F+3Aj
                    ; sub_4A61F+3Ej ...
        cmp al, 6
        jz  short loc_4A688
        mov [bx+23F7h], dh

loc_4A688:              ; CODE XREF: sub_4A61F+59j
                    ; sub_4A61F+63j
        cmp al, 6
        jz  short loc_4A690
        mov [si+17BAh], cx

loc_4A690:              ; CODE XREF: sub_4A61F+6Bj
        jmp short loc_4A6A6
; ---------------------------------------------------------------------------

loc_4A692:              ; CODE XREF: sub_4A61F+4Aj
        push    si
        add si, 0FF86h
        call    sub_4AA34
        pop si
        jmp short loc_4A6A6
; ---------------------------------------------------------------------------

loc_4A69C:              ; CODE XREF: sub_4A61F+46j
        push    si
        add si, 0FF86h
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A6A6:              ; CODE XREF: sub_4A61F:loc_4A690j
                    ; sub_4A61F+7Bj ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+17BCh]
        cmp al, 8
        jz  short loc_4A6D7
        cmp al, 12h
        jz  short loc_4A6D7
        cmp al, 11h
        jz  short loc_4A6D7
        cmp al, 1
        jz  short loc_4A6F3
        cmp al, 4
        jz  short loc_4A6E9
        cmp al, 18h
        jnz short loc_4A6CD
        neg dh
        mov cx, 801Fh
        jmp short loc_4A6D7
; ---------------------------------------------------------------------------

loc_4A6CD:              ; CODE XREF: sub_4A61F+A5j
        cmp al, 3
        jnz short loc_4A6DF
        mov word_510D1, 1

loc_4A6D7:              ; CODE XREF: sub_4A61F+91j
                    ; sub_4A61F+95j ...
        cmp al, 6
        jz  short loc_4A6DF
        mov [bx+23F8h], dh

loc_4A6DF:              ; CODE XREF: sub_4A61F+B0j
                    ; sub_4A61F+BAj
        cmp al, 6
        jz  short loc_4A6E7
        mov [si+17BCh], cx

loc_4A6E7:              ; CODE XREF: sub_4A61F+C2j
        jmp short loc_4A6FD
; ---------------------------------------------------------------------------

loc_4A6E9:              ; CODE XREF: sub_4A61F+A1j
        push    si
        add si, 0FF88h
        call    sub_4AA34
        pop si
        jmp short loc_4A6FD
; ---------------------------------------------------------------------------

loc_4A6F3:              ; CODE XREF: sub_4A61F+9Dj
        push    si
        add si, 0FF88h
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A6FD:              ; CODE XREF: sub_4A61F:loc_4A6E7j
                    ; sub_4A61F+D2j ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+17BEh]
        cmp al, 8
        jz  short loc_4A72E
        cmp al, 12h
        jz  short loc_4A72E
        cmp al, 11h
        jz  short loc_4A72E
        cmp al, 1
        jz  short loc_4A74A
        cmp al, 4
        jz  short loc_4A740
        cmp al, 18h
        jnz short loc_4A724
        neg dh
        mov cx, 801Fh
        jmp short loc_4A72E
; ---------------------------------------------------------------------------

loc_4A724:              ; CODE XREF: sub_4A61F+FCj
        cmp al, 3
        jnz short loc_4A736
        mov word_510D1, 1

loc_4A72E:              ; CODE XREF: sub_4A61F+E8j
                    ; sub_4A61F+ECj ...
        cmp al, 6
        jz  short loc_4A736
        mov [bx+23F9h], dh

loc_4A736:              ; CODE XREF: sub_4A61F+107j
                    ; sub_4A61F+111j
        cmp al, 6
        jz  short loc_4A73E
        mov [si+17BEh], cx

loc_4A73E:              ; CODE XREF: sub_4A61F+119j
        jmp short loc_4A754
; ---------------------------------------------------------------------------

loc_4A740:              ; CODE XREF: sub_4A61F+F8j
        push    si
        add si, 0FF8Ah
        call    sub_4AA34
        pop si
        jmp short loc_4A754
; ---------------------------------------------------------------------------

loc_4A74A:              ; CODE XREF: sub_4A61F+F4j
        push    si
        add si, 0FF8Ah
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A754:              ; CODE XREF: sub_4A61F:loc_4A73Ej
                    ; sub_4A61F+129j ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+1832h]
        cmp al, 8
        jz  short loc_4A785
        cmp al, 12h
        jz  short loc_4A785
        cmp al, 11h
        jz  short loc_4A785
        cmp al, 1
        jz  short loc_4A7A1
        cmp al, 4
        jz  short loc_4A797
        cmp al, 18h
        jnz short loc_4A77B
        neg dh
        mov cx, 801Fh
        jmp short loc_4A785
; ---------------------------------------------------------------------------

loc_4A77B:              ; CODE XREF: sub_4A61F+153j
        cmp al, 3
        jnz short loc_4A78D
        mov word_510D1, 1

loc_4A785:              ; CODE XREF: sub_4A61F+13Fj
                    ; sub_4A61F+143j ...
        cmp al, 6
        jz  short loc_4A78D
        mov [bx+2433h], dh

loc_4A78D:              ; CODE XREF: sub_4A61F+15Ej
                    ; sub_4A61F+168j
        cmp al, 6
        jz  short loc_4A795
        mov [si+1832h], cx

loc_4A795:              ; CODE XREF: sub_4A61F+170j
        jmp short loc_4A7AB
; ---------------------------------------------------------------------------

loc_4A797:              ; CODE XREF: sub_4A61F+14Fj
        push    si
        add si, 0FFFEh
        call    sub_4AA34
        pop si
        jmp short loc_4A7AB
; ---------------------------------------------------------------------------

loc_4A7A1:              ; CODE XREF: sub_4A61F+14Bj
        push    si
        add si, 0FFFEh
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A7AB:              ; CODE XREF: sub_4A61F:loc_4A795j
                    ; sub_4A61F+180j ...
        pop cx
        mov [si+1834h], cx
        mov dh, dl
        push    cx
        mov ax, [si+1836h]
        cmp al, 8
        jz  short loc_4A7E0
        cmp al, 12h
        jz  short loc_4A7E0
        cmp al, 11h
        jz  short loc_4A7E0
        cmp al, 1
        jz  short loc_4A7FC
        cmp al, 4
        jz  short loc_4A7F2
        cmp al, 18h
        jnz short loc_4A7D6
        neg dh
        mov cx, 801Fh
        jmp short loc_4A7E0
; ---------------------------------------------------------------------------

loc_4A7D6:              ; CODE XREF: sub_4A61F+1AEj
        cmp al, 3
        jnz short loc_4A7E8
        mov word_510D1, 1

loc_4A7E0:              ; CODE XREF: sub_4A61F+19Aj
                    ; sub_4A61F+19Ej ...
        cmp al, 6
        jz  short loc_4A7E8
        mov [bx+2435h], dh

loc_4A7E8:              ; CODE XREF: sub_4A61F+1B9j
                    ; sub_4A61F+1C3j
        cmp al, 6
        jz  short loc_4A7F0
        mov [si+1836h], cx

loc_4A7F0:              ; CODE XREF: sub_4A61F+1CBj
        jmp short loc_4A806
; ---------------------------------------------------------------------------

loc_4A7F2:              ; CODE XREF: sub_4A61F+1AAj
        push    si
        add si, 2
        call    sub_4AA34
        pop si
        jmp short loc_4A806
; ---------------------------------------------------------------------------

loc_4A7FC:              ; CODE XREF: sub_4A61F+1A6j
        push    si
        add si, 2
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A806:              ; CODE XREF: sub_4A61F:loc_4A7F0j
                    ; sub_4A61F+1DBj ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+18AAh]
        cmp al, 8
        jz  short loc_4A837
        cmp al, 12h
        jz  short loc_4A837
        cmp al, 11h
        jz  short loc_4A837
        cmp al, 1
        jz  short loc_4A853
        cmp al, 4
        jz  short loc_4A849
        cmp al, 18h
        jnz short loc_4A82D
        neg dh
        mov cx, 801Fh
        jmp short loc_4A837
; ---------------------------------------------------------------------------

loc_4A82D:              ; CODE XREF: sub_4A61F+205j
        cmp al, 3
        jnz short loc_4A83F
        mov word_510D1, 1

loc_4A837:              ; CODE XREF: sub_4A61F+1F1j
                    ; sub_4A61F+1F5j ...
        cmp al, 6
        jz  short loc_4A83F
        mov [bx+246Fh], dh

loc_4A83F:              ; CODE XREF: sub_4A61F+210j
                    ; sub_4A61F+21Aj
        cmp al, 6
        jz  short loc_4A847
        mov [si+18AAh], cx

loc_4A847:              ; CODE XREF: sub_4A61F+222j
        jmp short loc_4A85D
; ---------------------------------------------------------------------------

loc_4A849:              ; CODE XREF: sub_4A61F+201j
        push    si
        add si, 76h ; 'v'
        call    sub_4AA34
        pop si
        jmp short loc_4A85D
; ---------------------------------------------------------------------------

loc_4A853:              ; CODE XREF: sub_4A61F+1FDj
        push    si
        add si, 76h ; 'v'
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A85D:              ; CODE XREF: sub_4A61F:loc_4A847j
                    ; sub_4A61F+232j ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+18ACh]
        cmp al, 8
        jz  short loc_4A88E
        cmp al, 12h
        jz  short loc_4A88E
        cmp al, 11h
        jz  short loc_4A88E
        cmp al, 1
        jz  short loc_4A8AA
        cmp al, 4
        jz  short loc_4A8A0
        cmp al, 18h
        jnz short loc_4A884
        neg dh
        mov cx, 801Fh
        jmp short loc_4A88E
; ---------------------------------------------------------------------------

loc_4A884:              ; CODE XREF: sub_4A61F+25Cj
        cmp al, 3
        jnz short loc_4A896
        mov word_510D1, 1

loc_4A88E:              ; CODE XREF: sub_4A61F+248j
                    ; sub_4A61F+24Cj ...
        cmp al, 6
        jz  short loc_4A896
        mov [bx+2470h], dh

loc_4A896:              ; CODE XREF: sub_4A61F+267j
                    ; sub_4A61F+271j
        cmp al, 6
        jz  short loc_4A89E
        mov [si+18ACh], cx

loc_4A89E:              ; CODE XREF: sub_4A61F+279j
        jmp short loc_4A8B4
; ---------------------------------------------------------------------------

loc_4A8A0:              ; CODE XREF: sub_4A61F+258j
        push    si
        add si, 78h ; 'x'
        call    sub_4AA34
        pop si
        jmp short loc_4A8B4
; ---------------------------------------------------------------------------

loc_4A8AA:              ; CODE XREF: sub_4A61F+254j
        push    si
        add si, 78h ; 'x'
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A8B4:              ; CODE XREF: sub_4A61F:loc_4A89Ej
                    ; sub_4A61F+289j ...
        pop cx
        mov dh, dl
        push    cx
        mov ax, [si+18AEh]
        cmp al, 8
        jz  short loc_4A8E5
        cmp al, 12h
        jz  short loc_4A8E5
        cmp al, 11h
        jz  short loc_4A8E5
        cmp al, 1
        jz  short loc_4A901
        cmp al, 4
        jz  short loc_4A8F7
        cmp al, 18h
        jnz short loc_4A8DB
        neg dh
        mov cx, 801Fh
        jmp short loc_4A8E5
; ---------------------------------------------------------------------------

loc_4A8DB:              ; CODE XREF: sub_4A61F+2B3j
        cmp al, 3
        jnz short loc_4A8ED
        mov word_510D1, 1

loc_4A8E5:              ; CODE XREF: sub_4A61F+29Fj
                    ; sub_4A61F+2A3j ...
        cmp al, 6
        jz  short loc_4A8ED
        mov [bx+2471h], dh

loc_4A8ED:              ; CODE XREF: sub_4A61F+2BEj
                    ; sub_4A61F+2C8j
        cmp al, 6
        jz  short loc_4A8F5
        mov [si+18AEh], cx

loc_4A8F5:              ; CODE XREF: sub_4A61F+2D0j
        jmp short loc_4A90B
; ---------------------------------------------------------------------------

loc_4A8F7:              ; CODE XREF: sub_4A61F+2AFj
        push    si
        add si, 7Ah ; 'z'
        call    sub_4AA34
        pop si
        jmp short loc_4A90B
; ---------------------------------------------------------------------------

loc_4A901:              ; CODE XREF: sub_4A61F+2ABj
        push    si
        add si, 7Ah ; 'z'
        call    sub_4A9C4
        pop si
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4A90B:              ; CODE XREF: sub_4A61F:loc_4A8F5j
                    ; sub_4A61F+2E0j ...
        pop cx
        call    sound?4
        retn
sub_4A61F   endp


; =============== S U B R O U T I N E =======================================


sub_4A910   proc near       ; CODE XREF: runLevel:noFlashing3p
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov al, byte_510DB
        cmp al, 1
        jle short loc_4A954
        mov si, word_510DC
        cmp word ptr leveldata[si], 0
        jnz short loc_4A932
        mov word ptr leveldata[si], 14h

loc_4A932:              ; CODE XREF: sub_4A910+1Aj
        mov di, [si+6155h]
        mov si, word_5177E
        call    sub_4F200
        inc byte_510DB
        cmp byte_510DB, 28h ; '('
        jl  short loc_4A954
        mov si, word_510DC
        call    sub_4A61F
        mov byte_510DB, 0

loc_4A954:              ; CODE XREF: sub_4A910+Fj
                    ; sub_4A910+36j
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_4A910   endp


; =============== S U B R O U T I N E =======================================


sub_4A95F   proc near       ; CODE XREF: runLevel+372p
                    ; sub_4A3E9+7p ...
        mov al, byte_510B0
        mov byte_510B4, al
        mov al, byte_510B1
        mov byte_510B5, al
        mov al, byte_510B2
        mov byte_510B6, al
        cmp byte_510DE, 0
        jnz short locret_4A97F
        cmp byte_599D4, 0
        jz  short loc_4A980

locret_4A97F:               ; CODE XREF: sub_4A95F+17j
        retn
; ---------------------------------------------------------------------------

loc_4A980:              ; CODE XREF: sub_4A95F+1Ej
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, bx
        add si, 8A9Ch
        mov al, byte_510B4
        add al, [si+0Bh]

loc_4A994:              ; CODE XREF: sub_4A95F+3Ej
        cmp al, 3Ch ; '<'
        jl  short loc_4A99F
        sub al, 3Ch ; '<'
        inc byte ptr [si+0Ah]
        jmp short loc_4A994
; ---------------------------------------------------------------------------

loc_4A99F:              ; CODE XREF: sub_4A95F+37j
        mov [si+0Bh], al
        mov al, byte_510B5
        add al, [si+0Ah]

loc_4A9A8:              ; CODE XREF: sub_4A95F+52j
        cmp al, 3Ch ; '<'
        jl  short loc_4A9B3
        sub al, 3Ch ; '<'
        inc byte ptr [si+9]
        jmp short loc_4A9A8
; ---------------------------------------------------------------------------

loc_4A9B3:              ; CODE XREF: sub_4A95F+4Bj
        mov [si+0Ah], al
        mov al, byte_510B6
        add al, [si+9]
        jnb short loc_4A9C0
        mov al, 0FFh

loc_4A9C0:              ; CODE XREF: sub_4A95F+5Dj
        mov [si+9], al
        retn
sub_4A95F   endp


; =============== S U B R O U T I N E =======================================


sub_4A9C4   proc near       ; CODE XREF: sub_4A61F+81p
                    ; sub_4A61F+D8p ...
        mov [si+1834h], cx
        and ah, 0F0h
        cmp ah, 10h
        jz  short loc_4A9EF
        cmp ah, 70h ; 'p'
        jz  short loc_4A9EF
        cmp ah, 20h ; ' '
        jz  short loc_4AA05
        cmp ah, 30h ; '0'
        jz  short loc_4AA12
        cmp ah, 50h ; 'P'
        jz  short loc_4AA1F
        cmp ah, 60h ; '`'
        jz  short loc_4AA26
        cmp ah, 70h ; 'p'
        jz  short loc_4AA2D
        retn
; ---------------------------------------------------------------------------

loc_4A9EF:              ; CODE XREF: sub_4A9C4+Aj sub_4A9C4+Fj
        sub si, 78h ; 'x'
        call    sub_4AAB4
        add si, 0F0h ; '?'
        cmp word ptr leveldata[si], 9999h
        jnz short locret_4AA04
        call    sub_4AAB4

locret_4AA04:               ; CODE XREF: sub_4A9C4+3Bj
        retn
; ---------------------------------------------------------------------------

loc_4AA05:              ; CODE XREF: sub_4A9C4+14j
        add si, 2
        call    sub_4AAB4
        add si, 76h ; 'v'
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AA12:              ; CODE XREF: sub_4A9C4+19j
        sub si, 2
        call    sub_4AAB4
        add si, 7Ah ; 'z'
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AA1F:              ; CODE XREF: sub_4A9C4+1Ej
        sub si, 2
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AA26:              ; CODE XREF: sub_4A9C4+23j
        add si, 2
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AA2D:              ; CODE XREF: sub_4A9C4+28j
        add si, 78h ; 'x'
        call    sub_4AAB4
        retn
sub_4A9C4   endp


; =============== S U B R O U T I N E =======================================


sub_4AA34   proc near       ; CODE XREF: sub_4A61F+77p
                    ; sub_4A61F+CEp ...
        mov leveldata[si], cx
        and ah, 0F0h
        cmp ah, 10h
        jz  short loc_4AA5F
        cmp ah, 70h ; 'p'
        jz  short loc_4AA5F
        cmp ah, 20h ; ' '
        jz  short loc_4AA75
        cmp ah, 30h ; '0'
        jz  short loc_4AA8A
        cmp ah, 50h ; 'P'
        jz  short loc_4AA9F
        cmp ah, 60h ; '`'
        jz  short loc_4AAA6
        cmp ah, 70h ; 'p'
        jz  short loc_4AAAD
        retn
; ---------------------------------------------------------------------------

loc_4AA5F:              ; CODE XREF: sub_4AA34+Aj sub_4AA34+Fj
        sub si, 78h ; 'x'
        call    sub_4AAB4
        add si, 0F0h ; '?'
        cmp leveldata[si], 9999h
        jnz short locret_4AA74
        call    sub_4AAB4

locret_4AA74:               ; CODE XREF: sub_4AA34+3Bj
        retn
; ---------------------------------------------------------------------------

loc_4AA75:              ; CODE XREF: sub_4AA34+14j
        add si, 2
        call    sub_4AAB4
        add si, 76h ; 'v'
        cmp leveldata[si], 9999h
        jnz short locret_4AA89
        call    sub_4AAB4

locret_4AA89:               ; CODE XREF: sub_4AA34+50j
        retn
; ---------------------------------------------------------------------------

loc_4AA8A:              ; CODE XREF: sub_4AA34+19j
        sub si, 2
        call    sub_4AAB4
        add si, 7Ah ; 'z'
        cmp word ptr leveldata[si], 9999h
        jnz short locret_4AA9E
        call    sub_4AAB4

locret_4AA9E:               ; CODE XREF: sub_4AA34+65j
        retn
; ---------------------------------------------------------------------------

loc_4AA9F:              ; CODE XREF: sub_4AA34+1Ej
        sub si, 2
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AAA6:              ; CODE XREF: sub_4AA34+23j
        add si, 2
        call    sub_4AAB4
        retn
; ---------------------------------------------------------------------------

loc_4AAAD:              ; CODE XREF: sub_4AA34+28j
        add si, 78h ; 'x'
        call    sub_4AAB4
        retn
sub_4AA34   endp


; =============== S U B R O U T I N E =======================================


sub_4AAB4   proc near       ; CODE XREF: sub_4A9C4+2Ep
                    ; sub_4A9C4+3Dp ...
        cmp byte ptr leveldata[si], 1Fh
        jnz short loc_4AABC
        retn
; ---------------------------------------------------------------------------

loc_4AABC:              ; CODE XREF: sub_4AAB4+5j
        mov word ptr leveldata[si], 0
        push    si
        push    ds
        mov di, [si+6155h]
        mov si, word_51580
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4AAD3:              ; CODE XREF: sub_4AAB4+27j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4AAD3
        pop ds
        pop si
        retn
sub_4AAB4   endp


; =============== S U B R O U T I N E =======================================


readMenuDat proc near       ; CODE XREF: readEverything+9p
        mov ax, 3D00h
        mov dx, offset aMenu_dat ; "MENU.DAT"
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4AAED
        jmp exit
; ---------------------------------------------------------------------------

loc_4AAED:              ; CODE XREF: readMenuDat+8j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        push    ds
        mov ax, seg menuseg
        mov ds, ax
        assume ds:nothing
        mov ax, 3F00h
        mov cx, 7D00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_4AB0B
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_4AB0B:              ; CODE XREF: readMenuDat+25j
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_4AB1A
        jmp exit
; ---------------------------------------------------------------------------

locret_4AB1A:               ; CODE XREF: readMenuDat+35j
        retn
readMenuDat endp


; =============== S U B R O U T I N E =======================================


sub_4AB1B   proc near       ; CODE XREF: runMainMenu+28Fp
                    ; DATA XREF: data:off_50318o
        cmp byte_59B85, 0
        jnz short loc_4AB4A
        mov si, 8A9Ch
        mov ax, 2D2Dh
        mov bl, 0
        mov cx, 14h

loc_4AB2D:              ; CODE XREF: sub_4AB1B+2Dj
        cmp [si], ax
        jnz short loc_4AB42
        cmp [si+2], ax
        jnz short loc_4AB42
        cmp [si+4], ax
        jnz short loc_4AB42
        cmp [si+6], ax
        jnz short loc_4AB42
        jmp short loc_4AB56
; ---------------------------------------------------------------------------

loc_4AB42:              ; CODE XREF: sub_4AB1B+14j
                    ; sub_4AB1B+19j ...
        add si, 80h ; '?'
        inc bl
        loop    loc_4AB2D

loc_4AB4A:              ; CODE XREF: sub_4AB1B+5j
        mov si, 81DBh
        mov di, 89F7h
        mov ah, 6
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AB56:              ; CODE XREF: sub_4AB1B+25j
        mov byte_59820, bl
        call    sub_4B899
        mov si, 8193h
        mov di, 89F7h
        mov ah, 4
        call    sub_4BA5F
        mov ax, 2020h
        mov si, 820Bh
        mov [si], ax
        mov [si+2], ax
        mov [si+4], ax
        mov [si+6], ax
        mov word_58475, 0

loc_4AB7F:              ; CODE XREF: sub_4AB1B+6Aj
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4AB7F

noKeyPressed:               ; CODE XREF: sub_4AB1B+79j
                    ; sub_4AB1B+8Aj ...
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4ABEB
        mov al, keyPressed
        cmp al, 0
        jz  short noKeyPressed
        mov keyPressed, 0
        mov bl, al
        xor bh, bh
        mov al, [bx+16FAh]
        cmp al, 0
        jz  short noKeyPressed
        cmp al, 0Ah
        jz  short loc_4ABEB
        cmp al, 8
        jz  short loc_4ABCC
        mov si, 820Bh
        mov bx, word_58475
        cmp bx, 8
        jge short noKeyPressed
        mov [bx+si], al
        inc bx
        mov word_58475, bx
        mov di, 89FFh
        mov ah, 6
        call    sub_4BA5F
        jmp short noKeyPressed
; ---------------------------------------------------------------------------

loc_4ABCC:              ; CODE XREF: sub_4AB1B+92j
        mov bx, word_58475
        cmp bx, 0
        jz  short noKeyPressed
        dec bx
        mov si, 820Bh
        mov al, 20h ; ' '
        mov [bx+si], al
        mov word_58475, bx
        mov di, 89FFh
        mov ah, 6
        call    sub_4BA5F
        jmp short noKeyPressed
; ---------------------------------------------------------------------------

loc_4ABEB:              ; CODE XREF: sub_4AB1B+72j
                    ; sub_4AB1B+8Ej ...
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4ABEB
        mov ax, 2020h
        mov si, 820Bh
        cmp [si], ax
        jnz short loc_4AC1E
        cmp [si+2], ax
        jnz short loc_4AC1E
        cmp [si+4], ax
        jnz short loc_4AC1E
        cmp [si+6], ax
        jnz short loc_4AC1E
        mov si, 8226h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        call    sub_4B85C
        call    sub_4B8BE
        retn
; ---------------------------------------------------------------------------

loc_4AC1E:              ; CODE XREF: sub_4AB1B+E0j
                    ; sub_4AB1B+E5j ...
        mov ax, 2D2Dh
        cmp [si], ax
        jnz short loc_4AC46
        cmp [si+2], ax
        jnz short loc_4AC46
        cmp [si+4], ax
        jnz short loc_4AC46
        cmp [si+6], ax
        jnz short loc_4AC46
        mov si, 81ABh
        mov di, 89F7h
        mov ah, 6
        call    sub_4BA5F
        call    sub_4B85C
        call    sub_4B8BE
        retn
; ---------------------------------------------------------------------------

loc_4AC46:              ; CODE XREF: sub_4AB1B+108j
                    ; sub_4AB1B+10Dj ...
        push    es
        mov ax, ds
        mov es, ax
        assume es:data

loc_4AC4B:              ; CODE XREF: sub_4AB1B+14Cj
        mov si, 820Bh
        cmp byte ptr [si+7], 20h ; ' '
        jnz short loc_4AC69
        mov cx, 7
        add si, 6
        mov di, si
        inc di
        std
        rep movsb
        cld
        mov si, 820Bh
        mov byte ptr [si], 20h ; ' '
        jmp short loc_4AC4B
; ---------------------------------------------------------------------------

loc_4AC69:              ; CODE XREF: sub_4AB1B+137j
        pop es
        assume es:nothing
        mov di, 8A9Ch
        mov si, 820Bh
        mov cx, 14h

loc_4AC73:              ; CODE XREF: sub_4AB1B+18Cj
        mov ax, [si]
        cmp ax, [di]
        jnz short loc_4ACA3
        mov ax, [si+2]
        cmp ax, [di+2]
        jnz short loc_4ACA3
        mov ax, [si+4]
        cmp ax, [di+4]
        jnz short loc_4ACA3
        mov ax, [si+6]
        cmp ax, [di+6]
        jnz short loc_4ACA3
        mov si, 81C3h
        mov di, 89F7h
        mov ah, 6
        call    sub_4BA5F
        call    sub_4B85C
        call    sub_4B8BE
        retn
; ---------------------------------------------------------------------------

loc_4ACA3:              ; CODE XREF: sub_4AB1B+15Cj
                    ; sub_4AB1B+164j ...
        add di, 80h ; '?'
        loop    loc_4AC73
        mov bh, byte_59820
        mov byte_5981F, bh
        xor bl, bl
        shr bx, 1
        mov di, 8A9Ch
        add di, bx
        mov si, 820Bh
        mov ax, [si]
        mov [di], ax
        add si, 2
        add di, 2
        mov ax, [si]
        mov [di], ax
        add si, 2
        add di, 2
        mov ax, [si]
        mov [di], ax
        add si, 2
        add di, 2
        mov ax, [si]
        mov [di], ax
        add si, 2
        add di, 2
        mov si, 8226h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        call    sub_4CFB2
        call    sub_4CFDB
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        call    sub_4C141
        call    sub_4C0DD
        call    sub_4B85C
        call    sub_4B8BE
        retn
sub_4AB1B   endp


; =============== S U B R O U T I N E =======================================


sub_4AD0E   proc near
        cmp byte_59B85, 0
        jnz short loc_4AD3C
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8A9Ch
        add si, bx
        mov word ptr dword_58477, si
        mov ax, 2D2Dh
        cmp ax, [si]
        jnz short loc_4AD48
        cmp ax, [si+2]
        jnz short loc_4AD48
        cmp ax, [si+4]
        jnz short loc_4AD48
        cmp ax, [si+6]
        jnz short loc_4AD48

loc_4AD3C:              ; CODE XREF: sub_4AD0E+5j
        mov si, 82B6h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AD48:              ; CODE XREF: sub_4AD0E+1Dj
                    ; sub_4AD0E+22j ...
        mov di, 828Eh
        mov ax, [si]
        mov [di], ax
        mov ax, [si+2]
        mov [di+2], ax
        mov ax, [si+4]
        mov [di+4], ax
        mov ax, [si+6]
        mov [di+6], ax
        mov si, 8286h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F

loc_4AD6C:              ; CODE XREF: sub_4AD0E+64j
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4AD6C

loc_4AD74:              ; CODE XREF: sub_4AD0E+88j
        call    videoloop
        call    getMouseStatus
        mov word_5847D, bx
        mov mousex, cx
        mov mousey, dx
        call    sub_4B899
        call    sub_4B85C
        call    sub_4B8BE
        mov bx, word_5847D
        cmp bx, 0
        jz  short loc_4AD74
        mov cx, mousex
        mov dx, mousey
        mov si, 5Ah ; 'Z'
        cmp [si], cx
        jg  short loc_4ADCE
        cmp [si+2], dx
        jg  short loc_4ADCE
        cmp [si+4], cx
        jl  short loc_4ADCE
        cmp [si+6], dx
        jl  short loc_4ADCE
        mov di, word ptr dword_58477
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov cx, 8
        mov al, 2Dh ; '-'
        rep stosb
        mov al, 0
        mov cx, 78h ; 'x'
        rep stosb
        pop es
        assume es:nothing

loc_4ADCE:              ; CODE XREF: sub_4AD0E+97j
                    ; sub_4AD0E+9Cj ...
        call    sub_4B899
        mov si, 8226h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        call    sub_4CFB2
        call    sub_4CFDB
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        call    sub_4C141
        call    sub_4C0DD

loc_4ADF3:              ; CODE XREF: sub_4AD0E+EBj
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4ADF3
        call    sub_4B85C
        retn
sub_4AD0E   endp


; =============== S U B R O U T I N E =======================================


sub_4ADFF   proc near
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8A9Ch
        add si, bx
        mov ax, 2D2Dh
        cmp ax, [si]
        jnz short loc_4AE2E
        cmp ax, [si+2]
        jnz short loc_4AE2E
        cmp ax, [si+4]
        jnz short loc_4AE2E
        cmp ax, [si+6]
        jnz short loc_4AE2E
        mov si, 82B6h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AE2E:              ; CODE XREF: sub_4ADFF+12j
                    ; sub_4ADFF+17j ...
        add si, 0Ch
        mov cx, 6Fh ; 'o'
        mov al, 2
        mov bl, 0

loc_4AE38:              ; CODE XREF: sub_4ADFF+40j
        cmp al, [si]
        jnz short loc_4AE3E
        inc bl

loc_4AE3E:              ; CODE XREF: sub_4ADFF+3Bj
        inc si
        loop    loc_4AE38
        cmp word_51970, 0
        jz  short loc_4AE4A
        jmp short loc_4AE5B
; ---------------------------------------------------------------------------

loc_4AE4A:              ; CODE XREF: sub_4ADFF+47j
        cmp bl, 3
        jl  short loc_4AE5B
        mov si, 826Eh
        mov di, 89F7h
        mov ah, 6
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AE5B:              ; CODE XREF: sub_4ADFF+49j
                    ; sub_4ADFF+4Ej
        mov ax, word_51ABC
        dec ax
        mov si, 949Eh
        add si, ax
        cmp byte ptr [si], 2
        jz  short loc_4AE75
        mov si, 82CEh
        mov di, 89F7h
        mov ah, 4
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AE75:              ; CODE XREF: sub_4ADFF+68j
        mov si, 82A9h
        mov ax, word_51ABC
        call    sub_4BF4D
        mov si, 829Eh
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F

loc_4AE89:              ; CODE XREF: sub_4ADFF+90j
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4AE89

loc_4AE91:              ; CODE XREF: sub_4ADFF+B4j
        call    videoloop
        call    getMouseStatus
        mov word_5847D, bx
        mov mousex, cx
        mov mousey, dx
        call    sub_4B899
        call    sub_4B85C
        call    sub_4B8BE
        mov bx, word_5847D
        cmp bx, 0
        jz  short loc_4AE91
        mov cx, mousex
        mov dx, mousey
        mov si, 5Ah ; 'Z'
        cmp [si], cx
        jg  short loc_4AEE9
        cmp [si+2], dx
        jg  short loc_4AEE9
        cmp [si+4], cx
        jl  short loc_4AEE9
        cmp [si+6], dx
        jl  short loc_4AEE9
        mov byte_510BB, 2
        call    sub_4D24D
        call    sub_4CFB2
        call    sub_4CFDB
        mov byte_51ABE, 0
        call    sub_4C34A

loc_4AEE9:              ; CODE XREF: sub_4ADFF+C3j
                    ; sub_4ADFF+C8j ...
        call    sub_4B899
        mov si, 8226h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        call    sub_4C293
        call    sub_4C141
        call    sub_4C0DD

loc_4AF00:              ; CODE XREF: sub_4ADFF+107j
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4AF00
        call    sub_4B85C
        retn
sub_4ADFF   endp


; =============== S U B R O U T I N E =======================================


sub_4AF0C   proc near
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        add bx, 8A9Ch
        mov bp, bx
        mov si, bx
        mov ax, 2D2Dh
        cmp ax, [si]
        jnz short loc_4AF3E
        cmp ax, [si+2]
        jnz short loc_4AF3E
        cmp ax, [si+4]
        jnz short loc_4AF3E
        cmp ax, [si+6]
        jnz short loc_4AF3E
        mov si, 82B6h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4AF3E:              ; CODE XREF: sub_4AF0C+15j
                    ; sub_4AF0C+1Aj ...
        mov ax, 5F5Fh
        mov word_586FB, ax
        mov word_586FD, ax
        mov word_586FF, ax
        mov word_58701, ax
        mov word_58703, ax
        mov word_5870D, ax
        mov byte_5870F, al
        mov word_58710, ax
        mov word_58712, ax
        mov word_58714, ax
        cmp word_51970, 0
        jz  short loc_4AFE3
        mov al, 0Ah
        sub al, gameSpeed
        aam
        or  ax, 3030h
        xchg    al, ah
        mov word_586FB, 3C20h
        mov word_586FD, 4C44h
        mov word_586FF, 3A59h
        mov word_58701, ax
        mov word_58703, 203Eh
        mov word_5870D, 3C20h
        mov word_58712, 5A48h
        mov word_58714, 203Eh
        mov byte_59B94, 0
        mov byte_59B96, 0

loc_4AFAA:              ; CODE XREF: sub_4AF0C+A3j
        test    byte_59B96, 0FFh
        jz  short loc_4AFAA
        mov byte_59B96, 0

loc_4AFB6:              ; CODE XREF: sub_4AF0C+B9j
        call    videoloop
        call    sub_4D457
        inc byte_59B94
        cmp byte_59B96, 32h ; '2'
        jb  short loc_4AFB6
        mov al, byte_59B94
        xor ah, ah
        push    cx
        mov cl, 64h ; 'd'
        div cl
        pop cx
        or  al, 30h
        mov byte_5870F, al
        mov al, ah
        aam
        or  ax, 3030h
        xchg    al, ah
        mov word_58710, ax

loc_4AFE3:              ; CODE XREF: sub_4AF0C+58j
        mov si, 60D5h
        call    fade
        call    vgaloadbackseg
        mov byte_5091A, 0
        mov si, 83A4h
        mov di, 5716h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 83BFh
        mov di, 6560h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 83E0h
        mov di, 6A1Eh
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 8411h
        mov di, 73AEh
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, bp
        mov di, 843Eh
        mov cx, 8

loc_4B025:              ; CODE XREF: sub_4AF0C+11Fj
        mov al, [si]
        mov [di], al
        inc si
        inc di
        loop    loc_4B025
        mov si, 842Ch
        mov di, 7D36h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, bp
        mov al, [si+7Eh]
        cmp al, 71h ; 'q'
        jnz short loc_4B046
        mov byte_5091A, 1

loc_4B046:              ; CODE XREF: sub_4AF0C+133j
        mov si, 845Eh
        call    sub_4BF4D
        mov si, 8447h
        mov di, 81FAh
        mov ah, 0Fh
        call    sub_4BDF0
        mov di, bp
        mov al, [di+0Bh]
        mov si, 8479h
        call    sub_4BF4D
        mov si, 8476h
        mov byte ptr [si+3], 3Ah ; ':'
        mov al, [di+0Ah]
        call    sub_4BF4D
        mov si, 8473h
        mov byte ptr [si+3], 3Ah ; ':'
        mov al, [di+9]
        mov ah, 20h ; ' '
        call    sub_4BF4F
        mov si, 8462h
        mov di, 86BEh
        mov ah, 0Fh
        call    sub_4BDF0
        mov di, bp
        mov al, [di+9]
        mov bl, 3Ch ; '<'
        mul bl
        add al, [di+0Ah]
        adc ah, 0
        mov bl, [di+0Bh]
        cmp bl, 1Eh
        jl  short loc_4B0A1
        inc ax

loc_4B0A1:              ; CODE XREF: sub_4AF0C+192j
        mov bl, [di+7Eh]
        div bl
        push    ax
        mov al, ah
        mov bl, 0Ah
        mul bl
        mov bl, [di+7Eh]
        div bl
        mov si, 849Ch
        call    sub_4BF4D
        pop ax
        cmp al, 0
        jnz short loc_4B0C2
        mov byte_5091A, 2

loc_4B0C2:              ; CODE XREF: sub_4AF0C+1AFj
        mov si, 849Ah
        mov byte ptr [si+3], 2Eh ; '.'
        mov ah, 20h ; ' '
        call    sub_4BF4F
        cmp byte_5091A, 1
        jnz short loc_4B0E2
        mov si, 84CFh
        mov di, 903Fh
        mov ah, 0Fh
        call    sub_4BDF0
        jmp short loc_4B105
; ---------------------------------------------------------------------------

loc_4B0E2:              ; CODE XREF: sub_4AF0C+1C7j
        cmp byte_5091A, 2
        jnz short loc_4B0F6
        mov si, 84A8h
        mov di, 9041h
        mov ah, 0Fh
        call    sub_4BDF0
        jmp short loc_4B105
; ---------------------------------------------------------------------------

loc_4B0F6:              ; CODE XREF: sub_4AF0C+1DBj
        mov si, 847Dh
        mov byte ptr [si+1Ch], 20h ; ' '
        mov di, 9040h
        mov ah, 0Fh
        call    sub_4BDF0

loc_4B105:              ; CODE XREF: sub_4AF0C+1D4j
                    ; sub_4AF0C+1E8j
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 5FD5h
        call    fade
        call    sub_47E98
        mov si, 60D5h
        call    fade
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 6015h
        call    fade
        retn
sub_4AF0C   endp


; =============== S U B R O U T I N E =======================================


sub_4B149   proc near
        call    vgaloadgfxseg
        call    sub_4C5AF
        call    sub_47E98
        call    loc_4C44F
        call    sub_4C2F2
        retn
sub_4B149   endp


; =============== S U B R O U T I N E =======================================


sub_4B159   proc near       ; CODE XREF: runMainMenu+6Fp
        call    readDemo
        or  cx, cx
        jnz short loc_4B163
        jmp locret_4B1F1
; ---------------------------------------------------------------------------

loc_4B163:              ; CODE XREF: sub_4B159+5j
        mov word_5196C, 1
        mov byte_510DE, 1
        push    es
        mov ax, seg demoseg
        mov es, ax
        assume es:demoseg
        mov bx, 0
        mov cx, 0

loc_4B17A:              ; CODE XREF: sub_4B159+2Dj
        mov ax, es:[bx]
        add bx, 2
        cmp ax, 0FFFFh
        jz  short loc_4B188
        inc cx
        jmp short loc_4B17A
; ---------------------------------------------------------------------------

loc_4B188:              ; CODE XREF: sub_4B159+2Aj
        push    cx
        call    getTime
        call    sub_4A1AE
        xor dx, dx
        pop cx
        div cx
        mov bx, 0
        shl dx, 1
        add bx, dx
        mov bx, es:[bx]
        cmp bx, 0FFFFh
        jnz short loc_4B1AE
        mov word_5196C, 0
        mov byte_510DE, 0

loc_4B1AE:              ; CODE XREF: sub_4B159+48j
        mov al, es:[bx]
        xor ah, ah
        push    bx
        mov bx, dx
        shr dx, 1
        mov word_599D6, dx
        mov word_599D8, 0
        cmp al, 6Fh ; 'o'
        ja  short loc_4B1CF
        or  al, al
        jz  short loc_4B1CF
        mov byte ptr word_599D8, al
        mov dl, al

loc_4B1CF:              ; CODE XREF: sub_4B159+6Bj
                    ; sub_4B159+6Fj
        mov al, dl
        mov bx, [bx-67CAh]
        mov timeOfDay, bx
        pop bx
        mov word_510E6, ax
        inc bx
        pop es
        assume es:nothing
        mov word_510DF, bx
        mov word_5A33C, bx
        mov byte_510E1, 0
        mov byte_510E2, 1

locret_4B1F1:               ; CODE XREF: sub_4B159+7j
        retn
sub_4B159   endp


; =============== S U B R O U T I N E =======================================


demoSomething?  proc near       ; CODE XREF: start+3BAp
                    ; runMainMenu+12Ep ...
        push    ax
        call    readDemo
        pop ax
        push    ax
        mov bx, ax
        shl bx, 1
        mov ax, [bx-67CAh]
        mov timeOfDay, ax
        pop ax
        mov word_5196C, 1
        mov byte_510DE, 1
        push    es
        mov dx, seg demoseg
        mov es, dx
        assume es:demoseg
        mov bx, 0
        shl ax, 1
        add bx, ax
        mov bx, es:[bx]
        cmp bx, 0FFFFh
        jnz short loc_4B22F
        mov word_5196C, 0
        mov byte_510DE, 0

loc_4B22F:              ; CODE XREF: demoSomething?+30j
        mov word_599D8, 0
        shr al, 1
        mov ah, es:[bx]
        cmp ah, 6Fh ; 'o'
        ja  short loc_4B248
        or  ah, ah
        jz  short loc_4B248
        mov al, ah
        mov byte ptr word_599D8, al

loc_4B248:              ; CODE XREF: demoSomething?+4Bj
                    ; demoSomething?+4Fj
        xor ah, ah
        mov word_510E6, ax
        inc bx
        pop es
        assume es:nothing
        mov word_510DF, bx
        mov word_5A33C, bx
        mov byte_510E1, 0
        mov byte_510E2, 1
        retn
demoSomething?  endp

; ---------------------------------------------------------------------------
loc_4B262:
        mov byte_50915, 1
        mov byte_50913, 0
        mov byte_50914, 1
        mov ax, word_5195D
        sub ax, word_58471
        cmp ax, word_58473
        jnb short loc_4B27F
        retn
; ---------------------------------------------------------------------------

loc_4B27F:              ; CODE XREF: code:465Cj
        call    sub_4B899
        mov ax, word_5195D
        mov word_58473, ax
        cmp word_58471, 1
        jbe short loc_4B293
        dec word_58471

loc_4B293:              ; CODE XREF: code:466Dj
        cmp byte_59B85, 0
        jnz short loc_4B2A5
        cmp byte_58D46, 0
        jbe short loc_4B2A5
        dec byte_58D46

loc_4B2A5:              ; CODE XREF: code:4678j code:467Fj
        call    sub_4C0DD
        call    sub_4B85C
        call    sub_4B8BE
        retn
; ---------------------------------------------------------------------------
loc_4B2AF:
        mov byte_50915, 1
        mov byte_50913, 1
        mov byte_50914, 0
        mov ax, word_5195D
        sub ax, word_58471
        cmp ax, word_58473
        jnb short loc_4B2CC
        retn
; ---------------------------------------------------------------------------

loc_4B2CC:              ; CODE XREF: code:46A9j
        call    sub_4B899
        mov ax, word_5195D
        mov word_58473, ax
        cmp word_58471, 1
        jbe short loc_4B2E0
        dec word_58471

loc_4B2E0:              ; CODE XREF: code:46BAj
        cmp byte_59B85, 0
        jnz short loc_4B2F2
        cmp byte_58D46, 13h
        jnb short loc_4B2F2
        inc byte_58D46

loc_4B2F2:              ; CODE XREF: code:46C5j code:46CCj
        call    sub_4C0DD
        call    sub_4B85C
        call    sub_4B8BE
        retn

; =============== S U B R O U T I N E =======================================


sub_4B2FC   proc near       ; CODE XREF: sub_4B375+56p
        mov si, 60D5h
        call    fade
        call    vgaloadbackseg
        mov si, 8718h
        mov ah, 0Fh
        mov di, 5BDFh
        call    sub_4BDF0
        mov si, 8728h
        mov ah, 0Fh
        mov di, 6EE3h
        call    sub_4BDF0
        mov si, 8756h
        mov ah, 0Fh
        mov di, 760Eh
        call    sub_4BDF0
        mov si, 8777h
        mov ah, 0Fh
        mov di, 7D31h
        call    sub_4BDF0
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 5FD5h
        call    fade
        call    sub_47E98
        mov si, 60D5h
        call    fade
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 6015h
        call    fade
        retn
sub_4B2FC   endp


; =============== S U B R O U T I N E =======================================


sub_4B375   proc near       ; CODE XREF: runMainMenu+11Ep
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8A9Ch
        add si, bx
        mov ax, 2D2Dh
        cmp [si], ax
        jnz short loc_4B3A4
        cmp [si+2], ax
        jnz short loc_4B3A4
        cmp [si+4], ax
        jnz short loc_4B3A4
        cmp [si+6], ax
        jnz short loc_4B3A4
        mov si, 82B6h
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4B3A4:              ; CODE XREF: sub_4B375+12j
                    ; sub_4B375+17j ...
        mov ax, word_51ABC
        cmp ax, 6Fh ; 'o'
        jle short loc_4B3DB
        cmp word_51ABC, 70h ; 'p'
        jnz short loc_4B3B4
        retn
; ---------------------------------------------------------------------------

loc_4B3B4:              ; CODE XREF: sub_4B375+3Cj
        add si, 0Ch
        mov cx, 6Fh ; 'o'
        mov bl, 0

loc_4B3BC:              ; CODE XREF: sub_4B375+4Fj
        cmp byte ptr [si], 1
        jnz short loc_4B3C3
        inc bl

loc_4B3C3:              ; CODE XREF: sub_4B375+4Aj
        inc si
        loop    loc_4B3BC
        cmp bl, 6Fh ; 'o'
        jnz short loc_4B3CF
        call    sub_4B2FC
        retn
; ---------------------------------------------------------------------------

loc_4B3CF:              ; CODE XREF: sub_4B375+54j
        mov si, 82CEh
        mov di, 89F7h
        mov ah, 2
        call    sub_4BA5F
        retn
; ---------------------------------------------------------------------------

loc_4B3DB:              ; CODE XREF: sub_4B375+35j
        dec ax
        mov si, 949Eh
        add si, ax
        mov al, [si]
        cmp al, 6
        jz  short loc_4B404
        mov word_5196C, 1
        mov byte_510DE, 0
        cmp al, 4
        jnz short loc_4B3FD
        mov byte_510B3, 0
        jmp short loc_4B40F
; ---------------------------------------------------------------------------

loc_4B3FD:              ; CODE XREF: sub_4B375+7Fj
        mov byte_510B3, 1
        jmp short loc_4B40F
; ---------------------------------------------------------------------------

loc_4B404:              ; CODE XREF: sub_4B375+70j
        mov si, 82CEh
        mov di, 89F7h
        mov ah, 8
        call    sub_4BA5F

loc_4B40F:              ; CODE XREF: sub_4B375+86j
                    ; sub_4B375+8Dj
        call    sub_49544
        mov ax, word_51ABC
        call    sub_4BF4A
        retn
sub_4B375   endp


; =============== S U B R O U T I N E =======================================


sub_4B419   proc near
        xor al, al
        cmp byte_519B5, al
        jz  short loc_4B423
        not al

loc_4B423:              ; CODE XREF: sub_4B419+6j
        cmp byte ptr word_59B65, 0
        jz  short loc_4B42C
        not al

loc_4B42C:              ; CODE XREF: sub_4B419+Fj
        inc al
        jnz short loc_4B433
        jmp loc_4B583
; ---------------------------------------------------------------------------

loc_4B433:              ; CODE XREF: sub_4B419+15j
        mov ax, word_5195D
        sub ax, word_59B8C
        cmp ax, word_59B8E
        jnb short loc_4B443
        jmp locret_4B582
; ---------------------------------------------------------------------------

loc_4B443:              ; CODE XREF: sub_4B419+25j
        mov ax, word_5195D
        mov word_59B8E, ax
        cmp word_59B8C, 1
        jbe short loc_4B454
        dec word_59B8C

loc_4B454:              ; CODE XREF: sub_4B419+35j
                    ; sub_4B419+9Aj
        mov ax, word ptr aLevels_dat_0+8 ; "AT"
        mov dl, byte ptr word_519B3
        or  dl, byte ptr word_519A7
        jnz short loc_4B482
        cmp ax, 5441h
        jnz short loc_4B46B
        mov ax, 3030h
        jmp short loc_4B4A3
; ---------------------------------------------------------------------------

loc_4B46B:              ; CODE XREF: sub_4B419+4Bj
        cmp ax, 3939h
        jnz short loc_4B475
        mov ax, 5441h
        jmp short loc_4B4A3
; ---------------------------------------------------------------------------

loc_4B475:              ; CODE XREF: sub_4B419+55j
        inc ah
        cmp ah, 39h ; '9'
        jbe short loc_4B4A3
        mov ah, 30h ; '0'
        inc al
        jmp short loc_4B4A3
; ---------------------------------------------------------------------------

loc_4B482:              ; CODE XREF: sub_4B419+46j
        cmp ax, 5441h
        jnz short loc_4B48C
        mov ax, 3939h
        jmp short loc_4B4A3
; ---------------------------------------------------------------------------

loc_4B48C:              ; CODE XREF: sub_4B419+6Cj
        cmp ax, 3030h
        jnz short loc_4B496
        mov ax, 5441h
        jmp short loc_4B4A3
; ---------------------------------------------------------------------------

loc_4B496:              ; CODE XREF: sub_4B419+76j
        dec ah
        cmp ah, 30h ; '0'
        jnb short loc_4B4A3
        mov ah, 39h ; '9'
        dec al
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4B4A3:              ; CODE XREF: sub_4B419+50j
                    ; sub_4B419+5Aj ...
        mov word ptr aLevels_dat_0+8, ax ; "AT"
        mov ax, 3D00h
        mov dx, 17AFh
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4B4B8
        cmp ax, 2
        jz  short loc_4B454
        jmp exit
; ---------------------------------------------------------------------------

loc_4B4B8:              ; CODE XREF: sub_4B419+95j
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_4B4C6
        jmp exit
; ---------------------------------------------------------------------------

loc_4B4C6:              ; CODE XREF: sub_4B419+A8j
        mov ax, word ptr aLevels_dat_0+8 ; "AT"
        mov word ptr aLevelSet??+0Fh, ax ; "??  "
        cmp ah, 54h ; 'T'
        jnz short loc_4B4D3
        mov al, 53h ; 'S'

loc_4B4D3:              ; CODE XREF: sub_4B419+B6j
        mov word ptr aLevel_lst+7, ax ; "ST"
        mov word ptr aPlayer_lst+8, ax ; "ST"
        mov word ptr aHallfame_lst+0Ah, ax ; "ST"
        cmp ah, 54h ; 'T'
        jnz short loc_4B4E4
        mov ax, 4E49h

loc_4B4E4:              ; CODE XREF: sub_4B419+C6j
        mov word ptr aDemo0_bin+7, ax ; "IN"
        cmp ah, 4Eh ; 'N'
        jnz short loc_4B4EF
        mov ax, 5641h

loc_4B4EF:              ; CODE XREF: sub_4B419+D1j
        cmp byte ptr dword_59B76, 0
        jnz short loc_4B4F9
        mov word ptr aSavegame_sav+0Ah, ax ; "AV"

loc_4B4F9:              ; CODE XREF: sub_4B419+DBj
        mov si, 9EEDh
        cmp ah, 56h ; 'V'
        jnz short loc_4B504
        mov si, 9F05h

loc_4B504:              ; CODE XREF: sub_4B419+E6j
        mov di, 89F7h
        mov ah, 4
        call    sub_4BA5F
        call    readLevelsLst
        call    readDemo
        push    es
        push    ds
        pop es
        assume es:data
        cmp byte_59B85, 0
        jz  short loc_4B52A
        lea di, byte_58DB4+4
        mov cx, 6Fh ; 'o'
        mov al, 2
        rep stosb
        pop es
        assume es:nothing
        jmp short loc_4B565
; ---------------------------------------------------------------------------

loc_4B52A:              ; CODE XREF: sub_4B419+101j
        lea di, word_58DAC
        mov cx, 14h

loc_4B531:              ; CODE XREF: sub_4B419+129j
        push    cx
        mov ax, 2D2Dh
        mov cx, 4
        rep stosw
        xor ax, ax
        mov cx, 3Ch ; '<'
        rep stosw
        pop cx
        loop    loc_4B531
        lea di, asc_59824   ; "    "
        mov cx, 3

loc_4B54B:              ; CODE XREF: sub_4B419+143j
        push    cx
        mov ax, 2020h
        mov cx, 4
        rep stosw
        xor ax, ax
        mov cx, 2
        rep stosw
        pop cx
        loop    loc_4B54B
        pop es
        call    readHallfameLst
        call    readPlayersLst

loc_4B565:              ; CODE XREF: sub_4B419+10Fj
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        call    sub_4C141
        call    sub_4C1A9
        call    sub_4C0DD
        call    sub_4B899
        call    sub_4B85C
        call    sub_4B8BE

locret_4B582:               ; CODE XREF: sub_4B419+27j
        retn
; ---------------------------------------------------------------------------

loc_4B583:              ; CODE XREF: sub_4B419+17j
        mov si, 60D5h
        call    fade
        call    vgaloadbackseg
        mov si, 84FFh
        mov di, 786Dh
        mov ah, 0Fh
        call    sub_4BDF0
        mov ah, 19h
        int 21h     ; DOS - GET DEFAULT DISK NUMBER
        mov byte_59B9A, al
        cmp al, 0
        jz  short loc_4B5B3
        cmp al, 1
        jz  short loc_4B5B3
        mov si, 851Bh
        mov di, 81F5h
        mov ah, 0Fh
        call    sub_4BDF0
        jmp short loc_4B5BE
; ---------------------------------------------------------------------------

loc_4B5B3:              ; CODE XREF: sub_4B419+187j
                    ; sub_4B419+18Bj
        mov si, 853Ah
        mov di, 81F5h
        mov ah, 0Fh
        call    sub_4BDF0

loc_4B5BE:              ; CODE XREF: sub_4B419+198j
        mov si, 8562h
        mov di, 0A81Ah
        mov ah, 0Fh
        call    sub_4BDF0
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 5FD5h
        call    fade

loc_4B5E6:              ; CODE XREF: sub_4B419+1D3j
        call    getMouseStatus
        cmp bx, 0
        jnz short loc_4B5E6

loc_4B5EE:              ; CODE XREF: sub_4B419+20Fj
        cmp word_5197A, 1
        jz  short loc_4B63D
        mov al, keyPressed
        xor dl, dl
        cmp al, 1Eh     ; A
        jz  short loc_4B62A
        inc dl
        cmp al, 30h ; '0'   ; B
        jz  short loc_4B62A
        inc dl
        cmp al, 2Eh ; '.'   ; C
        jz  short loc_4B62A
        inc dl
        cmp al, 20h ; ' '   ; D
        jz  short loc_4B62A
        inc dl
        cmp al, 12h     ; E
        jz  short loc_4B62A
        inc dl
        cmp al, 21h ; '!'   ; F
        jz  short loc_4B62A
        mov dl, byte_59B9A
        cmp al, 1Ch     ; Enter
        jz  short loc_4B62A
        cmp al, 1       ; Esc
        jz  short loc_4B63D
        jmp short loc_4B5EE
; ---------------------------------------------------------------------------

loc_4B62A:              ; CODE XREF: sub_4B419+1E3j
                    ; sub_4B419+1E9j ...
        mov ah, 0Eh
        int 21h     ; DOS - SELECT DISK
                    ; DL = new default drive number (0 = A, 1 = B, etc.)
                    ; Return: AL = number of logical drives
        mov byte_59B86, 0
        call    readMoving
        cmp byte_59B86, 0FFh
        jnz short loc_4B647

loc_4B63D:              ; CODE XREF: sub_4B419+1DAj
                    ; sub_4B419+20Dj
        mov dl, byte_59B9A
        mov ah, 0Eh
        int 21h     ; DOS - SELECT DISK
                    ; DL = new default drive number (0 = A, 1 = B, etc.)
                    ; Return: AL = number of logical drives
        jmp short loc_4B64D
; ---------------------------------------------------------------------------

loc_4B647:              ; CODE XREF: sub_4B419+222j
        call    readEverything
        call    vgaloadbackseg

loc_4B64D:              ; CODE XREF: sub_4B419+22Cj
        mov si, 60D5h
        call    fade
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 6015h
        call    fade
        retn
sub_4B419   endp


; =============== S U B R O U T I N E =======================================


sub_4B671   proc near
        mov byte_50912, 1
        mov byte_50910, 1
        mov byte_50911, 0
        mov ax, word_5195D
        sub ax, word_5846D
        cmp ax, word_5846F
        jnb short loc_4B68E
        retn
; ---------------------------------------------------------------------------

loc_4B68E:              ; CODE XREF: sub_4B671+1Aj
        mov ax, word_5195D
        mov word_5846F, ax
        cmp word_5846D, 1
        jbe short loc_4B69F
        dec word_5846D

loc_4B69F:              ; CODE XREF: sub_4B671+28j
        cmp byte_59B85, 0
        jnz short loc_4B6B1
        cmp byte_5981F, 13h
        jnb short loc_4B6B1
        inc byte_5981F

loc_4B6B1:              ; CODE XREF: sub_4B671+33j
                    ; sub_4B671+3Aj
        call    sub_4B899
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        call    sub_4C141
        call    sub_4B85C
        call    sub_4B8BE
        retn
sub_4B671   endp


; =============== S U B R O U T I N E =======================================


sub_4B6C9   proc near
        mov byte_50912, 1
        mov byte_50910, 0
        mov byte_50911, 1
        mov ax, word_5195D
        sub ax, word_5846D
        cmp ax, word_5846F
        jnb short loc_4B6E6
        retn
; ---------------------------------------------------------------------------

loc_4B6E6:              ; CODE XREF: sub_4B6C9+1Aj
        mov ax, word_5195D
        mov word_5846F, ax
        cmp word_5846D, 1
        jbe short loc_4B6F7
        dec word_5846D

loc_4B6F7:              ; CODE XREF: sub_4B6C9+28j
        cmp byte_59B85, 0
        jnz short loc_4B709
        cmp byte_5981F, 0
        jbe short loc_4B709
        dec byte_5981F

loc_4B709:              ; CODE XREF: sub_4B6C9+33j
                    ; sub_4B6C9+3Aj
        call    sub_4B899
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C293
        call    sub_4C141
        call    sub_4B85C
        call    sub_4B8BE
        retn
sub_4B6C9   endp


; =============== S U B R O U T I N E =======================================


sub_4B721   proc near
        mov al, byte_58D47
        mov byte_58D46, al
        call    sub_4C0DD
        retn
sub_4B721   endp


; =============== S U B R O U T I N E =======================================


sub_4B72B   proc near
        mov byte_50918, 1
        mov byte_50916, 1
        mov byte_50917, 0
        mov ax, word_5195D
        sub ax, word_58469
        cmp ax, word_5846B
        jnb short loc_4B748
        retn
; ---------------------------------------------------------------------------

loc_4B748:              ; CODE XREF: sub_4B72B+1Aj
        mov ax, word_5195D
        mov word_5846B, ax
        cmp word_58469, 1
        jbe short loc_4B759
        dec word_58469

loc_4B759:              ; CODE XREF: sub_4B72B+28j
        cmp word_51ABC, 71h ; 'q'
        jnb short locret_4B770
        inc word_51ABC
        call    sub_4B899
        call    sub_4C141
        call    sub_4B85C
        call    sub_4B8BE

locret_4B770:               ; CODE XREF: sub_4B72B+33j
        retn
sub_4B72B   endp


; =============== S U B R O U T I N E =======================================


sub_4B771   proc near
        mov byte_50918, 1
        mov byte_50916, 0
        mov byte_50917, 1
        mov ax, word_5195D
        sub ax, word_58469
        cmp ax, word_5846B
        jnb short loc_4B78E
        retn
; ---------------------------------------------------------------------------

loc_4B78E:              ; CODE XREF: sub_4B771+1Aj
        mov ax, word_5195D
        mov word_5846B, ax
        cmp word_58469, 1
        jbe short loc_4B79F
        dec word_58469

loc_4B79F:              ; CODE XREF: sub_4B771+28j
        cmp word_51ABC, 1
        jbe short locret_4B7B6
        dec word_51ABC
        call    sub_4B899
        call    sub_4C141
        call    sub_4B85C
        call    sub_4B8BE

locret_4B7B6:               ; CODE XREF: sub_4B771+33j
        retn
sub_4B771   endp


; =============== S U B R O U T I N E =======================================


sub_4B7B7   proc near
        mov si, 60D5h
        call    fade
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    vgaloadbackseg
        mov si, 861Dh
        mov di, 5252h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 8638h
        mov di, 609Bh
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 865Ch
        mov di, 6563h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 866Eh
        mov di, 786Fh
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 8691h
        mov di, 7D34h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 86B2h
        mov di, 81F7h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 86D5h
        mov di, 9E90h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 86F7h
        mov di, 0A818h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 5FD5h
        call    fade
        call    sub_47E98
        mov si, 60D5h
        call    fade
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov si, 6015h
        call    fade
        retn
sub_4B7B7   endp


; =============== S U B R O U T I N E =======================================


sub_4B85C   proc near       ; CODE XREF: sub_4AB1B+FCp
                    ; sub_4AB1B+124p ...
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov ax, mousey
        mov bx, 7Ah ; 'z'
        mul bx
        add ax, 4D5Ch
        mov si, ax
        mov ax, mousex
        shr ax, 1
        shr ax, 1
        shr ax, 1
        add si, ax
        mov word_5847B, si
        mov di, 4D34h
        mov cx, 10h
        push    ds
        mov ax, es
        mov ds, ax

loc_4B88D:              ; CODE XREF: sub_4B85C+39j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4B88D
        pop ds
        retn
sub_4B85C   endp


; =============== S U B R O U T I N E =======================================


sub_4B899   proc near       ; CODE XREF: start+417p sub_4AB1B+3Fp ...
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov si, 4D34h
        mov di, word_5847B
        mov cx, 10h
        push    ds
        mov ax, es
        mov ds, ax

loc_4B8B2:              ; CODE XREF: sub_4B899+21j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4B8B2
        pop ds
        retn
sub_4B899   endp


; =============== S U B R O U T I N E =======================================


sub_4B8BE   proc near       ; CODE XREF: sub_4AB1B+FFp
                    ; sub_4AB1B+127p ...
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 8
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 7
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color masking disable
                    ; bits 0-3 disable planes from compare logic in read mode 01
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov si, 1520h
        mov bx, word_5195D
        shr bx, 1
        shr bx, 1
        ;and bx, 0Eh
		db  83h, 0E3h, 0Eh
        mov si, [bx+si]
        mov di, word_5847B
        mov bx, mousex
        and bl, 7
        mov bh, 8
        sub bh, bl
        mov cx, 8
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        push    ds
        mov ax, es
        mov ds, ax
        push    si
        push    di
        mov cx, 8

loc_4B926:              ; CODE XREF: sub_4B8BE+85j
        push    cx
        mov al, [si]
        mov ah, al
        mov cl, bl
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di], al
        mov al, ah
        mov cl, bh
        shl al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di+1], al
        add si, 7Ah ; 'z'
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4B926
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 5
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 5
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        pop di
        pop si
        push    si
        push    di
        mov cx, 8

loc_4B96A:              ; CODE XREF: sub_4B8BE+C9j
        push    cx
        mov al, [si]
        mov ah, al
        mov cl, bl
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di], al
        mov al, ah
        mov cl, bh
        shl al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di+1], al
        add si, 7Ah ; 'z'
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4B96A
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 8
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 8
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        pop di
        pop si
        push    si
        push    di
        mov cx, 8

loc_4B9AE:              ; CODE XREF: sub_4B8BE+10Dj
        push    cx
        mov al, [si]
        mov ah, al
        mov cl, bl
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di], al
        mov al, ah
        mov cl, bh
        shl al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di+1], al
        add si, 7Ah ; 'z'
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4B9AE
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 9
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 9
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        pop di
        pop si
        push    si
        push    di
        mov cx, 8

loc_4B9F2:              ; CODE XREF: sub_4B8BE+151j
        push    cx
        mov al, [si]
        mov ah, al
        mov cl, bl
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di], al
        mov al, ah
        mov cl, bh
        shl al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di+1], al
        add si, 7Ah ; 'z'
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4B9F2
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        pop di
        pop si
        mov cx, 8

loc_4BA34:              ; CODE XREF: sub_4B8BE+193j
        push    cx
        mov al, [si]
        mov ah, al
        mov cl, bl
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di], al
        mov al, ah
        mov cl, bh
        shl al, cl
        out dx, al      ; EGA port: graphics controller data register
        xor [di+1], al
        add si, 7Ah ; 'z'
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4BA34
        pop ds
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_4B8BE   endp


; =============== S U B R O U T I N E =======================================


sub_4BA5F   proc near       ; CODE XREF: sub_4AB1B+37p
                    ; sub_4AB1B+4Ap ...
        cmp byte_5A33F, 1
        jnz short loc_4BA69
        jmp locret_4BDEF
; ---------------------------------------------------------------------------

loc_4BA69:              ; CODE XREF: sub_4BA5F+5j
        mov byte_51969, ah
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov cl, 0

loc_4BA8D:              ; CODE XREF: sub_4BA5F:loc_4BDECj
        mov bl, [si]
        cmp bl, 0
        jnz short loc_4BA97
        jmp locret_4BDEF
; ---------------------------------------------------------------------------

loc_4BA97:              ; CODE XREF: sub_4BA5F+33j
        cmp bl, 0Ah
        jnz short loc_4BA9F
        jmp locret_4BDEF
; ---------------------------------------------------------------------------

loc_4BA9F:              ; CODE XREF: sub_4BA5F+3Bj
        inc si
        sub bl, 20h ; ' '
        xor bh, bh
        add bx, 5B15h
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov ah, 0FCh ; '?'
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, 0FCh ; '?'
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        shr ah, cl
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov ah, [bx]
        mov ch, cl
        mov al, 8
        sub al, cl
        mov cl, al
        shl ah, cl
        mov cl, ch
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        sub di, 356h
        add cl, 6
        cmp cl, 8
        jl  short loc_4BDEC
        sub cl, 8
        inc di

loc_4BDEC:              ; CODE XREF: sub_4BA5F+387j
        jmp loc_4BA8D
; ---------------------------------------------------------------------------

locret_4BDEF:               ; CODE XREF: sub_4BA5F+7j
                    ; sub_4BA5F+35j ...
        retn
sub_4BA5F   endp


; =============== S U B R O U T I N E =======================================


sub_4BDF0   proc near       ; CODE XREF: sub_47F39+2Ap
                    ; sub_4AF0C+EDp ...
        cmp byte_5A33F, 1
        jnz short loc_4BDFA
        jmp locret_4BF49
; ---------------------------------------------------------------------------

loc_4BDFA:              ; CODE XREF: sub_4BDF0+5j
        mov byte_51969, ah
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov cl, 0

loc_4BE1E:              ; CODE XREF: sub_4BDF0:loc_4BF46j
        mov bl, [si]
        cmp bl, 0
        jnz short loc_4BE28
        jmp locret_4BF49
; ---------------------------------------------------------------------------

loc_4BE28:              ; CODE XREF: sub_4BDF0+33j
        cmp bl, 0Ah
        jnz short loc_4BE30
        jmp locret_4BF49
; ---------------------------------------------------------------------------

loc_4BE30:              ; CODE XREF: sub_4BDF0+3Bj
        inc si
        sub bl, 20h ; ' '
        xor bh, bh
        add bx, 5B15h
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov al, [bx]
        shr al, cl
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov al, [bx]
        mov ch, cl
        mov ah, 8
        sub ah, cl
        mov cl, ah
        shl al, cl
        mov cl, ch
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di+1], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        sub di, 356h
        add cl, 6
        cmp cl, 8
        jl  short loc_4BF46
        sub cl, 8
        inc di

loc_4BF46:              ; CODE XREF: sub_4BDF0+150j
        jmp loc_4BE1E
; ---------------------------------------------------------------------------

locret_4BF49:               ; CODE XREF: sub_4BDF0+7j
                    ; sub_4BDF0+35j ...
        retn
sub_4BDF0   endp


; =============== S U B R O U T I N E =======================================


sub_4BF4A   proc near       ; CODE XREF: start+3F7p sub_4955B+398p ...
        mov si, 0A017h
sub_4BF4A   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4BF4D   proc near       ; CODE XREF: sub_4ADFF+7Cp
                    ; sub_4AF0C+13Dp ...
        mov ah, 30h ; '0'
sub_4BF4D   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4BF4F   proc near       ; CODE XREF: sub_4AF0C+16Fp
                    ; sub_4AF0C+1BFp ...
        push    ax
        mov ah, 30h ; '0'
        mov [si], ah
        mov [si+1], ah
        mov [si+2], ah

loc_4BF5A:              ; CODE XREF: sub_4BF4F+11j
        sub al, 64h ; 'd'
        jb  short loc_4BF62
        inc byte ptr [si]
        jmp short loc_4BF5A
; ---------------------------------------------------------------------------

loc_4BF62:              ; CODE XREF: sub_4BF4F+Dj
        inc si
        add al, 64h ; 'd'

loc_4BF65:              ; CODE XREF: sub_4BF4F+1Cj
        sub al, 0Ah
        jb  short loc_4BF6D
        inc byte ptr [si]
        jmp short loc_4BF65
; ---------------------------------------------------------------------------

loc_4BF6D:              ; CODE XREF: sub_4BF4F+18j
        inc si
        add al, 0Ah
        add [si], al
        pop ax
        cmp ah, 20h ; ' '
        jnz short locret_4BF8C
        dec si
        dec si
        cmp byte ptr [si], 30h ; '0'
        jnz short loc_4BF8B
        mov byte ptr [si], 20h ; ' '
        inc si
        cmp byte ptr [si], 30h ; '0'
        jnz short loc_4BF8B
        mov byte ptr [si], 20h ; ' '

loc_4BF8B:              ; CODE XREF: sub_4BF4F+2Ej
                    ; sub_4BF4F+37j
        inc si

locret_4BF8C:               ; CODE XREF: sub_4BF4F+27j
        retn
sub_4BF4F   endp


; =============== S U B R O U T I N E =======================================


sub_4BF8D   proc near       ; CODE XREF: sub_4C0DDp
        cmp byte_59B85, 0
        jz  short loc_4BF97
        jmp locret_4C0DC
; ---------------------------------------------------------------------------

loc_4BF97:              ; CODE XREF: sub_4BF8D+5j
        mov cx, 14h
        mov si, 8A9Ch
        mov di, 8A38h
        mov dl, 0

loc_4BFA2:              ; CODE XREF: sub_4BF8D+38j
        mov [di], dl
        mov al, [si+7Eh]
        mov [di+1], al
        mov al, [si+9]
        mov [di+2], al
        mov al, [si+0Ah]
        mov [di+3], al
        mov al, [si+0Bh]
        mov [di+4], al
        inc dl
        add si, 80h ; '?'
        add di, 5
        loop    loc_4BFA2

loc_4BFC7:              ; CODE XREF: sub_4BF8D+B4j
        mov dx, 0
        mov cx, 13h
        mov si, 8A38h
        mov di, 8A3Dh

loc_4BFD3:              ; CODE XREF: sub_4BF8D+AFj
        mov al, [si+1]
        cmp [di+1], al
        jl  short loc_4C036
        jg  short loc_4BFFD
        mov al, [si+2]
        cmp [di+2], al
        jg  short loc_4C036
        jl  short loc_4BFFD
        mov al, [si+3]
        cmp [di+3], al
        jg  short loc_4C036
        jl  short loc_4BFFD
        mov al, [si+4]
        cmp [di+4], al
        jg  short loc_4C036
        jl  short loc_4BFFD
        jmp short loc_4C036
; ---------------------------------------------------------------------------

loc_4BFFD:              ; CODE XREF: sub_4BF8D+4Ej
                    ; sub_4BF8D+58j ...
        mov al, [si]
        mov ah, [di]
        mov [si], ah
        mov [di], al
        mov al, [si+1]
        mov ah, [di+1]
        mov [si+1], ah
        mov [di+1], al
        mov al, [si+2]
        mov ah, [di+2]
        mov [si+2], ah
        mov [di+2], al
        mov al, [si+3]
        mov ah, [di+3]
        mov [si+3], ah
        mov [di+3], al
        mov al, [si+4]
        mov ah, [di+4]
        mov [si+4], ah
        mov [di+4], al
        inc dx

loc_4C036:              ; CODE XREF: sub_4BF8D+4Cj
                    ; sub_4BF8D+56j ...
        add si, 5
        add di, 5
        loop    loc_4BFD3
        cmp dx, 0
        jnz short loc_4BFC7
        mov cx, 14h
        mov dl, 0
        mov si, 8A38h

loc_4C04B:              ; CODE XREF: sub_4BF8D+CFj
        mov al, [si]
        cmp al, byte_5981F
        jnz short loc_4C057
        mov byte_58D47, dl

loc_4C057:              ; CODE XREF: sub_4BF8D+C4j
        add si, 5
        inc dl
        loop    loc_4C04B
        mov cx, 14h

loc_4C061:
        mov si, 8A38h
        mov di, 883Ch

loc_4C067:              ; CODE XREF: sub_4BF8D+14Dj
        mov al, [si+1]
        cmp al, 71h ; 'q'
        jnz short loc_4C078
        mov word ptr [di], 3939h

loc_4C072:
        mov byte ptr [di+2], 39h ; '9'
        jmp short loc_4C07F
; ---------------------------------------------------------------------------

loc_4C078:              ; CODE XREF: sub_4BF8D+DFj
        push    si
        mov si, di
        call    sub_4BF4F
        pop si

loc_4C07F:              ; CODE XREF: sub_4BF8D+E9j
        add di, 4
        push    si
        mov ah, [si]
        xor al, al
        shr ax, 1
        mov si, 8A9Ch
        add si, ax
        mov bx, 8

loc_4C091:              ; CODE XREF: sub_4BF8D+10Bj
        mov al, [si]
        mov [di], al
        inc si
        inc di
        dec bx
        jnz short loc_4C091
        pop si
        push    di
        push    si
        mov al, [si+4]
        mov si, di
        add si, 7
        call    sub_4BF4D
        mov si, di
        add si, 7
        mov byte ptr [si], 3Ah ; ':'
        pop si
        push    si
        mov al, [si+3]
        mov si, di
        add si, 4
        call    sub_4BF4D
        mov si, di
        add si, 4
        mov byte ptr [si], 3Ah ; ':'
        pop si
        push    si
        mov al, [si+2]
        mov si, di
        add si, 1
        call    sub_4BF4D
        pop si
        pop di
        add di, 0Bh
        add si, 5
        loop    loc_4C067

locret_4C0DC:               ; CODE XREF: sub_4BF8D+7j
        retn
sub_4BF8D   endp


; =============== S U B R O U T I N E =======================================


sub_4C0DD   proc near       ; CODE XREF: sub_4AB1B+1E9p
                    ; sub_4AD0E+E2p ...
        call    sub_4BF8D
        mov si, 880Eh
        mov al, byte_58D46
        xor ah, ah
        mov bl, 17h
        mul bl
        add si, ax
        push    si
        mov ah, 8
        mov di, 7935h
        call    sub_4BA5F
        pop si
        add si, 17h
        push    si
        mov ah, 8
        mov di, 7D7Fh
        call    sub_4BA5F
        pop si
        add si, 17h
        push    si
        mov ah, 6
        mov di, 81C9h
        call    sub_4BA5F
        pop si
        add si, 17h
        push    si
        mov ah, 8
        mov di, 8613h
        call    sub_4BA5F
        pop si
        add si, 17h
        mov ah, 8
        mov di, 8A5Dh
        call    sub_4BA5F
        mov si, 8359h
        mov al, byte_58D46
        inc al
        call    sub_4BF4D
        mov si, 835Ah
        mov di, 81DAh
        mov ah, 6
        call    sub_4BA5F
        retn
sub_4C0DD   endp


; =============== S U B R O U T I N E =======================================


sub_4C141   proc near       ; CODE XREF: start+41Ap sub_4955B+39Bp ...
        mov si, 949Eh
        mov bx, word_51ABC
        sub bx, 2
        add si, bx
        mov al, [si]
        mov byte_59821, al
        mov al, [si+1]
        mov byte_59822, al
        mov al, [si+2]
        mov byte_59823, al
        mov ax, word_51ABC
        dec ax
        mov bx, 1Ch
        mul bx
        mov si, ax
        add si, 2A6Ch
        sub si, 1Ch
        push    si
        mov di, 974Ch
        mov ah, byte_59821
        call    sub_4BA5F
        pop si
        add si, 1Ch
        push    si
        mov di, 9B96h
        mov ah, byte_59822
        call    sub_4BA5F
        mov cx, 1Ch
        pop si
        push    si
        mov di, 87A8h
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        rep movsb
        pop es
        assume es:nothing
        pop si
        add si, 1Ch
        mov di, 9FE0h
        mov ah, byte_59823
        call    sub_4BA5F
        retn
sub_4C141   endp


; =============== S U B R O U T I N E =======================================


sub_4C1A9   proc near       ; CODE XREF: sub_4B419+15Ap
                    ; sub_4C2F2+11p
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov si, 9514h
        mov di, 836Bh
        mov cx, 3

loc_4C1B7:              ; CODE XREF: sub_4C1A9+56j
        push    cx
        push    si
        mov al, [si+0Bh]
        mov si, di
        add si, 0Fh
        call    sub_4BF4D
        mov si, di
        add si, 0Fh
        mov byte ptr [si], 3Ah ; ':'
        pop si
        push    si
        mov al, [si+0Ah]
        mov si, di
        add si, 0Ch
        call    sub_4BF4D
        mov si, di
        add si, 0Ch
        mov byte ptr [si], 3Ah ; ':'
        pop si
        push    si
        mov al, [si+9]
        mov si, di
        add si, 9
        mov ah, 20h ; ' '
        call    sub_4BF4F
        pop si
        push    si
        mov cx, 8
        rep movsb
        pop si
        add si, 0Ch
        add di, 0Bh
        pop cx
        loop    loc_4C1B7
        pop es
        assume es:nothing
        mov si, 836Bh
        mov ah, 8
        mov di, 5ACBh
        call    sub_4BA5F
        mov si, 837Eh
        mov ah, 8
        mov di, 5F15h
        call    sub_4BA5F
        mov si, 8391h
        mov ah, 8
        mov di, 635Fh
        call    sub_4BA5F
        retn
sub_4C1A9   endp


; =============== S U B R O U T I N E =======================================


sub_4C224   proc near       ; CODE XREF: sub_4C293+5Bp
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, bx
        add si, 8A9Ch
        mov bp, si
        mov di, 79C3h
        mov ah, 8
        call    sub_4BA5F
        mov di, bp
        xor ah, ah
        mov al, [di+0Bh]
        mov si, 8363h
        call    sub_4BF4D
        mov si, 8363h
        mov byte ptr [si], 3Ah ; ':'
        mov di, bp
        xor ah, ah
        mov al, [di+0Ah]
        sub si, 3
        call    sub_4BF4D
        mov si, 8360h
        mov byte ptr [si], 3Ah ; ':'
        mov di, bp
        xor ah, ah
        mov al, [di+9]
        sub si, 3
        call    sub_4BF4D
        mov si, 835Dh
        mov di, 79CAh
        mov ah, 8
        call    sub_4BA5F
        mov di, bp
        xor ah, ah
        mov al, [di+7Eh]
        mov si, 8367h
        call    sub_4BF4D
        mov si, 8367h
        mov di, 79D2h
        mov ah, 8
        call    sub_4BA5F
        retn
sub_4C224   endp


; =============== S U B R O U T I N E =======================================


sub_4C293   proc near       ; CODE XREF: start+32Cp start+407p ...
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, bx
        add si, 8A9Ch
        push    si
        mov di, 879Fh
        mov cx, 8
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        rep movsb
        pop es
        assume es:nothing
        sub si, 8
        mov di, 9B86h
        mov ah, 6
        call    sub_4BA5F
        pop si
        push    si
        cmp byte_5981F, 0
        jbe short loc_4C2CA
        sub si, 80h ; '?'
        jmp short loc_4C2CD
; ---------------------------------------------------------------------------

loc_4C2CA:              ; CODE XREF: sub_4C293+2Fj
        mov si, 821Dh

loc_4C2CD:              ; CODE XREF: sub_4C293+35j
        mov di, 973Ch
        mov ah, 8
        call    sub_4BA5F
        pop si
        cmp byte_5981F, 13h
        jnb short loc_4C2E3
        add si, 80h ; '?'
        jmp short loc_4C2E6
; ---------------------------------------------------------------------------

loc_4C2E3:              ; CODE XREF: sub_4C293+48j
        mov si, 821Dh

loc_4C2E6:              ; CODE XREF: sub_4C293+4Ej
        mov di, 9FD0h
        mov ah, 8
        call    sub_4BA5F
        call    sub_4C224
        retn
sub_4C293   endp


; =============== S U B R O U T I N E =======================================


sub_4C2F2   proc near       ; CODE XREF: sub_4B149+Cp
                    ; sub_4C407+1Fp ...
        mov si, 817Bh
        mov di, 89F7h
        mov ah, 4
        call    sub_4BA5F
        call    sub_4C293
        call    sub_4C141
        call    sub_4C1A9
        call    sub_4C0DD
        cmp byte_59B83, 0
        jz  short locret_4C349
        mov byte_59B83, 0
        cmp byte_5A19B, 0
        jz  short loc_4C32D
        cmp byte_5A19C, 0
        jz  short loc_4C328
        mov si, 9E8Dh
        jmp short loc_4C33C
; ---------------------------------------------------------------------------

loc_4C328:              ; CODE XREF: sub_4C2F2+2Fj
        mov si, 9EBDh
        jmp short loc_4C33C
; ---------------------------------------------------------------------------

loc_4C32D:              ; CODE XREF: sub_4C2F2+28j
        cmp byte_5A19C, 0
        jz  short loc_4C339
        mov si, 9EA5h
        jmp short loc_4C33C
; ---------------------------------------------------------------------------

loc_4C339:              ; CODE XREF: sub_4C2F2+40j
        mov si, 9ED5h

loc_4C33C:              ; CODE XREF: sub_4C2F2+34j
                    ; sub_4C2F2+39j ...
        mov di, 89F7h
        mov ah, 4
        call    sub_4BA5F
        mov byte_5A19B, 0

locret_4C349:               ; CODE XREF: sub_4C2F2+1Cj
        retn
sub_4C2F2   endp


; =============== S U B R O U T I N E =======================================


sub_4C34A   proc near       ; CODE XREF: start+404p sub_4AB1B+1E0p ...
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8AA8h
        add si, bx
        mov di, 8A9Ch
        add di, bx
        push    di
        mov di, 949Eh
        mov cx, 6Fh ; 'o'
        mov al, 6

loc_4C365:              ; CODE XREF: sub_4C34A+1Ej
        mov [di], al
        inc di
        loop    loc_4C365
        push    si
        mov al, 1
        mov cx, 6Fh ; 'o'
        mov di, 949Eh

loc_4C373:              ; CODE XREF: sub_4C34A+53j
        mov ah, [si]
        cmp ah, 2
        jnz short loc_4C37F
        mov byte ptr [di], 8
        jmp short loc_4C39B
; ---------------------------------------------------------------------------

loc_4C37F:              ; CODE XREF: sub_4C34A+2Ej
        cmp ah, 1
        jnz short loc_4C389
        mov byte ptr [di], 4
        jmp short loc_4C39B
; ---------------------------------------------------------------------------

loc_4C389:              ; CODE XREF: sub_4C34A+38j
        or  ah, ah
        jnz short loc_4C39B
        cmp al, 1
        jnz short loc_4C396
        mov byte ptr [di], 2
        jmp short loc_4C399
; ---------------------------------------------------------------------------

loc_4C396:              ; CODE XREF: sub_4C34A+45j
        mov byte ptr [di], 6

loc_4C399:              ; CODE XREF: sub_4C34A+4Aj
        mov al, ah

loc_4C39B:              ; CODE XREF: sub_4C34A+33j
                    ; sub_4C34A+3Dj ...
        inc si
        inc di
        loop    loc_4C373
        pop si
        pop di
        mov cx, 6Fh ; 'o'
        mov bx, 1

loc_4C3A7:              ; CODE XREF: sub_4C34A+65j
        mov al, [si]
        cmp al, 0
        jz  short loc_4C3D6
        inc si
        inc bx
        loop    loc_4C3A7
        sub si, 6Fh ; 'o'
        mov bx, 1
        mov cx, 6Fh ; 'o'

loc_4C3BA:              ; CODE XREF: sub_4C34A+78j
        mov al, [si]
        cmp al, 2
        jz  short loc_4C3D6
        inc si
        inc bx
        loop    loc_4C3BA
        cmp byte_51ABE, 0
        jz  short loc_4C3D1
        mov word_51ABC, 71h ; 'q'

loc_4C3D1:              ; CODE XREF: sub_4C34A+7Fj
        mov byte ptr [di+7Eh], 71h ; 'q'
        retn
; ---------------------------------------------------------------------------

loc_4C3D6:              ; CODE XREF: sub_4C34A+61j
                    ; sub_4C34A+74j
        cmp byte_51ABE, 0
        jz  short loc_4C3E1
        mov word_51ABC, bx

loc_4C3E1:              ; CODE XREF: sub_4C34A+91j
        cmp bl, 1
        jnz short loc_4C403
        cmp word ptr [di], 2D2Dh
        jnz short loc_4C403
        cmp word ptr [di+2], 2D2Dh
        jnz short loc_4C403
        cmp word ptr [di+4], 2D2Dh
        jnz short loc_4C403
        cmp word ptr [di+6], 2D2Dh
        jnz short loc_4C403
        mov bl, 0

loc_4C403:              ; CODE XREF: sub_4C34A+9Aj
                    ; sub_4C34A+A0j ...
        mov [di+7Eh], bl
        retn
sub_4C34A   endp


; =============== S U B R O U T I N E =======================================


sub_4C407   proc near       ; CODE XREF: runMainMenu+5Dp
        mov byte_510A6, 0
        cmp byte_510BA, 0
        jz  short loc_4C431
        mov byte_510BA, 0
        call    sub_4C4F9
        call    sub_4C611
        mov byte_51ABE, 0
        call    sub_4C34A
        call    sub_4C2F2
        mov si, 6015h
        call    fade
        jmp short loc_4C499
; ---------------------------------------------------------------------------

loc_4C431:              ; CODE XREF: sub_4C407+Aj
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        cmp word_5195F, 140h
        jb  short loc_4C449
        mov di, 4D34h
        call    sub_4C4BD

loc_4C449:              ; CODE XREF: sub_4C407+3Aj
        mov di, 4D84h
        call    sub_4C4BD

;ploc_4C44F::
loc_4C44F:              ; CODE XREF: sub_4B149+9p
        call    sub_4C611
        mov byte_51ABE, 0
        call    sub_4C34A
        call    sub_4C2F2
        call    videoloop
        call    sub_4D457
        mov bx, 4D83h

loc_4C466:              ; CODE XREF: sub_4C407+90j
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov byte_510A6, 7
        call    videoloop
        call    sub_4D457
        mov byte_510A6, 3
        call    videoloop
        call    sub_4D457
        sub bx, 1
        cmp bx, 4D5Ch
        jnb short loc_4C466

loc_4C499:              ; CODE XREF: sub_4C407+28j
        mov bx, 4D5Ch
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov byte_510A6, 0
        call    videoloop
        retn
sub_4C407   endp


; =============== S U B R O U T I N E =======================================


sub_4C4BD   proc near       ; CODE XREF: sub_4C407+3Fp
                    ; sub_4C407+45p
        mov si, word_51967
        mov word_51967, di
        mov bx, di
        mov dx, 0C8h ; '?'
        push    ds
        mov ax, es
        mov ds, ax

loc_4C4CF:              ; CODE XREF: sub_4C4BD+1Ej
        mov cx, 28h ; '('
        rep movsb
        add si, 52h ; 'R'
        add di, 52h ; 'R'
        dec dx
        jnz short loc_4C4CF
        pop ds
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        call    sub_4D457
        retn
sub_4C4BD   endp


; =============== S U B R O U T I N E =======================================


sub_4C4F9   proc near       ; CODE XREF: sub_4C407+11p
        mov si, 60D5h
        call    sub_4D836
        call    vgaloadbackseg
        mov si, 8577h
        mov di, 6A2Ch
        mov ah, 0Fh
        call    sub_4BDF0
        cmp byte_5195A, 0
        jnz short loc_4C52C
        mov si, 8582h
        mov di, 73A9h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 85ACh
        mov di, 7D35h
        mov ah, 0Fh
        call    sub_4BDF0
        jmp short loc_4C55C
; ---------------------------------------------------------------------------

loc_4C52C:              ; CODE XREF: sub_4C4F9+19j
        mov si, 85DCh
        mov al, byte_5195B
        sub al, byte_5195A
        mov ah, 20h ; ' '
        call    sub_4BF4F
        mov si, 85EBh
        mov al, byte_5195B
        mov ah, 20h ; ' '
        call    sub_4BF4F
        mov si, 85C9h
        mov di, 73A9h
        mov ah, 0Fh
        call    sub_4BDF0
        mov si, 85EFh
        mov di, 7D39h
        mov ah, 0Fh
        call    sub_4BDF0

loc_4C55C:              ; CODE XREF: sub_4C4F9+31j
        mov si, 8600h
        mov di, 86BDh
        mov ah, 0Fh
        call    sub_4BDF0
        mov bx, 4D84h
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        mov si, 5FD5h
        call    sub_4D836
        cmp word_5197A, 1
        jz  short loc_4C591
        call    sub_47E98

loc_4C591:              ; CODE XREF: sub_4C4F9+93j
        mov si, 60D5h
        call    sub_4D836
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        retn
sub_4C4F9   endp


; =============== S U B R O U T I N E =======================================


sub_4C5AF   proc near       ; CODE XREF: sub_4B149+3p
        mov byte_510A6, 0
        call    videoloop
        mov bx, 4D5Ch

loc_4C5BA:              ; CODE XREF: sub_4C5AF+3Cj
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov byte_510A6, 1
        call    videoloop
        call    sub_4D457
        mov byte_510A6, 5
        call    videoloop
        call    sub_4D457
        add bx, 1
        cmp bx, 4D84h
        jb  short loc_4C5BA
        mov bx, 4D84h
        mov word_51967, bx
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov byte_510A6, 0
        call    videoloop
        retn
sub_4C5AF   endp


; =============== S U B R O U T I N E =======================================


sub_4C611   proc near       ; CODE XREF: sub_4C407+14p
                    ; sub_4C407:loc_4C44Fp ...
        push    ds
        mov ax, seg menuseg
        mov ds, ax
        assume ds:nothing
        mov si, 0
        mov di, 4D5Ch
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0C8h ; '?'

loc_4C63E:              ; CODE XREF: sub_4C611+4Dj
        push    cx
        mov ah, 1

loc_4C641:              ; CODE XREF: sub_4C611+47j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_4C641
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4C63E
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        pop ds
        assume ds:data
        retn
sub_4C611   endp


; =============== S U B R O U T I N E =======================================


vgaloadgfxseg:
        push    ds
        mov ax, seg gfxseg

; START OF FUNCTION CHUNK FOR vgaloadbackseg

vgaloadseginax:              ; CODE XREF: vgaloadbackseg+4j code:5AD9j
        mov ds, ax
        assume ds:nothing
        mov si, 0
        mov di, 4D84h
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0C8h ; '?'

loc_4C6AD:              ; CODE XREF: vgaloadbackseg-22j
        push    cx
        mov ah, 1

loc_4C6B0:              ; CODE XREF: vgaloadbackseg-28j
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_4C6B0
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_4C6AD
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        pop ds
        assume ds:data
        retn
; END OF FUNCTION CHUNK FOR vgaloadbackseg

; =============== S U B R O U T I N E =======================================


vgaloadbackseg:
        push    ds
        mov ax, backseg
        jmp short vgaloadseginax

; ---------------------------------------------------------------------------
vgaloadcontrolsseg:
        push ds
        mov ax, controlsseg
        jmp short vgaloadseginax
; ---------------------------------------------------------------------------
loc_4C6FB:
        call    sub_4C705
        call    sound?4
        call    sub_4CAFC
        retn

; =============== S U B R O U T I N E =======================================


sub_4C705   proc near       ; CODE XREF: code:5ADBp
        call    loadBeep
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C705   endp


; =============== S U B R O U T I N E =======================================


sub_4C70F   proc near
        call    loadBeep2
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C70F   endp


; =============== S U B R O U T I N E =======================================


sub_4C719   proc near
        call    loadBlaster
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C719   endp


; =============== S U B R O U T I N E =======================================


sub_4C723   proc near
        call    loadAdlib
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C723   endp


; =============== S U B R O U T I N E =======================================


sub_4C72D   proc near
        call    loadRoland
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C72D   endp


; =============== S U B R O U T I N E =======================================


sub_4C737   proc near
        call    loadCombined
        call    sound?4
        call    sub_4CAFC
        retn
sub_4C737   endp


; =============== S U B R O U T I N E =======================================


sub_4C741   proc near
        cmp byte_59886, 1
        jnz short loc_4C752
        call    sound?3
        mov byte_59886, 0
        jmp short loc_4C75A
; ---------------------------------------------------------------------------

loc_4C752:              ; CODE XREF: sub_4C741+5j
        mov byte_59886, 1
        call    sound?2

loc_4C75A:              ; CODE XREF: sub_4C741+Fj
        call    sub_4CC7C
        retn
sub_4C741   endp

; ---------------------------------------------------------------------------
loc_4C75E:
        cmp byte_59885, 1
        jnz short loc_4C76C
        mov byte_59885, 0
        jmp short loc_4C774
; ---------------------------------------------------------------------------

loc_4C76C:              ; CODE XREF: code:5B43j
        mov byte_59885, 1
        call    sound?4

loc_4C774:              ; CODE XREF: code:5B4Aj
        call    sub_4CC7C
        retn
; ---------------------------------------------------------------------------
loc_4C778:
        mov byte_50940, 0
        call    sub_4CCDF
        retn
; ---------------------------------------------------------------------------
loc_4C781:
        mov byte_50940, 1
        call    sub_4921B
        call    sub_4CCDF
        retn
; ---------------------------------------------------------------------------
loc_4C78D:
        mov word_58463, 1
        retn

; =============== S U B R O U T I N E =======================================


runMainMenu proc near       ; CODE XREF: start+43Ap
        mov byte_5A33E, 0
        mov word_599D8, 0
        mov byte_599D4, 0
        mov word_58465, 0EF98h
        cmp word_58467, 0
        jz  short loc_4C7EC
        call    sub_4C611
        mov byte_51ABE, 1
        call    sub_4C34A
        call    sub_4C2F2
        mov bx, 4D5Ch
        mov dx, 3D4h
        mov al, 0Dh
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (low)
        inc dx
        mov al, bl
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 0Ch
        out dx, al      ; Video: CRT cntrlr addr
                    ; regen start address (high)
        inc dx
        mov al, bh
        out dx, al      ; Video: CRT controller internal registers
        mov byte_510A6, 0
        call    videoloop
        mov si, 6015h
        call    fade
        mov word_58467, 0
        jmp short loc_4C7F4
; ---------------------------------------------------------------------------

loc_4C7EC:              ; CODE XREF: runMainMenu+1Bj
        mov byte_59B83, 1
        call    sub_4C407

loc_4C7F4:              ; CODE XREF: runMainMenu+56j
        call    sound?2
        call    sub_4B85C
        call    sub_4B8BE

loc_4C7FD:              ; CODE XREF: runMainMenu+121j
                    ; runMainMenu+219j ...
        inc word_58465
        jnz short loc_4C806
        call    sub_4B159

loc_4C806:              ; CODE XREF: runMainMenu+6Dj
        cmp word_5196C, 0
        jz  short loc_4C81A
        mov word_5196C, 0
        call    sub_4CFB2
        call    sub_4CFDB
        retn
; ---------------------------------------------------------------------------

loc_4C81A:              ; CODE XREF: runMainMenu+77j
        call    videoloop
        inc word_5195D
        call    getMouseStatus
        mov word_5847D, bx
        cmp mousex, cx
        jnz short loc_4C834
        cmp mousey, dx
        jz  short loc_4C83A

loc_4C834:              ; CODE XREF: runMainMenu+98j
        mov word_58465, 0EF98h

loc_4C83A:              ; CODE XREF: runMainMenu+9Ej
        mov mousex, cx
        mov mousey, dx
        call    sub_4B899
        call    sub_4B85C
        call    sub_4B8BE
        call    sub_4D0AD
        call    sub_48E59
        call    sub_4A1BF
        cmp byte_50910, 0
        jnz short loc_4C862
        cmp byte_50911, 0
        jz  short loc_4C867

loc_4C862:              ; CODE XREF: runMainMenu+C5j
        mov byte_50912, 1

loc_4C867:              ; CODE XREF: runMainMenu+CCj
        mov byte_50910, 0
        mov byte_50911, 0
        cmp byte_50913, 0
        jnz short loc_4C87F
        cmp byte_50914, 0
        jz  short loc_4C884

loc_4C87F:              ; CODE XREF: runMainMenu+E2j
        mov byte_50915, 1

loc_4C884:              ; CODE XREF: runMainMenu+E9j
        mov byte_50913, 0
        mov byte_50914, 0
        cmp byte_50916, 0
        jnz short loc_4C89C
        cmp byte_50917, 0
        jz  short loc_4C8A1

loc_4C89C:              ; CODE XREF: runMainMenu+FFj
        mov byte_50918, 1

loc_4C8A1:              ; CODE XREF: runMainMenu+106j
        mov byte_50916, 0
        mov byte_50917, 0
        cmp byte_50941, 4
        jle short loc_4C8B8
        call    sub_4B375
        jmp loc_4C7FD
; ---------------------------------------------------------------------------

loc_4C8B8:              ; CODE XREF: runMainMenu+11Cj
        cmp byte_519B8, 1
        jnz short loc_4C8C8
        mov ax, 0
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C8C8:              ; CODE XREF: runMainMenu+129j
        cmp byte_519B9, 1
        jnz short loc_4C8D8
        mov ax, 1
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C8D8:              ; CODE XREF: runMainMenu+139j
        cmp byte_519BA, 1
        jnz short loc_4C8E8
        mov ax, 2
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C8E8:              ; CODE XREF: runMainMenu+149j
        cmp byte_519BB, 1
        jnz short loc_4C8F8
        mov ax, 3
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C8F8:              ; CODE XREF: runMainMenu+159j
        cmp byte_519BC, 1
        jnz short loc_4C908
        mov ax, 4
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C908:              ; CODE XREF: runMainMenu+169j
        cmp byte_519BD, 1
        jnz short loc_4C918
        mov ax, 5
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C918:              ; CODE XREF: runMainMenu+179j
        cmp byte_519BE, 1
        jnz short loc_4C928
        mov ax, 6
        call    demoSomething?
        jmp loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C928:              ; CODE XREF: runMainMenu+189j
        cmp byte_519BF, 1
        jnz short loc_4C937
        mov ax, 7
        call    demoSomething?
        jmp short loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C937:              ; CODE XREF: runMainMenu+199j
        cmp byte_519C0, 1
        jnz short loc_4C946
        mov ax, 8
        call    demoSomething?
        jmp short loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C946:              ; CODE XREF: runMainMenu+1A8j
        cmp byte_519C1, 1
        jnz short loc_4C955
        mov ax, 9
        call    demoSomething?
        jmp short loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C955:              ; CODE XREF: runMainMenu+1B7j
        cmp byte_519D4, 1
        jnz short loc_4C977
        cmp demoFileName, 0
        jz  short loc_4C977
        cmp byte_599D5, 1
        jnz short loc_4C977
        mov byte_599D4, 1
        mov ax, 0
        call    demoSomething?
        jmp short loc_4C9B0
; ---------------------------------------------------------------------------

loc_4C977:              ; CODE XREF: runMainMenu+1C6j
                    ; runMainMenu+1CDj ...
        cmp byte_519D5, 1
        jnz short loc_4C9B0
        cmp demoFileName, 0
        jz  short loc_4C9B0
        mov byte_599D4, 1
        mov word_5196C, 1
        mov byte_510DE, 0
        mov byte_510B3, 0
        mov byte_5A2F9, 1
        call    sub_49544
        mov byte ptr a00s0010_sp+3, 2Dh ; '-' ; "001$0.SP"
        mov word ptr a00s0010_sp+4, 2D2Dh ; "01$0.SP"
        jmp loc_4C7FD
; ---------------------------------------------------------------------------

loc_4C9B0:              ; CODE XREF: runMainMenu+131j
                    ; runMainMenu+141j ...
        mov bx, word_5847D
        cmp bx, 2
        jz  short loc_4CA34
        cmp byte_5197E, 1
        jz  short loc_4CA34
        cmp word_5197A, 1
        jz  short loc_4CA34
        cmp bx, 1
        jz  short loc_4C9FF
        mov word_58469, 10h
        mov word_5846B, 0
        mov word_5846D, 10h
        mov word_5846F, 0
        mov word_58471, 10h
        mov word_58473, 0
        mov word_59B8C, 10h
        mov word_59B8E, 0
        jmp loc_4C7FD
; ---------------------------------------------------------------------------

loc_4C9FF:              ; CODE XREF: runMainMenu+236j
        mov word_58465, 0EF98h
        mov cx, mousex
        mov dx, mousey
        mov si, offset menudata

checkmousecoords:              ; CODE XREF: runMainMenu+29Bj
        cmp [si], cx
        jg  short nomousehit
        cmp [si+2], dx
        jg  short nomousehit
        cmp [si+4], cx
        jl  short nomousehit
        cmp [si+6], dx
        jl  short nomousehit
        call [si+8]
        jmp loc_4C7FD
; ---------------------------------------------------------------------------

nomousehit:              ; CODE XREF: runMainMenu+27Ej
                    ; runMainMenu+283j ...
        add si, 0Ah
        cmp word ptr [si], 0FFFFh
        jnz short checkmousecoords
        jmp loc_4C7FD
; ---------------------------------------------------------------------------

loc_4CA34:              ; CODE XREF: runMainMenu+223j
                    ; runMainMenu+22Aj ...
        mov word_5197A, 1
        call    sub_4CFB2
        call    sub_4CFDB
        retn
runMainMenu endp

; ---------------------------------------------------------------------------

showControls:                              ; DATA XREF: data:0044o
                mov     byte_50919, 0FFh
                call    vgaloadcontrolsseg
                call    sub_4CAFC
                call    sub_4CC7C
                call    sub_4CCDF
                mov     si, 6055h
                call    sub_4D836
                call    sub_4C5AF  ; DO SLIDE
                mov     word_58463, 0
                call    sub_4B85C
                call    sub_4B8BE

loc_4CA67:                              ; CODE XREF: code:5E89j
                                        ; code:5EBFj ...
                call    videoloop
                call    sub_4CD3C
                inc     word_5195D
                call    getMouseStatus
                mov     word_5847D, bx
                add     cx, 140h
                mov     mousex, cx
                mov     mousey, dx
                call    sub_4B899
                call    sub_4B85C
                call    sub_4B8BE
                mov     bx, word_5847D
                cmp     bx, 2
                jz      short loc_4CAEC
                cmp     byte_5197E, 1
                jz      short loc_4CAEC
                cmp     word_58463, 1
                jz      short loc_4CAEC
                cmp     bx, 1
                jz      short loc_4CAAB
                jmp     short loc_4CA67
; ---------------------------------------------------------------------------

loc_4CAAB:                              ; CODE XREF: code:5E87j
                mov     cx, mousex
                sub     cx, 140h
                mov     dx, mousey
                mov     si, offset controlsbuttons ; 0ACh

loc_4CABA:                              ; CODE XREF: code:5EC7j
                cmp     [si], cx
                jg      short loc_4CAE1
                cmp     [si+2], dx
                jg      short loc_4CAE1
                cmp     [si+4], cx
                jl      short loc_4CAE1
                cmp     [si+6], dx
                jl      short loc_4CAE1
                call    word ptr [si+8]

loc_4CAD0:                              ; CODE XREF: code:5EBDj
                call    videoloop
                inc     word_5195D
                call    getMouseStatus
                cmp     bx, 0
                jnz     short loc_4CAD0
                jmp     short loc_4CA67
; ---------------------------------------------------------------------------

loc_4CAE1:                              ; CODE XREF: code:5E9Cj
                                        ; code:5EA1j ...
                add     si, 0Ah
                cmp     word ptr [si], 0FFFFh
                jnz     short loc_4CABA
                jmp     loc_4CA67
; ---------------------------------------------------------------------------

loc_4CAEC:                              ; CODE XREF: code:5E74j
                                        ; code:5E7Bj ...
                call    sub_4755A
                call    loc_4C44F
                call    sub_4C2F2
                mov     si, 6015h
                call    sub_4D836
                retn

; =============== S U B R O U T I N E =======================================


sub_4CAFC   proc near       ; CODE XREF: code:5AE1p sub_4C705+6p ...
        mov si, 578Bh
        mov cx, 5
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 130h
        call    sub_4CF13
        mov ah, 4
        mov si, 161h
        call    sub_4CF13
        mov si, 68B1h
        mov cx, 9
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 1A7h
        call    sub_4CF13
        mov ah, 4
        mov si, 1CAh
        call    sub_4CF13
        mov si, 79DAh
        mov cx, 7
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 1F4h
        call    sub_4CF13
        mov ah, 4
        mov si, 225h
        call    sub_4CF13
        mov si, 8B01h
        mov cx, 8
        mov dx, 8
        call    sub_4CE9C
        mov si, 5629h
        mov cx, 9
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 2E2h
        call    sub_4CF13
        mov si, 6380h
        mov cx, 5
        mov dx, 5
        call    sub_4CE9C
        mov ah, 4
        mov si, 328h
        call    sub_4CF13
        mov si, 6386h
        mov cx, 5
        mov dx, 5
        call    sub_4CE9C
        mov ah, 4
        mov si, 36Eh
        call    sub_4CF13
        mov ah, 4
        mov si, 28Eh
        call    sub_4CF13
        cmp sndType, 3
        jnz short loc_4CBC6
        mov si, 578Bh
        mov cx, 5
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 130h
        call    sub_4CF13
        mov ah, 6
        mov si, 161h
        call    sub_4CF13
        jmp locret_4CC7B
; ---------------------------------------------------------------------------

loc_4CBC6:              ; CODE XREF: sub_4CAFC+A9j
        cmp sndType, 4
        jnz short loc_4CC11
        mov ah, 6
        mov si, 1CAh
        call    sub_4CF13
        cmp musType, 3
        jnz short loc_4CBF3
        mov si, 68B1h
        mov cx, 9
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 1A7h
        call    sub_4CF13
        jmp locret_4CC7B
; ---------------------------------------------------------------------------

loc_4CBF3:              ; CODE XREF: sub_4CAFC+DEj
        mov si, 8B01h
        mov cx, 8
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 1F4h
        call    sub_4CF13
        mov ah, 6
        mov si, 28Eh
        call    sub_4CF13
        jmp short locret_4CC7B
; ---------------------------------------------------------------------------

loc_4CC11:              ; CODE XREF: sub_4CAFC+CFj
        cmp sndType, 5
        jnz short loc_4CC36
        mov si, 79DAh
        mov cx, 7
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 1F4h
        call    sub_4CF13
        mov ah, 6
        mov si, 225h
        call    sub_4CF13
        jmp short locret_4CC7B
; ---------------------------------------------------------------------------

loc_4CC36:              ; CODE XREF: sub_4CAFC+11Aj
        mov si, 5629h
        mov cx, 9
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 2E2h
        call    sub_4CF13
        cmp sndType, 1
        jnz short loc_4CC67
        mov si, 6380h
        mov cx, 5
        mov dx, 5
        call    sub_4CE11
        mov ah, 6
        mov si, 328h
        call    sub_4CF13
        jmp short locret_4CC7B
; ---------------------------------------------------------------------------

loc_4CC67:              ; CODE XREF: sub_4CAFC+153j
        mov si, 6386h
        mov cx, 5
        mov dx, 5
        call    sub_4CE11
        mov ah, 6
        mov si, 36Eh
        call    sub_4CF13

locret_4CC7B:               ; CODE XREF: sub_4CAFC+C7j
                    ; sub_4CAFC+F4j ...
        retn
sub_4CAFC   endp


; =============== S U B R O U T I N E =======================================


sub_4CC7C   proc near       ; CODE XREF: sub_4C741:loc_4C75Ap
                    ; code:loc_4C774p
        cmp byte_59886, 1
        jnz short loc_4CC99
        mov si, 7CC3h
        mov cx, 5
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 3B4h
        call    sub_4CF13
        jmp short loc_4CCAD
; ---------------------------------------------------------------------------

loc_4CC99:              ; CODE XREF: sub_4CC7C+5j
        mov si, 7CC3h
        mov cx, 5
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 3B4h
        call    sub_4CF13

loc_4CCAD:              ; CODE XREF: sub_4CC7C+1Bj
        cmp byte_59885, 1
        jnz short loc_4CCCA
        mov si, 8F59h
        mov cx, 3
        mov dx, 8
        call    sub_4CE11
        mov ah, 6
        mov si, 3DEh
        call    sub_4CF13
        jmp short locret_4CCDE
; ---------------------------------------------------------------------------

loc_4CCCA:              ; CODE XREF: sub_4CC7C+36j
        mov si, 8F59h
        mov cx, 3
        mov dx, 8
        call    sub_4CE9C
        mov ah, 4
        mov si, 3DEh
        call    sub_4CF13

locret_4CCDE:               ; CODE XREF: sub_4CC7C+4Cj
        retn
sub_4CC7C   endp


; =============== S U B R O U T I N E =======================================


sub_4CCDF   proc near       ; CODE XREF: code:5B5Dp code:5B69p
        cmp byte_50940, 0
        jnz short loc_4CD10
        mov si, 7714h
        mov cx, 1
        mov dx, 3Eh ; '>'
        call    sub_4CE11
        mov si, 7792h
        mov cx, 1
        mov dx, 3Ah ; ':'
        call    sub_4CE9C
        mov ah, 4
        mov si, 478h
        call    sub_4CF13
        mov ah, 6
        mov si, 4E1h
        call    sub_4CF13
        jmp short loc_4CD38
; ---------------------------------------------------------------------------

loc_4CD10:              ; CODE XREF: sub_4CCDF+5j
        mov si, 7714h
        mov cx, 1
        mov dx, 3Eh ; '>'
        call    sub_4CE9C
        mov si, 7792h
        mov cx, 1
        mov dx, 3Ah ; ':'
        call    sub_4CE11
        mov ah, 6
        mov si, 478h
        call    sub_4CF13
        mov ah, 4
        mov si, 4E1h
        call    sub_4CF13

loc_4CD38:              ; CODE XREF: sub_4CCDF+2Fj
        call    sub_4CD3C
        retn
sub_4CCDF   endp


; =============== S U B R O U T I N E =======================================


sub_4CD3C   proc near       ; CODE XREF: sub_4CCDF:loc_4CD38p
        call    sub_48E59
        call    sub_4A1BF
        mov bl, byte_50941
        cmp bl, byte_50919
        jnz short loc_4CD4D
        retn
; ---------------------------------------------------------------------------

loc_4CD4D:              ; CODE XREF: sub_4CD3C+Ej
        mov byte_50919, bl
        cmp byte_50941, 0
        jnz short loc_4CD6A
        mov ah, 6
        mov si, 424h
        call    sub_4CF13
        mov ah, 4
        mov si, 46Ah
        call    sub_4CF13
        jmp short loc_4CDAE
; ---------------------------------------------------------------------------

loc_4CD6A:              ; CODE XREF: sub_4CD3C+1Aj
        cmp byte_50941, 4
        jbe short loc_4CD9E
        mov ah, 6
        mov si, 46Ah
        call    sub_4CF13
        cmp byte_50941, 9
        jnz short loc_4CD8F
        mov byte_50941, 0
        mov ah, 6
        mov si, 424h
        call    sub_4CF13
        jmp short loc_4CDAE
; ---------------------------------------------------------------------------

loc_4CD8F:              ; CODE XREF: sub_4CD3C+42j
        sub byte_50941, 4
        mov ah, 4
        mov si, 424h
        call    sub_4CF13
        jmp short loc_4CDAE
; ---------------------------------------------------------------------------

loc_4CD9E:              ; CODE XREF: sub_4CD3C+33j
        mov ah, 4
        mov si, 424h
        call    sub_4CF13
        mov ah, 4
        mov si, 46Ah
        call    sub_4CF13

loc_4CDAE:              ; CODE XREF: sub_4CD3C+2Cj
                    ; sub_4CD3C+51j ...
        mov ah, 4
        mov si, 432h
        call    sub_4CF13
        mov ah, 4
        mov si, 440h
        call    sub_4CF13
        mov ah, 4
        mov si, 44Eh
        call    sub_4CF13
        mov ah, 4
        mov si, 45Ch
        call    sub_4CF13
        cmp byte_50941, 1
        jnz short loc_4CDDF
        mov ah, 6
        mov si, 432h
        call    sub_4CF13
        jmp short locret_4CE10
; ---------------------------------------------------------------------------

loc_4CDDF:              ; CODE XREF: sub_4CD3C+97j
        cmp byte_50941, 2
        jnz short loc_4CDF0
        mov ah, 6
        mov si, 440h
        call    sub_4CF13
        jmp short locret_4CE10
; ---------------------------------------------------------------------------

loc_4CDF0:              ; CODE XREF: sub_4CD3C+A8j
        cmp byte_50941, 3
        jnz short loc_4CE01
        mov ah, 6
        mov si, 44Eh
        call    sub_4CF13
        jmp short locret_4CE10
; ---------------------------------------------------------------------------

loc_4CE01:              ; CODE XREF: sub_4CD3C+B9j
        cmp byte_50941, 4
        jnz short locret_4CE10
        mov ah, 6
        mov si, 45Ch
        call    sub_4CF13

locret_4CE10:               ; CODE XREF: sub_4CD3C+A1j
                    ; sub_4CD3C+B2j ...
        retn
sub_4CD3C   endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

sub_4CE11   proc near       ; CODE XREF: sub_4CAFC+B4p
                    ; sub_4CAFC+E9p ...

var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFFEh
        push    si
        push    cx
        push    dx
        call    sub_4B899
        pop dx
        pop cx
        pop si
        mov bx, dx
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 8
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 7
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color masking disable
                    ; bits 0-3 disable planes from compare logic in read mode 01
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov di, si
        push    ds
        mov ax, es
        mov ds, ax
        mov [bp+var_2], cx
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register

loc_4CE68:              ; CODE XREF: sub_4CE11+5Aj
                    ; sub_4CE11+6Aj
        lodsb
        out dx, al      ; EGA port: graphics controller data register
        stosb
        loop    loc_4CE68
        mov cx, [bp+var_2]
        add si, 7Ah ; 'z'
        sub si, cx
        add di, 7Ah ; 'z'
        sub di, cx
        dec bx
        jnz short loc_4CE68
        pop ds
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        call    sub_4B85C
        call    sub_4B8BE
        mov sp, bp
        pop bp
        retn
sub_4CE11   endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

sub_4CE9C   proc near       ; CODE XREF: sub_4CAFC+9p
                    ; sub_4CAFC+25p ...

var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFFEh
        push    si
        push    cx
        push    dx
        call    sub_4B899
        pop dx
        pop cx
        pop si
        mov bx, dx
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 8
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 2
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color compare.
                    ; Data bits 0-3 select color for read mode 01
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 7
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; color masking disable
                    ; bits 0-3 disable planes from compare logic in read mode 01
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov di, si
        push    ds
        mov ax, es
        mov ds, ax
        mov [bp+var_2], cx
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register

loc_4CEF3:              ; CODE XREF: sub_4CE9C+5Aj
                    ; sub_4CE9C+6Aj
        lodsb
        out dx, al      ; EGA port: graphics controller data register
        stosb
        loop    loc_4CEF3
        mov cx, [bp+var_2]
        add si, 7Ah ; 'z'
        sub si, cx
        add di, 7Ah ; 'z'
        sub di, cx
        dec bx
        jnz short loc_4CEF3
        pop ds
        call    sub_4B85C
        call    sub_4B8BE
        mov sp, bp
        pop bp
        retn
sub_4CE9C   endp


; =============== S U B R O U T I N E =======================================


sub_4CF13   proc near       ; CODE XREF: sub_4CAFC+11p
                    ; sub_4CAFC+19p ...
        push    si
        push    ax
        call    sub_4B899
        pop ax
        pop si
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register

loc_4CF38:              ; CODE XREF: sub_4CF13+96j
        mov bl, [si]
        cmp bl, 0FFh
        jz  short loc_4CFAB
        mov di, 4D84h
        mov ax, [si+3]
        mov cx, 7Ah ; 'z'
        mul cx
        add di, ax
        mov dx, [si+1]
        mov cx, dx
        shr dx, 1
        shr dx, 1
        shr dx, 1
        add di, dx
        and cl, 7
        mov ah, 80h ; '?'
        shr ah, cl
        mov cx, [si+5]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov al, ah

loc_4CF6F:              ; CODE XREF: sub_4CF13:loc_4CFA4j
        out dx, al      ; EGA port: graphics controller data register
        xor es:[di], al
        or  bl, bl
        jnz short loc_4CF7E
        ror al, 1
        jnb short loc_4CF7C
        inc di

loc_4CF7C:              ; CODE XREF: sub_4CF13+66j
        jmp short loc_4CFA4
; ---------------------------------------------------------------------------

loc_4CF7E:              ; CODE XREF: sub_4CF13+62j
        cmp bl, 1
        jnz short loc_4CF88
        sub di, 7Ah ; 'z'
        jmp short loc_4CFA4
; ---------------------------------------------------------------------------

loc_4CF88:              ; CODE XREF: sub_4CF13+6Ej
        cmp bl, 2
        jnz short loc_4CF97
        sub di, 7Ah ; 'z'
        ror al, 1
        jnb short loc_4CF95
        inc di

loc_4CF95:              ; CODE XREF: sub_4CF13+7Fj
        jmp short loc_4CFA4
; ---------------------------------------------------------------------------

loc_4CF97:              ; CODE XREF: sub_4CF13+78j
        cmp bl, 3
        jnz short loc_4CFA4
        add di, 7Ah ; 'z'
        ror al, 1
        jnb short loc_4CFA4
        inc di

loc_4CFA4:              ; CODE XREF: sub_4CF13:loc_4CF7Cj
                    ; sub_4CF13+73j ...
        loop    loc_4CF6F
        add si, 7
        jmp short loc_4CF38
; ---------------------------------------------------------------------------

loc_4CFAB:              ; CODE XREF: sub_4CF13+2Aj
        call    sub_4B85C
        call    sub_4B8BE
        retn
sub_4CF13   endp


; =============== S U B R O U T I N E =======================================


sub_4CFB2   proc near       ; CODE XREF: sub_4AB1B+1D5p
                    ; sub_4AD0E+CEp ...
        cmp byte_59B85, 0
        jnz short locret_4CFDA
        mov ax, 3C00h
        mov cx, 2
        mov dx, 37E5h
        int 21h     ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                    ; CX = attributes for file
                    ; DS:DX -> ASCIZ filename (may include drive and path)
        jb  short locret_4CFDA
        mov bx, ax
        mov ax, 4000h
        mov cx, 0A00h
        mov dx, 8A9Ch
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        jb  short locret_4CFDA
        mov ax, 3E00h
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

locret_4CFDA:               ; CODE XREF: sub_4CFB2+5j
                    ; sub_4CFB2+12j ...
        retn
sub_4CFB2   endp


; =============== S U B R O U T I N E =======================================


sub_4CFDB   proc near       ; CODE XREF: sub_4AB1B+1D8p
                    ; sub_4AD0E+D1p ...
        cmp byte_59B85, 0
        jnz short locret_4D003
        mov ax, 3C00h
        mov cx, 2
        mov dx, 37FDh
        int 21h     ; DOS - 2+ - CREATE A FILE WITH HANDLE (CREAT)
                    ; CX = attributes for file
                    ; DS:DX -> ASCIZ filename (may include drive and path)
        jb  short locret_4D003
        mov bx, ax
        mov ax, 4000h
        mov cx, 24h ; '$'
        mov dx, 9514h
        int 21h     ; DOS - 2+ - WRITE TO FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to write, DS:DX -> buffer
        jb  short locret_4D003
        mov ax, 3E00h
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle

locret_4D003:               ; CODE XREF: sub_4CFDB+5j
                    ; sub_4CFDB+12j ...
        retn
sub_4CFDB   endp


; =============== S U B R O U T I N E =======================================


sub_4D004   proc near       ; CODE XREF: sub_4D0AD+17p
                    ; sub_4D0AD+2Ap ...
        push    si
        push    ax
        call    sub_4B899
        pop ax
        pop si
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register

loc_4D029:              ; CODE XREF: sub_4D004+96j
        mov bl, [si]
        cmp bl, 0FFh
        jz  short loc_4D09C
        mov di, 4D5Ch
        mov ax, [si+3]
        mov cx, 7Ah ; 'z'
        mul cx
        add di, ax
        mov dx, [si+1]
        mov cx, dx
        shr dx, 1
        shr dx, 1
        shr dx, 1
        add di, dx
        and cl, 7
        mov ah, 80h ; '?'
        shr ah, cl
        mov cx, [si+5]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        mov al, ah

loc_4D060:              ; CODE XREF: sub_4D004:loc_4D095j
        out dx, al      ; EGA port: graphics controller data register
        xor es:[di], al
        or  bl, bl
        jnz short loc_4D06F
        ror al, 1
        jnb short loc_4D06D
        inc di

loc_4D06D:              ; CODE XREF: sub_4D004+66j
        jmp short loc_4D095
; ---------------------------------------------------------------------------

loc_4D06F:              ; CODE XREF: sub_4D004+62j
        cmp bl, 1
        jnz short loc_4D079
        sub di, 7Ah ; 'z'
        jmp short loc_4D095
; ---------------------------------------------------------------------------

loc_4D079:              ; CODE XREF: sub_4D004+6Ej
        cmp bl, 2
        jnz short loc_4D088
        sub di, 7Ah ; 'z'
        ror al, 1
        jnb short loc_4D086
        inc di

loc_4D086:              ; CODE XREF: sub_4D004+7Fj
        jmp short loc_4D095
; ---------------------------------------------------------------------------

loc_4D088:              ; CODE XREF: sub_4D004+78j
        cmp bl, 3
        jnz short loc_4D095
        add di, 7Ah ; 'z'
        ror al, 1
        jnb short loc_4D095
        inc di

loc_4D095:              ; CODE XREF: sub_4D004:loc_4D06Dj
                    ; sub_4D004+73j ...
        loop    loc_4D060
        add si, 7
        jmp short loc_4D029
; ---------------------------------------------------------------------------

loc_4D09C:              ; CODE XREF: sub_4D004+2Aj
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        call    sub_4B85C
        call    sub_4B8BE
        retn
sub_4D004   endp


; =============== S U B R O U T I N E =======================================


sub_4D0AD   proc near       ; CODE XREF: runMainMenu+B7p
        cmp byte_50912, 0
        jz  short loc_4D105
        cmp byte_50911, 0
        jz  short loc_4D0BF
        mov ah, 0Dh
        jmp short loc_4D0C1
; ---------------------------------------------------------------------------

loc_4D0BF:              ; CODE XREF: sub_4D0AD+Cj
        mov ah, 7

loc_4D0C1:              ; CODE XREF: sub_4D0AD+10j
        mov si, 504h
        call    sub_4D004
        cmp byte_50911, 0
        jz  short loc_4D0D2
        mov ah, 7
        jmp short loc_4D0D4
; ---------------------------------------------------------------------------

loc_4D0D2:              ; CODE XREF: sub_4D0AD+1Fj
        mov ah, 0Dh

loc_4D0D4:              ; CODE XREF: sub_4D0AD+23j
        mov si, 519h
        call    sub_4D004
        cmp byte_50910, 0
        jz  short loc_4D0E5
        mov ah, 0Dh
        jmp short loc_4D0E7
; ---------------------------------------------------------------------------

loc_4D0E5:              ; CODE XREF: sub_4D0AD+32j
        mov ah, 7

loc_4D0E7:              ; CODE XREF: sub_4D0AD+36j
        mov si, 52Eh
        call    sub_4D004
        cmp byte_50910, 0
        jz  short loc_4D0F8
        mov ah, 7
        jmp short loc_4D0FA
; ---------------------------------------------------------------------------

loc_4D0F8:              ; CODE XREF: sub_4D0AD+45j
        mov ah, 0Dh

loc_4D0FA:              ; CODE XREF: sub_4D0AD+49j
        mov si, 543h
        call    sub_4D004
        mov byte_50912, 0

loc_4D105:              ; CODE XREF: sub_4D0AD+5j
        cmp byte_50915, 0
        jz  short loc_4D15D
        cmp byte_50914, 0
        jz  short loc_4D117
        mov ah, 0Dh
        jmp short loc_4D119
; ---------------------------------------------------------------------------

loc_4D117:              ; CODE XREF: sub_4D0AD+64j
        mov ah, 7

loc_4D119:              ; CODE XREF: sub_4D0AD+68j
        mov si, 558h
        call    sub_4D004
        cmp byte_50914, 0
        jz  short loc_4D12A
        mov ah, 7
        jmp short loc_4D12C
; ---------------------------------------------------------------------------

loc_4D12A:              ; CODE XREF: sub_4D0AD+77j
        mov ah, 0Dh

loc_4D12C:              ; CODE XREF: sub_4D0AD+7Bj
        mov si, 56Dh
        call    sub_4D004
        cmp byte_50913, 0
        jz  short loc_4D13D
        mov ah, 0Dh
        jmp short loc_4D13F
; ---------------------------------------------------------------------------

loc_4D13D:              ; CODE XREF: sub_4D0AD+8Aj
        mov ah, 7

loc_4D13F:              ; CODE XREF: sub_4D0AD+8Ej
        mov si, 582h
        call    sub_4D004
        cmp byte_50913, 0
        jz  short loc_4D150
        mov ah, 7
        jmp short loc_4D152
; ---------------------------------------------------------------------------

loc_4D150:              ; CODE XREF: sub_4D0AD+9Dj
        mov ah, 0Dh

loc_4D152:              ; CODE XREF: sub_4D0AD+A1j
        mov si, 597h
        call    sub_4D004
        mov byte_50915, 0

loc_4D15D:              ; CODE XREF: sub_4D0AD+5Dj
        cmp byte_50918, 0
        jz  short locret_4D1B5
        cmp byte_50917, 0
        jz  short loc_4D16F
        mov ah, 0Dh
        jmp short loc_4D171
; ---------------------------------------------------------------------------

loc_4D16F:              ; CODE XREF: sub_4D0AD+BCj
        mov ah, 7

loc_4D171:              ; CODE XREF: sub_4D0AD+C0j
        mov si, 5ACh
        call    sub_4D004
        cmp byte_50917, 0
        jz  short loc_4D182
        mov ah, 7
        jmp short loc_4D184
; ---------------------------------------------------------------------------

loc_4D182:              ; CODE XREF: sub_4D0AD+CFj
        mov ah, 0Dh

loc_4D184:              ; CODE XREF: sub_4D0AD+D3j
        mov si, 5C1h
        call    sub_4D004
        cmp byte_50916, 0
        jz  short loc_4D195
        mov ah, 0Dh
        jmp short loc_4D197
; ---------------------------------------------------------------------------

loc_4D195:              ; CODE XREF: sub_4D0AD+E2j
        mov ah, 7

loc_4D197:              ; CODE XREF: sub_4D0AD+E6j
        mov si, 5D6h
        call    sub_4D004
        cmp byte_50916, 0
        jz  short loc_4D1A8
        mov ah, 7
        jmp short loc_4D1AA
; ---------------------------------------------------------------------------

loc_4D1A8:              ; CODE XREF: sub_4D0AD+F5j
        mov ah, 0Dh

loc_4D1AA:              ; CODE XREF: sub_4D0AD+F9j
        mov si, 5EBh
        call    sub_4D004
        mov byte_50918, 0

locret_4D1B5:               ; CODE XREF: sub_4D0AD+B5j
        retn
sub_4D0AD   endp


; =============== S U B R O U T I N E =======================================


sub_4D1B6   proc near       ; CODE XREF: sub_4D24D+2Ep
        cmp byte_510DE, 0
        jz  short loc_4D1BE
        retn
; ---------------------------------------------------------------------------

loc_4D1BE:              ; CODE XREF: sub_4D1B6+5j
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8A9Ch
        add si, bx
        cmp byte ptr [si+7Fh], 0
        jz  short loc_4D1D2
        retn
; ---------------------------------------------------------------------------

loc_4D1D2:              ; CODE XREF: sub_4D1B6+19j
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov cx, 6Fh ; 'o'
        mov bx, 0
        mov di, si
        add di, 0Ch

loc_4D1E2:              ; CODE XREF: sub_4D1B6+33j
        cmp byte ptr [di], 1
        jnz short loc_4D1E8
        inc bx

loc_4D1E8:              ; CODE XREF: sub_4D1B6+2Fj
        inc di
        loop    loc_4D1E2
        cmp bx, 6Fh ; 'o'
        jnz short loc_4D24B
        mov byte ptr [si+7Fh], 1
        mov cx, 3
        mov di, 9514h

loc_4D1FA:              ; CODE XREF: sub_4D1B6+78j
        cmp byte ptr [di+9], 0
        jnz short loc_4D20E
        cmp byte ptr [di+0Ah], 0
        jnz short loc_4D20E
        cmp byte ptr [di+0Bh], 0
        jnz short loc_4D20E
        jmp short loc_4D232
; ---------------------------------------------------------------------------

loc_4D20E:              ; CODE XREF: sub_4D1B6+48j
                    ; sub_4D1B6+4Ej ...
        mov al, [si+9]
        cmp al, [di+9]
        jl  short loc_4D232
        jnz short loc_4D22A
        mov al, [si+0Ah]
        cmp al, [di+0Ah]
        jl  short loc_4D232
        jnz short loc_4D22A
        mov al, [si+0Bh]
        cmp al, [di+0Bh]
        jl  short loc_4D232

loc_4D22A:              ; CODE XREF: sub_4D1B6+60j
                    ; sub_4D1B6+6Aj
        add di, 0Ch
        dec cx
        jnz short loc_4D1FA
        jmp short loc_4D24B
; ---------------------------------------------------------------------------

loc_4D232:              ; CODE XREF: sub_4D1B6+56j
                    ; sub_4D1B6+5Ej ...
        push    si
        add di, 2Fh ; '/'
        mov si, di
        sub si, 0Ch
        std
        mov cx, 24h ; '$'
        rep movsb
        cld
        pop si
        sub di, 0Bh
        mov cx, 0Ch
        rep movsb

loc_4D24B:              ; CODE XREF: sub_4D1B6+38j
                    ; sub_4D1B6+7Aj
        pop es
        assume es:nothing
        retn
sub_4D1B6   endp


; =============== S U B R O U T I N E =======================================


sub_4D24D   proc near       ; CODE XREF: sub_4ADFF+D9p
                    ; update?:loc_4E6A4p
        cmp byte_510DE, 0
        jnz short locret_4D27E
        cmp byte_5A2F9, 0
        jnz short locret_4D27E
        mov al, byte_510BB
        mov byte_510BB, 0
        mov bh, byte_5981F
        xor bl, bl
        shr bx, 1
        mov si, 8AA8h
        add si, bx
        mov bx, word_51ABC
        dec bx
        mov [bx+si], al
        inc word_51ABC
        call    sub_4D1B6

locret_4D27E:               ; CODE XREF: sub_4D24D+5j sub_4D24D+Cj
        retn
sub_4D24D   endp

; ---------------------------------------------------------------------------
        nop

; =============== S U B R O U T I N E =======================================


checkVideo  proc near       ; CODE XREF: start+282p
        mov ah, 0Fh
        int 10h     ; - VIDEO - GET CURRENT VIDEO MODE
                    ; Return: AH = number of columns on screen
                    ; AL = current video mode
                    ; BH = current active display page
        mov currVideoMode, al
        mov ax, 0Dh
        int 10h     ; - VIDEO - SET VIDEO MODE
                    ; AL = mode
        mov bx, 0
        mov cx, 100h

videoCheckStart:            ; CODE XREF: checkVideo:checkAgainj
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, cl
        out dx, al      ; EGA port: graphics controller data register
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        in  al, dx      ; EGA port: graphics controller data register
        cmp al, cl
        jz  short checkAgain
        inc bx

checkAgain:             ; CODE XREF: checkVideo+29j
        loop    videoCheckStart
        or  bx, bx
        jnz short setStatusBit2
        mov videoStatusUnk, 1
        jmp short returnout
; ---------------------------------------------------------------------------

setStatusBit2:              ; CODE XREF: checkVideo+30j
        mov videoStatusUnk, 2

returnout:                  ; CODE XREF: checkVideo+37j
        retn
checkVideo  endp


; =============== S U B R O U T I N E =======================================


sub_4D2BF   proc near       ; CODE XREF: start+296p
        cmp videoStatusUnk, 1
        jnz short loc_4D2DA
        mov cx, 10h

loc_4D2C9:              ; CODE XREF: sub_4D2BF+17j
        push    cx
        mov ax, 1000h
        mov bl, cl
        dec bl
        mov bh, bl
        int 10h     ; - VIDEO - SET PALETTE REGISTER (Jr, PS, TANDY 1000, EGA, VGA)
                    ; BL = palette register to set
                    ; BH = color value to store
        pop cx
        loop    loc_4D2C9
        jmp short $+2
; ---------------------------------------------------------------------------

loc_4D2DA:              ; CODE XREF: sub_4D2BF+5j
                    ; sub_4D2BF+19j
        mov si, 60D5h
        call    fade
        retn
sub_4D2BF   endp


; =============== S U B R O U T I N E =======================================


sub_4D2E1   proc near       ; CODE XREF: start+450p
                    ; loadScreen2-7D7p
        mov ah, 0
        mov al, currVideoMode
        int 10h     ; - VIDEO - SET VIDEO MODE
                    ; AL = mode
        retn
sub_4D2E1   endp


; =============== S U B R O U T I N E =======================================


sub_4D2E9   proc near       ; CODE XREF: start+299p
        mov byte_58487, 0
        push    es
        mov ah, 35h ; '5'
        mov al, 33h ; '3'
        int 21h     ; DOS - 2+ - GET INTERRUPT VECTOR
                    ; AL = interrupt number
                    ; Return: ES:BX = value of interrupt vector
        mov ax, es
        or  ax, bx
        jz  short loc_4D33B
        cmp byte ptr es:[bx], 0CFh ; '?'
        jz  short loc_4D33B
        mov ax, 0
        int 33h     ; - MS MOUSE - RESET DRIVER AND READ STATUS
                    ; Return: AX = status
                    ; BX = number of buttons
        cmp bx, 2
        jz  short loc_4D310
        cmp bx, 3
        jnz short loc_4D33B

loc_4D310:              ; CODE XREF: sub_4D2E9+20j
        mov byte_58487, 1
        mov ax, 2
        int 33h     ; - MS MOUSE - HIDE MOUSE CURSOR
                    ; SeeAlso: AX=0001h, INT 16/AX=FFFFh
        mov ax, 7
        mov cx, 20h ; ' '
        mov dx, 260h
        int 33h     ; - MS MOUSE - DEFINE HORIZONTAL CURSOR RANGE
                    ; CX = minimum column, DX = maximum column
        mov ax, 8
        mov cx, 8
        mov dx, 0C0h ; '?'
        int 33h     ; - MS MOUSE - DEFINE VERTICAL CURSOR RANGE
                    ; CX = minimum row, DX = maximum row
        mov ax, 4
        mov cx, 140h
        mov dx, 64h ; 'd'
        int 33h     ; - MS MOUSE - POSITION MOUSE CURSOR
                    ; CX = column, DX = row

loc_4D33B:              ; CODE XREF: sub_4D2E9+10j
                    ; sub_4D2E9+16j ...
        mov word_58481, 0A0h ; '?'
        mov word_58485, 64h ; 'd'
        mov word ptr dword_58488, 1
        pop es
        retn
sub_4D2E9   endp


; =============== S U B R O U T I N E =======================================


getMouseStatus   proc near       ; CODE XREF: sub_47E98:mouseIsClickedp
                    ; sub_47E98+3Ep ...
        cmp byte_58487, 0
        jz  short loc_4D360
        mov ax, 3
        int 33h     ; - MS MOUSE - RETURN POSITION AND BUTTON STATUS
                    ; Return: BX = button status, CX = column, DX = row
        shr cx, 1
        jmp locret_4D40E
; ---------------------------------------------------------------------------

loc_4D360:              ; CODE XREF: getMouseStatus+5j
        xor bx, bx
        cmp byte_5197E, 1
        jnz short loc_4D36C
        mov bx, 2

loc_4D36C:              ; CODE XREF: getMouseStatus+18j
        cmp byte_51999, 1
        jnz short loc_4D376
        mov bx, 1

loc_4D376:              ; CODE XREF: getMouseStatus+22j
        mov cx, 1
        mov ax, word ptr dword_58488
        shr ax, 1
        shr ax, 1
        shr ax, 1
        inc ax
        cmp byte_519C5, 1
        jnz short loc_4D390
        sub word_58485, ax
        xor cx, cx

loc_4D390:              ; CODE XREF: getMouseStatus+39j
        cmp byte_519CD, 1
        jnz short loc_4D39D
        add word_58485, ax
        xor cx, cx

loc_4D39D:              ; CODE XREF: getMouseStatus+46j
        cmp byte_519C8, 1
        jnz short loc_4D3AA
        sub word_58481, ax
        xor cx, cx

loc_4D3AA:              ; CODE XREF: getMouseStatus+53j
        cmp byte_519CA, 1
        jnz short loc_4D3B7
        add word_58481, ax
        xor cx, cx

loc_4D3B7:              ; CODE XREF: getMouseStatus+60j
        or  cx, cx
        jnz short loc_4D3C1
        inc word ptr dword_58488
        jmp short loc_4D3C7
; ---------------------------------------------------------------------------

loc_4D3C1:              ; CODE XREF: getMouseStatus+6Aj
        mov word ptr dword_58488, 1

loc_4D3C7:              ; CODE XREF: getMouseStatus+70j
        cmp word ptr dword_58488, 40h ; '@'
        jbe short loc_4D3D4
        mov word ptr dword_58488, 40h ; '@'

loc_4D3D4:              ; CODE XREF: getMouseStatus+7Dj
        mov cx, word_58481
        mov dx, word_58485
        cmp cx, 10h
        jg  short loc_4D3E8
        mov cx, 10h
        mov word_58481, cx

loc_4D3E8:              ; CODE XREF: getMouseStatus+90j
        cmp cx, 130h
        jl  short loc_4D3F5
        mov cx, 130h
        mov word_58481, cx

loc_4D3F5:              ; CODE XREF: getMouseStatus+9Dj
        cmp dx, 8
        jg  short loc_4D401
        mov dx, 8
        mov word_58485, dx

loc_4D401:              ; CODE XREF: getMouseStatus+A9j
        cmp dx, 0C0h ; '?'
        jl  short locret_4D40E
        mov dx, 0C0h ; '?'
        mov word_58485, dx

locret_4D40E:               ; CODE XREF: getMouseStatus+Ej
                    ; getMouseStatus+B6j
        retn
getMouseStatus   endp


; =============== S U B R O U T I N E =======================================


videoloop   proc near       ; CODE XREF: crt?2+52p crt?1+3Ep ...
        push    dx
        push    ax
        cmp byte ptr dword_59B67, 0
        jnz short waitForVsync
        mov dx, 3DAh
        cli
        in  al, dx      ; Video status bits:
                    ; 0: retrace.  1=display is in vert or horiz retrace.
                    ; 1: 1=light pen is triggered; 0=armed
                    ; 2: 1=light pen switch is open; 0=closed
                    ; 3: 1=vertical sync pulse is occurring.
        mov ah, al
        mov dx, 3C0h
        mov al, 33h ; '3'
        out dx, al      ; EGA: horizontal pixel panning:
                    ; Number of dots to shift data left.
                    ; Bits 0-3 valid (0-0fH)
        mov al, byte_510A6
        out dx, al      ; EGA: palette register: select colors for attribute AL:
                    ; 0: RED
                    ; 1: GREEN
                    ; 2: BLUE
                    ; 3: blue
                    ; 4: green
                    ; 5: red
        test    ah, 8
        jnz short loc_4D453

waitForVsync:              ; CODE XREF: videoloop+7j
                    ; videoloop+31j
        sti
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        mov dx, 3DAh
        cli
        in  al, dx      ; Video status bits:
                    ; 0: retrace.  1=display is in vert or horiz retrace.
                    ; 1: 1=light pen is triggered; 0=armed
                    ; 2: 1=light pen switch is open; 0=closed
                    ; 3: 1=vertical sync pulse is occurring.
        test    al, 1000b
        jz  short waitForVsync
        cmp byte ptr dword_59B67, 0
        jz  short loc_4D453
        mov dx, 3C0h
        mov al, 33h ; '3'
        out dx, al      ; EGA: horizontal pixel panning:
                    ; Number of dots to shift data left.
                    ; Bits 0-3 valid (0-0fH)
        mov al, byte_510A6
        out dx, al      ; EGA: palette register: select colors for attribute AL:
                    ; 0: RED
                    ; 1: GREEN
                    ; 2: BLUE
                    ; 3: blue
                    ; 4: green
                    ; 5: red

loc_4D453:              ; CODE XREF: videoloop+1Dj
                    ; videoloop+38j
        sti
        pop ax
        pop dx
        retn
videoloop   endp


; =============== S U B R O U T I N E =======================================


sub_4D457   proc near       ; CODE XREF: crt?2+55p crt?1+41p ...
        push    dx
        push    ax

loc_4D459:              ; CODE XREF: sub_4D457+8j
        mov dx, 3DAh
        in  al, dx      ; Video status bits:
                    ; 0: retrace.  1=display is in vert or horiz retrace.
                    ; 1: 1=light pen is triggered; 0=armed
                    ; 2: 1=light pen switch is open; 0=closed
                    ; 3: 1=vertical sync pulse is occurring.
        test    al, 8
        jnz short loc_4D459
        pop ax
        pop dx
        retn
sub_4D457   endp


; =============== S U B R O U T I N E =======================================


sub_4D464   proc near       ; CODE XREF: start+332p sub_4A463+3p
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3D4h
        mov al, 13h
        out dx, al      ; Video: CRT cntrlr addr
                    ; vertical displayed adjustment
        inc dx
        mov al, 3Dh ; '='
        out dx, al      ; Video: CRT controller internal registers
        cmp videoStatusUnk, 1
        jnz short loc_4D4CF
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, 5Fh ; '_'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 7
        out dx, al      ; Video: CRT cntrlr addr
                    ; bit 8 for certain CRTC regs. Data bits:
                    ; 0: vertical total (Reg 06)
                    ; 1: vert disp'd enable end (Reg 12H)
                    ; 2: vert retrace start (Reg 10H)
                    ; 3: start vert blanking (Reg 15H)
                    ; 4: line compare (Reg 18H)
                    ; 5: cursor location (Reg 0aH)
        inc dx
        mov al, 3Fh ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 9
        out dx, al      ; Video: CRT cntrlr addr
                    ; maximum scan line
        inc dx
        mov al, 80h ; '?'
        out dx, al      ; Video: CRT controller internal registers
        call    videoloop
        mov dx, 3DAh
        cli
        in  al, dx      ; Video status bits:
                    ; 0: retrace.  1=display is in vert or horiz retrace.
                    ; 1: 1=light pen is triggered; 0=armed
                    ; 2: 1=light pen switch is open; 0=closed
                    ; 3: 1=vertical sync pulse is occurring.
        mov dx, 3C0h
        mov al, 30h ; '0'
        out dx, al      ; EGA: mode control bits:
                    ; 0: 1=graph modes, 0=text
                    ; 1: 1=MDA
                    ; 2: 1=9th dot=8th dot for line/box chars
                    ;    0=use bkgd colr as 9th dot of char
                    ; 3: 1=enable blink, 0=allow 4-bit bkgd
        mov al, 21h ; '!'
        out dx, al      ; EGA: palette register: select colors for attribute AL:
                    ; 0: RED
                    ; 1: GREEN
                    ; 2: BLUE
                    ; 3: blue
                    ; 4: green
                    ; 5: red
        sti
        jmp short locret_4D4E3
; ---------------------------------------------------------------------------

loc_4D4CF:              ; CODE XREF: sub_4D464+37j
        mov dx, 3D4h
        mov al, 18h
        out dx, al      ; Video: CRT cntrlr addr
                    ; line compare (scan line). Used for split screen operations.
        inc dx
        mov al, 0B0h ; '?'
        out dx, al      ; Video: CRT controller internal registers
        mov dx, 3D4h
        mov al, 7
        out dx, al      ; Video: CRT cntrlr addr
                    ; bit 8 for certain CRTC regs. Data bits:
                    ; 0: vertical total (Reg 06)
                    ; 1: vert disp'd enable end (Reg 12H)
                    ; 2: vert retrace start (Reg 10H)
                    ; 3: start vert blanking (Reg 15H)
                    ; 4: line compare (Reg 18H)
                    ; 5: cursor location (Reg 0aH)
        inc dx
        mov al, 1
        out dx, al      ; Video: CRT controller internal registers

locret_4D4E3:               ; CODE XREF: sub_4D464+69j
        retn
sub_4D464   endp


; =============== S U B R O U T I N E =======================================


sub_4D4E4   proc near       ; CODE XREF: start+2B2p start+2C7p
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3D4h
        mov al, 13h
        out dx, al      ; Video: CRT cntrlr addr
                    ; vertical displayed adjustment
        inc dx
        mov al, 3Dh ; '='
        out dx, al      ; Video: CRT controller internal registers
        retn
sub_4D4E4   endp


; =============== S U B R O U T I N E =======================================


sub_4D517   proc near       ; CODE XREF: start+2AFp
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 0FFFFh
        mov di, 0
        rep stosb
        retn
sub_4D517   endp


; =============== S U B R O U T I N E =======================================


readLevels  proc near       ; CODE XREF: start:loc_46F3Ep
                    ; sub_4A463p
        cmp byte_510DE, 0
        jz  short loc_4D59F
        cmp byte ptr word_599D8, 0
        jnz short loc_4D599
        cmp byte_599D4, 0
        jnz short loc_4D59F
        mov ax, word_510E6
        push    es
        push    ds
        push    ds
        pop es
        assume es:data
        mov si, seg demoseg
        mov ds, si
        assume ds:demoseg
        mov si, 0BE20h
        mov di, offset fileLevelData
        mov cx, ax
        shl cx, 1
        add ax, cx
        mov cl, 9
        shl ax, cl
        add si, ax
        mov cx, 300h
        cld
        rep movsw
        mov di, 87DAh
        mov ax, 532Eh
        stosw
        mov ax, 50h ; 'P'
        stosw
        sub si, 5Ah ; 'Z'
        mov cx, 17h
        rep movsb
        pop ds
        assume ds:data
        pop es
        assume es:nothing
        jmp loc_4D64B
; ---------------------------------------------------------------------------

loc_4D599:              ; CODE XREF: readLevels+Cj
        lea dx, aLevels_dat ; "LEVELS.DAT"
        jmp short loc_4D5A3
; ---------------------------------------------------------------------------

loc_4D59F:              ; CODE XREF: readLevels+5j
                    ; readLevels+13j
        lea dx, aLevels_dat_0 ; "LEVELS.DAT"

loc_4D5A3:              ; CODE XREF: readLevels+55j
        mov ax, 3D00h
        cmp byte_599D4, 0
        jz  short loc_4D5BB
        mov dx, offset demoFileName
        cmp word_599DA, 0
        jz  short loc_4D5BB
        lea dx, aLevels_dat ; "LEVELS.DAT"

loc_4D5BB:              ; CODE XREF: readLevels+63j
                    ; readLevels+6Dj
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4D5C2
        jmp exit
; ---------------------------------------------------------------------------

loc_4D5C2:              ; CODE XREF: readLevels+75j
        mov lastFileHandle, ax
        cmp byte_510DE, 0
        jz  short loc_4D5D1
        mov ax, word_510E6
        jmp short loc_4D5D4
; ---------------------------------------------------------------------------

loc_4D5D1:              ; CODE XREF: readLevels+82j
        mov ax, word_51ABC

loc_4D5D4:              ; CODE XREF: readLevels+87j
        cmp byte_599D4, 0
        jz  short loc_4D5E3
        mov ax, word_599DA
        or  ax, ax
        jnz short loc_4D5E3
        inc ax

loc_4D5E3:              ; CODE XREF: readLevels+91j
                    ; readLevels+98j
        dec ax
        mov bx, ax
        shl bx, 1
        add ax, bx
        shl ax, 1
        mov cl, 8
        mov dx, ax
        shl dx, cl
        shr ax, cl
        mov cx, ax
        mov ax, 4200h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - MOVE FILE READ/WRITE POINTER (LSEEK)
                    ; AL = method: offset from beginning of file
        jnb short loc_4D604
        jmp exit
; ---------------------------------------------------------------------------

loc_4D604:              ; CODE XREF: readLevels+B7j
        mov ax, 3F00h
        mov bx, lastFileHandle
        mov cx, levelDataLength
        mov dx, offset fileLevelData
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_4D618
        jmp exit
; ---------------------------------------------------------------------------

loc_4D618:              ; CODE XREF: readLevels+CBj
        cmp byte ptr word_599D8, 0
        jz  short loc_4D64B
        mov byte ptr word_599D8+1, 0FFh
        push    es
        mov ax, demoseg
        mov es, ax
        assume es:demoseg
        lea si, ds:[00768h]
        lea di, ds:[0BE20h]
        mov ax, word_599D6
        mov word_510E6, ax
        mov cx, ax
        shl cx, 1
        add ax, cx
        mov cl, 9
        shl ax, cl
        add di, ax
        mov cx, 300h
        cld
        rep movsw
        pop es
        assume es:nothing

loc_4D64B:              ; CODE XREF: readLevels+4Ej
                    ; readLevels+D5j
        cmp byte_510DE, 0
        jz  short loc_4D65D
        mov ax, word_51076
        mov timeOfDay, ax
        mov di, 87DAh
        jmp short loc_4D660
; ---------------------------------------------------------------------------

loc_4D65D:              ; CODE XREF: readLevels+108j
        mov di, 87A8h

loc_4D660:              ; CODE XREF: readLevels+113j
        push    es
        push    ds
        pop es
        assume es:data
        cld
        cmp word_599D8, 0
        jnz short loc_4D679
        cmp byte_599D4, 0
        jz  short loc_4D68C
        cmp word_599DA, 0
        jz  short loc_4D682

loc_4D679:              ; CODE XREF: readLevels+121j
        mov ax, 4942h
        stosw
        mov ax, 4Eh ; 'N'
        jmp short loc_4D689
; ---------------------------------------------------------------------------

loc_4D682:              ; CODE XREF: readLevels+12Fj
        mov ax, 532Eh
        stosw
        mov ax, 50h ; 'P'

loc_4D689:              ; CODE XREF: readLevels+138j
        stosw
        jmp short loc_4D68F
; ---------------------------------------------------------------------------

loc_4D68C:              ; CODE XREF: readLevels+128j
        add di, 4

loc_4D68F:              ; CODE XREF: readLevels+142j
        mov si, 0D0Eh
        mov cx, 17h
        rep movsb
        pop es
        assume es:nothing
        push    es
        push    ds
        pop es
        assume es:data
        mov si, offset fileLevelData
        mov di, offset levelBuffer
        mov cx, 300h
        cld
        rep movsw
        pop es
        assume es:nothing
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov cx, levelDataLength
        mov si, offset fileLevelData
        mov di, offset leveldata
        xor ah, ah

loc_4D6B8:              ; CODE XREF: readLevels+172j
        lodsb
        stosw
        loop    loc_4D6B8
        mov di, 2434h
        xor al, al
        mov cx, levelbytes
        rep stosb
        pop es
        assume es:nothing
        cmp byte_510DE, 0
        jz  short loc_4D6DC
        cmp byte ptr word_599D8, 0
        jnz short loc_4D6DC
        cmp byte_599D4, 0
        jz  short loc_4D6EA

loc_4D6DC:              ; CODE XREF: readLevels+184j
                    ; readLevels+18Bj
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short loc_4D6EA
        jmp exit
; ---------------------------------------------------------------------------

loc_4D6EA:              ; CODE XREF: readLevels+192j
                    ; readLevels+19Dj
        mov byte ptr word_599D8, 0
        retn
readLevels  endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

fade        proc near       ; CODE XREF: start+2C1p start+312p ...

var_8       = word ptr -8
var_6       = word ptr -6
var_4       = word ptr -4
var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFF8h
        push    es
        cmp videoStatusUnk, 2
        jnz short loc_4D706
        call    sub_4D836
        pop es
        mov sp, bp
        pop bp
        retn
; ---------------------------------------------------------------------------

loc_4D706:              ; CODE XREF: fade+Cj
        push    si
        mov ax, ds
        mov es, ax
        assume es:data
        mov ax, word_510A2
        mov [bp+var_8], ax
        mov word_510A2, 0
        mov cx, 40h ; '@'
        mov di, offset fileLevelData

loc_4D71D:              ; CODE XREF: fade+33j
        lodsb
        shl al, 1
        shl al, 1
        stosb
        loop    loc_4D71D
        mov dx, 3C7h
        mov al, 0
        out dx, al
        mov dx, 3C9h
        mov di, 6115h
        mov cx, 10h

loc_4D734:              ; CODE XREF: fade+51j
        in  al, dx
        mov [di], al
        inc di
        in  al, dx
        mov [di], al
        inc di
        in  al, dx
        mov [di], al
        inc di
        inc di
        loop    loc_4D734
        mov ax, 0
        mov [bp+var_2], ax
        mov ax, 3Fh ; '?'
        mov [bp+var_4], ax

loc_4D74F:              ; CODE XREF: fade+134j
        mov dx, 3C8h
        mov al, 0
        out dx, al
        mov cx, 10h
        mov si, offset fileLevelData
        mov di, 6115h

loc_4D75E:              ; CODE XREF: fade+115j
        mov al, [si]
        xor ah, ah
        mov bx, [bp+var_2]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        mov [bp+var_6], ax
        mov al, [di]
        xor ah, ah
        mov bx, [bp+var_4]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        add ax, [bp+var_6]
        inc di
        inc si
        mov dx, 3C9h
        out dx, al
        mov al, [si]
        xor ah, ah
        mov bx, [bp+var_2]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        mov [bp+var_6], ax
        mov al, [di]
        xor ah, ah
        mov bx, [bp+var_4]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        add ax, [bp+var_6]
        inc di
        inc si
        mov dx, 3C9h
        out dx, al
        mov al, [si]
        xor ah, ah
        mov bx, [bp+var_2]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        mov [bp+var_6], ax
        mov al, [di]
        xor ah, ah
        mov bx, [bp+var_4]
        mul bx
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        shr ax, 1
        add ax, [bp+var_6]
        inc di
        inc si
        mov dx, 3C9h
        out dx, al
        inc si
        inc di
        dec cx
        jz  short loc_4D808
        jmp loc_4D75E
; ---------------------------------------------------------------------------

loc_4D808:              ; CODE XREF: fade+113j
        cmp fastMode, 1
        jz  short isFastMode4
        call    videoloop
        call    sub_4D457

isFastMode4:              ; CODE XREF: fade+11Dj
        dec [bp+var_4]
        mov ax, [bp+var_2]
        inc ax
        mov [bp+var_2], ax
        cmp ax, 3Fh ; '?'
        jg  short loc_4D827
        jmp loc_4D74F
; ---------------------------------------------------------------------------

loc_4D827:              ; CODE XREF: fade+132j
        pop si
        call    sub_4D836
        mov ax, [bp+var_8]
        mov word_510A2, ax
        pop es
        assume es:nothing
        mov sp, bp
        pop bp
        retn
fade        endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

sub_4D836   proc near       ; CODE XREF: start+2B8p
                    ; loadScreen2+B5p ...

var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFFEh
        mov ax, word_510A2
        mov [bp+var_2], ax
        mov word_510A2, 0
        cmp videoStatusUnk, 1
        jnz short loc_4D872
        mov cx, 10h
        mov dx, 3C8h
        mov al, 0
        out dx, al
        mov dx, 3C9h

loc_4D85B:              ; CODE XREF: sub_4D836+38j
        lodsb
        shl al, 1
        shl al, 1
        out dx, al
        lodsb
        shl al, 1
        shl al, 1
        out dx, al
        lodsb
        shl al, 1
        shl al, 1
        out dx, al
        lodsb
        loop    loc_4D85B
        jmp short loc_4D89E
; ---------------------------------------------------------------------------

loc_4D872:              ; CODE XREF: sub_4D836+17j
        mov cx, 10h
        mov dx, 0
        mov di, 611h

loc_4D87B:              ; CODE XREF: sub_4D836+58j
        lodsb
        lodsb
        lodsb
        lodsb
        mov bh, al
        and bh, 7
        and al, 8
        shl al, 1
        or  bh, al
        mov [di], bh
        inc di
        inc dx
        loop    loc_4D87B
        push    es
        mov ax, ds
        mov es, ax
        assume es:data
        mov ax, 1002h
        mov dx, 611h
        int 10h     ; - VIDEO - SET ALL PALETTE REGISTERS (Jr, PS, TANDY 1000, EGA, VGA)
                    ; ES:DX -> 17-byte palette register list
        pop es
        assume es:nothing

loc_4D89E:              ; CODE XREF: sub_4D836+3Aj
        mov ax, [bp+var_2]
        mov word_510A2, ax
        mov sp, bp
        pop bp
        retn
sub_4D836   endp

; ---------------------------------------------------------------------------
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  8Bh ; ?
        db 0C0h ; +

; =============== S U B R O U T I N E =======================================


sub_4D8B0   proc near       ; CODE XREF: start+2A5p
        push    ds
        xor ax, ax
        mov ds, ax
        assume ds:nothing
        mov bx, 200h
        mov [bx], ax
        mov ax, seg soundseg
        mov [bx+2], ax
        xor ax, ax
        mov bx, 204h
        mov [bx], ax
        mov ax, seg sound2seg
        mov [bx+2], ax
        pop ds
        assume ds:data
        mov byte_59885, 0
        mov byte_59886, 0
        mov soundEnabled?, 0
        retn
sub_4D8B0   endp


; =============== S U B R O U T I N E =======================================


soundShutdown?  proc near       ; CODE XREF: start+48Ep
                    ; loadScreen2-7DAp
        mov soundEnabled?, 0
        call    sound?1
        retn
soundShutdown?  endp

; ---------------------------------------------------------------------------
        call    sound?1
        mov musType, 0
        mov sndType, 0
        mov soundEnabled?, 0
        retn

; =============== S U B R O U T I N E =======================================


loadBeep    proc near       ; CODE XREF: readConfig:loc_4751Ap
                    ; readConfig:loc_47551p ...
        call    sound?1
        mov dx, offset aBeep_snd ; "BEEP.SND"
        mov cx, 0AC4h
        call    readSound
        mov musType, 1
        mov sndType, 1
        mov soundEnabled?, 1
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadBeep    endp


; =============== S U B R O U T I N E =======================================


loadBeep2   proc near       ; CODE XREF: readConfig+4Cp sub_4C70Fp
        call    sound?1
        mov dx, offset aBeep_snd ; "BEEP.SND"
        mov cx, 0AC4h
        call    readSound
        mov dx, offset aSample_snd ; "SAMPLE.SND"
        mov cx, 8DACh
        call    readSound2
        mov musType, 1
        mov sndType, 2
        mov soundEnabled?, 1
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadBeep2   endp


; =============== S U B R O U T I N E =======================================


loadAdlib   proc near       ; CODE XREF: readConfig+56p sub_4C723p
        call    sound?1
        mov dx, offset aAdlib_snd ; "ADLIB.SND"
        mov cx, 14EAh
        call    readSound
        mov musType, 3
        mov sndType, 3
        mov soundEnabled?, 0
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadAdlib   endp


; =============== S U B R O U T I N E =======================================


loadBlaster  proc near       ; CODE XREF: readConfig+60p sub_4C719p
        call    sound?1
        mov dx, offset aAdlib_snd ; "ADLIB.SND"
        mov cx, 14EAh
        call    readSound
        mov dx, offset aBlaster_snd ; "BLASTER.SND"
        mov cx, 991Bh
        call    readSound2
        mov musType, 3
        mov sndType, 4
        mov soundEnabled?, 0
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadBlaster  endp


; =============== S U B R O U T I N E =======================================


loadRoland  proc near       ; CODE XREF: readConfig+6Ap sub_4C72Dp
        call    sound?1
        mov dx, offset aRoland_snd ; "ROLAND.SND"
        mov cx, 0F80h
        call    readSound
        mov musType, 5
        mov sndType, 5
        mov soundEnabled?, 0
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadRoland  endp


; =============== S U B R O U T I N E =======================================


loadCombined proc near       ; CODE XREF: readConfig+74p sub_4C737p
        call    sound?1
        mov dx, offset aRoland_snd ; "ROLAND.SND"
        mov cx, 0F80h
        call    readSound
        mov dx, offset aBlaster_snd ; "BLASTER.SND"
        mov cx, 991Bh
        call    readSound2
        mov musType, 5
        mov sndType, 4
        mov soundEnabled?, 0
        call    sound?2
        mov byte_59889, 0
        mov byte_5988A, 64h ; 'd'
        mov byte_5988B, 0
        mov byte_5988C, 0
        retn
loadCombined endp


; =============== S U B R O U T I N E =======================================


readSound   proc near       ; CODE XREF: loadBeep+9p loadBeep2+9p ...
        mov ax, 3D00h
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4DA51
        jmp exit
; ---------------------------------------------------------------------------

loc_4DA51:              ; CODE XREF: readSound+5j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        push    ds
        mov ax, seg soundseg
        mov ds, ax
        assume ds:soundseg
        mov ax, 3F00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_4DA6C
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_4DA6C:              ; CODE XREF: readSound+1Fj
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_4DA7B
        jmp exit
; ---------------------------------------------------------------------------

locret_4DA7B:               ; CODE XREF: readSound+2Fj
        retn
readSound   endp


; =============== S U B R O U T I N E =======================================


readSound2  proc near       ; CODE XREF: loadBeep2+12p
                    ; loadBlaster+12p ...
        mov ax, 3D00h
        int 21h     ; DOS - 2+ - OPEN DISK FILE WITH HANDLE
                    ; DS:DX -> ASCIZ filename
                    ; AL = access mode
                    ; 0 - read
        jnb short loc_4DA86
        jmp exit
; ---------------------------------------------------------------------------

loc_4DA86:              ; CODE XREF: readSound2+5j
        mov lastFileHandle, ax
        mov bx, lastFileHandle
        push    ds
        mov ax, seg sound2seg
        mov ds, ax
        assume ds:sound2seg
        mov ax, 3F00h
        mov dx, 0
        int 21h     ; DOS - 2+ - READ FROM FILE WITH HANDLE
                    ; BX = file handle, CX = number of bytes to read
                    ; DS:DX -> buffer
        jnb short loc_4DAA1
        pop ds
        assume ds:data
        jmp exit
; ---------------------------------------------------------------------------

loc_4DAA1:              ; CODE XREF: readSound2+1Fj
        pop ds
        mov ax, 3E00h
        mov bx, lastFileHandle
        int 21h     ; DOS - 2+ - CLOSE A FILE WITH HANDLE
                    ; BX = file handle
        jnb short locret_4DAB0
        jmp exit
; ---------------------------------------------------------------------------

locret_4DAB0:               ; CODE XREF: readSound2+2Fj
        retn
readSound2  endp


; =============== S U B R O U T I N E =======================================


sound?1     proc near       ; CODE XREF: soundShutdown?+5p
                    ; code:6CC7p ...
        mov soundEnabled?, 0
        cmp musType, 1
        jnz short loc_4DAC9
        mov ah, 2
        int 80h     ; LINUX -
        in  al, 61h     ; PC/XT PPI port B bits:
                    ; 0: Tmr 2 gate ??? OR 03H=spkr ON
                    ; 1: Tmr 2 data ?  AND  0fcH=spkr OFF
                    ; 3: 1=read high switches
                    ; 4: 0=enable RAM parity checking
                    ; 5: 0=enable I/O channel check
                    ; 6: 0=hold keyboard clock low
                    ; 7: 0=enable kbrd
        and al, 0FCh
        out 61h, al     ; PC/XT PPI port B bits:
                    ; 0: Tmr 2 gate ??? OR 03H=spkr ON
                    ; 1: Tmr 2 data ?  AND  0fcH=spkr OFF
                    ; 3: 1=read high switches
                    ; 4: 0=enable RAM parity checking
                    ; 5: 0=enable I/O channel check
                    ; 6: 0=hold keyboard clock low
                    ; 7: 0=enable kbrd
        jmp short loc_4DAE8
; ---------------------------------------------------------------------------

loc_4DAC9:              ; CODE XREF: sound?1+Aj
        cmp musType, 3
        jnz short loc_4DAD9
        mov dx, 388h
        mov ah, 2
        int 80h     ; LINUX -
        jmp short loc_4DAE8
; ---------------------------------------------------------------------------

loc_4DAD9:              ; CODE XREF: sound?1+1Dj
        cmp musType, 5
        jnz short loc_4DAE8
        mov ah, 2
        int 80h     ; LINUX -
        mov ah, 10h
        int 80h     ; LINUX -

loc_4DAE8:              ; CODE XREF: sound?1+16j sound?1+26j ...
        mov musType, 0
        cmp sndType, 2
        jnz short loc_4DAFA
        mov ah, 1
        int 81h
        jmp short loc_4DB05
; ---------------------------------------------------------------------------

loc_4DAFA:              ; CODE XREF: sound?1+41j
        cmp sndType, 4
        jnz short loc_4DB05
        mov ah, 2
        int 81h

loc_4DB05:              ; CODE XREF: sound?1+47j sound?1+4Ej
        mov sndType, 0
        retn
sound?1     endp


; =============== S U B R O U T I N E =======================================


sound?2     proc near       ; CODE XREF: start+39Bp start+410p ...
        cmp byte_59886, 1
        jz  short loc_4DB13
        retn
; ---------------------------------------------------------------------------

loc_4DB13:              ; CODE XREF: sound?2+5j
        cmp musType, 1
        jnz short loc_4DB26
        mov ax, 0
        int 80h     ; LINUX - old_setup_syscall
        mov soundEnabled?, 1
        jmp short locret_4DB4D
; ---------------------------------------------------------------------------

loc_4DB26:              ; CODE XREF: sound?2+Dj
        cmp musType, 3
        jnz short loc_4DB3C
        mov dx, 388h
        mov ax, 0
        int 80h     ; LINUX - old_setup_syscall
        mov soundEnabled?, 1
        jmp short locret_4DB4D
; ---------------------------------------------------------------------------

loc_4DB3C:              ; CODE XREF: sound?2+20j
        cmp musType, 5
        jnz short locret_4DB4D
        mov ax, 0
        int 80h     ; LINUX - old_setup_syscall
        mov soundEnabled?, 1

locret_4DB4D:               ; CODE XREF: sound?2+19j sound?2+2Fj ...
        retn
sound?2     endp


; =============== S U B R O U T I N E =======================================


sound?3     proc near       ; CODE XREF: start+354p runLevel+41p ...
        cmp musType, 1
        jnz short loc_4DB5B
        mov ah, 2
        int 80h     ; LINUX -
        jmp short locret_4DB76
; ---------------------------------------------------------------------------

loc_4DB5B:              ; CODE XREF: sound?3+5j
        cmp musType, 3
        jnz short loc_4DB6B
        mov dx, 388h
        mov ah, 2
        int 80h     ; LINUX -
        jmp short locret_4DB76
; ---------------------------------------------------------------------------

loc_4DB6B:              ; CODE XREF: sound?3+12j
        cmp musType, 5
        jnz short locret_4DB76
        mov ah, 2
        int 80h     ; LINUX -

locret_4DB76:               ; CODE XREF: sound?3+Bj sound?3+1Bj ...
        retn
sound?3     endp


; =============== S U B R O U T I N E =======================================


sound?4     proc near       ; CODE XREF: sub_4A61F+2EDp code:5ADEp ...
        cmp byte_59885, 1
        jz  short loc_4DB7F
        retn
; ---------------------------------------------------------------------------

loc_4DB7F:              ; CODE XREF: sound?4+5j
        cmp byte_59889, 5
        jl  short loc_4DB87
        retn
; ---------------------------------------------------------------------------

loc_4DB87:              ; CODE XREF: sound?4+Dj
        mov byte_5988B, 0Fh
        mov byte_59889, 5
        cmp sndType, 1
        jnz short loc_4DB9F
        mov ax, 400h
        int 80h     ; LINUX -
        jmp short locret_4DBDF
; ---------------------------------------------------------------------------

loc_4DB9F:              ; CODE XREF: sound?4+1Fj
        cmp sndType, 2
        jnz short loc_4DBB4
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 0
        int 81h
        jmp short locret_4DBDF
; ---------------------------------------------------------------------------

loc_4DBB4:              ; CODE XREF: sound?4+2Dj
        cmp sndType, 3
        jnz short loc_4DBC5
        mov ax, 400h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DBDF
; ---------------------------------------------------------------------------

loc_4DBC5:              ; CODE XREF: sound?4+42j
        cmp sndType, 4
        jnz short loc_4DBD3
        mov ax, 0
        int 81h
        jmp short locret_4DBDF
; ---------------------------------------------------------------------------

loc_4DBD3:              ; CODE XREF: sound?4+53j
        cmp sndType, 5
        jnz short locret_4DBDF
        mov ax, 400h
        int 80h     ; LINUX -

locret_4DBDF:               ; CODE XREF: sound?4+26j sound?4+3Bj ...
        retn
sound?4     endp


; =============== S U B R O U T I N E =======================================


sound?5     proc near       ; CODE XREF: update?:loc_4E55Cp
                    ; update?:loc_4E588p ...
        cmp byte_59885, 1
        jz  short loc_4DBE8
        retn
; ---------------------------------------------------------------------------

loc_4DBE8:              ; CODE XREF: sound?5+5j
        cmp byte_59889, 5
        jl  short loc_4DBF0
        retn
; ---------------------------------------------------------------------------

loc_4DBF0:              ; CODE XREF: sound?5+Dj
        mov byte_5988B, 0Fh
        mov byte_59889, 4
        cmp sndType, 1
        jnz short loc_4DC08
        mov ax, 401h
        int 80h     ; LINUX -
        jmp short locret_4DC48
; ---------------------------------------------------------------------------

loc_4DC08:              ; CODE XREF: sound?5+1Fj
        cmp sndType, 2
        jnz short loc_4DC1D
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 1
        int 81h
        jmp short locret_4DC48
; ---------------------------------------------------------------------------

loc_4DC1D:              ; CODE XREF: sound?5+2Dj
        cmp sndType, 3
        jnz short loc_4DC2E
        mov ax, 401h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DC48
; ---------------------------------------------------------------------------

loc_4DC2E:              ; CODE XREF: sound?5+42j
        cmp sndType, 4
        jnz short loc_4DC3C
        mov ax, 1
        int 81h
        jmp short locret_4DC48
; ---------------------------------------------------------------------------

loc_4DC3C:              ; CODE XREF: sound?5+53j
        cmp sndType, 5
        jnz short locret_4DC48
        mov ax, 401h
        int 80h     ; LINUX -

locret_4DC48:               ; CODE XREF: sound?5+26j sound?5+3Bj ...
        retn
sound?5     endp


; =============== S U B R O U T I N E =======================================


sound?6     proc near       ; CODE XREF: update?+B8Bp
                    ; update?+136Cp
        cmp byte_59885, 1
        jz  short loc_4DC51
        retn
; ---------------------------------------------------------------------------

loc_4DC51:              ; CODE XREF: sound?6+5j
        cmp byte_59889, 2
        jl  short loc_4DC59
        retn
; ---------------------------------------------------------------------------

loc_4DC59:              ; CODE XREF: sound?6+Dj
        mov byte_5988B, 7
        mov byte_59889, 2
        cmp sndType, 1
        jnz short loc_4DC71
        mov ax, 402h
        int 80h     ; LINUX -
        jmp short locret_4DCB1
; ---------------------------------------------------------------------------

loc_4DC71:              ; CODE XREF: sound?6+1Fj
        cmp sndType, 2
        jnz short loc_4DC86
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 2
        int 81h
        jmp short locret_4DCB1
; ---------------------------------------------------------------------------

loc_4DC86:              ; CODE XREF: sound?6+2Dj
        cmp sndType, 3
        jnz short loc_4DC97
        mov ax, 402h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DCB1
; ---------------------------------------------------------------------------

loc_4DC97:              ; CODE XREF: sound?6+42j
        cmp sndType, 4
        jnz short loc_4DCA5
        mov ax, 2
        int 81h
        jmp short locret_4DCB1
; ---------------------------------------------------------------------------

loc_4DCA5:              ; CODE XREF: sound?6+53j
        cmp sndType, 5
        jnz short locret_4DCB1
        mov ax, 402h
        int 80h     ; LINUX -

locret_4DCB1:               ; CODE XREF: sound?6+26j sound?6+3Bj ...
        retn
sound?6     endp


; =============== S U B R O U T I N E =======================================


sound?7     proc near       ; CODE XREF: movefun:loc_48125p
                    ; movefun2:loc_48573p
        cmp byte_59885, 1
        jz  short loc_4DCBA
        retn
; ---------------------------------------------------------------------------

loc_4DCBA:              ; CODE XREF: sound?7+5j
        cmp byte_59889, 2
        jl  short loc_4DCC2
        retn
; ---------------------------------------------------------------------------

loc_4DCC2:              ; CODE XREF: sound?7+Dj
        mov byte_5988B, 7
        mov byte_59889, 2
        cmp sndType, 1
        jnz short loc_4DCDA
        mov ax, 403h
        int 80h     ; LINUX -
        jmp short locret_4DD1A
; ---------------------------------------------------------------------------

loc_4DCDA:              ; CODE XREF: sound?7+1Fj
        cmp sndType, 2
        jnz short loc_4DCEF
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 3
        int 81h
        jmp short locret_4DD1A
; ---------------------------------------------------------------------------

loc_4DCEF:              ; CODE XREF: sound?7+2Dj
        cmp sndType, 3
        jnz short loc_4DD00
        mov ax, 403h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DD1A
; ---------------------------------------------------------------------------

loc_4DD00:              ; CODE XREF: sound?7+42j
        cmp sndType, 4
        jnz short loc_4DD0E
        mov ax, 3
        int 81h
        jmp short locret_4DD1A
; ---------------------------------------------------------------------------

loc_4DD0E:              ; CODE XREF: sound?7+53j
        cmp sndType, 5
        jnz short locret_4DD1A
        mov ax, 403h
        int 80h     ; LINUX -

locret_4DD1A:               ; CODE XREF: sound?7+26j sound?7+3Bj ...
        retn
sound?7     endp


; =============== S U B R O U T I N E =======================================


sound?8     proc near       ; CODE XREF: movefun7:loc_4A0ABp
        cmp byte_59885, 1
        jz  short loc_4DD23
        retn
; ---------------------------------------------------------------------------

loc_4DD23:              ; CODE XREF: sound?8+5j
        cmp byte_59889, 3
        jl  short loc_4DD2B
        retn
; ---------------------------------------------------------------------------

loc_4DD2B:              ; CODE XREF: sound?8+Dj
        mov byte_5988B, 3
        mov byte_59889, 3
        cmp sndType, 1
        jnz short loc_4DD43
        mov ax, 404h
        int 80h     ; LINUX -
        jmp short locret_4DD83
; ---------------------------------------------------------------------------

loc_4DD43:              ; CODE XREF: sound?8+1Fj
        cmp sndType, 2
        jnz short loc_4DD58
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 4
        int 81h
        jmp short locret_4DD83
; ---------------------------------------------------------------------------

loc_4DD58:              ; CODE XREF: sound?8+2Dj
        cmp sndType, 3
        jnz short loc_4DD69
        mov ax, 404h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DD83
; ---------------------------------------------------------------------------

loc_4DD69:              ; CODE XREF: sound?8+42j
        cmp sndType, 4
        jnz short loc_4DD77
        mov ax, 4
        int 81h
        jmp short locret_4DD83
; ---------------------------------------------------------------------------

loc_4DD77:              ; CODE XREF: sound?8+53j
        cmp sndType, 5
        jnz short locret_4DD83
        mov ax, 404h
        int 80h     ; LINUX -

locret_4DD83:               ; CODE XREF: sound?8+26j sound?8+3Bj ...
        retn
sound?8     endp


; =============== S U B R O U T I N E =======================================


sound?9     proc near       ; CODE XREF: runLevel+2F4p
                    ; update?:loc_4E3E1p ...
        cmp byte_59885, 1
        jz  short xxxxxxxxdcdc
        retn
; ---------------------------------------------------------------------------

xxxxxxxxdcdc:               ; CODE XREF: sound?9+5j
        cmp byte_59889, 1
        jl  short loc_4DD94
        retn
; ---------------------------------------------------------------------------

loc_4DD94:              ; CODE XREF: sound?9+Dj
        mov byte_5988B, 3
        mov byte_59889, 1
        cmp sndType, 1
        jnz short loc_4DDAC
        mov ax, 405h
        int 80h     ; LINUX -
        jmp short locret_4DDEC
; ---------------------------------------------------------------------------

loc_4DDAC:              ; CODE XREF: sound?9+1Fj
        cmp sndType, 2
        jnz short loc_4DDC1
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 5
        int 81h
        jmp short locret_4DDEC
; ---------------------------------------------------------------------------

loc_4DDC1:              ; CODE XREF: sound?9+2Dj
        cmp sndType, 3
        jnz short loc_4DDD2
        mov ax, 405h
        mov dx, 388h
        int 80h     ; LINUX -
        jmp short locret_4DDEC
; ---------------------------------------------------------------------------

loc_4DDD2:              ; CODE XREF: sound?9+42j
        cmp sndType, 4
        jnz short loc_4DDE0
        mov ax, 5
        int 81h
        jmp short locret_4DDEC
; ---------------------------------------------------------------------------

loc_4DDE0:              ; CODE XREF: sound?9+53j
        cmp sndType, 5
        jnz short locret_4DDEC
        mov ax, 405h
        int 80h     ; LINUX -

locret_4DDEC:               ; CODE XREF: sound?9+26j sound?9+3Bj ...
        retn
sound?9     endp


; =============== S U B R O U T I N E =======================================


sound?10    proc near       ; CODE XREF: update?+7EBp
        cmp byte_59885, 1
        jz  short loc_4DDF5
        retn
; ---------------------------------------------------------------------------

loc_4DDF5:              ; CODE XREF: sound?10+5j
        mov byte_5988B, 0FAh ; '?'
        mov byte_59889, 0Ah
        call    sound?3
        cmp sndType, 1
        jnz short loc_4DE10
        mov ax, 1
        int 80h     ; LINUX - sys_exit
; ---------------------------------------------------------------------------
        jmp short locret_4DE5E
; ---------------------------------------------------------------------------

loc_4DE10:              ; CODE XREF: sound?10+1Aj
        cmp sndType, 2
        jnz short loc_4DE25
        mov dx, 5D38h
        mov ah, 3
        int 81h
        mov ax, 6
        int 81h
        jmp short locret_4DE5E
; ---------------------------------------------------------------------------

loc_4DE25:              ; CODE XREF: sound?10+28j
        cmp sndType, 3
        jnz short loc_4DE36
        mov ax, 1
        mov dx, 388h
        int 80h     ; LINUX - sys_exit
; ---------------------------------------------------------------------------
        jmp short locret_4DE5E
; ---------------------------------------------------------------------------

loc_4DE36:              ; CODE XREF: sound?10+3Dj
        cmp sndType, 4
        jnz short loc_4DE52
        cmp musType, 5
        jnz short loc_4DE4B
        mov ax, 1
        int 80h     ; LINUX - sys_exit
; ---------------------------------------------------------------------------
        jmp short locret_4DE5E
; ---------------------------------------------------------------------------

loc_4DE4B:              ; CODE XREF: sound?10+55j
        mov ax, 6
        int 81h
        jmp short locret_4DE5E
; ---------------------------------------------------------------------------

loc_4DE52:              ; CODE XREF: sound?10+4Ej
        cmp sndType, 5
        jnz short locret_4DE5E
        mov ax, 1
        int 80h     ; LINUX - sys_exit
; ---------------------------------------------------------------------------

locret_4DE5E:               ; CODE XREF: sound?10+21j sound?10+36j ...
        retn
sound?10    endp


; =============== S U B R O U T I N E =======================================


sound?11    proc near       ; CODE XREF: int8handler+51p
        cmp musType, 1
        jnz short loc_4DE6C
        mov ah, 1
        int 80h     ; LINUX -
        jmp short locret_4DE87
; ---------------------------------------------------------------------------

loc_4DE6C:              ; CODE XREF: sound?11+5j
        cmp musType, 3
        jnz short loc_4DE7C
        mov dx, 388h
        mov ah, 1
        int 80h     ; LINUX -
        jmp short locret_4DE87
; ---------------------------------------------------------------------------

loc_4DE7C:              ; CODE XREF: sound?11+12j
        cmp musType, 5
        jnz short locret_4DE87
        mov ah, 1
        int 80h     ; LINUX -

locret_4DE87:               ; CODE XREF: sound?11+Bj sound?11+1Bj ...
        retn
sound?11    endp

; ---------------------------------------------------------------------------
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  8Bh ; ?
        db 0C0h ; +

; =============== S U B R O U T I N E =======================================


update?     proc near       ; CODE XREF: gameloop?+Ep

        cmp byte ptr leveldata[si], 3
        jz  short hasValidMurphy
        mov word_510CF, 0
        retn
; ---------------------------------------------------------------------------

hasValidMurphy:              ; CODE XREF: update?+5j
        mov word_510CF, 1
        mov word_510C7, si
        mov ax, leveldata[si]
        cmp ax, 3
        jz  short loc_4DEB4
        jmp loc_4EA07
; ---------------------------------------------------------------------------

loc_4DEB4:              ; CODE XREF: update?+1Fj
        mov byte_510D8, 0
        cmp byte_5101C, 0
        jz  short loc_4DEE1
        cmp byte ptr [si+17BCh], 0Ch
        jz  short loc_4DEE1
        cmp byte ptr [si+17BCh], 15h
        jz  short loc_4DEE1
        cmp byte ptr [si+17BCh], 17h
        jz  short loc_4DEE1
        cmp word ptr [si+18ACh], 0
        jnz short loc_4DEE1
        mov byte_510D8, 1

loc_4DEE1:              ; CODE XREF: update?+2Ej update?+35j ...
        mov bl, byte_50941
        cmp bl, 0
        jz  short loc_4DEED
        jmp loc_4E001
; ---------------------------------------------------------------------------

loc_4DEED:              ; CODE XREF: update?+58j
        mov byte_510D3, 1
        cmp byte_510D8, 0
        jz  short loc_4DEFC
        jmp loc_4E38A
; ---------------------------------------------------------------------------

loc_4DEFC:              ; CODE XREF: update?+67j
        mov ax, word_5195D
        and ax, 3
        jz  short loc_4DF05
        retn
; ---------------------------------------------------------------------------

loc_4DF05:              ; CODE XREF: update?+72j
        inc word_510CD
        cmp word_510CD, 4
        jnz short loc_4DF1E
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4DF1E:              ; CODE XREF: update?+7Ej
        cmp word_510CD, 1F4h
        jg  short loc_4DF27
        retn
; ---------------------------------------------------------------------------

loc_4DF27:              ; CODE XREF: update?+94j
        cmp word_510CD, 20Ah
        jg  short loc_4DF4A
        push    si
        mov di, [si+6155h]
        mov si, 14F4h
        mov bx, word_510CD
        sub bx, 1F4h
        shr bx, 1
        shl bx, 1
        mov si, [bx+si]
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4DF4A:              ; CODE XREF: update?+9Dj
        cmp word_510CD, 3E8h
        jg  short loc_4DF53
        retn
; ---------------------------------------------------------------------------

loc_4DF53:              ; CODE XREF: update?+C0j
        cmp word_510CD, 3FEh
        jg  short loc_4DF76
        push    si
        mov di, [si+6155h]
        mov si, 14F4h
        mov bx, word_510CD
        sub bx, 3E8h
        shr bx, 1
        shl bx, 1
        mov si, [bx+si]
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4DF76:              ; CODE XREF: update?+C9j
        cmp word_510CD, 640h
        jg  short loc_4DF7F
        retn
; ---------------------------------------------------------------------------

loc_4DF7F:              ; CODE XREF: update?+ECj
        cmp word_510CD, 656h
        jg  short loc_4DFA2
        push    si
        mov di, [si+6155h]
        mov si, 14F4h
        mov bx, word_510CD
        sub bx, 640h
        shr bx, 1
        shl bx, 1
        mov si, [bx+si]
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4DFA2:              ; CODE XREF: update?+F5j
        cmp word_510CD, 676h
        jg  short locret_4DFBE
        cmp word ptr [si+1832h], 0
        jnz short loc_4DFBF
        cmp word ptr [si+1836h], 0
        jnz short loc_4DFE0
        mov word_510CD, 24h ; '$'

locret_4DFBE:               ; CODE XREF: update?+118j
        retn
; ---------------------------------------------------------------------------

loc_4DFBF:              ; CODE XREF: update?+11Fj
        push    si
        mov di, [si+6155h]
        mov si, 150Eh
        mov bx, word_510CD
        sub bx, 656h
        shr bx, 1
        shr bx, 1
        shr bx, 1
        shr bx, 1
        shl bx, 1
        mov si, [bx+si]
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4DFE0:              ; CODE XREF: update?+126j
        push    si
        mov di, [si+6155h]
        mov si, 1516h
        mov bx, word_510CD
        sub bx, 656h
        shr bx, 1
        shr bx, 1
        shr bx, 1
        shr bx, 1
        shl bx, 1
        mov si, [bx+si]
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4E001:              ; CODE XREF: update?+5Aj
        cmp byte_510D8, 0
        jz  short loc_4E035
        cmp word ptr [si+18ACh], 0
        jnz short loc_4E035
        cmp bl, 1
        jnz short loc_4E01B
        cmp word ptr [si+17BCh], 2
        jz  short loc_4E035

loc_4E01B:              ; CODE XREF: update?+182j
        cmp bl, 2
        jnz short loc_4E027
        cmp word ptr [si+1832h], 2
        jz  short loc_4E035

loc_4E027:              ; CODE XREF: update?+18Ej
        cmp bl, 4
        jnz short loc_4E033
        cmp word ptr [si+1836h], 2
        jz  short loc_4E035

loc_4E033:              ; CODE XREF: update?+19Aj
        mov bl, 3

loc_4E035:              ; CODE XREF: update?+176j update?+17Dj ...
        cmp bl, 1
        jnz short loc_4E041
        mov byte_510D3, 0
        jmp short loc_4E0AA
; ---------------------------------------------------------------------------

loc_4E041:              ; CODE XREF: update?+1A8j
        cmp bl, 2
        jnz short loc_4E04E
        mov byte_510D3, 0
        jmp loc_4E10C
; ---------------------------------------------------------------------------

loc_4E04E:              ; CODE XREF: update?+1B4j
        cmp bl, 3
        jnz short loc_4E05B
        mov byte_510D3, 0
        jmp loc_4E186
; ---------------------------------------------------------------------------

loc_4E05B:              ; CODE XREF: update?+1C1j
        cmp bl, 4
        jnz short loc_4E068
        mov byte_510D3, 0
        jmp loc_4E1E8
; ---------------------------------------------------------------------------

loc_4E068:              ; CODE XREF: update?+1CEj
        cmp bl, 5
        jnz short loc_4E075
        mov byte_510D3, 0
        jmp loc_4E260
; ---------------------------------------------------------------------------

loc_4E075:              ; CODE XREF: update?+1DBj
        cmp bl, 6
        jnz short loc_4E082
        mov byte_510D3, 0
        jmp loc_4E28A
; ---------------------------------------------------------------------------

loc_4E082:              ; CODE XREF: update?+1E8j
        cmp bl, 7
        jnz short loc_4E08F
        mov byte_510D3, 0
        jmp loc_4E2BA
; ---------------------------------------------------------------------------

loc_4E08F:              ; CODE XREF: update?+1F5j
        cmp bl, 8
        jnz short loc_4E09C
        mov byte_510D3, 0
        jmp loc_4E2E4
; ---------------------------------------------------------------------------

loc_4E09C:              ; CODE XREF: update?+202j
        cmp bl, 9
        jnz short loc_4E0A4
        jmp loc_4E314
; ---------------------------------------------------------------------------

loc_4E0A4:              ; CODE XREF: update?+20Fj
        mov byte_510D3, 0
        retn
; ---------------------------------------------------------------------------

loc_4E0AA:              ; CODE XREF: update?+1AFj update?+279j
        mov ax, [si+17BCh]
        cmp ax, 0
        jnz short loc_4E0B6
        jmp loc_4E344
; ---------------------------------------------------------------------------

loc_4E0B6:              ; CODE XREF: update?+221j
        cmp ax, 2
        jnz short loc_4E0BE
        jmp loc_4E3E1
; ---------------------------------------------------------------------------

loc_4E0BE:              ; CODE XREF: update?+229j
        cmp al, 19h
        jnz short loc_4E0C5
        jmp loc_4E3D0
; ---------------------------------------------------------------------------

loc_4E0C5:              ; CODE XREF: update?+230j
        cmp ax, 4
        jnz short loc_4E0CD
        jmp loc_4E55C
; ---------------------------------------------------------------------------

loc_4E0CD:              ; CODE XREF: update?+238j
        cmp ax, 7
        jnz short loc_4E0D5
        jmp loc_4E674
; ---------------------------------------------------------------------------

loc_4E0D5:              ; CODE XREF: update?+240j
        cmp al, 13h
        jnz short loc_4E0DC
        jmp loc_4E712
; ---------------------------------------------------------------------------

loc_4E0DC:              ; CODE XREF: update?+247j
        cmp al, 0Ch
        jnz short loc_4E0E3
        jmp loc_4E7DE
; ---------------------------------------------------------------------------

loc_4E0E3:              ; CODE XREF: update?+24Ej
        cmp al, 15h
        jnz short loc_4E0EA
        jmp loc_4E7DE
; ---------------------------------------------------------------------------

loc_4E0EA:              ; CODE XREF: update?+255j
        cmp al, 17h
        jnz short loc_4E0F1
        jmp loc_4E7DE
; ---------------------------------------------------------------------------

loc_4E0F1:              ; CODE XREF: update?+25Cj
        cmp al, 14h
        jnz short loc_4E0F8
        jmp loc_4E847
; ---------------------------------------------------------------------------

loc_4E0F8:              ; CODE XREF: update?+263j
        cmp al, 12h
        jnz short loc_4E0FF
        jmp loc_4E8F9
; ---------------------------------------------------------------------------

loc_4E0FF:              ; CODE XREF: update?+26Aj
        push    si
        sub si, 78h ; 'x'
        call    sub_4F21F
        pop si
        jb  short locret_4E10B
        jmp short loc_4E0AA
; ---------------------------------------------------------------------------

locret_4E10B:               ; CODE XREF: update?+277j
        retn
; ---------------------------------------------------------------------------

loc_4E10C:              ; CODE XREF: update?+1BBj update?+2F3j
        mov word_510CB, 1
        mov ax, [si+1832h]
        cmp ax, 0
        jnz short loc_4E11E
        jmp loc_4E36D
; ---------------------------------------------------------------------------

loc_4E11E:              ; CODE XREF: update?+289j
        cmp ax, 2
        jnz short loc_4E126
        jmp loc_4E41E
; ---------------------------------------------------------------------------

loc_4E126:              ; CODE XREF: update?+291j
        cmp al, 19h
        jnz short loc_4E12D
        jmp loc_4E40D
; ---------------------------------------------------------------------------

loc_4E12D:              ; CODE XREF: update?+298j
        cmp ax, 4
        jnz short loc_4E135
        jmp loc_4E588
; ---------------------------------------------------------------------------

loc_4E135:              ; CODE XREF: update?+2A0j
        cmp ax, 7
        jnz short loc_4E13D
        jmp loc_4E674
; ---------------------------------------------------------------------------

loc_4E13D:              ; CODE XREF: update?+2A8j
        cmp ax, 1
        jnz short loc_4E145
        jmp loc_4E6BA
; ---------------------------------------------------------------------------

loc_4E145:              ; CODE XREF: update?+2B0j
        cmp al, 13h
        jnz short loc_4E14C
        jmp loc_4E73C
; ---------------------------------------------------------------------------

loc_4E14C:              ; CODE XREF: update?+2B7j
        cmp al, 0Bh
        jnz short loc_4E153
        jmp loc_4E7F5
; ---------------------------------------------------------------------------

loc_4E153:              ; CODE XREF: update?+2BEj
        cmp al, 16h
        jnz short loc_4E15A
        jmp loc_4E7F5
; ---------------------------------------------------------------------------

loc_4E15A:              ; CODE XREF: update?+2C5j
        cmp al, 17h
        jnz short loc_4E161
        jmp loc_4E7F5
; ---------------------------------------------------------------------------

loc_4E161:              ; CODE XREF: update?+2CCj
        cmp ax, 14h
        jnz short loc_4E169
        jmp loc_4E863
; ---------------------------------------------------------------------------

loc_4E169:              ; CODE XREF: update?+2D4j
        cmp ax, 12h
        jnz short loc_4E171
        jmp loc_4E920
; ---------------------------------------------------------------------------

loc_4E171:              ; CODE XREF: update?+2DCj
        cmp ax, 8
        jnz short loc_4E179
        jmp loc_4E993
; ---------------------------------------------------------------------------

loc_4E179:              ; CODE XREF: update?+2E4j
        push    si
        sub si, 2
        call    sub_4F21F
        pop si
        jb  short locret_4E185
        jmp short loc_4E10C
; ---------------------------------------------------------------------------

locret_4E185:               ; CODE XREF: update?+2F1j
        retn
; ---------------------------------------------------------------------------

loc_4E186:              ; CODE XREF: update?+1C8j update?+355j
        mov ax, leveldata[si+78h]
        cmp ax, 0
        jnz short loc_4E192
        jmp loc_4E38A
; ---------------------------------------------------------------------------

loc_4E192:              ; CODE XREF: update?+2FDj
        cmp ax, 2
        jnz short loc_4E19A
        jmp loc_4E44F
; ---------------------------------------------------------------------------

loc_4E19A:              ; CODE XREF: update?+305j
        cmp al, 19h
        jnz short loc_4E1A1
        jmp loc_4E43E
; ---------------------------------------------------------------------------

loc_4E1A1:              ; CODE XREF: update?+30Cj
        cmp ax, 4
        jnz short loc_4E1A9
        jmp loc_4E5A8
; ---------------------------------------------------------------------------

loc_4E1A9:              ; CODE XREF: update?+314j
        cmp ax, 7
        jnz short loc_4E1B1
        jmp loc_4E674
; ---------------------------------------------------------------------------

loc_4E1B1:              ; CODE XREF: update?+31Cj
        cmp al, 13h
        jnz short loc_4E1B8
        jmp loc_4E766
; ---------------------------------------------------------------------------

loc_4E1B8:              ; CODE XREF: update?+323j
        cmp al, 0Ah
        jnz short loc_4E1BF
        jmp loc_4E80C
; ---------------------------------------------------------------------------

loc_4E1BF:              ; CODE XREF: update?+32Aj
        cmp al, 15h
        jnz short loc_4E1C6
        jmp loc_4E80C
; ---------------------------------------------------------------------------

loc_4E1C6:              ; CODE XREF: update?+331j
        cmp al, 17h
        jnz short loc_4E1CD
        jmp loc_4E80C
; ---------------------------------------------------------------------------

loc_4E1CD:              ; CODE XREF: update?+338j
        cmp al, 14h
        jnz short loc_4E1D4
        jmp loc_4E87F
; ---------------------------------------------------------------------------

loc_4E1D4:              ; CODE XREF: update?+33Fj
        cmp al, 12h
        jnz short loc_4E1DB
        jmp loc_4E947
; ---------------------------------------------------------------------------

loc_4E1DB:              ; CODE XREF: update?+346j
        push    si
        add si, 78h ; 'x'
        call    sub_4F21F
        pop si
        jb  short locret_4E1E7
        jmp short loc_4E186
; ---------------------------------------------------------------------------

locret_4E1E7:               ; CODE XREF: update?+353j
        retn
; ---------------------------------------------------------------------------

loc_4E1E8:              ; CODE XREF: update?+1D5j update?+3CDj
        mov word_510CB, 0
        mov ax, leveldata[si+2]
        cmp ax, 0
        jnz short loc_4E1FA
        jmp loc_4E3B3
; ---------------------------------------------------------------------------

loc_4E1FA:              ; CODE XREF: update?+365j
        cmp ax, 2
        jnz short loc_4E202
        jmp loc_4E48C
; ---------------------------------------------------------------------------

loc_4E202:              ; CODE XREF: update?+36Dj
        cmp al, 19h
        jnz short loc_4E209
        jmp loc_4E47B
; ---------------------------------------------------------------------------

loc_4E209:              ; CODE XREF: update?+374j
        cmp ax, 4
        jnz short loc_4E211
        jmp loc_4E5D4
; ---------------------------------------------------------------------------

loc_4E211:              ; CODE XREF: update?+37Cj
        cmp ax, 7
        jnz short loc_4E219
        jmp loc_4E674
; ---------------------------------------------------------------------------

loc_4E219:              ; CODE XREF: update?+384j
        cmp ax, 1
        jnz short loc_4E221
        jmp loc_4E6E1
; ---------------------------------------------------------------------------

loc_4E221:              ; CODE XREF: update?+38Cj
        cmp al, 13h
        jnz short loc_4E228
        jmp loc_4E790
; ---------------------------------------------------------------------------

loc_4E228:              ; CODE XREF: update?+393j
        cmp al, 9
        jnz short loc_4E22F
        jmp loc_4E823
; ---------------------------------------------------------------------------

loc_4E22F:              ; CODE XREF: update?+39Aj
        cmp al, 16h
        jnz short loc_4E236
        jmp loc_4E823
; ---------------------------------------------------------------------------

loc_4E236:              ; CODE XREF: update?+3A1j
        cmp al, 17h
        jnz short loc_4E23D
        jmp loc_4E823
; ---------------------------------------------------------------------------

loc_4E23D:              ; CODE XREF: update?+3A8j
        cmp al, 14h
        jnz short loc_4E244
        jmp loc_4E89A
; ---------------------------------------------------------------------------

loc_4E244:              ; CODE XREF: update?+3AFj
        cmp al, 12h
        jnz short loc_4E24B
        jmp loc_4E96D
; ---------------------------------------------------------------------------

loc_4E24B:              ; CODE XREF: update?+3B6j
        cmp ax, 8
        jnz short loc_4E253
        jmp loc_4E9B9
; ---------------------------------------------------------------------------

loc_4E253:              ; CODE XREF: update?+3BEj
        push    si
        add si, 2
        call    sub_4F21F
        pop si
        jb  short locret_4E25F
        jmp short loc_4E1E8
; ---------------------------------------------------------------------------

locret_4E25F:               ; CODE XREF: update?+3CBj
        retn
; ---------------------------------------------------------------------------

loc_4E260:              ; CODE XREF: update?+1E2j
        mov ax, leveldata[si-78h]
        cmp ax, 2
        jnz short loc_4E26C
        jmp loc_4E4BD
; ---------------------------------------------------------------------------

loc_4E26C:              ; CODE XREF: update?+3D7j
        cmp al, 19h
        jnz short loc_4E273
        jmp loc_4E4AC
; ---------------------------------------------------------------------------

loc_4E273:              ; CODE XREF: update?+3DEj
        cmp ax, 4
        jnz short loc_4E27B
        jmp loc_4E5F4
; ---------------------------------------------------------------------------

loc_4E27B:              ; CODE XREF: update?+3E6j
        cmp al, 13h
        jnz short loc_4E282
        jmp loc_4E712
; ---------------------------------------------------------------------------

loc_4E282:              ; CODE XREF: update?+3EDj
        cmp al, 14h
        jnz short locret_4E289
        jmp loc_4E8B6
; ---------------------------------------------------------------------------

locret_4E289:               ; CODE XREF: update?+3F4j
        retn
; ---------------------------------------------------------------------------

loc_4E28A:              ; CODE XREF: update?+1EFj
        mov word_510CB, 1
        mov ax, [si+1832h]
        cmp ax, 2
        jnz short loc_4E29C
        jmp loc_4E4E9
; ---------------------------------------------------------------------------

loc_4E29C:              ; CODE XREF: update?+407j
        cmp al, 19h
        jnz short loc_4E2A3
        jmp loc_4E4D8
; ---------------------------------------------------------------------------

loc_4E2A3:              ; CODE XREF: update?+40Ej
        cmp ax, 4
        jnz short loc_4E2AB
        jmp loc_4E614
; ---------------------------------------------------------------------------

loc_4E2AB:              ; CODE XREF: update?+416j
        cmp al, 13h
        jnz short loc_4E2B2
        jmp loc_4E73C
; ---------------------------------------------------------------------------

loc_4E2B2:              ; CODE XREF: update?+41Dj
        cmp al, 14h
        jnz short locret_4E2B9
        jmp loc_4E8C5
; ---------------------------------------------------------------------------

locret_4E2B9:               ; CODE XREF: update?+424j
        retn
; ---------------------------------------------------------------------------

loc_4E2BA:              ; CODE XREF: update?+1FCj
        mov ax, [si+18ACh]
        cmp ax, 2
        jnz short loc_4E2C6
        jmp loc_4E515
; ---------------------------------------------------------------------------

loc_4E2C6:              ; CODE XREF: update?+431j
        cmp al, 19h
        jnz short loc_4E2CD
        jmp loc_4E504
; ---------------------------------------------------------------------------

loc_4E2CD:              ; CODE XREF: update?+438j
        cmp ax, 4
        jnz short loc_4E2D5
        jmp loc_4E634
; ---------------------------------------------------------------------------

loc_4E2D5:              ; CODE XREF: update?+440j
        cmp al, 13h
        jnz short loc_4E2DC
        jmp loc_4E766
; ---------------------------------------------------------------------------

loc_4E2DC:              ; CODE XREF: update?+447j
        cmp al, 14h
        jnz short locret_4E2E3
        jmp loc_4E8D4
; ---------------------------------------------------------------------------

locret_4E2E3:               ; CODE XREF: update?+44Ej
        retn
; ---------------------------------------------------------------------------

loc_4E2E4:              ; CODE XREF: update?+209j
        mov word_510CB, 0
        mov ax, [si+1836h]
        cmp ax, 2
        jnz short loc_4E2F6
        jmp loc_4E541
; ---------------------------------------------------------------------------

loc_4E2F6:              ; CODE XREF: update?+461j
        cmp al, 19h
        jnz short loc_4E2FD
        jmp loc_4E530
; ---------------------------------------------------------------------------

loc_4E2FD:              ; CODE XREF: update?+468j
        cmp ax, 4
        jnz short loc_4E305
        jmp loc_4E654
; ---------------------------------------------------------------------------

loc_4E305:              ; CODE XREF: update?+470j
        cmp al, 13h
        jnz short loc_4E30C
        jmp loc_4E790
; ---------------------------------------------------------------------------

loc_4E30C:              ; CODE XREF: update?+477j
        cmp al, 14h
        jnz short locret_4E313
        jmp loc_4E8E3
; ---------------------------------------------------------------------------

locret_4E313:               ; CODE XREF: update?+47Ej
        retn
; ---------------------------------------------------------------------------

loc_4E314:              ; CODE XREF: update?+211j
        cmp byte_5195C, 0
        jz  short locret_4E343
        cmp byte_510DB, 0
        jnz short locret_4E343
        cmp byte_510D3, 1
        jnz short locret_4E343
        mov byte ptr [si+1835h], 2Ah ; '*'
        mov word_510EE, 40h ; '@'
        mov dx, 110Eh
        mov byte_510DB, 1
        mov word_510DC, si
        jmp loc_4E9F3
; ---------------------------------------------------------------------------

locret_4E343:               ; CODE XREF: update?+489j update?+490j ...
        retn
; ---------------------------------------------------------------------------

loc_4E344:              ; CODE XREF: update?+223j
        cmp word_510CB, 0
        jz  short loc_4E350
        mov dx, 0DFEh
        jmp short loc_4E353
; ---------------------------------------------------------------------------

loc_4E350:              ; CODE XREF: update?+4B9j
        mov dx, 0E0Eh

loc_4E353:              ; CODE XREF: update?+4BEj
        mov byte ptr [si+17BDh], 1
        mov byte ptr [si+17BCh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E36D:              ; CODE XREF: update?+28Bj
        mov dx, 0E1Eh
        mov byte ptr [si+1833h], 2
        mov byte ptr [si+1832h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E38A:              ; CODE XREF: update?+69j update?+2FFj
        cmp word_510CB, 0
        jz  short loc_4E396
        mov dx, 0E2Eh
        jmp short loc_4E399
; ---------------------------------------------------------------------------

loc_4E396:              ; CODE XREF: update?+4FFj
        mov dx, 0E3Eh

loc_4E399:              ; CODE XREF: update?+504j
        mov byte ptr [si+18ADh], 3
        mov byte ptr [si+18ACh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E3B3:              ; CODE XREF: update?+367j
        mov dx, 0E4Eh
        mov byte ptr [si+1837h], 4
        mov byte ptr [si+1836h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E3D0:              ; CODE XREF: update?+232j
        cmp byte ptr [si+17BDh], 0
        jl  short loc_4E3DB
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E3DB:              ; CODE XREF: update?+545j
        mov word ptr [si+17BCh], 2

loc_4E3E1:              ; CODE XREF: update?+22Bj
        call    sound?9
        cmp word_510CB, 0
        jz  short loc_4E3F0
        mov dx, 0E6Eh
        jmp short loc_4E3F3
; ---------------------------------------------------------------------------

loc_4E3F0:              ; CODE XREF: update?+559j
        mov dx, 0E7Eh

loc_4E3F3:              ; CODE XREF: update?+55Ej
        mov byte ptr [si+17BDh], 5
        mov byte ptr [si+17BCh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E40D:              ; CODE XREF: update?+29Aj
        cmp byte ptr [si+1833h], 0
        jl  short loc_4E418
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E418:              ; CODE XREF: update?+582j
        mov word ptr [si+1832h], 2

loc_4E41E:              ; CODE XREF: update?+293j
        call    sound?9
        mov dx, 0E8Eh
        mov byte ptr [si+1833h], 2
        mov byte ptr [si+1832h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E43E:              ; CODE XREF: update?+30Ej
        cmp byte ptr [si+18ADh], 0
        jl  short loc_4E449
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E449:              ; CODE XREF: update?+5B3j
        mov word ptr [si+18ACh], 2

loc_4E44F:              ; CODE XREF: update?+307j
        call    sound?9
        cmp word_510CB, 0
        jz  short loc_4E45E
        mov dx, 0E9Eh
        jmp short loc_4E461
; ---------------------------------------------------------------------------

loc_4E45E:              ; CODE XREF: update?+5C7j
        mov dx, 0EAEh

loc_4E461:              ; CODE XREF: update?+5CCj
        mov byte ptr [si+18ADh], 7
        mov byte ptr [si+18ACh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E47B:              ; CODE XREF: update?+376j
        cmp byte ptr [si+1837h], 0
        jl  short loc_4E486
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E486:              ; CODE XREF: update?+5F0j
        mov word ptr [si+1836h], 2

loc_4E48C:              ; CODE XREF: update?+36Fj
        call    sound?9
        mov dx, 0EBEh
        mov byte ptr [si+1837h], 8
        mov byte ptr [si+1836h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E4AC:              ; CODE XREF: update?+3E0j
        cmp byte ptr [si+17BDh], 0
        jl  short loc_4E4B7
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E4B7:              ; CODE XREF: update?+621j
        mov word ptr [si+17BCh], 2

loc_4E4BD:              ; CODE XREF: update?+3D9j
        push    si
        mov di, [si+6155h]
        mov si, word_51840
        call    sub_4F200
        pop si
        call    sound?9
        mov dx, 0ECEh
        mov byte ptr [si+1835h], 10h
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E4D8:              ; CODE XREF: update?+410j
        cmp byte ptr [si+1833h], 0
        jl  short loc_4E4E3
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E4E3:              ; CODE XREF: update?+64Dj
        mov word ptr [si+1832h], 2

loc_4E4E9:              ; CODE XREF: update?+409j
        push    si
        mov di, [si+6155h]
        mov si, word_51842
        call    sub_4F200
        pop si
        call    sound?9
        mov dx, 0EDEh
        mov byte ptr [si+1835h], 11h
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E504:              ; CODE XREF: update?+43Aj
        cmp byte ptr [si+18ADh], 0
        jl  short loc_4E50F
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E50F:              ; CODE XREF: update?+679j
        mov word ptr [si+18ACh], 2

loc_4E515:              ; CODE XREF: update?+433j
        push    si
        mov di, [si+6155h]
        mov si, word_51844
        call    sub_4F200
        pop si
        call    sound?9
        mov dx, 0EEEh
        mov byte ptr [si+1835h], 12h
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E530:              ; CODE XREF: update?+46Aj
        cmp byte ptr [si+1837h], 0
        jl  short loc_4E53B
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4E53B:              ; CODE XREF: update?+6A5j
        mov word ptr [si+1836h], 2

loc_4E541:              ; CODE XREF: update?+463j
        push    si
        mov di, [si+6155h]
        mov si, word_51846
        call    sub_4F200
        pop si
        call    sound?9
        mov dx, 0EFEh
        mov byte ptr [si+1835h], 13h
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E55C:              ; CODE XREF: update?+23Aj
        call    sound?5
        cmp word_510CB, 0
        jz  short loc_4E56B
        mov dx, 0F0Eh
        jmp short loc_4E56E
; ---------------------------------------------------------------------------

loc_4E56B:              ; CODE XREF: update?+6D4j
        mov dx, 0F1Eh

loc_4E56E:              ; CODE XREF: update?+6D9j
        mov byte ptr [si+17BDh], 9
        mov byte ptr [si+17BCh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E588:              ; CODE XREF: update?+2A2j
        call    sound?5
        mov dx, 0F2Eh
        mov byte ptr [si+1833h], 0Ah
        mov byte ptr [si+1832h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E5A8:              ; CODE XREF: update?+316j
        call    sound?5
        cmp word_510CB, 0
        jz  short loc_4E5B7
        mov dx, 0F3Eh
        jmp short loc_4E5BA
; ---------------------------------------------------------------------------

loc_4E5B7:              ; CODE XREF: update?+720j
        mov dx, 0F4Eh

loc_4E5BA:              ; CODE XREF: update?+725j
        mov byte ptr [si+18ADh], 0Bh
        mov byte ptr [si+18ACh], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 78h ; 'x'
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E5D4:              ; CODE XREF: update?+37Ej
        call    sound?5
        mov dx, 0F5Eh
        mov byte ptr [si+1837h], 0Ch
        mov byte ptr [si+1836h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 2
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E5F4:              ; CODE XREF: update?+3E8j
        push    si
        mov di, [si+6155h]
        mov si, word_51840
        call    sub_4F200
        pop si
        call    sound?5
        mov dx, 0F6Eh
        mov byte ptr [si+1835h], 14h
        mov byte ptr [si+17BDh], 0FFh
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E614:              ; CODE XREF: update?+418j
        push    si
        mov di, [si+6155h]
        mov si, word_51842
        call    sub_4F200
        pop si
        call    sound?5
        mov dx, 0F7Eh
        mov byte ptr [si+1835h], 15h
        mov byte ptr [si+1833h], 0FFh
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E634:              ; CODE XREF: update?+442j
        push    si
        mov di, [si+6155h]
        mov si, word_51844
        call    sub_4F200
        pop si
        call    sound?5
        mov dx, 0F8Eh
        mov byte ptr [si+1835h], 16h
        mov byte ptr [si+18ADh], 0FFh
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E654:              ; CODE XREF: update?+472j
        push    si
        mov di, [si+6155h]
        mov si, word_51846
        call    sub_4F200
        pop si
        call    sound?5
        mov dx, 0F9Eh
        mov byte ptr [si+1835h], 17h
        mov byte ptr [si+1837h], 0FFh
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E674:              ; CODE XREF: update?+242j update?+2AAj ...
        cmp byte_5195A, 0
        jnz short locret_4E6B9
        call    sound?10
        push    si
        mov byte_5A19B, 1
        mov byte_510BB, 1
        mov byte_510BA, 0
        cmp byte_5A2F9, 0
        jnz short loc_4E6A4
        cmp byte_510B3, 0
        jz  short loc_4E6A4
        mov byte_5A323, 1
        call    sub_4A95F

loc_4E6A4:              ; CODE XREF: update?+803j update?+80Aj
        call    sub_4D24D
        mov word_51978, 40h ; '@'
        pop si
        mov dx, 0E5Eh
        mov byte ptr [si+1835h], 0Dh
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

locret_4E6B9:               ; CODE XREF: update?+7E9j
        retn
; ---------------------------------------------------------------------------

loc_4E6BA:              ; CODE XREF: update?+2B2j
        mov ax, [si+1830h]
        cmp ax, 0
        jz  short loc_4E6C4
        retn
; ---------------------------------------------------------------------------

loc_4E6C4:              ; CODE XREF: update?+831j
        mov byte ptr [si+1831h], 1
        push    si
        mov di, [si+6155h]
        mov si, word_5157A
        call    sub_4F200
        pop si
        mov dx, 0FAEh
        mov byte ptr [si+1835h], 0Eh
        jmp loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E6E1:              ; CODE XREF: update?+38Ej
        mov ax, [si+1838h]
        cmp ax, 0
        jz  short loc_4E6EB
        retn
; ---------------------------------------------------------------------------

loc_4E6EB:              ; CODE XREF: update?+858j
        mov ax, [si+18AEh]
        cmp ax, 0
        jnz short loc_4E6F5
        retn
; ---------------------------------------------------------------------------

loc_4E6F5:              ; CODE XREF: update?+862j
        mov byte ptr [si+1839h], 1
        push    si
        mov di, [si+6155h]
        mov si, word_5157C
        call    sub_4F200
        pop si
        mov dx, 0FBEh
        mov byte ptr [si+1835h], 0Fh
        jmp loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E712:              ; CODE XREF: update?+249j update?+3EFj
        push    si
        mov di, [si+6155h]
        mov si, word_51840
        call    sub_4F200
        pop si
        cmp byte_5196B, 0
        jz  short loc_4E72D
        mov word_510CD, 0Ah
        retn
; ---------------------------------------------------------------------------

loc_4E72D:              ; CODE XREF: update?+894j
        push    si
        mov di, [si+60DDh]
        mov si, word_51848
        call    sub_4F200
        pop si
        jmp short loc_4E7B8
; ---------------------------------------------------------------------------

loc_4E73C:              ; CODE XREF: update?+2B9j update?+41Fj
        push    si
        mov di, [si+6155h]
        mov si, word_51842
        call    sub_4F200
        pop si
        cmp byte_5196B, 0
        jz  short loc_4E757
        mov word_510CD, 0Ah
        retn
; ---------------------------------------------------------------------------

loc_4E757:              ; CODE XREF: update?+8BEj
        push    si
        mov di, [si+6153h]
        mov si, word_51848
        call    sub_4F200
        pop si
        jmp short loc_4E7B8
; ---------------------------------------------------------------------------

loc_4E766:              ; CODE XREF: update?+325j update?+449j
        push    si
        mov di, [si+6155h]
        mov si, word_51844
        call    sub_4F200
        pop si
        cmp byte_5196B, 0
        jz  short loc_4E781
        mov word_510CD, 0Ah
        retn
; ---------------------------------------------------------------------------

loc_4E781:              ; CODE XREF: update?+8E8j
        push    si
        mov di, [si+61CDh]
        mov si, word_51848
        call    sub_4F200
        pop si
        jmp short loc_4E7B8
; ---------------------------------------------------------------------------

loc_4E790:              ; CODE XREF: update?+395j update?+479j
        push    si
        mov di, [si+6155h]
        mov si, word_51846
        call    sub_4F200
        pop si
        cmp byte_5196B, 0
        jz  short loc_4E7AB
        mov word_510CD, 0Ah
        retn
; ---------------------------------------------------------------------------

loc_4E7AB:              ; CODE XREF: update?+912j
        push    si
        mov di, [si+6157h]
        mov si, word_51848
        call    sub_4F200
        pop si

loc_4E7B8:              ; CODE XREF: update?+8AAj update?+8D4j ...
        mov byte_5196A, 7
        mov byte_5196B, 1
        push    si
        mov si, 0
        mov cx, 5A0h

loc_4E7C9:              ; CODE XREF: update?+94Aj
        cmp word ptr leveldata[si], 12h
        jnz short loc_4E7D7
        push    cx
        push    si
        call    sub_4A61F
        pop si
        pop cx

loc_4E7D7:              ; CODE XREF: update?+93Ej
        add si, 2
        loop    loc_4E7C9
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4E7DE:              ; CODE XREF: update?+250j update?+257j ...
        cmp word ptr [si+1744h], 0
        jz  short loc_4E7E6
        retn
; ---------------------------------------------------------------------------

loc_4E7E6:              ; CODE XREF: update?+953j
        mov dx, 0FCEh
        mov byte ptr [si+1835h], 18h
        mov byte ptr [si+1745h], 3
        jmp short loc_4E838
; ---------------------------------------------------------------------------

loc_4E7F5:              ; CODE XREF: update?+2C0j update?+2C7j ...
        cmp word ptr [si+1830h], 0
        jz  short loc_4E7FD
        retn
; ---------------------------------------------------------------------------

loc_4E7FD:              ; CODE XREF: update?+96Aj
        mov dx, 0FDEh
        mov byte ptr [si+1835h], 19h
        mov byte ptr [si+1831h], 3
        jmp short loc_4E838
; ---------------------------------------------------------------------------

loc_4E80C:              ; CODE XREF: update?+32Cj update?+333j ...
        cmp word ptr [si+1924h], 0
        jz  short loc_4E814
        retn
; ---------------------------------------------------------------------------

loc_4E814:              ; CODE XREF: update?+981j
        mov dx, 0FEEh
        mov byte ptr [si+1835h], 1Ah
        mov byte ptr [si+1925h], 3
        jmp short loc_4E838
; ---------------------------------------------------------------------------

loc_4E823:              ; CODE XREF: update?+39Cj update?+3A3j ...
        cmp word ptr [si+1838h], 0
        jz  short loc_4E82B
        retn
; ---------------------------------------------------------------------------

loc_4E82B:              ; CODE XREF: update?+998j
        mov dx, 0FFEh
        mov byte ptr [si+1835h], 1Bh
        mov byte ptr [si+1839h], 3

loc_4E838:              ; CODE XREF: update?+963j update?+97Aj ...
        mov word_510EE, 0
        mov word_510D9, 1
        jmp loc_4E9F3
; ---------------------------------------------------------------------------

loc_4E847:              ; CODE XREF: update?+265j
        cmp word_510CB, 0
        jz  short loc_4E853
        mov dx, 100Eh
        jmp short loc_4E856
; ---------------------------------------------------------------------------

loc_4E853:              ; CODE XREF: update?+9BCj
        mov dx, 101Eh

loc_4E856:              ; CODE XREF: update?+9C1j
        mov byte ptr [si+1835h], 1Ch
        mov byte ptr [si+17BDh], 3
        jmp loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E863:              ; CODE XREF: update?+2D6j
        mov dx, 102Eh
        mov byte ptr [si+1833h], 1Dh
        mov byte ptr [si+1832h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        sub si, 2
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E87F:              ; CODE XREF: update?+341j
        cmp word_510CB, 0
        jz  short loc_4E88B
        mov dx, 103Eh
        jmp short loc_4E88E
; ---------------------------------------------------------------------------

loc_4E88B:              ; CODE XREF: update?+9F4j
        mov dx, 104Eh

loc_4E88E:              ; CODE XREF: update?+9F9j
        mov byte ptr [si+1835h], 1Eh
        mov byte ptr [si+18ADh], 3
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E89A:              ; CODE XREF: update?+3B1j
        mov dx, 105Eh
        mov byte ptr [si+1837h], 1Fh
        mov byte ptr [si+1836h], 3
        mov byte ptr [si+1835h], 3
        mov byte ptr leveldata[si], 0
        add si, 2
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E8B6:              ; CODE XREF: update?+3F6j
        mov dx, 106Eh
        mov byte ptr [si+1835h], 20h ; ' '
        mov byte ptr [si+17BDh], 3
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E8C5:              ; CODE XREF: update?+426j
        mov dx, 107Eh
        mov byte ptr [si+1835h], 21h ; '!'
        mov byte ptr [si+1833h], 3
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E8D4:              ; CODE XREF: update?+450j
        mov dx, 108Eh
        mov byte ptr [si+1835h], 22h ; '"'
        mov byte ptr [si+18ADh], 3
        jmp short loc_4E8F0
; ---------------------------------------------------------------------------

loc_4E8E3:              ; CODE XREF: update?+480j
        mov dx, 109Eh
        mov byte ptr [si+1835h], 23h ; '#'
        mov byte ptr [si+1837h], 3

loc_4E8F0:              ; CODE XREF: update?+4DAj update?+4F7j ...
        mov word_510EE, 0
        jmp loc_4E9ED
; ---------------------------------------------------------------------------

loc_4E8F9:              ; CODE XREF: update?+26Cj
        mov ax, [si+1744h]
        cmp ax, 0
        jz  short loc_4E903
        retn
; ---------------------------------------------------------------------------

loc_4E903:              ; CODE XREF: update?+A70j
        mov byte ptr [si+1745h], 12h
        push    si
        mov di, [si+6155h]
        mov si, word_5157C
        call    sub_4F200
        pop si
        mov dx, 10AEh
        mov byte ptr [si+1835h], 24h ; '$'
        jmp loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E920:              ; CODE XREF: update?+2DEj
        mov ax, [si+1830h]
        cmp ax, 0
        jz  short loc_4E92A
        retn
; ---------------------------------------------------------------------------

loc_4E92A:              ; CODE XREF: update?+A97j
        mov byte ptr [si+1831h], 12h
        push    si
        mov di, [si+6155h]
        mov si, word_5157A
        call    sub_4F200
        pop si
        mov dx, 10BEh
        mov byte ptr [si+1835h], 25h ; '%'
        jmp loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E947:              ; CODE XREF: update?+348j
        mov ax, [si+1924h]
        cmp ax, 0
        jz  short loc_4E951
        retn
; ---------------------------------------------------------------------------

loc_4E951:              ; CODE XREF: update?+ABEj
        mov byte ptr [si+1925h], 12h
        push    si
        mov di, [si+6155h]
        mov si, word_5157C
        call    sub_4F200
        pop si
        mov dx, 10CEh
        mov byte ptr [si+1835h], 27h ; '''
        jmp short loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E96D:              ; CODE XREF: update?+3B8j
        mov ax, [si+1838h]
        cmp ax, 0
        jz  short loc_4E977
        retn
; ---------------------------------------------------------------------------

loc_4E977:              ; CODE XREF: update?+AE4j
        mov byte ptr [si+1839h], 12h
        push    si
        mov di, [si+6155h]
        mov si, word_5157C
        call    sub_4F200
        pop si
        mov dx, 10DEh
        mov byte ptr [si+1835h], 26h ; '&'
        jmp short loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E993:              ; CODE XREF: update?+2E6j
        mov ax, [si+1830h]
        cmp ax, 0
        jz  short loc_4E99D
        retn
; ---------------------------------------------------------------------------

loc_4E99D:              ; CODE XREF: update?+B0Aj
        mov byte ptr [si+1831h], 8
        push    si
        mov di, [si+6155h]
        mov si, word_5157A
        call    sub_4F200
        pop si
        mov dx, 10EEh
        mov byte ptr [si+1835h], 28h ; '('
        jmp short loc_4E9E7
; ---------------------------------------------------------------------------

loc_4E9B9:              ; CODE XREF: update?+3C0j
        mov ax, [si+1838h]
        cmp ax, 0
        jz  short loc_4E9C3
        retn
; ---------------------------------------------------------------------------

loc_4E9C3:              ; CODE XREF: update?+B30j
        mov ax, [si+18AEh]
        cmp ax, 0
        jnz short loc_4E9CD
        retn
; ---------------------------------------------------------------------------

loc_4E9CD:              ; CODE XREF: update?+B3Aj
        mov byte ptr [si+1839h], 1
        push    si
        mov di, [si+6155h]
        mov si, word_5157C
        call    sub_4F200
        pop si
        mov dx, 10FEh
        mov byte ptr [si+1835h], 29h ; ')'

loc_4E9E7:              ; CODE XREF: update?+84Ej update?+87Fj ...
        mov word_510EE, 8

loc_4E9ED:              ; CODE XREF: update?+A66j
        mov word_510D9, 0

loc_4E9F3:              ; CODE XREF: update?+4B0j update?+9B4j
        push    si
        push    di
        push    es
        mov si, dx
        mov di, 0DE0h
        mov ax, ds
        mov es, ax
        assume es:data
        mov cx, 7
        rep movsw
        pop es
        assume es:nothing
        pop di
        pop si

loc_4EA07:              ; CODE XREF: update?+21j
        mov word_510CD, 0
        mov ax, word_510EE
        cmp ax, 0
        jz  short loc_4EA6B
        dec ax
        mov word_510EE, ax
        jnz short loc_4EA1E
        call    sound?6

loc_4EA1E:              ; CODE XREF: update?+B89j
        mov bl, [si+1835h]
        cmp bl, 0Eh
        jnz short loc_4EA2A
        jmp loc_4ED49
; ---------------------------------------------------------------------------

loc_4EA2A:              ; CODE XREF: update?+B95j
        cmp bl, 0Fh
        jnz short loc_4EA32
        jmp loc_4ED81
; ---------------------------------------------------------------------------

loc_4EA32:              ; CODE XREF: update?+B9Dj
        cmp bl, 28h ; '('
        jnz short loc_4EA3A
        jmp loc_4EDB9
; ---------------------------------------------------------------------------

loc_4EA3A:              ; CODE XREF: update?+BA5j
        cmp bl, 29h ; ')'
        jnz short loc_4EA42
        jmp loc_4EDF1
; ---------------------------------------------------------------------------

loc_4EA42:              ; CODE XREF: update?+BADj
        cmp bl, 24h ; '$'
        jnz short loc_4EA4A
        jmp loc_4EE29
; ---------------------------------------------------------------------------

loc_4EA4A:              ; CODE XREF: update?+BB5j
        cmp bl, 25h ; '%'
        jnz short loc_4EA52
        jmp loc_4EE61
; ---------------------------------------------------------------------------

loc_4EA52:              ; CODE XREF: update?+BBDj
        cmp bl, 27h ; '''
        jnz short loc_4EA5A
        jmp loc_4EE99
; ---------------------------------------------------------------------------

loc_4EA5A:              ; CODE XREF: update?+BC5j
        cmp bl, 26h ; '&'
        jnz short loc_4EA62
        jmp loc_4EED1
; ---------------------------------------------------------------------------

loc_4EA62:              ; CODE XREF: update?+BCDj
        cmp bl, 2Ah ; '*'
        jnz short locret_4EA6A
        jmp loc_4EF09
; ---------------------------------------------------------------------------

locret_4EA6A:               ; CODE XREF: update?+BD5j
        retn
; ---------------------------------------------------------------------------

loc_4EA6B:              ; CODE XREF: update?+B83j
        push    si
        push    di
        mov ax, word_510FA
        add word_510E8, ax
        mov ax, word_510FC
        add word_510EA, ax
        mov di, [si+6155h]
        add di, word_510F0
        mov si, word_510F8
        mov ax, [si]
        add si, 2
        mov word_510F8, si
        mov si, ax
        mov bx, word_510F4
        mov dx, word_510F6
        push    ds
        mov ax, es
        mov ds, ax

loc_4EA9F:              ; CODE XREF: update?+C28j
        mov cx, bx
        rep movsb
        add si, 7Ah ; 'z'
        sub si, bx
        add di, 7Ah ; 'z'
        sub di, bx
        cmp si, 4D34h
        jb  short loc_4EAB7
        sub si, 4D0Ch

loc_4EAB7:              ; CODE XREF: update?+C21j
        dec dx
        jnz short loc_4EA9F
        mov ax, ds
        pop ds
        cmp word_510D9, 0
        jz  short loc_4EAFA
        sub di, 7A0h
        add di, word_510F2
        mov si, word_510F8
        add si, 10h
        mov si, [si]
        mov dx, word_510F6
        push    ds
        mov ds, ax

loc_4EADC:              ; CODE XREF: update?+C65j
        mov cx, bx
        rep movsb
        add si, 7Ah ; 'z'
        sub si, bx
        add di, 7Ah ; 'z'
        sub di, bx
        cmp si, 4D34h
        jb  short loc_4EAF4
        sub si, 4D0Ch

loc_4EAF4:              ; CODE XREF: update?+C5Ej
        dec dx
        jnz short loc_4EADC
        pop ds
        jmp short loc_4EB04
; ---------------------------------------------------------------------------

loc_4EAFA:              ; CODE XREF: update?+C32j
        mov ax, word_510F0
        add ax, word_510F2
        mov word_510F0, ax

loc_4EB04:              ; CODE XREF: update?+C68j
        mov si, word_510F8
        cmp word ptr [si], 0FFFFh
        jz  short loc_4EB10
        pop di
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EB10:              ; CODE XREF: update?+C7Bj
        pop di
        pop si
        mov ax, word_510FA
        shr ax, 1
        mov bx, word_510FC
        shr bx, 1
        add word_510C3, ax
        add word_510C5, bx
        mov bl, [si+1835h]
        mov byte ptr [si+1835h], 0
        cmp bl, 1
        jnz short loc_4EB36
        jmp loc_4EC93
; ---------------------------------------------------------------------------

loc_4EB36:              ; CODE XREF: update?+CA1j
        cmp bl, 2
        jnz short loc_4EB3E
        jmp loc_4ECB1
; ---------------------------------------------------------------------------

loc_4EB3E:              ; CODE XREF: update?+CA9j
        cmp bl, 3
        jnz short loc_4EB46
        jmp loc_4ECCF
; ---------------------------------------------------------------------------

loc_4EB46:              ; CODE XREF: update?+CB1j
        cmp bl, 4
        jnz short loc_4EB4E
        jmp loc_4EF53
; ---------------------------------------------------------------------------

loc_4EB4E:              ; CODE XREF: update?+CB9j
        cmp bl, 5
        jnz short loc_4EB56
        jmp loc_4EC93
; ---------------------------------------------------------------------------

loc_4EB56:              ; CODE XREF: update?+CC1j
        cmp bl, 6
        jnz short loc_4EB5E
        jmp loc_4ECB1
; ---------------------------------------------------------------------------

loc_4EB5E:              ; CODE XREF: update?+CC9j
        cmp bl, 7
        jnz short loc_4EB66
        jmp loc_4ECCF
; ---------------------------------------------------------------------------

loc_4EB66:              ; CODE XREF: update?+CD1j
        cmp bl, 8
        jnz short loc_4EB6E
        jmp loc_4EF53
; ---------------------------------------------------------------------------

loc_4EB6E:              ; CODE XREF: update?+CD9j
        cmp bl, 9
        jnz short loc_4EB76
        jmp loc_4EC85
; ---------------------------------------------------------------------------

loc_4EB76:              ; CODE XREF: update?+CE1j
        cmp bl, 0Ah
        jnz short loc_4EB7E
        jmp loc_4ECA3
; ---------------------------------------------------------------------------

loc_4EB7E:              ; CODE XREF: update?+CE9j
        cmp bl, 0Bh
        jnz short loc_4EB86
        jmp loc_4ECC1
; ---------------------------------------------------------------------------

loc_4EB86:              ; CODE XREF: update?+CF1j
        cmp bl, 0Ch
        jnz short loc_4EB8E
        jmp loc_4EF45
; ---------------------------------------------------------------------------

loc_4EB8E:              ; CODE XREF: update?+CF9j
        cmp bl, 0Eh
        jnz short loc_4EB96
        jmp loc_4ECE3
; ---------------------------------------------------------------------------

loc_4EB96:              ; CODE XREF: update?+D01j
        cmp bl, 0Fh
        jnz short loc_4EB9E
        jmp loc_4ED06
; ---------------------------------------------------------------------------

loc_4EB9E:              ; CODE XREF: update?+D09j
        cmp bl, 10h
        jnz short loc_4EBA6
        jmp loc_4EF71
; ---------------------------------------------------------------------------

loc_4EBA6:              ; CODE XREF: update?+D11j
        cmp bl, 11h
        jnz short loc_4EBAE
        jmp loc_4EF8D
; ---------------------------------------------------------------------------

loc_4EBAE:              ; CODE XREF: update?+D19j
        cmp bl, 13h
        jnz short loc_4EBB6
        jmp loc_4EFC5
; ---------------------------------------------------------------------------

loc_4EBB6:              ; CODE XREF: update?+D21j
        cmp bl, 12h
        jnz short loc_4EBBE
        jmp loc_4EFA9
; ---------------------------------------------------------------------------

loc_4EBBE:              ; CODE XREF: update?+D29j
        cmp bl, 14h
        jnz short loc_4EBC6
        jmp loc_4EF63
; ---------------------------------------------------------------------------

loc_4EBC6:              ; CODE XREF: update?+D31j
        cmp bl, 15h
        jnz short loc_4EBCE
        jmp loc_4EF7F
; ---------------------------------------------------------------------------

loc_4EBCE:              ; CODE XREF: update?+D39j
        cmp bl, 17h
        jnz short loc_4EBD6
        jmp loc_4EFB7
; ---------------------------------------------------------------------------

loc_4EBD6:              ; CODE XREF: update?+D41j
        cmp bl, 16h
        jnz short loc_4EBDE
        jmp loc_4EF9B
; ---------------------------------------------------------------------------

loc_4EBDE:              ; CODE XREF: update?+D49j
        cmp bl, 0Dh
        jnz short loc_4EBE6
        jmp loc_4ED42
; ---------------------------------------------------------------------------

loc_4EBE6:              ; CODE XREF: update?+D51j
        cmp bl, 18h
        jnz short loc_4EBEE
        jmp loc_4EFD3
; ---------------------------------------------------------------------------

loc_4EBEE:              ; CODE XREF: update?+D59j
        cmp bl, 19h
        jnz short loc_4EBF6
        jmp loc_4F001
; ---------------------------------------------------------------------------

loc_4EBF6:              ; CODE XREF: update?+D61j
        cmp bl, 1Ah
        jnz short loc_4EBFE
        jmp loc_4F02E
; ---------------------------------------------------------------------------

loc_4EBFE:              ; CODE XREF: update?+D69j
        cmp bl, 1Bh
        jnz short loc_4EC06
        jmp loc_4F05C
; ---------------------------------------------------------------------------

loc_4EC06:              ; CODE XREF: update?+D71j
        cmp bl, 1Ch
        jnz short loc_4EC0E
        jmp loc_4F089
; ---------------------------------------------------------------------------

loc_4EC0E:              ; CODE XREF: update?+D79j
        cmp bl, 1Dh
        jnz short loc_4EC16
        jmp loc_4F09C
; ---------------------------------------------------------------------------

loc_4EC16:              ; CODE XREF: update?+D81j
        cmp bl, 1Eh
        jnz short loc_4EC1E
        jmp loc_4F0AC
; ---------------------------------------------------------------------------

loc_4EC1E:              ; CODE XREF: update?+D89j
        cmp bl, 1Fh
        jnz short loc_4EC26
        jmp loc_4F0BF
; ---------------------------------------------------------------------------

loc_4EC26:              ; CODE XREF: update?+D91j
        cmp bl, 20h ; ' '
        jnz short loc_4EC2E
        jmp loc_4F0CF
; ---------------------------------------------------------------------------

loc_4EC2E:              ; CODE XREF: update?+D99j
        cmp bl, 21h ; '!'
        jnz short loc_4EC36
        jmp loc_4F0E6
; ---------------------------------------------------------------------------

loc_4EC36:              ; CODE XREF: update?+DA1j
        cmp bl, 22h ; '"'
        jnz short loc_4EC3E
        jmp loc_4F0FD
; ---------------------------------------------------------------------------

loc_4EC3E:              ; CODE XREF: update?+DA9j
        cmp bl, 23h ; '#'
        jnz short loc_4EC46
        jmp loc_4F114
; ---------------------------------------------------------------------------

loc_4EC46:              ; CODE XREF: update?+DB1j
        cmp bl, 24h ; '$'
        jnz short loc_4EC4E
        jmp loc_4F12B
; ---------------------------------------------------------------------------

loc_4EC4E:              ; CODE XREF: update?+DB9j
        cmp bl, 25h ; '%'
        jnz short loc_4EC56
        jmp loc_4F148
; ---------------------------------------------------------------------------

loc_4EC56:              ; CODE XREF: update?+DC1j
        cmp bl, 27h ; '''
        jnz short loc_4EC5E
        jmp loc_4F165
; ---------------------------------------------------------------------------

loc_4EC5E:              ; CODE XREF: update?+DC9j
        cmp bl, 26h ; '&'
        jnz short loc_4EC66
        jmp loc_4F182
; ---------------------------------------------------------------------------

loc_4EC66:              ; CODE XREF: update?+DD1j
        cmp bl, 28h ; '('
        jnz short loc_4EC6E
        jmp loc_4F19F
; ---------------------------------------------------------------------------

loc_4EC6E:              ; CODE XREF: update?+DD9j
        cmp bl, 29h ; ')'
        jnz short loc_4EC76
        jmp loc_4F1BC
; ---------------------------------------------------------------------------

loc_4EC76:              ; CODE XREF: update?+DE1j
        cmp bl, 2Ah ; '*'
        jnz short loc_4EC7E
        jmp loc_4F1EA
; ---------------------------------------------------------------------------

loc_4EC7E:              ; CODE XREF: update?+DE9j
        mov word_51974, 1
        retn
; ---------------------------------------------------------------------------

loc_4EC85:              ; CODE XREF: update?+CE3j
        cmp byte_5195A, 0
        jbe short loc_4EC90
        dec byte_5195A

loc_4EC90:              ; CODE XREF: update?+DFAj
        call    sub_4FD21

loc_4EC93:              ; CODE XREF: update?+CA3j update?+CC3j
        mov word ptr leveldata[si], 3
        add si, 78h ; 'x'
        call    sub_487FE
        sub si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_4ECA3:              ; CODE XREF: update?+CEBj
        cmp byte_5195A, 0
        jbe short loc_4ECAE
        dec byte_5195A

loc_4ECAE:              ; CODE XREF: update?+E18j
        call    sub_4FD21

loc_4ECB1:              ; CODE XREF: update?+CABj update?+CCBj
        mov word ptr leveldata[si], 3
        add si, 2
        call    sub_487FE
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_4ECC1:              ; CODE XREF: update?+CF3j
        cmp byte_5195A, 0
        jbe short loc_4ECCC
        dec byte_5195A

loc_4ECCC:              ; CODE XREF: update?+E36j
        call    sub_4FD21

loc_4ECCF:              ; CODE XREF: update?+CB3j update?+CD3j
        cmp byte ptr [si+17BCh], 1Fh
        jz  short loc_4ECDC
        mov word ptr [si+17BCh], 0

loc_4ECDC:              ; CODE XREF: update?+E44j
        mov word ptr leveldata[si], 3
        retn
; ---------------------------------------------------------------------------

loc_4ECE3:              ; CODE XREF: update?+D03j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4ECF0
        mov word ptr leveldata[si], 0

loc_4ECF0:              ; CODE XREF: update?+E58j
        mov word ptr [si+1832h], 3
        mov word ptr [si+1830h], 1
        sub si, 4
        call    sub_4ED29
        add si, 2
        retn
; ---------------------------------------------------------------------------

loc_4ED06:              ; CODE XREF: update?+D0Bj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4ED13
        mov word ptr leveldata[si], 0

loc_4ED13:              ; CODE XREF: update?+E7Bj
        mov word ptr [si+1836h], 3
        mov word ptr [si+1838h], 1
        add si, 4
        call    sub_4ED29
        sub si, 2
        retn
update?     endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4ED29   proc near       ; CODE XREF: update?+E6Fp update?+E92p
        cmp byte ptr [si+18ACh], 11h
        jz  short loc_4ED38
        cmp byte ptr [si+18ACh], 0BBh ; '?'
        jz  short loc_4ED38
        retn
; ---------------------------------------------------------------------------

loc_4ED38:              ; CODE XREF: sub_4ED29+5j sub_4ED29+Cj
        add si, 78h ; 'x'
        call    sub_4A61F
        sub si, 78h ; 'x'
        retn
sub_4ED29   endp

; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR update?

loc_4ED42:              ; CODE XREF: update?+D53j
        mov word_51974, 1
        retn
; ---------------------------------------------------------------------------

loc_4ED49:              ; CODE XREF: update?+B97j
        mov bl, byte_50941
        cmp bl, 2
        jnz short loc_4ED5A
        cmp word ptr [si+1832h], 1
        jnz short loc_4ED5A
        retn
; ---------------------------------------------------------------------------

loc_4ED5A:              ; CODE XREF: update?+EC0j update?+EC7j
        mov word ptr leveldata[si], 3
        mov word ptr [si+1832h], 1
        cmp byte ptr [si+1830h], 1Fh
        jz  short loc_4ED73
        mov word ptr [si+1830h], 0

loc_4ED73:              ; CODE XREF: update?+EDBj
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4ED81:              ; CODE XREF: update?+B9Fj
        mov bl, byte_50941
        cmp bl, 4
        jnz short loc_4ED92
        cmp word ptr [si+1836h], 1
        jnz short loc_4ED92
        retn
; ---------------------------------------------------------------------------

loc_4ED92:              ; CODE XREF: update?+EF8j update?+EFFj
        mov word ptr leveldata[si], 3
        mov word ptr [si+1836h], 1
        cmp byte ptr [si+1838h], 1Fh
        jz  short loc_4EDAB
        mov word ptr [si+1838h], 0

loc_4EDAB:              ; CODE XREF: update?+F13j
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EDB9:              ; CODE XREF: update?+BA7j
        mov bl, byte_50941
        cmp bl, 2
        jnz short loc_4EDCA
        cmp word ptr [si+1832h], 8
        jnz short loc_4EDCA
        retn
; ---------------------------------------------------------------------------

loc_4EDCA:              ; CODE XREF: update?+F30j update?+F37j
        mov word ptr leveldata[si], 3
        mov word ptr [si+1832h], 8
        cmp byte ptr [si+1830h], 1Fh
        jz  short loc_4EDE3
        mov word ptr [si+1830h], 0

loc_4EDE3:              ; CODE XREF: update?+F4Bj
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EDF1:              ; CODE XREF: update?+BAFj
        mov bl, byte_50941
        cmp bl, 4
        jnz short loc_4EE02
        cmp word ptr [si+1836h], 8
        jnz short loc_4EE02
        retn
; ---------------------------------------------------------------------------

loc_4EE02:              ; CODE XREF: update?+F68j update?+F6Fj
        mov word ptr leveldata[si], 3
        mov word ptr [si+1836h], 8
        cmp byte ptr [si+1838h], 1Fh
        jz  short loc_4EE1B
        mov word ptr [si+1838h], 0

loc_4EE1B:              ; CODE XREF: update?+F83j
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EE29:              ; CODE XREF: update?+BB7j
        mov bl, byte_50941
        cmp bl, 1
        jnz short loc_4EE3A
        cmp word ptr [si+17BCh], 12h
        jnz short loc_4EE3A
        retn
; ---------------------------------------------------------------------------

loc_4EE3A:              ; CODE XREF: update?+FA0j update?+FA7j
        mov word ptr leveldata[si], 3
        mov word ptr [si+17BCh], 12h
        cmp byte ptr [si+1744h], 1Fh
        jz  short loc_4EE53
        mov word ptr [si+1744h], 0

loc_4EE53:              ; CODE XREF: update?+FBBj
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EE61:              ; CODE XREF: update?+BBFj
        mov bl, byte_50941
        cmp bl, 2
        jnz short loc_4EE72
        cmp word ptr [si+1832h], 12h
        jnz short loc_4EE72
        retn
; ---------------------------------------------------------------------------

loc_4EE72:              ; CODE XREF: update?+FD8j update?+FDFj
        mov word ptr leveldata[si], 3
        mov word ptr [si+1832h], 12h
        cmp byte ptr [si+1830h], 1Fh
        jz  short loc_4EE8B
        mov word ptr [si+1830h], 0

loc_4EE8B:              ; CODE XREF: update?+FF3j
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EE99:              ; CODE XREF: update?+BC7j
        mov bl, byte_50941
        cmp bl, 3
        jnz short loc_4EEAA
        cmp word ptr [si+18ACh], 12h
        jnz short loc_4EEAA
        retn
; ---------------------------------------------------------------------------

loc_4EEAA:              ; CODE XREF: update?+1010j
                    ; update?+1017j
        mov word ptr leveldata[si], 3
        mov word ptr [si+18ACh], 12h
        cmp byte ptr [si+1924h], 1Fh
        jz  short loc_4EEC3
        mov word ptr [si+1924h], 0

loc_4EEC3:              ; CODE XREF: update?+102Bj
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EED1:              ; CODE XREF: update?+BCFj
        mov bl, byte_50941
        cmp bl, 4
        jnz short loc_4EEE2
        cmp word ptr [si+1836h], 12h
        jnz short loc_4EEE2
        retn
; ---------------------------------------------------------------------------

loc_4EEE2:              ; CODE XREF: update?+1048j
                    ; update?+104Fj
        mov word ptr leveldata[si], 3
        mov word ptr [si+1836h], 12h
        cmp byte ptr [si+1838h], 1Fh
        jz  short loc_4EEFB
        mov word ptr [si+1838h], 0

loc_4EEFB:              ; CODE XREF: update?+1063j
        push    si
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EF09:              ; CODE XREF: update?+BD7j
        mov bl, byte_50941
        cmp bl, 9
        jnz short loc_4EF2C
        cmp word_510EE, 20h ; ' '
        jg  short locret_4EF2B
        push    si
        mov di, [si+6155h]
        mov si, word_51790
        call    sub_4F200
        mov byte_510DB, 1
        pop si

locret_4EF2B:               ; CODE XREF: update?+1087j
        retn
; ---------------------------------------------------------------------------

loc_4EF2C:              ; CODE XREF: update?+1080j
        push    si
        mov word ptr leveldata[si], 3
        mov di, [si+6155h]
        mov si, word_5157E
        call    sub_4F200
        mov byte_510DB, 0
        pop si
        retn
; ---------------------------------------------------------------------------

loc_4EF45:              ; CODE XREF: update?+CFBj
        cmp byte_5195A, 0
        jbe short loc_4EF50
        dec byte_5195A

loc_4EF50:              ; CODE XREF: update?+10BAj
        call    sub_4FD21

loc_4EF53:              ; CODE XREF: update?+CBBj update?+CDBj
        sub si, 2
        call    sub_487FE
        add si, 2
        mov word ptr leveldata[si], 3
        retn
; ---------------------------------------------------------------------------

loc_4EF63:              ; CODE XREF: update?+D33j
        cmp byte_5195A, 0
        jbe short loc_4EF6E
        dec byte_5195A

loc_4EF6E:              ; CODE XREF: update?+10D8j
        call    sub_4FD21

loc_4EF71:              ; CODE XREF: update?+D13j
        cmp byte ptr [si+17BCh], 1Fh
        jz  short locret_4EF7E
        mov word ptr [si+17BCh], 0

locret_4EF7E:               ; CODE XREF: update?+10E6j
        retn
; ---------------------------------------------------------------------------

loc_4EF7F:              ; CODE XREF: update?+D3Bj
        cmp byte_5195A, 0
        jbe short loc_4EF8A
        dec byte_5195A

loc_4EF8A:              ; CODE XREF: update?+10F4j
        call    sub_4FD21

loc_4EF8D:              ; CODE XREF: update?+D1Bj
        cmp byte ptr [si+1832h], 1Fh
        jz  short locret_4EF9A
        mov word ptr [si+1832h], 0

locret_4EF9A:               ; CODE XREF: update?+1102j
        retn
; ---------------------------------------------------------------------------

loc_4EF9B:              ; CODE XREF: update?+D4Bj
        cmp byte_5195A, 0
        jbe short loc_4EFA6
        dec byte_5195A

loc_4EFA6:              ; CODE XREF: update?+1110j
        call    sub_4FD21

loc_4EFA9:              ; CODE XREF: update?+D2Bj
        cmp byte ptr [si+18ACh], 1Fh
        jz  short locret_4EFB6
        mov word ptr [si+18ACh], 0

locret_4EFB6:               ; CODE XREF: update?+111Ej
        retn
; ---------------------------------------------------------------------------

loc_4EFB7:              ; CODE XREF: update?+D43j
        cmp byte_5195A, 0
        jbe short loc_4EFC2
        dec byte_5195A

loc_4EFC2:              ; CODE XREF: update?+112Cj
        call    sub_4FD21

loc_4EFC5:              ; CODE XREF: update?+D23j
        cmp byte ptr [si+1836h], 1Fh
        jz  short locret_4EFD2
        mov word ptr [si+1836h], 0

locret_4EFD2:               ; CODE XREF: update?+113Aj
        retn
; ---------------------------------------------------------------------------

loc_4EFD3:              ; CODE XREF: update?+D5Bj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4EFE0
        mov word ptr leveldata[si], 0

loc_4EFE0:              ; CODE XREF: update?+1148j
        mov word ptr [si+1744h], 3
        mov word_510D9, 0
        sub si, 0F0h ; '?'
        cmp byte ptr [si+18ADh], 1
        jnz short locret_4F000
        add si, 78h ; 'x'
        call    sub_4F2AF
        sub si, 78h ; 'x'

locret_4F000:               ; CODE XREF: update?+1165j
        retn
; ---------------------------------------------------------------------------

loc_4F001:              ; CODE XREF: update?+D63j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F00E
        mov word ptr leveldata[si], 0

loc_4F00E:              ; CODE XREF: update?+1176j
        mov word ptr [si+1830h], 3
        mov word_510D9, 0
        sub si, 4
        cmp byte ptr [si+1837h], 1
        jnz short locret_4F02D
        add si, 2
        call    sub_4F2AF
        sub si, 2

locret_4F02D:               ; CODE XREF: update?+1192j
        retn
; ---------------------------------------------------------------------------

loc_4F02E:              ; CODE XREF: update?+D6Bj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F03B
        mov word ptr leveldata[si], 0

loc_4F03B:              ; CODE XREF: update?+11A3j
        mov word ptr [si+1924h], 3
        mov word_510D9, 0
        add si, 0F0h ; '?'
        cmp byte ptr [si+17BDh], 1
        jnz short locret_4F05B
        sub si, 78h ; 'x'
        call    sub_4F2AF
        add si, 78h ; 'x'

locret_4F05B:               ; CODE XREF: update?+11C0j
        retn
; ---------------------------------------------------------------------------

loc_4F05C:              ; CODE XREF: update?+D73j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F069
        mov word ptr leveldata[si], 0

loc_4F069:              ; CODE XREF: update?+11D1j
        mov word ptr [si+1838h], 3
        mov word_510D9, 0
        add si, 4
        cmp byte ptr [si+1833h], 1
        jnz short locret_4F088
        sub si, 2
        call    sub_4F2AF
        add si, 2

locret_4F088:               ; CODE XREF: update?+11EDj
        retn
; ---------------------------------------------------------------------------

loc_4F089:              ; CODE XREF: update?+D7Bj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F096
        mov word ptr leveldata[si], 0

loc_4F096:              ; CODE XREF: update?+11FEj
        sub si, 78h ; 'x'
        jmp loc_4FDAF
; ---------------------------------------------------------------------------

loc_4F09C:              ; CODE XREF: update?+D83j
        cmp byte ptr [si+1836h], 1Fh
        jz  short loc_4F0A9
        mov word ptr [si+1836h], 0

loc_4F0A9:              ; CODE XREF: update?+1211j
        jmp loc_4FDAF
; ---------------------------------------------------------------------------

loc_4F0AC:              ; CODE XREF: update?+D8Bj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F0B9
        mov word ptr leveldata[si], 0

loc_4F0B9:              ; CODE XREF: update?+1221j
        add si, 78h ; 'x'
        jmp loc_4FDAF
; ---------------------------------------------------------------------------

loc_4F0BF:              ; CODE XREF: update?+D93j
        cmp byte ptr [si+1832h], 1Fh
        jz  short loc_4F0CC
        mov word ptr [si+1832h], 0

loc_4F0CC:              ; CODE XREF: update?+1234j
        jmp loc_4FDAF
; ---------------------------------------------------------------------------

loc_4F0CF:              ; CODE XREF: update?+D9Bj
        cmp byte ptr [si+17BCh], 1Fh
        jz  short loc_4F0DC
        mov word ptr [si+17BCh], 0

loc_4F0DC:              ; CODE XREF: update?+1244j
        sub si, 78h ; 'x'
        call    sub_4FDB5
        add si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_4F0E6:              ; CODE XREF: update?+DA3j
        cmp byte ptr [si+1832h], 1Fh
        jz  short loc_4F0F3
        mov word ptr [si+1832h], 0

loc_4F0F3:              ; CODE XREF: update?+125Bj
        sub si, 2
        call    sub_4FDB5
        add si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F0FD:              ; CODE XREF: update?+DABj
        cmp byte ptr [si+18ACh], 1Fh
        jz  short loc_4F10A
        mov word ptr [si+18ACh], 0

loc_4F10A:              ; CODE XREF: update?+1272j
        add si, 78h ; 'x'
        call    sub_4FDB5
        sub si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_4F114:              ; CODE XREF: update?+DB3j
        cmp byte ptr [si+1836h], 1Fh
        jz  short loc_4F121
        mov word ptr [si+1836h], 0

loc_4F121:              ; CODE XREF: update?+1289j
        add si, 2
        call    sub_4FDB5
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F12B:              ; CODE XREF: update?+DBBj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F138
        mov word ptr leveldata[si], 0

loc_4F138:              ; CODE XREF: update?+12A0j
        mov word ptr [si+17BCh], 3
        mov word ptr [si+1744h], 12h
        sub si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_4F148:              ; CODE XREF: update?+DC3j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F155
        mov word ptr leveldata[si], 0

loc_4F155:              ; CODE XREF: update?+12BDj
        mov word ptr [si+1832h], 3
        mov word ptr [si+1830h], 12h
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F165:              ; CODE XREF: update?+DCBj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F172
        mov word ptr leveldata[si], 0

loc_4F172:              ; CODE XREF: update?+12DAj
        mov word ptr [si+18ACh], 3
        mov word ptr [si+1924h], 12h
        add si, 78h ; 'x'
        retn
; ---------------------------------------------------------------------------

loc_4F182:              ; CODE XREF: update?+DD3j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F18F
        mov word ptr leveldata[si], 0

loc_4F18F:              ; CODE XREF: update?+12F7j
        mov word ptr [si+1836h], 3
        mov word ptr [si+1838h], 12h
        add si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F19F:              ; CODE XREF: update?+DDBj
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F1AC
        mov word ptr leveldata[si], 0

loc_4F1AC:              ; CODE XREF: update?+1314j
        mov word ptr [si+1832h], 3
        mov word ptr [si+1830h], 8
        sub si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F1BC:              ; CODE XREF: update?+DE3j
        cmp byte ptr leveldata[si], 1Fh
        jz  short loc_4F1C9
        mov word ptr leveldata[si], 0

loc_4F1C9:              ; CODE XREF: update?+1331j
        mov word ptr [si+1836h], 3
        mov word ptr [si+1838h], 8
        cmp word ptr [si+18B0h], 0
        jnz short loc_4F1E6
        mov byte ptr [si+1839h], 20h ; ' '
        mov byte ptr [si+18B1h], 8

loc_4F1E6:              ; CODE XREF: update?+134Aj
        add si, 2
        retn
; ---------------------------------------------------------------------------

loc_4F1EA:              ; CODE XREF: update?+DEBj
        mov word ptr leveldata[si], 3
        mov byte_510DB, 2
        dec byte_5195C
        call    sub_4FDCE
        call    sound?6
        retn
; END OF FUNCTION CHUNK FOR update?

; =============== S U B R O U T I N E =======================================


sub_4F200   proc near       ; CODE XREF: sub_4A291+26p
                    ; sub_4A910+2Ap ...
        push    ds
        mov ax, es
        mov ds, ax
        mov dx, 10h

loc_4F208:              ; CODE XREF: sub_4F200+1Bj
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        cmp si, 4D34h
        jb  short loc_4F21A
        sub si, 4D0Ch

loc_4F21A:              ; CODE XREF: sub_4F200+14j
        dec dx
        jnz short loc_4F208
        pop ds
        retn
sub_4F200   endp


; =============== S U B R O U T I N E =======================================


sub_4F21F   proc near       ; CODE XREF: update?+273p update?+2EDp ...
        cmp ax, 0FFFFh
        jz  short loc_4F296
        cmp ax, 0AAAAh
        jz  short loc_4F296
        cmp ah, 0
        jz  short loc_4F296
        cmp al, 1
        jz  short loc_4F24F
        cmp al, 1Fh
        jz  short loc_4F298
        cmp al, 8
        jz  short loc_4F296
        cmp al, 9
        jz  short loc_4F296
        cmp al, 0Ah
        jz  short loc_4F296
        cmp al, 0Bh
        jz  short loc_4F296
        cmp al, 0Ch
        jz  short loc_4F296
        call    sub_4A61F
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F24F:              ; CODE XREF: sub_4F21F+11j
        cmp bl, 2
        jz  short loc_4F25E
        cmp bl, 4
        jz  short loc_4F27A
        call    sub_4A61F
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F25E:              ; CODE XREF: sub_4F21F+33j
        and ah, 0F0h
        cmp ah, 20h ; ' '
        jz  short loc_4F278
        cmp ah, 40h ; '@'
        jz  short loc_4F278
        cmp ah, 50h ; 'P'
        jz  short loc_4F278
        cmp ah, 70h ; 'p'
        jz  short loc_4F278
        call    sub_4A61F

loc_4F278:              ; CODE XREF: sub_4F21F+45j
                    ; sub_4F21F+4Aj ...
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F27A:              ; CODE XREF: sub_4F21F+38j
        and ah, 0F0h
        cmp ah, 30h ; '0'
        jz  short loc_4F294
        cmp ah, 40h ; '@'
        jz  short loc_4F294
        cmp ah, 60h ; '`'
        jz  short loc_4F294
        cmp ah, 70h ; 'p'
        jz  short loc_4F294
        call    sub_4A61F

loc_4F294:              ; CODE XREF: sub_4F21F+61j
                    ; sub_4F21F+66j ...
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F296:              ; CODE XREF: sub_4F21F+3j sub_4F21F+8j ...
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F298:              ; CODE XREF: sub_4F21F+15j
        test    ah, 80h
        jnz short loc_4F2A2
        cmp ah, 4
        jge short loc_4F2A7

loc_4F2A2:              ; CODE XREF: sub_4F21F+7Cj
        call    sub_4A61F
        stc
        retn
; ---------------------------------------------------------------------------

loc_4F2A7:              ; CODE XREF: sub_4F21F+81j
        mov leveldata[si], 0
        clc
        retn
sub_4F21F   endp


; =============== S U B R O U T I N E =======================================


sub_4F2AF   proc near       ; CODE XREF: update?+116Ap
                    ; update?+1197p ...
        mov cl, byte_51037
        xor ch, ch
        cmp cx, 0
        jz  short locret_4F2CA
        mov di, 0D28h

loc_4F2BD:              ; CODE XREF: sub_4F2AF+19j
        mov bx, [di]
        xchg    bl, bh
        cmp bx, si
        jz  short loc_4F2CB
        add di, 6
        loop    loc_4F2BD

locret_4F2CA:               ; CODE XREF: sub_4F2AF+9j
        retn
; ---------------------------------------------------------------------------

loc_4F2CB:              ; CODE XREF: sub_4F2AF+14j
        mov al, [di+2]
        mov byte_5101C, al
        mov al, [di+3]
        mov byte_51035, al
        mov al, [di+4]
        mov byte_510D7, al
        mov ax, word_510AC
        xor ax, timeOfDay
        mov word_510AC, ax
        retn
sub_4F2AF   endp

; ---------------------------------------------------------------------------
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  2Eh ; .
        db  8Bh ; ?
        db 0C0h ; +
        db  8Bh ; ?
        db 0C0h ; +

; =============== S U B R O U T I N E =======================================


movefun4  proc near       ; DATA XREF: data:162Co
        cmp byte_510D7, 1
        jz  short notSnikSnak
        cmp byte ptr leveldata[si], sniksnak ; 17
        jnz short notSnikSnak
        mov bl, byte ptr leveldata[si+1]
        xor bh, bh
        shl bx, 1
        mov ax, movingFunctions3[bx]
        cmp ax, 0FFFFh
        jz  short notSnikSnak
        call    ax

notSnikSnak:                ; CODE XREF: movefun4+5j
                    ; movefun4+Cj ...
        retn
movefun4  endp


; =============== S U B R O U T I N E =======================================


sub_4F312   proc near       ; DATA XREF: data:movingFunctions3o
        mov ax, word_5195D
        and ax, 3
        jz  short loc_4F320
        cmp ax, 3
        jz  short loc_4F362
        retn
; ---------------------------------------------------------------------------

loc_4F320:              ; CODE XREF: sub_4F312+6j
        push    ds
        push    si
        push    bx
        mov di, [si+6155h]
        mov si, [bx+1388h]
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F332:              ; CODE XREF: sub_4F312+28j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4F332
        pop bx
        pop si
        pop ds
        shr bx, 1
        inc bx
        db  83h, 0E3h, 07h ;and bx, 7
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F34A:              ; CODE XREF: sub_4F312+79j
                    ; sub_4F312+9Cj ...
        cmp ah, 1Bh
        jz  short locret_4F361
        cmp ah, 19h
        jz  short locret_4F361
        cmp ah, 18h
        jz  short locret_4F361
        cmp ah, 1Ah
        jz  short locret_4F361
        call    sub_4A61F

locret_4F361:               ; CODE XREF: sub_4F312+3Bj
                    ; sub_4F312+40j ...
        retn
; ---------------------------------------------------------------------------

loc_4F362:              ; CODE XREF: sub_4F312+Bj
        mov bl, [si+1835h]
        cmp bl, 0
        jz  short loc_4F37B
        cmp bl, 2
        jz  short loc_4F39E
        cmp bl, 4
        jz  short loc_4F3C1
        cmp bl, 6
        jz  short loc_4F3E7
        retn
; ---------------------------------------------------------------------------

loc_4F37B:              ; CODE XREF: sub_4F312+57j
        cmp word ptr [si+17BCh], 0
        jz  short loc_4F38E
        mov ax, [si+17BCh]
        cmp byte ptr [si+17BCh], 3
        jz  short loc_4F34A
        retn
; ---------------------------------------------------------------------------

loc_4F38E:              ; CODE XREF: sub_4F312+6Ej
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1011h
        retn
; ---------------------------------------------------------------------------

loc_4F39E:              ; CODE XREF: sub_4F312+5Cj
        cmp word ptr [si+1832h], 0
        jz  short loc_4F3B1
        mov ax, [si+1832h]
        cmp byte ptr [si+1832h], 3
        jz  short loc_4F34A
        retn
; ---------------------------------------------------------------------------

loc_4F3B1:              ; CODE XREF: sub_4F312+91j
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1811h
        retn
; ---------------------------------------------------------------------------

loc_4F3C1:              ; CODE XREF: sub_4F312+61j
        cmp word ptr [si+18ACh], 0
        jz  short loc_4F3D7
        mov ax, [si+18ACh]
        cmp byte ptr [si+18ACh], 3
        jnz short locret_4F3D6
        jmp loc_4F34A
; ---------------------------------------------------------------------------

locret_4F3D6:               ; CODE XREF: sub_4F312+BFj
        retn
; ---------------------------------------------------------------------------

loc_4F3D7:              ; CODE XREF: sub_4F312+B4j
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2011h
        retn
; ---------------------------------------------------------------------------

loc_4F3E7:              ; CODE XREF: sub_4F312+66j
        cmp word ptr [si+1836h], 0
        jz  short loc_4F3FD
        mov ax, [si+1836h]
        cmp byte ptr [si+1836h], 3
        jnz short locret_4F3FC
        jmp loc_4F34A
; ---------------------------------------------------------------------------

locret_4F3FC:               ; CODE XREF: sub_4F312+E5j
        retn
; ---------------------------------------------------------------------------

loc_4F3FD:              ; CODE XREF: sub_4F312+DAj
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2811h
        retn
sub_4F312   endp


; =============== S U B R O U T I N E =======================================


sub_4F40D   proc near       ; DATA XREF: data:155Ao
        mov ax, word_5195D
        and ax, 3
        jz  short loc_4F41B
        cmp ax, 3
        jz  short loc_4F45F
        retn
; ---------------------------------------------------------------------------

loc_4F41B:              ; CODE XREF: sub_4F40D+6j
        push    ds
        push    si
        mov di, [si+6155h]
        mov si, [bx+1388h]
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F42C:              ; CODE XREF: sub_4F40D+27j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4F42C
        pop si
        pop ds
        shr bx, 1
        inc bl
        and bl, 7
        or  bl, 8
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F447:              ; CODE XREF: sub_4F40D+7Bj
                    ; sub_4F40D+9Ej ...
        cmp ah, 1Bh
        jz  short locret_4F45E
        cmp ah, 19h
        jz  short locret_4F45E
        cmp ah, 18h
        jz  short locret_4F45E
        cmp ah, 1Ah
        jz  short locret_4F45E
        call    sub_4A61F

locret_4F45E:               ; CODE XREF: sub_4F40D+3Dj
                    ; sub_4F40D+42j ...
        retn
; ---------------------------------------------------------------------------

loc_4F45F:              ; CODE XREF: sub_4F40D+Bj
        mov bl, [si+1835h]
        cmp bl, 8
        jz  short loc_4F478
        cmp bl, 0Ah
        jz  short loc_4F4E4
        cmp bl, 0Ch
        jz  short loc_4F4BE
        cmp bl, 0Eh
        jz  short loc_4F49B
        retn
; ---------------------------------------------------------------------------

loc_4F478:              ; CODE XREF: sub_4F40D+59j
        cmp word ptr [si+17BCh], 0
        jz  short loc_4F48B
        mov ax, [si+17BCh]
        cmp byte ptr [si+17BCh], 3
        jz  short loc_4F447
        retn
; ---------------------------------------------------------------------------

loc_4F48B:              ; CODE XREF: sub_4F40D+70j
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1011h
        retn
; ---------------------------------------------------------------------------

loc_4F49B:              ; CODE XREF: sub_4F40D+68j
        cmp word ptr [si+1832h], 0
        jz  short loc_4F4AE
        mov ax, [si+1832h]
        cmp byte ptr [si+1832h], 3
        jz  short loc_4F447
        retn
; ---------------------------------------------------------------------------

loc_4F4AE:              ; CODE XREF: sub_4F40D+93j
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1811h
        retn
; ---------------------------------------------------------------------------

loc_4F4BE:              ; CODE XREF: sub_4F40D+63j
        cmp word ptr [si+18ACh], 0
        jz  short loc_4F4D4
        mov ax, [si+18ACh]
        cmp byte ptr [si+18ACh], 3
        jnz short locret_4F4D3
        jmp loc_4F447
; ---------------------------------------------------------------------------

locret_4F4D3:               ; CODE XREF: sub_4F40D+C1j
        retn
; ---------------------------------------------------------------------------

loc_4F4D4:              ; CODE XREF: sub_4F40D+B6j
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2011h
        retn
; ---------------------------------------------------------------------------

loc_4F4E4:              ; CODE XREF: sub_4F40D+5Ej
        cmp word ptr [si+1836h], 0
        jz  short loc_4F4FA
        mov ax, [si+1836h]
        cmp byte ptr [si+1836h], 3
        jnz short locret_4F4F9
        jmp loc_4F447
; ---------------------------------------------------------------------------

locret_4F4F9:               ; CODE XREF: sub_4F40D+E7j
        retn
; ---------------------------------------------------------------------------

loc_4F4FA:              ; CODE XREF: sub_4F40D+DCj
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2811h
        retn
sub_4F40D   endp


; =============== S U B R O U T I N E =======================================


sub_4F50A   proc near       ; DATA XREF: data:156Ao
        push    si
        mov di, [si+61CDh]
        mov si, [bx+1388h]
        sub bx, 1Eh
        sub di, [bx+6C95h]
        sub di, [bx+6C95h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_4F526:              ; CODE XREF: sub_4F50A+24j
        movsb
        movsb
        add di, 78h ; 'x'
        add si, 78h ; 'x'
        loop    loc_4F526
        pop ds
        pop si
        shr bx, 1
        cmp bl, 7
        jnz short loc_4F546
        cmp byte ptr [si+18ACh], 1Fh
        jz  short loc_4F546
        mov word ptr [si+18ACh], 0

loc_4F546:              ; CODE XREF: sub_4F50A+2Dj
                    ; sub_4F50A+34j
        cmp bl, 8
        jge short loc_4F553
        add bl, 10h
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F553:              ; CODE XREF: sub_4F50A+3Fj
        mov word ptr leveldata[si], 11h
        cmp word ptr [si+1832h], 0
        jnz short loc_4F566
        mov byte ptr [si+1835h], 1
        retn
; ---------------------------------------------------------------------------

loc_4F566:              ; CODE XREF: sub_4F50A+54j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4F573
        mov byte ptr [si+1835h], 1
        retn
; ---------------------------------------------------------------------------

loc_4F573:              ; CODE XREF: sub_4F50A+61j
        cmp word ptr [si+17BCh], 0
        jnz short loc_4F58A
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1011h
        retn
; ---------------------------------------------------------------------------

loc_4F58A:              ; CODE XREF: sub_4F50A+6Ej
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4F595
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F595:              ; CODE XREF: sub_4F50A+85j
        cmp word ptr [si+1836h], 0
        jnz short loc_4F5A2
        mov byte ptr [si+1835h], 9
        retn
; ---------------------------------------------------------------------------

loc_4F5A2:              ; CODE XREF: sub_4F50A+90j
        cmp byte ptr [si+1836h], 3
        jnz short loc_4F5AF
        mov byte ptr [si+1835h], 9
        retn
; ---------------------------------------------------------------------------

loc_4F5AF:              ; CODE XREF: sub_4F50A+9Dj
        mov byte ptr [si+1835h], 1
        retn
sub_4F50A   endp


; =============== S U B R O U T I N E =======================================


sub_4F5B5   proc near       ; DATA XREF: data:157Ao
        push    si
        mov di, [si+6155h]
        mov si, [bx+1388h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F5C6:              ; CODE XREF: sub_4F5B5+1Bj
        movsb
        movsb
        movsb
        movsb
        add di, 76h ; 'v'
        add si, 76h ; 'v'
        loop    loc_4F5C6
        pop ds
        pop si
        shr bx, 1
        db  83h, 0E3h, 07h ;and bx, 7
        inc bx
        cmp bl, 7
        jnz short loc_4F5EC
        cmp byte ptr [si+1836h], 1Fh
        jz  short loc_4F5EC
        mov word ptr [si+1836h], 0

loc_4F5EC:              ; CODE XREF: sub_4F5B5+28j
                    ; sub_4F5B5+2Fj
        cmp bl, 8
        jge short loc_4F5F9
        add bl, 18h
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F5F9:              ; CODE XREF: sub_4F5B5+3Aj
        mov word ptr leveldata[si], 11h
        cmp word ptr [si+18ACh], 0
        jnz short loc_4F60C
        mov byte ptr [si+1835h], 3
        retn
; ---------------------------------------------------------------------------

loc_4F60C:              ; CODE XREF: sub_4F5B5+4Fj
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4F619
        mov byte ptr [si+1835h], 3
        retn
; ---------------------------------------------------------------------------

loc_4F619:              ; CODE XREF: sub_4F5B5+5Cj
        cmp word ptr [si+1832h], 0
        jnz short loc_4F630
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1811h
        retn
; ---------------------------------------------------------------------------

loc_4F630:              ; CODE XREF: sub_4F5B5+69j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4F63B
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F63B:              ; CODE XREF: sub_4F5B5+80j
        cmp word ptr [si+17BCh], 0
        jnz short loc_4F648
        mov byte ptr [si+1835h], 0Fh
        retn
; ---------------------------------------------------------------------------

loc_4F648:              ; CODE XREF: sub_4F5B5+8Bj
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4F655
        mov byte ptr [si+1835h], 0Fh
        retn
; ---------------------------------------------------------------------------

loc_4F655:              ; CODE XREF: sub_4F5B5+98j
        mov byte ptr [si+1835h], 3
        retn
sub_4F5B5   endp


; =============== S U B R O U T I N E =======================================


sub_4F65B   proc near       ; DATA XREF: data:158Ao
        push    si
        mov di, [si+60DDh]
        mov si, [bx+1388h]
        sub bx, 40h ; '@'
        add di, [bx+6C95h]
sub_4F65B   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4F66B   proc near
        add di, [bx+6C95h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_4F677:              ; CODE XREF: sub_4F66B+14j
        movsb
        movsb
        add di, 78h ; 'x'
        add si, 78h ; 'x'
        loop    loc_4F677
        pop ds
        pop si
        shr bx, 1
        inc bl
        cmp bl, 7
        jnz short loc_4F699
        cmp byte ptr [si+17BCh], 1Fh
        jz  short loc_4F699
        mov word ptr [si+17BCh], 0

loc_4F699:              ; CODE XREF: sub_4F66B+1Fj
                    ; sub_4F66B+26j
        cmp bl, 8
        jge short loc_4F6A6
        add bl, 20h ; ' '
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F6A6:              ; CODE XREF: sub_4F66B+31j
        mov word ptr leveldata[si], 11h
        cmp word ptr [si+1836h], 0
        jnz short loc_4F6B9
        mov byte ptr [si+1835h], 5
        retn
; ---------------------------------------------------------------------------

loc_4F6B9:              ; CODE XREF: sub_4F66B+46j
        cmp byte ptr [si+1836h], 3
        jnz short loc_4F6C6
        mov byte ptr [si+1835h], 5
        retn
; ---------------------------------------------------------------------------

loc_4F6C6:              ; CODE XREF: sub_4F66B+53j
        cmp word ptr [si+18ACh], 0
        jnz short loc_4F6DD
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2011h
        retn
; ---------------------------------------------------------------------------

loc_4F6DD:              ; CODE XREF: sub_4F66B+60j
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4F6E8
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F6E8:              ; CODE XREF: sub_4F66B+77j
        cmp word ptr [si+1832h], 0
        jnz short loc_4F6F5
        mov byte ptr [si+1835h], 0Dh
        retn
; ---------------------------------------------------------------------------

loc_4F6F5:              ; CODE XREF: sub_4F66B+82j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4F702
        mov byte ptr [si+1835h], 0Dh
        retn
; ---------------------------------------------------------------------------

loc_4F702:              ; CODE XREF: sub_4F66B+8Fj
        mov byte ptr [si+1835h], 5
        retn
sub_4F66B   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4F708   proc near       ; DATA XREF: data:159Ao
        push    si
        mov di, [si+6153h]
        mov si, [bx+1388h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F719:              ; CODE XREF: sub_4F708+1Bj
        movsb
        movsb
        movsb
        movsb
        add di, 76h ; 'v'
        add si, 76h ; 'v'
        loop    loc_4F719
        pop ds
        pop si
        shr bx, 1
        and bl, 7
        inc bl
        cmp bl, 7
        jnz short loc_4F740
        cmp byte ptr [si+1832h], 1Fh
        jz  short loc_4F740
        mov word ptr [si+1832h], 0

loc_4F740:              ; CODE XREF: sub_4F708+29j
                    ; sub_4F708+30j
        cmp bl, 8
        jge short loc_4F74D
        add bl, 28h ; '('
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F74D:              ; CODE XREF: sub_4F708+3Bj
        mov word ptr leveldata[si], 11h
        cmp word ptr [si+17BCh], 0
        jnz short loc_4F760
        mov byte ptr [si+1835h], 7
        retn
; ---------------------------------------------------------------------------

loc_4F760:              ; CODE XREF: sub_4F708+50j
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4F76D
        mov byte ptr [si+1835h], 7
        retn
; ---------------------------------------------------------------------------

loc_4F76D:              ; CODE XREF: sub_4F708+5Dj
        cmp word ptr [si+1836h], 0
        jnz short loc_4F784
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2811h
        retn
; ---------------------------------------------------------------------------

loc_4F784:              ; CODE XREF: sub_4F708+6Aj
        cmp byte ptr [si+1836h], 3
        jnz short loc_4F78F
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F78F:              ; CODE XREF: sub_4F708+81j
        cmp word ptr [si+18ACh], 0
        jnz short loc_4F79C
        mov byte ptr [si+1835h], 0Bh
        retn
; ---------------------------------------------------------------------------

loc_4F79C:              ; CODE XREF: sub_4F708+8Cj
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4F7A9
        mov byte ptr [si+1835h], 0Bh
        retn
; ---------------------------------------------------------------------------

loc_4F7A9:              ; CODE XREF: sub_4F708+99j
        mov byte ptr [si+1835h], 7
        retn
sub_4F708   endp


; =============== S U B R O U T I N E =======================================


movefun6  proc near       ; DATA XREF: data:163Ao
        cmp byte_510D7, 1
        jz  short locret_4F7D0
        cmp byte ptr leveldata[si], 18h
        jnz short locret_4F7D0
        mov bl, byte ptr leveldata[si+1]
        xor bh, bh
        shl bx, 1
        mov ax, movingFunctions2[bx]
        cmp ax, 0FFFFh
        jz  short locret_4F7D0
        call    ax

locret_4F7D0:               ; CODE XREF: movefun6+5j
                    ; movefun6+Cj ...
        retn
movefun6  endp


; =============== S U B R O U T I N E =======================================


sub_4F7D1   proc near       ; DATA XREF: data:movingFunctions2o
        mov ax, word_5195D
        and ax, 3
        jz  short loc_4F7DF
        cmp ax, 3
        jz  short loc_4F80D
        retn
; ---------------------------------------------------------------------------

loc_4F7DF:              ; CODE XREF: sub_4F7D1+6j
        push    ds
        push    si
        push    bx
        mov di, [si+6155h]
        mov si, [bx+13E8h]
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F7F1:              ; CODE XREF: sub_4F7D1+28j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4F7F1
        pop bx
        pop si
        pop ds
        shr bx, 1
        inc bx
        db  83h, 0E3h, 07h ;and bx, 7
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F809:              ; CODE XREF: sub_4F7D1+61j
                    ; sub_4F7D1+80j ...
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F80D:              ; CODE XREF: sub_4F7D1+Bj
        mov bl, [si+1835h]
        cmp bl, 0
        jz  short loc_4F826
        cmp bl, 2
        jz  short loc_4F845
        cmp bl, 4
        jz  short loc_4F864
        cmp bl, 6
        jz  short loc_4F883
        retn
; ---------------------------------------------------------------------------

loc_4F826:              ; CODE XREF: sub_4F7D1+43j
        cmp word ptr [si+17BCh], 0
        jz  short loc_4F835
        cmp byte ptr [si+17BCh], 3
        jz  short loc_4F809
        retn
; ---------------------------------------------------------------------------

loc_4F835:              ; CODE XREF: sub_4F7D1+5Aj
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1018h
        retn
; ---------------------------------------------------------------------------

loc_4F845:              ; CODE XREF: sub_4F7D1+48j
        cmp word ptr [si+1832h], 0
        jz  short loc_4F854
        cmp byte ptr [si+1832h], 3
        jz  short loc_4F809
        retn
; ---------------------------------------------------------------------------

loc_4F854:              ; CODE XREF: sub_4F7D1+79j
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1818h
        retn
; ---------------------------------------------------------------------------

loc_4F864:              ; CODE XREF: sub_4F7D1+4Dj
        cmp word ptr [si+18ACh], 0
        jz  short loc_4F873
        cmp byte ptr [si+18ACh], 3
        jz  short loc_4F809
        retn
; ---------------------------------------------------------------------------

loc_4F873:              ; CODE XREF: sub_4F7D1+98j
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2018h
        retn
; ---------------------------------------------------------------------------

loc_4F883:              ; CODE XREF: sub_4F7D1+52j
        cmp word ptr [si+1836h], 0
        jz  short loc_4F895
        cmp byte ptr [si+1836h], 3
        jnz short locret_4F894
        jmp loc_4F809
; ---------------------------------------------------------------------------

locret_4F894:               ; CODE XREF: sub_4F7D1+BEj
        retn
; ---------------------------------------------------------------------------

loc_4F895:              ; CODE XREF: sub_4F7D1+B7j
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2818h
        retn
sub_4F7D1   endp


; =============== S U B R O U T I N E =======================================


sub_4F8A5   proc near       ; DATA XREF: data:15BAo
        mov ax, word_5195D
        and ax, 3
        jz  short loc_4F8B3
        cmp ax, 3
        jz  short loc_4F8E3
        retn
; ---------------------------------------------------------------------------

loc_4F8B3:              ; CODE XREF: sub_4F8A5+6j
        push    ds
        push    si
        mov di, [si+6155h]
        mov si, [bx+13E8h]
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4F8C4:              ; CODE XREF: sub_4F8A5+27j
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4F8C4
        pop si
        pop ds
        shr bx, 1
        inc bl
        and bl, 7
        or  bl, 8
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F8DF:              ; CODE XREF: sub_4F8A5+63j
                    ; sub_4F8A5+82j ...
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4F8E3:              ; CODE XREF: sub_4F8A5+Bj
        mov bl, [si+1835h]
        cmp bl, 8
        jz  short loc_4F8FC
        cmp bl, 0Ah
        jz  short loc_4F959
        cmp bl, 0Ch
        jz  short loc_4F93A
        cmp bl, 0Eh
        jz  short loc_4F91B
        retn
; ---------------------------------------------------------------------------

loc_4F8FC:              ; CODE XREF: sub_4F8A5+45j
        cmp word ptr [si+17BCh], 0
        jz  short loc_4F90B
        cmp byte ptr [si+17BCh], 3
        jz  short loc_4F8DF
        retn
; ---------------------------------------------------------------------------

loc_4F90B:              ; CODE XREF: sub_4F8A5+5Cj
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1018h
        retn
; ---------------------------------------------------------------------------

loc_4F91B:              ; CODE XREF: sub_4F8A5+54j
        cmp word ptr [si+1832h], 0
        jz  short loc_4F92A
        cmp byte ptr [si+1832h], 3
        jz  short loc_4F8DF
        retn
; ---------------------------------------------------------------------------

loc_4F92A:              ; CODE XREF: sub_4F8A5+7Bj
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1818h
        retn
; ---------------------------------------------------------------------------

loc_4F93A:              ; CODE XREF: sub_4F8A5+4Fj
        cmp word ptr [si+18ACh], 0
        jz  short loc_4F949
        cmp byte ptr [si+18ACh], 3
        jz  short loc_4F8DF
        retn
; ---------------------------------------------------------------------------

loc_4F949:              ; CODE XREF: sub_4F8A5+9Aj
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2018h
        retn
; ---------------------------------------------------------------------------

loc_4F959:              ; CODE XREF: sub_4F8A5+4Aj
        cmp word ptr [si+1836h], 0
        jz  short loc_4F96B
        cmp byte ptr [si+1836h], 3
        jnz short locret_4F96A
        jmp loc_4F8DF
; ---------------------------------------------------------------------------

locret_4F96A:               ; CODE XREF: sub_4F8A5+C0j
        retn
; ---------------------------------------------------------------------------

loc_4F96B:              ; CODE XREF: sub_4F8A5+B9j
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2818h
        retn
sub_4F8A5   endp


; =============== S U B R O U T I N E =======================================


sub_4F97B   proc near       ; DATA XREF: data:15CAo
        push    si
        mov di, [si+61CDh]
        mov si, [bx+13E8h]
        sub bx, 1Eh
        sub di, [bx+6C95h]
        sub di, [bx+6C95h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_4F997:              ; CODE XREF: sub_4F97B+24j
        movsb
        movsb
        add di, 78h ; 'x'
        add si, 78h ; 'x'
        loop    loc_4F997
        pop ds
        pop si
        shr bx, 1
        cmp bl, 7
        jnz short loc_4F9B7
        cmp byte ptr [si+18ACh], 1Fh
        jz  short loc_4F9B7
        mov word ptr [si+18ACh], 0

loc_4F9B7:              ; CODE XREF: sub_4F97B+2Dj
                    ; sub_4F97B+34j
        cmp bl, 8
        jge short loc_4F9C4
        add bl, 10h
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4F9C4:              ; CODE XREF: sub_4F97B+3Fj
        mov word ptr leveldata[si], 18h
        cmp word ptr [si+1832h], 0
        jnz short loc_4F9D7
        mov byte ptr [si+1835h], 1
        retn
; ---------------------------------------------------------------------------

loc_4F9D7:              ; CODE XREF: sub_4F97B+54j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4F9E4
        mov byte ptr [si+1835h], 1
        retn
; ---------------------------------------------------------------------------

loc_4F9E4:              ; CODE XREF: sub_4F97B+61j
        cmp word ptr [si+17BCh], 0
        jnz short loc_4F9FB
        mov word ptr leveldata[si], 1BBh
        sub si, 78h ; 'x'
        mov word ptr leveldata[si], 1018h
        retn
; ---------------------------------------------------------------------------

loc_4F9FB:              ; CODE XREF: sub_4F97B+6Ej
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4FA06
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4FA06:              ; CODE XREF: sub_4F97B+85j
        cmp word ptr [si+1836h], 0
        jnz short loc_4FA13
        mov byte ptr [si+1835h], 9
        retn
; ---------------------------------------------------------------------------

loc_4FA13:              ; CODE XREF: sub_4F97B+90j
        cmp byte ptr [si+1836h], 3
        jnz short loc_4FA20
        mov byte ptr [si+1835h], 9
        retn
; ---------------------------------------------------------------------------

loc_4FA20:              ; CODE XREF: sub_4F97B+9Dj
        mov byte ptr [si+1835h], 1
        retn
sub_4F97B   endp


; =============== S U B R O U T I N E =======================================


sub_4FA26   proc near       ; DATA XREF: data:15DAo
        push    si
        mov di, [si+6155h]
        mov si, [bx+13E8h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4FA37:              ; CODE XREF: sub_4FA26+1Bj
        movsb
        movsb
        movsb
        movsb
        add di, 76h ; 'v'
        add si, 76h ; 'v'
        loop    loc_4FA37
        pop ds
        pop si
        shr bx, 1
        db  83h, 0E3h, 07h ;and bx, 7
        inc bx
        cmp bl, 7
        jnz short loc_4FA5D
        cmp byte ptr [si+1836h], 1Fh
        jz  short loc_4FA5D
        mov word ptr [si+1836h], 0

loc_4FA5D:              ; CODE XREF: sub_4FA26+28j
                    ; sub_4FA26+2Fj
        cmp bl, 8
        jge short loc_4FA6A
        add bl, 18h
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4FA6A:              ; CODE XREF: sub_4FA26+3Aj
        mov word ptr leveldata[si], 18h
        cmp word ptr [si+18ACh], 0
        jnz short loc_4FA7D
        mov byte ptr [si+1835h], 3
        retn
; ---------------------------------------------------------------------------

loc_4FA7D:              ; CODE XREF: sub_4FA26+4Fj
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4FA8A
        mov byte ptr [si+1835h], 3
        retn
; ---------------------------------------------------------------------------

loc_4FA8A:              ; CODE XREF: sub_4FA26+5Cj
        cmp word ptr [si+1832h], 0
        jnz short loc_4FAA1
        mov word ptr leveldata[si], 2BBh
        sub si, 2
        mov word ptr leveldata[si], 1818h
        retn
; ---------------------------------------------------------------------------

loc_4FAA1:              ; CODE XREF: sub_4FA26+69j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4FAAC
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4FAAC:              ; CODE XREF: sub_4FA26+80j
        cmp word ptr [si+17BCh], 0
        jnz short loc_4FAB9
        mov byte ptr [si+1835h], 0Fh
        retn
; ---------------------------------------------------------------------------

loc_4FAB9:              ; CODE XREF: sub_4FA26+8Bj
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4FAC6
        mov byte ptr [si+1835h], 0Fh
        retn
; ---------------------------------------------------------------------------

loc_4FAC6:              ; CODE XREF: sub_4FA26+98j
        mov byte ptr [si+1835h], 3
        retn
sub_4FA26   endp


; =============== S U B R O U T I N E =======================================


sub_4FACC   proc near       ; DATA XREF: data:15EAo
        push    si
        mov di, [si+60DDh]
        mov si, [bx+13E8h]
        sub bx, 40h ; '@'
        add di, [bx+6C95h]
        add di, [bx+6C95h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 12h

loc_4FAE8:              ; CODE XREF: sub_4FACC+24j
        movsb
        movsb
        add di, 78h ; 'x'
        add si, 78h ; 'x'
        loop    loc_4FAE8
        pop ds
        pop si
        shr bx, 1
        inc bl
        cmp bl, 7
        jnz short loc_4FB0A
        cmp byte ptr [si+17BCh], 1Fh
        jz  short loc_4FB0A
        mov word ptr [si+17BCh], 0

loc_4FB0A:              ; CODE XREF: sub_4FACC+2Fj
                    ; sub_4FACC+36j
        cmp bl, 8
        jge short loc_4FB17
        add bl, 20h ; ' '
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4FB17:              ; CODE XREF: sub_4FACC+41j
        mov word ptr leveldata[si], 18h
        cmp word ptr [si+1836h], 0
        jnz short loc_4FB2A
        mov byte ptr [si+1835h], 5
        retn
; ---------------------------------------------------------------------------

loc_4FB2A:              ; CODE XREF: sub_4FACC+56j
        cmp byte ptr [si+1836h], 3
        jnz short loc_4FB37
        mov byte ptr [si+1835h], 5
        retn
; ---------------------------------------------------------------------------

loc_4FB37:              ; CODE XREF: sub_4FACC+63j
        cmp word ptr [si+18ACh], 0
        jnz short loc_4FB4E
        mov word ptr leveldata[si], 3BBh
        add si, 78h ; 'x'
        mov word ptr leveldata[si], 2018h
        retn
; ---------------------------------------------------------------------------

loc_4FB4E:              ; CODE XREF: sub_4FACC+70j
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4FB59
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4FB59:              ; CODE XREF: sub_4FACC+87j
        cmp word ptr [si+1832h], 0
        jnz short loc_4FB66
        mov byte ptr [si+1835h], 0Dh
        retn
; ---------------------------------------------------------------------------

loc_4FB66:              ; CODE XREF: sub_4FACC+92j
        cmp byte ptr [si+1832h], 3
        jnz short loc_4FB73
        mov byte ptr [si+1835h], 0Dh
        retn
; ---------------------------------------------------------------------------

loc_4FB73:              ; CODE XREF: sub_4FACC+9Fj
        mov byte ptr [si+1835h], 5
        retn
sub_4FACC   endp


; =============== S U B R O U T I N E =======================================


sub_4FB79   proc near       ; DATA XREF: data:15FAo
        push    si
        mov di, [si+6153h]
        mov si, [bx+13E8h]
        push    ds
        mov ax, es
        mov ds, ax
        mov cx, 10h

loc_4FB8A:              ; CODE XREF: sub_4FB79+1Bj
        movsb
        movsb
        movsb
        movsb
        add di, 76h ; 'v'
        add si, 76h ; 'v'
        loop    loc_4FB8A
        pop ds
        pop si
        shr bx, 1
        and bl, 7
        inc bl
        cmp bl, 7
        jnz short loc_4FBB1
        cmp byte ptr [si+1832h], 1Fh
        jz  short loc_4FBB1
        mov word ptr [si+1832h], 0

loc_4FBB1:              ; CODE XREF: sub_4FB79+29j
                    ; sub_4FB79+30j
        cmp bl, 8
        jge short loc_4FBBE
        add bl, 28h ; '('
        mov [si+1835h], bl
        retn
; ---------------------------------------------------------------------------

loc_4FBBE:              ; CODE XREF: sub_4FB79+3Bj
        mov word ptr leveldata[si], 18h
        cmp word ptr [si+17BCh], 0
        jnz short loc_4FBD1
        mov byte ptr [si+1835h], 7
        retn
; ---------------------------------------------------------------------------

loc_4FBD1:              ; CODE XREF: sub_4FB79+50j
        cmp byte ptr [si+17BCh], 3
        jnz short loc_4FBDE
        mov byte ptr [si+1835h], 7
        retn
; ---------------------------------------------------------------------------

loc_4FBDE:              ; CODE XREF: sub_4FB79+5Dj
        cmp word ptr [si+1836h], 0
        jnz short loc_4FBF5
        mov word ptr leveldata[si], 4BBh
        add si, 2
        mov word ptr leveldata[si], 2818h
        retn
; ---------------------------------------------------------------------------

loc_4FBF5:              ; CODE XREF: sub_4FB79+6Aj
        cmp byte ptr [si+1836h], 3
        jnz short loc_4FC00
        call    sub_4A61F
        retn
; ---------------------------------------------------------------------------

loc_4FC00:              ; CODE XREF: sub_4FB79+81j
        cmp word ptr [si+18ACh], 0
        jnz short loc_4FC0D
        mov byte ptr [si+1835h], 0Bh
        retn
; ---------------------------------------------------------------------------

loc_4FC0D:              ; CODE XREF: sub_4FB79+8Cj
        cmp byte ptr [si+18ACh], 3
        jnz short loc_4FC1A
        mov byte ptr [si+1835h], 0Bh
        retn
; ---------------------------------------------------------------------------

loc_4FC1A:              ; CODE XREF: sub_4FB79+99j
        mov byte ptr [si+1835h], 7
        retn
sub_4FB79   endp


; =============== S U B R O U T I N E =======================================


sub_4FC20   proc near       ; CODE XREF: somethingspsig:loc_4944Fp
                    ; sub_501C0+22p ...
        cmp byte_510E3, 0
        jz  short loc_4FC6F
        cmp videoStatusUnk, 1
        jnz short loc_4FC33
        mov di, 177h
        jmp short loc_4FC36
; ---------------------------------------------------------------------------

loc_4FC33:              ; CODE XREF: sub_4FC20+Cj
        mov di, 201h

loc_4FC36:              ; CODE XREF: sub_4FC20+11j
        mov si, 87D1h
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FC4A
        mov di, 6AEh
        jmp short loc_4FC4D
; ---------------------------------------------------------------------------

loc_4FC4A:              ; CODE XREF: sub_4FC20+23j
        mov di, 932h

loc_4FC4D:              ; CODE XREF: sub_4FC20+28j
        mov si, 87DAh
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FC61
        mov di, 6B4h
        jmp short loc_4FC64
; ---------------------------------------------------------------------------

loc_4FC61:              ; CODE XREF: sub_4FC20+3Aj
        mov di, 938h

loc_4FC64:              ; CODE XREF: sub_4FC20+3Fj
        mov si, 87F6h
        mov ah, 8
        call    sub_500F3
        jmp loc_4FD1A
; ---------------------------------------------------------------------------

loc_4FC6F:              ; CODE XREF: sub_4FC20+5j
        cmp byte_510DE, 0
        jz  short loc_4FCC7
        cmp videoStatusUnk, 1
        jnz short loc_4FC82
        mov di, 177h
        jmp short loc_4FC85
; ---------------------------------------------------------------------------

loc_4FC82:              ; CODE XREF: sub_4FC20+5Bj
        mov di, 201h

loc_4FC85:              ; CODE XREF: sub_4FC20+60j
        mov si, 87D1h
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FC99
        mov di, 6AEh
        jmp short loc_4FC9C
; ---------------------------------------------------------------------------

loc_4FC99:              ; CODE XREF: sub_4FC20+72j
        mov di, 932h

loc_4FC9C:              ; CODE XREF: sub_4FC20+77j
        mov si, 87DAh
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FCB0
        mov di, 6B4h
        jmp short loc_4FCB3
; ---------------------------------------------------------------------------

loc_4FCB0:              ; CODE XREF: sub_4FC20+89j
        mov di, 938h

loc_4FCB3:              ; CODE XREF: sub_4FC20+8Ej
        mov si, 87DEh
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 2
        jnz short loc_4FD1A
        call    sub_50199
        jmp short loc_4FD1A
; ---------------------------------------------------------------------------

loc_4FCC7:              ; CODE XREF: sub_4FC20+54j
        cmp videoStatusUnk, 1
        jnz short loc_4FCD3
        mov di, 177h
        jmp short loc_4FCD6
; ---------------------------------------------------------------------------

loc_4FCD3:              ; CODE XREF: sub_4FC20+ACj
        mov di, 201h

loc_4FCD6:              ; CODE XREF: sub_4FC20+B1j
        mov si, 879Fh
        mov ah, 6
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FCEA
        mov di, 6AEh
        jmp short loc_4FCED
; ---------------------------------------------------------------------------

loc_4FCEA:              ; CODE XREF: sub_4FC20+C3j
        mov di, 932h

loc_4FCED:              ; CODE XREF: sub_4FC20+C8j
        mov si, 87A8h
        mov byte ptr [si+3], 0
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 1
        jnz short loc_4FD05
        mov di, 6B4h
        jmp short loc_4FD08
; ---------------------------------------------------------------------------

loc_4FD05:              ; CODE XREF: sub_4FC20+DEj
        mov di, 938h

loc_4FD08:              ; CODE XREF: sub_4FC20+E3j
        mov si, 87ACh
        mov ah, 8
        call    sub_500F3
        cmp videoStatusUnk, 2
        jnz short loc_4FD1A
        call    sub_50199

loc_4FD1A:              ; CODE XREF: sub_4FC20+4Cj
                    ; sub_4FC20+A0j ...
        call    sub_4FD21
        call    sub_4FDFD
        retn
sub_4FC20   endp


; =============== S U B R O U T I N E =======================================


sub_4FD21   proc near       ; CODE XREF: sub_4A3BB+13p
                    ; update?:loc_4EC90p ...
        push    si
        cmp byte_5195A, 1
        jnb short loc_4FD2E
        mov byte_5195A, 0

loc_4FD2E:              ; CODE XREF: sub_4FD21+6j
        mov al, byte_5195A
        mov si, 87C5h
        call    sub_4BF4D
        cmp videoStatusUnk, 1
        jnz short loc_4FD43
        mov di, 6CEh
        jmp short loc_4FD46
; ---------------------------------------------------------------------------

loc_4FD43:              ; CODE XREF: sub_4FD21+1Bj
        mov di, 952h

loc_4FD46:              ; CODE XREF: sub_4FD21+20j
        mov si, 87C5h
        cmp byte_5195A, 0
        jnz short loc_4FD54
        mov ah, 6
        jmp short loc_4FD56
; ---------------------------------------------------------------------------

loc_4FD54:              ; CODE XREF: sub_4FD21+2Dj
        mov ah, 8

loc_4FD56:              ; CODE XREF: sub_4FD21+31j
        call    sub_500F3
        cmp videoStatusUnk, 2
        jnz short loc_4FD63
        call    sub_50103

loc_4FD63:              ; CODE XREF: sub_4FD21+3Dj
        pop si
        retn
sub_4FD21   endp


; =============== S U B R O U T I N E =======================================


sub_4FD65   proc near       ; CODE XREF: runLevel+E9p
        cmp videoStatusUnk, 1
        jz  short loc_4FD6D
        retn
; ---------------------------------------------------------------------------

loc_4FD6D:              ; CODE XREF: sub_4FD65+5j
        mov al, byte_5197C
        cmp al, 0
        jnz short loc_4FD75
        retn
; ---------------------------------------------------------------------------

loc_4FD75:              ; CODE XREF: sub_4FD65+Dj
        dec al
        jz  short loc_4FD7D
        mov byte_5197C, al
        retn
; ---------------------------------------------------------------------------

loc_4FD7D:              ; CODE XREF: sub_4FD65+12j
        mov byte_5197C, al
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        push    ds
        mov si, word_5182E
        mov di, 6D2h
        mov ax, es
        mov ds, ax
        mov cx, 7

loc_4FD99:              ; CODE XREF: sub_4FD65+3Cj
        movsb
        movsb
        add si, 78h ; 'x'
        add di, 78h ; 'x'
        loop    loc_4FD99
        pop ds
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_4FD65   endp

; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR update?

loc_4FDAF:              ; CODE XREF: update?+1209j
                    ; update?:loc_4F0A9j ...
        mov word ptr leveldata[si], 3
; END OF FUNCTION CHUNK FOR update?

; =============== S U B R O U T I N E =======================================


sub_4FDB5   proc near       ; CODE XREF: update?+124Fp
                    ; update?+1266p ...
        cmp byte ptr word_59B73, 0
        jnz short loc_4FDCA
        cmp byte_510DB, 0
        jz  short loc_4FDCA
        cmp word_510DC, si
        jnz short loc_4FDCA
        retn
; ---------------------------------------------------------------------------

loc_4FDCA:              ; CODE XREF: sub_4FDB5+5j sub_4FDB5+Cj ...
        inc byte_5195C
sub_4FDB5   endp ; sp-analysis failed


; =============== S U B R O U T I N E =======================================


sub_4FDCE   proc near       ; CODE XREF: sub_4955B+7F4p
                    ; update?+1369p
        cmp videoStatusUnk, 1
        jz  short loc_4FDD6
        retn
; ---------------------------------------------------------------------------

loc_4FDD6:              ; CODE XREF: sub_4FDCE+5j
        push    si
        mov al, byte_5195C
        mov si, 87C9h
        call    sub_4BF4D
        mov di, 6D2h
        mov si, 87CAh
        cmp byte_5195C, 0
        jnz short loc_4FDF1
        mov ah, 8
        jmp short loc_4FDF3
; ---------------------------------------------------------------------------

loc_4FDF1:              ; CODE XREF: sub_4FDCE+1Dj
        mov ah, 6

loc_4FDF3:              ; CODE XREF: sub_4FDCE+21j
        call    sub_500F3
        pop si
        mov byte_5197C, 46h ; 'F'
        retn
sub_4FDCE   endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

sub_4FDFD   proc near       ; CODE XREF: runLevel+29p
                    ; runLevel:noFlashing2p ...

var_2       = word ptr -2

        push    bp
        mov bp, sp
        add sp, 0FFFEh
        mov [bp+var_2], 0
        mov al, byte_510B0
        cmp byte ptr word_510B7, al
        jz  short loc_4FE36
        mov byte ptr word_510B7, al
        mov si, 87CDh
        call    sub_4BF4D
        mov si, 87CEh
        cmp videoStatusUnk, 1
        jnz short loc_4FE29
        mov di, 188h
        jmp short loc_4FE2C
; ---------------------------------------------------------------------------

loc_4FE29:              ; CODE XREF: sub_4FDFD+25j
        mov di, 212h

loc_4FE2C:              ; CODE XREF: sub_4FDFD+2Aj
        mov ah, 6
        call    sub_500F3
        mov [bp+var_2], 1

loc_4FE36:              ; CODE XREF: sub_4FDFD+12j
        mov al, byte_510B1
        cmp byte ptr word_510B7+1, al
        jz  short loc_4FE5F
        mov byte ptr word_510B7+1, al
        mov si, 87CDh
        call    sub_4BF4D
        mov si, 87CEh
        cmp videoStatusUnk, 1
        jnz short loc_4FE57
        mov di, 185h
        jmp short loc_4FE5A
; ---------------------------------------------------------------------------

loc_4FE57:              ; CODE XREF: sub_4FDFD+53j
        mov di, 20Fh

loc_4FE5A:              ; CODE XREF: sub_4FDFD+58j
        mov ah, 6
        call    sub_500F3

loc_4FE5F:              ; CODE XREF: sub_4FDFD+40j
        mov al, byte_510B2
        cmp byte_510B9, al
        jz  short loc_4FE88
        mov byte_510B9, al
        mov si, 87CDh
        call    sub_4BF4D
        mov si, 87CEh
        cmp videoStatusUnk, 1
        jnz short loc_4FE80
        mov di, 182h
        jmp short loc_4FE83
; ---------------------------------------------------------------------------

loc_4FE80:              ; CODE XREF: sub_4FDFD+7Cj
        mov di, 20Ch

loc_4FE83:              ; CODE XREF: sub_4FDFD+81j
        mov ah, 6
        call    sub_500F3

loc_4FE88:              ; CODE XREF: sub_4FDFD+69j
        cmp videoStatusUnk, 2
        jnz short loc_4FE98
        cmp [bp+var_2], 0
        jz  short loc_4FE98
        call    sub_50144

loc_4FE98:              ; CODE XREF: sub_4FDFD+90j
                    ; sub_4FDFD+96j
        mov sp, bp
        pop bp
        retn
sub_4FDFD   endp


; =============== S U B R O U T I N E =======================================


sub_4FE9C   proc near       ; CODE XREF: sub_500F3+7p
        mov byte_51969, ah
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register

loc_4FEBE:              ; CODE XREF: sub_4FE9C+1C3j
        mov bl, [si]
        cmp bl, 0
        jnz short loc_4FEC8
        jmp loc_50062
; ---------------------------------------------------------------------------

loc_4FEC8:              ; CODE XREF: sub_4FE9C+27j
        cmp bl, 0Ah
        jnz short loc_4FED0
        jmp loc_50062
; ---------------------------------------------------------------------------

loc_4FED0:              ; CODE XREF: sub_4FE9C+2Fj
        inc si
        sub bl, 20h ; ' '
        xor bh, bh
        add bx, 5D15h
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        mov dx, 3CEh
        mov al, 0
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; set/reset.
                    ; Data bits 0-3 select planes for write mode 00
        inc dx
        mov al, byte_51969
        out dx, al      ; EGA port: graphics controller data register
        mov ah, [bx]
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, ah
        out dx, al      ; EGA port: graphics controller data register
        or  es:[di], al
        add di, 7Ah ; 'z'
        add bx, 40h ; '@'
        sub di, 355h
        jmp loc_4FEBE
; ---------------------------------------------------------------------------

loc_50062:              ; CODE XREF: sub_4FE9C+29j
                    ; sub_4FE9C+31j
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_4FE9C   endp


; =============== S U B R O U T I N E =======================================


sub_50077   proc near       ; CODE XREF: sub_500F3:loc_500FFp
        push    es
        mov ax, seg zeg000
        mov es, ax
        assume es:zeg000

loc_5007D:              ; CODE XREF: sub_50077+78j
        mov bl, [si]
        cmp bl, 0
        jnz short loc_50086
        jmp short loc_500F1
; ---------------------------------------------------------------------------

loc_50086:              ; CODE XREF: sub_50077+Bj
        cmp bl, 0Ah
        jnz short loc_5008D
        jmp short loc_500F1
; ---------------------------------------------------------------------------

loc_5008D:              ; CODE XREF: sub_50077+12j
        inc si
        sub bl, 20h ; ' '
        xor bh, bh
        add bx, 5D15h
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        mov ah, [bx]
        mov es:[di], ah
        add di, 0A8h ; '?'
        add bx, 40h ; '@'
        sub di, 497h
        jmp short loc_5007D
; ---------------------------------------------------------------------------

loc_500F1:              ; CODE XREF: sub_50077+Dj
                    ; sub_50077+14j
        pop es
        assume es:nothing
        retn
sub_50077   endp


; =============== S U B R O U T I N E =======================================


sub_500F3   proc near       ; CODE XREF: sub_4955B+446p
                    ; sub_4955B+6AFp ...
        cmp videoStatusUnk, 1
        jnz short loc_500FF
        call    sub_4FE9C
        jmp short locret_50102
; ---------------------------------------------------------------------------

loc_500FF:              ; CODE XREF: sub_500F3+5j
        call    sub_50077

locret_50102:               ; CODE XREF: sub_500F3+Aj
        retn
sub_500F3   endp


; =============== S U B R O U T I N E =======================================


sub_50103   proc near       ; CODE XREF: sub_4FD21+3Fp
        push    ds
        push    es
        mov ax, seg zeg000
        mov ds, ax
        assume ds:zeg000
        mov es, ax
        assume es:zeg000
        mov si, 951h
        mov di, 1911h
        pushf
        mov bx, 6

loc_50116:              ; CODE XREF: sub_50103+3Bj
        mov cx, 1Ch

loc_50119:              ; CODE XREF: sub_50103+30j
        lodsb
        rcr al, 1
        inc di
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        add si, 25h ; '%'
        add di, 25h ; '%'
        loop    loc_50119
        add si, 0B28h
        add di, 0B28h
        dec bx
        jnz short loc_50116
        popf
        pop es
        assume es:nothing
        pop ds
        assume ds:data
        retn
sub_50103   endp


; =============== S U B R O U T I N E =======================================


sub_50144   proc near       ; CODE XREF: sub_4FDFD+98p
        push    ds
        push    es
        mov ax, seg zeg000
        mov ds, ax
        assume ds:zeg000
        mov es, ax
        assume es:zeg000
        mov si, 20Bh
        mov di, 11CBh
        pushf
        mov bx, 6

loc_50157:              ; CODE XREF: sub_50144+4Fj
        mov cx, 1Ch

loc_5015A:              ; CODE XREF: sub_50144+44j
        lodsb
        rcr al, 1
        inc di
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        lodsb
        rcr al, 1
        stosb
        add si, 20h ; ' '
        add di, 20h ; ' '
        loop    loc_5015A
        add si, 0B28h
        add di, 0B28h
        dec bx
        jnz short loc_50157
        popf
        pop es
        assume es:nothing
        pop ds
        assume ds:data
        retn
sub_50144   endp


; =============== S U B R O U T I N E =======================================


sub_50199   proc near       ; CODE XREF: sub_4FC20+A2p
                    ; sub_4FC20+F7p
        push    es
        mov ax, seg zeg000
        mov es, ax
        assume es:zeg000
        mov di, 0FC0h
        push    ds
        mov ax, es
        mov ds, ax
        assume ds:zeg000
        mov si, 0
        mov bx, 7

loc_501AD:              ; CODE XREF: sub_50199+22j
        pushf
        mov cx, 0FC0h

loc_501B1:              ; CODE XREF: sub_50199+1Ej
        lodsb
        popf
        rcr al, 1
        pushf
        stosb
        loop    loc_501B1
        popf
        dec bx
        jnz short loc_501AD
        pop ds
        assume ds:data
        pop es
        assume es:nothing
        retn
sub_50199   endp


; =============== S U B R O U T I N E =======================================


sub_501C0   proc near       ; CODE XREF: start+338p sub_4955B+678p ...
        cmp videoStatusUnk, 2
        jnz short loc_501EA
        push    es
        mov ax, seg zeg000
        mov es, ax
        assume es:zeg000
        mov di, 0
        mov si, 4C15h
        mov dx, 60h ; '`'

loc_501D6:              ; CODE XREF: sub_501C0+1Fj
        mov cx, 28h ; '('
        rep movsb
        add di, 2
        dec dx
        jnz short loc_501D6
        pop es
        assume es:nothing
        call    sub_4FC20
        call    sub_5024B
        jmp short locret_5024A
; ---------------------------------------------------------------------------

loc_501EA:              ; CODE XREF: sub_501C0+5j
        mov si, 4C15h
        mov di, 0
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 18h

loc_50211:              ; CODE XREF: sub_501C0+71j
        push    cx
        mov ah, 1

loc_50214:              ; CODE XREF: sub_501C0+6Bj
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 28h ; '('
        rep movsb
        sub di, 28h ; '('
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_50214
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_50211
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        call    sub_4FC20

locret_5024A:               ; CODE XREF: sub_501C0+28j
        retn
sub_501C0   endp


; =============== S U B R O U T I N E =======================================


sub_5024B   proc near       ; CODE XREF: gameloop?+31p
                    ; sub_501C0+25p
        cmp videoStatusUnk, 1
        jnz short loc_50253
        retn
; ---------------------------------------------------------------------------

loc_50253:              ; CODE XREF: sub_5024B+5j
        mov si, 0
        mov bl, byte_510A6
        xor bh, bh
        mov ax, 0FC0h
        mul bx
        add si, ax
        push    ds
        mov ax, seg zeg000
        mov ds, ax
        assume ds:zeg000
        mov di, 0
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0
        out dx, al      ; EGA port: graphics controller data register
        mov dx, 3CEh
        mov al, 8
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; bit mask
                    ; Bits 0-7 select bits to be masked in all planes
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: graphics controller data register
        mov cx, 18h

loc_5028D:              ; CODE XREF: sub_5024B+62j
        push    cx
        mov ah, 1

loc_50290:              ; CODE XREF: sub_5024B+5Cj
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, ah
        out dx, al      ; EGA port: sequencer data register
        mov cx, 2Ah ; '*'
        rep movsb
        sub di, 2Ah ; '*'
        shl ah, 1
        test    ah, 0Fh
        jnz short loc_50290
        add di, 7Ah ; 'z'
        pop cx
        loop    loc_5028D
        mov dx, 3C4h
        mov al, 2
        out dx, al      ; EGA: sequencer address reg
                    ; map mask: data bits 0-3 enable writes to bit planes 0-3
        inc dx
        mov al, 0FFh
        out dx, al      ; EGA port: sequencer data register
        mov dx, 3CEh
        mov al, 1
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; enable set/reset
        inc dx
        mov al, 0Fh
        out dx, al      ; EGA port: graphics controller data register
        pop ds
        assume ds:data
        mov dx, 3CEh
        mov al, 5
        out dx, al      ; EGA: graph 1 and 2 addr reg:
                    ; mode register.Data bits:
                    ; 0-1: Write mode 0-2
                    ; 2: test condition
                    ; 3: read mode: 1=color compare, 0=direct
                    ; 4: 1=use odd/even RAM addressing
                    ; 5: 1=use CGA mid-res map (2-bits/pixel)
        inc dx
        mov al, 1
        out dx, al      ; EGA port: graphics controller data register
        retn
sub_5024B   endp


; =============== S U B R O U T I N E =======================================


sub_502CF   proc near       ; CODE XREF: start+2E6p
        mov si, 95A5h
        mov di, 531Bh
        mov ah, 1
        call    sub_4BA5F
        retn
sub_502CF   endp


; =============== S U B R O U T I N E =======================================


showNewCredits  proc near       ; CODE XREF: start+2ECp
        mov si, 9583h
        mov di, 9EE0h
        mov ah, 0Eh
        call    sub_4BA5F
        mov si, 9814h
        mov di, 0A3A4h
        mov ah, 0Eh
        call    sub_4BA5F

loc_502F1:              ; CODE XREF: showNewCredits+28j
        mov al, keyPressed
        cmp byte_519C3, 1
        jnz short loc_50301
        mov word_51970, 1

loc_50301:              ; CODE XREF: showNewCredits+1Ej
        cmp al, 0
        jz  short loc_502F1
        mov byte_510AB, 1
        retn
showNewCredits  endp

; ---------------------------------------------------------------------------
code        ends



include VARS.INC
include SEGMENTS.INC
include DATA.INC


end start
