; TCPAdetect.asm
; Verifies the presence of the TCPA BIOS interface
; Copyright (C) 2002  Jochen Lüll

; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.

; Version 0.1  26-OCT-2002

    jmp 07C0h:start     ; Goto segment 07C0

    ; Declare the string that will be printed
    msgStart   db  'TCPAdetect version 0.1      26-Oct-2002', 0Ah, 0Dh, 0Ah, 0Dh, '$'
    msgReboot    db  0Ah, 0Dh, 0Ah, 0Dh, 'Remove floppy disc and press CTRL-ALT-DEL to reboot', 0Ah, 0Dh, '$'
    msgNo      db  '  No TCPA capable BIOS detected!$'
    msgYes     db  '  TCPA capable BIOS detected!' , 0Ah, 0Dh, '  TCPA level: $'

    start:
            ; Update the segment registers
            mov ax, cs
            mov ds, ax
            mov es, ax

            call clear_screen
	    call hide_cursor

	    mov  si, msgStart
	    call print


	    mov ah, 0BBh
	    mov al, 00h
	    int 1Ah         ; TCPA presence check

	    cmp ax, 0
	    jne print_ok

  print_tcpa:
	    mov si, msgYes
	    call print

            add ch, 30h
	    mov al, ch
            mov ah, 0Eh     ; Print Major TCPA Version
            mov bx, 7
            int 10h
	    
	    mov al, "."
            mov ah, 0Eh     ; Print delimiter
            mov bx, 7
            int 10h

	    add cl, 30h
	    mov al, cl
            mov ah, 0Eh     ; Print Minor TCPA Version
            mov bx, 7
            int 10h

            jmp end


    print_ok:
            mov  si, msgNo     ; Print msg
            call print
	    jmp  end

    end:
            mov  si, msgReboot
	    call print
	    jmp  hang

    print:
            lodsb           ; AL=memory contents at DS:SI

            cmp al, '$'     
            je print_end

            mov ah, 0Eh     ; Print AL
            mov bx, 7
            int 10h
            
            jmp print       ; Print next character

    print_end:
	    ret

    clear_screen:
        mov ah, 0
	mov al, 3
        int 10h 
        ret

    hide_cursor:
        mov ah, 1
	mov ch, 20h
	mov cl, 0
        int 10h
	ret


    hang:                   ; Hang!
            jmp hang
 

