//
// APPLE // slot initializer
//
include "inc/cmdsys.plh"
include "inc/args.plh"
sysflags restxt1|resxtxt1

var arg

if MACHID & MACHID_MODEL == MACHID_III
    puts("Not for Apple ///\n")
    return -1
fin
arg = argNext(argFirst)
if ^arg
    if arg->1 == '0'
        // Validate and reserve 80 column text pages
        if cmdsys:_sysflags_ & vid80col
            when MACHID & MACHID_MODEL
                is MACHID_IIC
                is MACHID_IIE
                    putc(21) // IIe disable
                    cmdsys:_sysflags_ = cmdsys:_sysflags_ & ~resxtxt1
                    break
                is MACHID_IIPLUS
                is MACHID_II
                    putc(26); putc('1'); putln // Videx disable
                    putc(20); putc('A'); putc('1'); putln// ALS SmartTerm disable
                    ^$C058
            wend
            cmdsys:_sysflags_ = cmdsys:_sysflags_ & ~vid80col
        fin
        call($FE89, 0, 0, 0, 0) // IN#0
        call($FE93, 0, 0, 0, 0) // PR#0
        call($FB2F, 0, 0, 0, 0) // INIT
        return modflagkeep
    elsif arg->1 >= '1' and arg->1 <= '7'
        if arg->1 == '3'
            // Validate and reserve 80 column text pages
            if  not (MACHID & MACHID_80COL)
                puts("80 column card not present\n")
                return 0
            fin
            when MACHID & MACHID_MODEL
                is MACHID_IIPLUS
                is MACHID_II
                    ^$C059
            wend
            cmdsys:_sysflags_ = cmdsys:_sysflags_ | vid80col
        fin
        call($C000 + ((arg->1 - '0') << 8), '\n', 0, 0, 0)
        return modflagkeep
    fin
fin
puts("Usage: INITSLOT [SLOT NUMBER 1-7]\n")
done
