OUT: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "OUT writes values to register and port hardware addresses. {{PageSyntax}} : OUT {{Parameter|registerAddress%}}, {{Parameter|value%}} {{Parameters}} * {{Parameter|registerAddress%}} is a value expressed as a decimal INTEGER or hexadecimal. * The INTEGER {{Parameter|value%}} sent is normally only 0 to 255 per byte register (8 bit) address. {{PageDescription}} * '''QB64 has limited access to registers. VGA memory and registers are emulated.''' *...") |
No edit summary |
||
Line 30: | Line 30: | ||
::::* Every 3 reads or writes, changes to next color attribute without a set | ::::* Every 3 reads or writes, changes to next color attribute without a set | ||
::::* Color setting is Red, Green and Blue attribute intensities in order. | ::::* Color setting is Red, Green and Blue attribute intensities in order. | ||
::::* Color attribute intensity values range from 0 to 63. | ::::* Color attribute intensity values range from 0 to 63. | ||
::::* Some [[DAC]] color attribute intensities cannot be changed using OUT. | ::::* Some [[DAC]] color attribute intensities cannot be changed using OUT. | ||
Line 42: | Line 42: | ||
''Example 1:'' Reading the default RGB color settings of color attribute 15. | ''Example 1:'' Reading the default RGB color settings of color attribute 15. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|OUT}} &H3C7, 15 'set color port attribute 15 for a read | {{Cl|OUT}} &H3C7, 15 'set color port attribute 15 for a read | ||
red% = {{Cl|INP}}(&H3C9) | red% = {{Cl|INP}}(&H3C9) | ||
green% = INP(&H3C9) | green% = INP(&H3C9) | ||
blue% = INP(&H3C9) | blue% = INP(&H3C9) | ||
PRINT red%, green%, blue% | PRINT red%, green%, blue% | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}} | {{OutputStart}} | ||
Line 55: | Line 55: | ||
''Example 2:'' Changing the color intensity settings of the [[SCREEN]] background [[COLOR]] 0 to bright white. | ''Example 2:'' Changing the color intensity settings of the [[SCREEN]] background [[COLOR]] 0 to bright white. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|OUT}} &H3C8, 0 'attribute number. 0 for black screen background | {{Cl|OUT}} &H3C8, 0 'attribute number. 0 for black screen background | ||
{{Cl|OUT}} &H3C9, 63 'red | {{Cl|OUT}} &H3C9, 63 'red | ||
{{Cl|OUT}} &H3C9, 63 'green | {{Cl|OUT}} &H3C9, 63 'green | ||
{{Cl|OUT}} &H3C9, 63 'blue | {{Cl|OUT}} &H3C9, 63 'blue | ||
{{CodeEnd}} | {{CodeEnd}} | ||
:''Explanation:'' In [[SCREEN]] 0 this is one way to make high intensity background colors. {{InlineCode}}[[COLOR]] ,15{{InlineCodeEnd}} is actually grey (7). | :''Explanation:'' In [[SCREEN]] 0 this is one way to make high intensity background colors. {{InlineCode}}[[COLOR]] ,15{{InlineCodeEnd}} is actually grey (7). | ||
Line 65: | Line 65: | ||
''Example 3:'' Toggling blinking colors in SCREEN beginning with build 20170816/61 | ''Example 3:'' Toggling blinking colors in SCREEN beginning with build 20170816/61 | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|OUT}} &H3C0, &H10 'disables blinking and enables high intensity backgrounds (colors 16-31) | {{Cl|OUT}} &H3C0, &H10 'disables blinking and enables high intensity backgrounds (colors 16-31) | ||
{{Cl|OUT}} &H3C0, 2 ^ 3 'reenables blinking and disables high intensity backgrounds (colors 16-31) | {{Cl|OUT}} &H3C0, 2 ^ 3 'reenables blinking and disables high intensity backgrounds (colors 16-31) | ||
Line 73: | Line 73: | ||
''Example 4:'' Restoring colors to a bitmap from the Red, Green and Blue [[BSAVE]]d indexed array of color values. | ''Example 4:'' Restoring colors to a bitmap from the Red, Green and Blue [[BSAVE]]d indexed array of color values. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|SCREEN (statement)|SCREEN}} 12 | {{Cl|SCREEN (statement)|SCREEN}} 12 | ||
{{Cl|OUT}} {{Cl|&H}}3C8, 0 ' set color port for output at attribute 0 | {{Cl|OUT}} {{Cl|&H}}3C8, 0 ' set color port for output at attribute 0 | ||
Line 79: | Line 79: | ||
{{Cl|OUT}} {{Cl|&H}}3C9, Image%(i) ' changes to next attribute after 3 RGB loops | {{Cl|OUT}} {{Cl|&H}}3C9, Image%(i) ' changes to next attribute after 3 RGB loops | ||
{{Cl|NEXT}} | {{Cl|NEXT}} | ||
{{Cl|PUT (graphics statement)|PUT}}(clm, row), Image(48) PSET | {{Cl|PUT (graphics statement)|PUT}}(clm, row), Image(48) PSET | ||
{{CodeEnd}} | {{CodeEnd}} | ||
:''Explanation:'' The color RGB intensity settings were imported from a file to the Image array using [[BLOAD]]. The color attribute advances to the next one every 3 writes using OUT. The color information was indexed to the start of the array. The image is after the color settings at index 48. Index 48 is the [[GET (graphics statement)|GET]] image width and 49 is the height. | :''Explanation:'' The color RGB intensity settings were imported from a file to the Image array using [[BLOAD]]. The color attribute advances to the next one every 3 writes using OUT. The color information was indexed to the start of the array. The image is after the color settings at index 48. Index 48 is the [[GET (graphics statement)|GET]] image width and 49 is the height. | ||
Line 87: | Line 87: | ||
* [[PALETTE]], [[_PALETTECOLOR]] | * [[PALETTE]], [[_PALETTECOLOR]] | ||
* [[INP]] {{text|(read register)}} | * [[INP]] {{text|(read register)}} | ||
* [[PEEK]] {{text|(read memory)}} | * [[PEEK]] {{text|(read memory)}} | ||
* [[POKE]] {{text|(write to memory)}} | * [[POKE]] {{text|(write to memory)}} | ||
* [[COLOR]], [[SCREEN]] | * [[COLOR]], [[SCREEN]] | ||
* [[BSAVE]], [[BLOAD]] | * [[BSAVE]], [[BLOAD]] | ||
* [[_BLINK]], [[_BLINK (function)]] | * [[_BLINK]], [[_BLINK (function)]] |
Revision as of 02:16, 23 January 2023
OUT writes values to register and port hardware addresses.
Syntax
- OUT registerAddress%, value%
- registerAddress% is a value expressed as a decimal INTEGER or hexadecimal.
- The INTEGER value% sent is normally only 0 to 255 per byte register (8 bit) address.
Description
- QB64 has limited access to registers. VGA memory and registers are emulated.
- OUT can be used to change color port and a limited number of other port settings in QB64.
- Some settings may be set in a specific order to gain access to settings and INP reads.
- SCREEN modes determine the number of available color palette attributes from 2 to 256 in SCREEN 13.
- Windows NT may block access to Parallel printer and Serial ports. See Port Access Libraries or other DLLs.
- _PALETTECOLOR can also be used to set RGB intensity values using 32 bit color values.
- OUT can toggle the blinking attribute of SCREEN 0 color 16-31 for legacy code. _BLINK is the preferred method. (starting with build 20170816/61).
Color Port Palette access using OUT
- OUT &H3C7, attribute : Set port to read RGB settings for start attribute
- INP &H3C9, colorIntensity : Reads RGB color intensity settings in order
- OUT &H3C8, attribute : Set port to write RGB settings for start attribute
- OUT &H3C9, colorIntensity : Writes RGB color intensity settings in order
- Every 3 reads or writes, changes to next color attribute without a set
- Color setting is Red, Green and Blue attribute intensities in order.
- Color attribute intensity values range from 0 to 63.
- Some DAC color attribute intensities cannot be changed using OUT.
QBasic/QuickBASIC
- In DOS, OUT accesses memory and hardware directly, unlike POKE, and could cause PC damage.
Examples
Example 1: Reading the default RGB color settings of color attribute 15.
OUT &H3C7, 15 'set color port attribute 15 for a read red% = INP(&H3C9) green% = INP(&H3C9) blue% = INP(&H3C9) PRINT red%, green%, blue% |
63 63 63 |
Example 2: Changing the color intensity settings of the SCREEN background COLOR 0 to bright white.
OUT &H3C8, 0 'attribute number. 0 for black screen background OUT &H3C9, 63 'red OUT &H3C9, 63 'green OUT &H3C9, 63 'blue |
- Explanation: In SCREEN 0 this is one way to make high intensity background colors. COLOR ,15 is actually grey (7).
Example 3: Toggling blinking colors in SCREEN beginning with build 20170816/61
OUT &H3C0, &H10 'disables blinking and enables high intensity backgrounds (colors 16-31) OUT &H3C0, 2 ^ 3 'reenables blinking and disables high intensity backgrounds (colors 16-31) |
- Note: In QB64, the recommended practice is to use the _BLINK {ON|OFF} statement.
Example 4: Restoring colors to a bitmap from the Red, Green and Blue BSAVEd indexed array of color values.
SCREEN 12 OUT &H3C8, 0 ' set color port for output at attribute 0 FOR i = 0 TO 47 ' 48 RGB values is (3 * 16) -1 color attributes from 0 in screen 12 OUT &H3C9, Image%(i) ' changes to next attribute after 3 RGB loops NEXT PUT(clm, row), Image(48) PSET |
- Explanation: The color RGB intensity settings were imported from a file to the Image array using BLOAD. The color attribute advances to the next one every 3 writes using OUT. The color information was indexed to the start of the array. The image is after the color settings at index 48. Index 48 is the GET image width and 49 is the height.
See also
- PALETTE, _PALETTECOLOR
- INP (read register)
- PEEK (read memory)
- POKE (write to memory)
- COLOR, SCREEN
- BSAVE, BLOAD
- _BLINK, _BLINK (function)
- Port Access Libraries (COM or LPT registers)
External Links