Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 15 of 20

Allegro DOS Owner's Manual: Chapter 6 Software Developer's Guide for MS-DOS, pages 117 to 125

Pages 117 to 125 of 166, from Allegro DOS Owner's Manual

The original document is the PDF (1.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Juniper Systems Allegro-DOS

Page 117

▲ Chapter 6 Software Developer’s Guide for DOS

Chapter 6

Software Developer’s Guide for MS-DOS Introduction Power Management Keyboard and Video Extended BIOS Functions Hardware Interrupt Listing I/O Port Mapping AT Keyboard Scan Codes Keyboard Key-Code Tables

Allegro DOS Owner’s Manual

117

Page 118

118

Allegro DOS Owner’s Manual

Page 119

Introduction to DOS Programmers This chapter of the manual includes technical information for DOS programmers. The power management information enables programmers to run the Allegro Field PC as efficiently as possible in terms of speed and power consumption. The keyboard and video interrupt functions can be used to control the keyboard and video screens. The extended BIOS functions, a hardware interrupt listing chart, I/O port mapping, AT scan codes, and keyboard key-code tables are also shown in this chapter.

Allegro DOS Owner’s Manual

119

Page 120

Power Management The Allegro has several power management functions integrated within the BIOS. Applications can use these functions to greatly enhance performance and operating time between battery charges. There is an internal automatic Power Manager, which can be set off or on, and five levels of performance, from 0 (miser) to 4 (hyper). There is a trade-off between battery operating time and performance. As the processor speed is increased the Allegro uses more power, causing the batteries to drain more quickly. For optimal power management, the processor should be run at high speed only when there is actual processing to be done, and run at low speed or stopped (sleep mode) the rest of the time. It is analogous to driving a car. Think of the processor as the car engine and the battery as the car fuel tank. When you press the gas pedal, the engine runs faster and in turn uses fuel more quickly. On most computers that run DOS, the processor is running at full throttle all of the time, even when there is no work to be done. While the processor is waiting for input, it is running at full speed in circles (programmers call this a spin loop). This is a tremendous waste of power, yet when DOS was designed desktop computers did not run on batteries and so power saving was not a concern. It is a serious problem in a battery operated system. Properly controlling CPU power during idle times has a dramatic effect on battery operating time. It can be handled at either the BIOS/operating system level, or at the application level. Starting and stopping the processor as needed is a simple concept, but can be difficult to implement effectively. The problem is determining when the processor is not doing any real work and can be safely shut down. When writing an application, the programmer usually knows when the processor is idly waiting for input, and by using Allegro’s power management API can design a very power efficient program. If the program has not been designed to use power management, the Allegro BIOS attempts to manage power automatically. However, the BIOS does not know for sure what the processor is doing. It can only guess, based on the level of activity it can see. For this reason, it is better to design power management into the program itself.

120

Allegro DOS Owner’s Manual

Page 121

For applications that do not take advantage of the Allegro power API, the BIOS Automatic Power Manager can greatly extend operating time and should be used when possible. In our experience, it works quite well with most applications. However, because the BIOS can only guess what the processor is doing, in some cases it may shut activities down when it should not and vice versa. If the program is misbehaving with Power Manager enabled, try disabling it. If the problem disappears, then there may be a conflict with your program and the Power Manager. If you encounter a situation where you cannot use the Power Manager, the next best thing for power savings is to set the performance level to the lowest possible setting in which the program still functions properly. If you are writing an application for Allegro, we strongly encourage designing power management into your program. Any time the processor is waiting for input, you may want to put it to sleep. The most common case where this technique is used is while waiting for a keystroke. See the Allegro Getch() example for a means to shut the processor down while waiting for a keystroke. A rule of thumb is whenever the processor may be waiting for 50 milliseconds or more for input it should be put to sleep. Another case where power management can be used is when an application temporarily needs to perform some high speed processing of data. The Allegro_CpuBusy() function can be used to override the Power Manager and put the processor into high speed mode while the processing is taking place. The Allegro_CpuDone() function is used to restore settings when processing is completed. Power management for DOS operation can be controlled by the user from the System Setup program (refer to Chapter 4, MS-DOS Operating System, System Setup Program for more details). It can be controlled programmatically through the Extended BIOS Functions (later in this chapter) as illustrated by the examples on the following pages written in C and Assembly language. Note that these examples are for DOS operation only.

Allegro DOS Owner’s Manual

121

Page 122

▲ Allegro Get Keystroke Function (Allegro_Getch()) The following function can be used to put the Allegro to sleep while waiting for a keystroke. char Allegro_Getch(void) { while(!kbhit()) // do sleep function until key is pressed { _asm { push ax push bx mov ax, 2F19h mov bl, 10000000b //load regs for sleep call int 10h //call sleep function pop bx pop ax } } return(getch()); }

▲ Allegro CPU Busy Function (Allegro_CpuBusy) This function overrides the Power Manager and causes the CPU to enter a high power state. It remains in this state until the Allegro_ CpuDone function is called. It is used to temporarily speed up the CPU when data needs to be processed rapidly. void Allegro_CpuBusy (void) { _asm { push ax push bx mov ax, 2E0Bh mov bl, 0 int 10h pop bx pop ax } }

122

Allegro DOS Owner’s Manual

// setup regs for function call // call cpu busy function

Page 123

▲ Allegro CPU Done Function (Allegro_CpuDone) This function is called to restore the Power Manager to the normal state after a CPU busy call. void Allegro_CpuDone (void) { _asm { push ax push bx mov ax, 2E0Bh mov bl, 1 int 10h pop bx pop ax } }

// setup regs for function call // call cpu done function

Allegro DOS Owner’s Manual

123

Page 124

Keyboard and Video A programmer can use the keyboard and video interrupt functions to control the keyboard and video screens. These functions are described below.

▲ Keyboard Intercept Functions BIOS interrupt 15h function 4Fh can be hooked to intercept raw (not yet translated) scan codes from the keyboard, which are contained in the AL register. The scan codes at this level are unique to the Allegro. Refer to the system scan codes in the Scan Code Tables found at the end of this chapter. BIOS interrupt 15h function 4Eh can be hooked to intercept translated scan codes from the keyboard, which are contained in the AX register. The scan codes at this level are standard 2 byte scan/ ASCII character codes. The keys on the keyboard can be remapped to output alternate characters through this interrupt.

▲ Video The Allegro display is a CGA compatible 320 x 200 pixel monochrome LCD. Text mode (BIOS video mode 3) supports four fonts which displays 40 columns x 25 lines, 40 x 16, 32 x 16, or 20 x 12 for the small, medium, large, or extra large fonts respectively. Font may be toggled with a hot key or set programmatically through the BIOS int 10h function 2E14h. A virtual 80 x 25 display with panning capability is supported for all fonts. Text attributes can be set to black/white, where CGA colors are mapped to either full on or full off, and gray shades, where CGA colors map to various shades of gray. This setting can be changed either in the System Setup program or through BIOS int 10h function 2F23h. Graphics modes supported are CGA mode 4 (320x200 pixel) with four shades of gray, and CGA mode 6 (640x200 pixel) where pixels are either on or off. Standard BIOS interrupt 10h functions are used to set the video mode. Only modes 3, 4, and 6 are supported. An autopan function can be enabled or disabled to cause the display to pan with the cursor around the 80 x 25 virtual window. Extended BIOS functions can be used to locate the display anywhere on the virtual window. In this way multiple “pages” can be set up on the single 80 x 25 window.

124

Allegro DOS Owner’s Manual

Page 125

Extended BIOS Functions Extended BIOS services are available through the use of an extended interrupt function BIOS call. The functions are placed in register AH. The subfunctions are placed in register AL. You then invoke INT 10h. When the subfunction requires data input (for example, to set the contrast), the data byte or word is generally passed in register BL or BX. The output byte is returned in register AL. An unsuccessful operation exits the function with the carry bit set. Function AH = 2Eh

Sub-Function AL = 00h AL = 01h AL = 02h AL = 03h AL = 04h AL = 06h AL = 07h AL = 0Ah AL = 0Bh AL = 0Ch AL = 0Dh AL = 0Fh AL = 10h AL = 11h AL = 12h AL = 14h AL = 15h AL = 19h AL = 1Ah AL = 20h AL = 24h AL = 26h

Meaning Pan left Pan right Pan up Pan down Pan XY - text mode PC card power while in suspend Suspend system Get Allegro status byte CPU busy/done Disable BIOS power manager Enable BIOS power manager Get CPU version Get keypad shift flag settings Set keypad shift flag settings Get Allegro ID Select font size (text mode only) Perform system hard reset Set LED brightness Get battery % charge Get BIOS version BIOS Setup pop-up window Get/set vehicle mode

AH = 2Fh

AL = 00h AL = 01h AL = 0Ch AL = 0Dh AL = 0Eh AL = 0Fh AL = 10h AL = 11h AL = 12h AL = 13h AL = 14h AL = 15h AL = 16h AL = 18h AL = 19h AL = 1Ah AL = 1Bh AL =1Eh AL =23h

Read status byte Read video contrast Set backlight off Set backlight on Set heater off Set heater auto Set key beep off Set key beep on Power down system Put system in reboot mode Put system in resume mode Set auto sleep duration Set video contrast Get performance level Set performance level Set auto-panning off Set auto-panning on Read miscellaneous BIOS setup bytes Video attributes

Allegro DOS Owner’s Manual

125