/* * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights * Reserved. This file contains Original Code and/or Modifications of * Original Code as defined in and that are subject to the Apple Public * Source License Version 2.0 (the "License"). You may not use this file * except in compliance with the License. Please obtain a copy of the * License at http://www.apple.com/publicsource and read it before using * this file. * * The Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * Copyright 1993 NeXT, Inc. * All rights reserved. */ #include "boot.h" #include "bootstruct.h" /* NOTE: Extremely stripped down boot2/graphics.c containing only text-mode activity spinner */ /* * for spinning disk */ static int currentIndicator = 0; //========================================================================== // Return the current video mode, VGA_TEXT_MODE or GRAPHICS_MODE. int getVideoMode(void) { return bootArgs->Video.v_display; } //========================================================================== // Display and clear the activity indicator. static char indicator[] = {'-', '\\', '|', '/', '-', '\\', '|', '/', '\0'}; #define kNumIndicators (sizeof(indicator) - 1) // To prevent a ridiculously fast-spinning indicator, // ensure a minimum of 1/9 sec between animation frames. #define MIN_TICKS 2 void spinActivityIndicator( void ) { static unsigned long lastTickTime = 0; unsigned long currentTickTime = time18(); static char string[3] = {'\0', '\b', '\0'}; if (currentTickTime < lastTickTime + MIN_TICKS) return; else lastTickTime = currentTickTime; if ( getVideoMode() == VGA_TEXT_MODE ) { if (currentIndicator >= kNumIndicators) currentIndicator = 0; string[0] = indicator[currentIndicator++]; printf(string); } } void clearActivityIndicator( void ) { if ( getVideoMode() == VGA_TEXT_MODE ) { printf(" \b"); } }