$save nolist /* *============================================================================ * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore, dba the ACME Software Deli, as the author * * While the ACME Software Deli does not work for money, there is nonetheless * a significant amount of work involved. The ACME Software Deli maintains the * rights to all code written, though it may be used and distributed as long as * the following conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in * your distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli *============================================================================ */ $if not VIDEOIO_EXT_INCLUDED $set (VIDEOIO_EXT_INCLUDED) /* * $Id: videoIO.ext 1157 2025-05-05 00:35:39Z rmgillmore $ */ $include (..\lib\comnDefs.ext) /* * ----------------------------------------------------------------------------- * Define some of the line drawing characters that may be the most useful. * These characters are the box drawing characters, both single and double * line. The corners (UPPER_LEFT, UPPER_RIGHT, LOWER_LEFT, LOWER_RIGHT) allow * for the proper connections of double line and single line combinations. * * The SINGLE indicator and DOUBLE indicator are as one might expect. When * there are two indicators (at the end of a definition), it clarifies the * definition of a corner, with the first indicator being the HORIZONTAL * characteristic, and the second indicator being the VERTICAL characteristic */ declare lineType literally 'byte', SINGLE_LINE literally '0', DOUBLE_LINE literally '1', NO_LINE literally '2', NUMBER_LINE_TYPES literally '3'; declare LINE_SINGLE_VERTICAL literally '0b3h', LINE_SINGLE_HORIZONTAL literally '0c4h', UPPER_LEFT_SINGLE_SINGLE literally '0dah', /* horizontal_vertical */ UPPER_RIGHT_SINGLE_SINGLE literally '0bfh', LOWER_LEFT_SINGLE_SINGLE literally '0c0h', LOWER_RIGHT_SINGLE_SINGLE literally '0d9h', LINE_DOUBLE_VERTICAL literally '0bah', LINE_DOUBLE_HORIZONTAL literally '0cdh', UPPER_LEFT_DOUBLE_DOUBLE literally '0c9h', UPPER_RIGHT_DOUBLE_DOUBLE literally '0bbh', LOWER_LEFT_DOUBLE_DOUBLE literally '0c8h', LOWER_RIGHT_DOUBLE_DOUBLE literally '0bch', UPPER_LEFT_SINGLE_DOUBLE literally '0d6h', UPPER_LEFT_DOUBLE_SINGLE literally '0d5h', UPPER_RIGHT_SINGLE_DOUBLE literally '0b7h', UPPER_RIGHT_DOUBLE_SINGLE literally '0b8h', LOWER_LEFT_SINGLE_DOUBLE literally '0d3h', LOWER_LEFT_DOUBLE_SINGLE literally '0d4h', LOWER_RIGHT_SINGLE_DOUBLE literally '0bdh', LOWER_RIGHT_DOUBLE_SINGLE literally '0beh', MIDDLE_LEFT_DOUBLE_SINGLE literally '198', MIDDLE_RIGHT_DOUBLE_SINGLE literally '181', MIDDLE_TOP_DOUBLE_SINGLE literally '209', MIDDLE_BOTTOM_DOUBLE_SINGLE literally '207'; /* * definitions for scrolling */ declare scrollDirection_t literally 'word', SCROLL_UP literally '0', SCROLL_DOWN literally '1', SCROLL_LEFT literally '2', SCROLL_RIGHT literally '3'; declare coordinate_t literally 'structure ( x byte, y byte )'; /* * ----------------------------------------------------------------------------- * The character attribute is defined as a byte, grouped in two blocks of four * bits. The upper four bits define the background color and whether the * character is to blink. The lower four bits define the foregound color (the * color of the character) including its intensity. * * v ( the "blink" attribute ) * vvv ( the background color ) * v ( the color intensity for the character ) * vvv ( the character color ) * * 0 010 1 111 ( green background with white characters ) * ----------------------------------------------------------------------------- */ declare black literally '000b', blue literally '001b', green literally '010b', cyan literally '011b', red literally '100b', magenta literally '101b', brown literally '110b', grey literally '111b', bold literally '1000b', darkGrey literally 'black or bold', lightBlue literally 'blue or bold', lightGreen literally 'green or bold', lightCyan literally 'cyan or bold', lightRed literally 'red or bold', lightMagenta literally 'magenta or bold', yellow literally 'brown or bold', white literally 'grey or bold'; declare blackBackground literally 'shl( black, 4 )', blueBackground literally 'shl( blue, 4 )', greenBackground literally 'shl( green, 4 )', cyanBackground literally 'shl( cyan, 4 )', redBackground literally 'shl( red , 4 )', magentaBackground literally 'shl( magenta , 4 )', brownBackground literally 'shl( brown , 4 )', greyBackground literally 'shl( grey , 4 )', blink literally 'shl( bold, 4 )'; declare videoInfoBuffer_t literally 'structure ( functionalityInfoPtr pointer, currentVideoMode byte, numberCharColumns word, refreshBufferLength word, startAddrLeftCorner word, videoPagesCursorPos (8) structure ( xCoord byte, yCoord byte ), cursorStartLine byte, cursorEndLine byte, activeDisplayPage byte, adapterBasePortAddr word, currentBasePortSetting (2) byte, numberCharRows byte, charHeightScanLine word, activeDisplayCode byte, inactiveDisplayCode byte, numberDisplayableColors word, numberDisplayPages byte, numberScanLines byte, primaryCharacterBlock byte, secondaryCharacterBlock byte, miscStateInformation byte, reserved (2) byte, videoMemoryAvailable byte, savePointerStateInfo byte, reservedEndBlock (12) byte )'; /* *** Implemented in Assembly *** */ /* * ------------------------------------------------------------------------- * the writeStringWithAttAr() function writes a string of the given length * with the associated attributes at the current location * ------------------------------------------------------------------------- */ writeStringWithAttrsAt: procedure ( stringPtr, stringLength, pointInWordForm ) external; declare stringPtr pointer, stringLength word, pointInWordForm word; end writeStringWithAttrsAt; $if not vGotoXYImplementation /* * ----------------------------------------------------------------------------- * the gotoxy() procedure accepts 2 bytes. The console cursor is positioned * at the desired coordinates so the next console I/O operation takes place * at that coordinates * ----------------------------------------------------------------------------- */ gotoxy: procedure ( xCoordinate, yCoordinate ) external; declare xCoordinate byte, yCoordinate byte; end gotoxy; $endif $if not vCurPosImplementation /* * ----------------------------------------------------------------------------- * the curPos() function returns an array of two bytes. The first byte * (the least significant byte of the word) is the xCoordinate. The second * byte (the most significant byte of the word) is the yCoordinate. * ----------------------------------------------------------------------------- */ curPos: procedure word external; end curPos; /* * ----------------------------------------------------------------------------- * the returnLoc() function accepts an array of two bytes. The first byte * (the least significant byte of the word) is the xCoordinate. The second * byte (the most significant byte of the word) is the yCoordinate. * * think of this function as the reverse of curPos(). * ----------------------------------------------------------------------------- */ returnLoc: procedure ( location ) external; declare location word; end returnLoc; $endif $if not vCurOnOffImplementation /* * ----------------------------------------------------------------------------- * the cursorOn() and cursorOff() functions show/hide the cursor * ----------------------------------------------------------------------------- */ cursorOn: procedure external; end cursorOn; cursorOff: procedure external; end cursorOff; $endif $if not vScreenSizeImplementation /* * ----------------------------------------------------------------------------- * the screenSize() function reports the screen size in two words. The first * word is the number of screen columns; the second word is the number of * screen rows. * ----------------------------------------------------------------------------- */ screenSize: procedure ( columnsPtr, rowsPtr ) external; declare columnsPtr pointer /* to a word */, rowsPtr pointer /* to a word */; end screenSize; $endif $if not vGetAttrImplementation /* * ----------------------------------------------------------------------------- * the getAttributeAtLocation() function reports the attribute at the specified * location. Display page zero is assumed. * ----------------------------------------------------------------------------- */ getAttributeAtLocation: procedure ( xCoordinate, yCoordinate ) byte external; declare xCoordinate byte, yCoordinate byte; end getAttributeAtLocation; $endif $if not vChangeAttrImplementation /* * ----------------------------------------------------------------------------- * the vChangeAttributeAt() function moves to the designated screen position * ( x, y ), then writes the new attribute as indicated * ----------------------------------------------------------------------------- */ vChangeAttributeAt: procedure ( newAttribute, xCoordinate, yCoordinate ) external; declare newAttribute byte, xCoordinate byte, yCoordinate byte; end vChangeAttributeAt; $endif $if not vInvertAttrImplementation /* * ----------------------------------------------------------------------------- * the vInvertAttribute() function inverts the color attribute specified * (preserving the blinking and intensity indicators), then returns the * attribute value * ----------------------------------------------------------------------------- */ vInvertAttribute: procedure ( attributeToInvert ) byte external; declare attributeToInvert byte; /* to a coordinate_t */ end vInvertAttribute; $endif $if not vInvertAtImplementation /* * ----------------------------------------------------------------------------- * the vInvertAttributeAt() function moves to the designated screen position * ( x, y ), reads the character attribute at that location, inverts the colors * (preserving the blinking and intensity indicators), then sets the attribute * to the calculated value * ----------------------------------------------------------------------------- */ vInvertAttributeAt: procedure ( positionPtr ) external; declare positionPtr pointer; /* to a coordinate_t */ end vInvertAttributeAt; $endif $if not vScrollWindowImplementation /* * ----------------------------------------------------------------------------- * the scrollWindow() function moves the specified window contents in the * direction indicated, filling the resulting blank line(s) using the attribute * at the window origin (before scrolling) * ----------------------------------------------------------------------------- */ scrollWindow: procedure ( upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn, direction ) external; declare upperLeftRow byte, upperLeftColumn byte, lowerRightRow byte, lowerRightColumn byte, direction scrollDirection_t; end scrollWindow; $endif $if not vClearImplementation /* * ----------------------------------------------------------------------------- * the clrWindow() function clears the specified window using the specified * video attribute * ----------------------------------------------------------------------------- */ clrWindow: procedure ( upperLeftX, upperLeftY, lowerRightX, lowerRightY, attribute ) external; declare upperLeftX byte, upperLeftY byte, lowerRightX byte, lowerRightY byte, attribute byte; end clrWindow; /* * ------------------------------------------------------------------------- * the clrscr() function clears the entire screen ( ( 0, 0 ) to * ( numberColumns-1, numberRows-1 ) ) using the videoAttribute at the * origin (0,0) screen location * ------------------------------------------------------------------------- */ clrscr: procedure external; end clrscr; $endif $if not vGetCharImplementation /* * ----------------------------------------------------------------------------- * the getCharacterAtLocation() function reports the character at the specified * location. Display page zero is assumed. * ----------------------------------------------------------------------------- */ getCharacterAtLocation: procedure ( xCoordinate, yCoordinate ) char external; declare xCoordinate byte, yCoordinate byte; end getCharacterAtLocation; $endif $if not vWriteCharImplementation /* * ------------------------------------------------------------------------- * the writeCharsAtCurrentLocation() function writes the character * indicated for the designated number of times * ------------------------------------------------------------------------- */ writeCharsAtCurrentLocation: procedure ( characterToWrite, numberToWrite ) external; declare characterToWrite char, numberToWrite byte; end writeCharsAtCurrentLocation; $endif $if not vWriteAtImplementation /* * ------------------------------------------------------------------------- * the writeAt() function moves to the designated screen position ( x, y ), * then writes the character indicated * ------------------------------------------------------------------------- */ writeAt: procedure ( charToWrite, xCoordinate, yCoordinate ) external; declare charToWrite char, xCoordinate byte, yCoordinate byte; end writeAt; $endif $if not vWriteManyImplementation /* * ------------------------------------------------------------------------- * the writeManyAt() function moves to the designated screen position * ( x, y ), then writes the character (and quantity) indicated * ------------------------------------------------------------------------- */ writeManyAt: procedure ( charToWrite, xCoordinate, yCoordinate, numberToWrite ) external; declare charToWrite char, xCoordinate byte, yCoordinate byte, numberToWrite byte; end writeManyAt; $endif $if not vDrawBoxImplementation /* * ----------------------------------------------------------------------------- * the drawBox() function creates a box of extended ASCII characters. The * line type is either SINGLE_LINE or DOUBLE_LINE, and may differ for the * horizontal and vertical lines. * * The upper left and lower right corners are specified using a pointer to the * coordinate type * ----------------------------------------------------------------------------- */ drawBox: procedure ( verticalLineType, horizontalLineType, upperLeft, lowerRight, clearWindow ) external; declare verticalLineType lineType, horizontalLineType lineType, upperLeft pointer, /* to coordinate_t */ lowerRight pointer, clearWindow boolean; /* True will clear the window inside */ end drawBox; $endif $endif $restore