home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / HARDWARE / LED_CRT.ZIP / LED-CRT.TXT
Encoding:
Text File  |  1986-12-17  |  25.2 KB  |  656 lines

  1.      The following text was copied from a photocopy distributed by Leading
  2. Edge Hardware Products.  It contained no copyright notice, and I can't
  3. imagine the LE would care that I reproduced it.  They'll send it to you free
  4. if you ask them for it.  I have proof-read this document very carefully, but
  5. gremlins may have crept in.  Use the information contained herein at your
  6. own risk.
  7.  
  8.                 The Model "D" Video Controller
  9.  
  10.      The Model "D" video controller has the combined capability of the IBM
  11. Monochrome Display Board and the IBM Color Graphics Display Board.  It also
  12. provides Hercules Compatible Monochrome Graphics and a High Resolution 640 X
  13. 200 16 color graphics mode.
  14.  
  15.      Since there is only one 6845 CRT controller chip used in the circuitry,
  16. the system cannot run in both modes simultaneously.  The video mode switch in
  17. the rear of the machine functions in two ways.  It physically changes the I/O
  18. address of the CRT controller chip and related registers between MONOCHROME
  19. (03BxH) and COLOR (03DxH) and is actually DIPswitch 2-5, which selects
  20. monochrome or color mode at power on.
  21.  
  22.      There is 64K of video RAM associated with the controller and resides
  23. from address B0000H to address BFFFFH.  This is used to hold the
  24. characters/attributes or graphic dot patterns to be displayed on the screen.
  25.  
  26.      Below is a description of each of the modes and sample programs for
  27. initializing the controller to be in each of the modes.  Throughout this
  28. document bit 7 is the most significant bit and bit 0 is the least significant
  29. bit.
  30.  
  31.  
  32. *********************
  33. *                   *
  34. *  MONOCHROME MODE  *
  35. *                   *
  36. *********************
  37.  
  38. 80 X 25 TEXT MODE
  39.  
  40.      In alphanumeric mode 80 columns by 25 rows of characters can be
  41. displayed.  The characters are mapped into even locations from addresses
  42. B0000H to B0FFFH.  The attributes are mapped into the odd locations.
  43. Location B0000 corresponds to the top left corner of the screen.  The
  44. attribute determines how the character is to be displayed.  The various
  45. attributes are as follows:
  46.  
  47.             data bits
  48.          7 6 5 4 3 2 1 0     hex         style of text
  49.          ---------------     ---         -------------------
  50.          0 0 0 0 0 0 0 0      00         no character display
  51.          0 0 0 0 0 0 0 1      01         underlined character
  52.          0 0 0 0 0 1 1 1      07         normal character
  53.          0 0 0 0 1 0 0 1      09         underline, high intensity
  54.          0 0 0 0 1 1 1 1      0F         high intensity character
  55.          0 1 1 1 0 0 0 0      70         reverse video character
  56.          1 0 0 0 0 0 0 1      81         blinking, underlined character
  57.          1 0 0 0 0 1 1 1      87         blinking, normal character
  58.          1 0 0 0 1 0 0 1      89         blinking, underline, high intensity
  59.          1 1 1 1 0 0 0 0      F0         blinking, reverse bideo
  60.          1 1 1 1 1 0 0 0      F8         blinking, reverse vieo, high intensity
  61.  
  62.      The attribute determines how the character is to be displayed.  The
  63. attribute byte in the color mode is much different than it was in the
  64. monochrome mode.  Each of the bits in the attribute byte areas follows:
  65.  
  66.         Data bit   7  =  BLINK CHARACTER
  67.                    6  =  RED BACKGROUND
  68.                    5  =  GREEN BACKGROUND
  69.                    4  =  BLUE BACKGROUND
  70.                    3  =  INTENSITY CHARACTER
  71.                    2  =  RED CHARACTER
  72.                    1  =  GREEN CHARACTER
  73.                    0  =  BLUE CHARACTER
  74.  
  75.      By setting some bits on and some bits off, you can create colored
  76. characters on a differently colored background.  Also you have the choice of
  77. making the character blink or not.
  78.  
  79.  
  80. 720 X 348 GRAPHICS MODE
  81.  
  82.      In monochrome graphics mode there are two pages of 720 X 348 pixels.
  83. Each data bit in each byte represents a pixel on the display.  Each scan line
  84. consists of 90 bytes of memory.  The adjacent scan lines which appear in the
  85. display are not mapped adjacently in the video memory.  Below is a
  86. representation of how the memory is arranged in the monochrome graphic mode.
  87.  
  88.             PAGE 0                                  PAGE 1
  89.           ------------                          ----------------
  90.  
  91.        +-----------------------+              +-----------------------+
  92. B0000  |                       |       B8000  |                       |
  93.        | SCAN LINES 0,4,8 ETC  |              | SCAN LINES 0,4,8 ETC  |
  94.        |                       |              |                       |
  95. B1FFF  |                       |       B9FFF  |                       |
  96.        +-----------------------+              +-----------------------+
  97. B2000  |                       |       BA000  |                       |
  98.        | SCAN LINES 1,5,9 ETC  |              | SCAN LINES 1,5,9 ETC  |
  99.        |                       |              |                       |
  100. B3FFF  |                       |       BBFFF  |                       |
  101.        +-----------------------+              +-----------------------+
  102. B4000  |                       |       BC000  |                       |
  103.        | SCAN LINES 2,6,10 ETC |              | SCAN LINES 2,6,10 ETC |
  104.        |                       |              |                       |
  105. B5FFF  |                       |       BDFFF  |                       |
  106.        +-----------------------+              +-----------------------+
  107. B6000  |                       |       BE000  |                       |
  108.        | SCAN LINES 3,7,11 ETC |              | SCAN LINES 3,7,11 ETC |
  109.        |                       |              |                       |
  110. B7FFF  |                       |       BFFFF  |                       |
  111.        +-----------------------+              +-----------------------+
  112.  
  113. The page selection is done in the Display Control Register.  This will be
  114. explained in detail later.
  115.  
  116.  
  117. With color graphics there are 3 separate and different modes available.
  118.  
  119. 320 X 200 MEDIUM RESOLUTION GRAPHICS MODE
  120.  
  121.      Each pair of data bits represents a pixel on the display.  Therefore
  122. pixel can have 1 of 4 colors as follows:
  123.  
  124.        data bit 7,6 = C1,C0 respectively for the 1st pixel
  125.                 5,4 = C1,C0 respectively for the 2nd pixel
  126.                 3,2 = C1,C0 respectively for the 3rd pixel
  127.                 1,0 = C1,C0 respectively for the 4th pixel
  128.  
  129.     C1     C0        color set 0  color set 1  color set 2  color set 3
  130. -----------------|--------------|------------|------------|-------------
  131.      0      0       -----------predetermined background color-----------
  132.      0      1      green          lt. green    cyan         lt. cyan
  133.      1      0      red            lt. red      magenta      lt. magenta
  134.      1      1      brown          yellow       lt. gray     white
  135.  
  136.      The color set and background color are selected by writing the
  137. appropriate value to the Color Mode Regsiter at location 03D9H.
  138.  
  139.         data bit    0 = blue background
  140.                     1 = green background
  141.                     2 = red background
  142.                     3 = intensity background
  143.                     4 = color set bit 0
  144.                     5 = color set bit 1
  145.                     6 =
  146.                     7 =
  147.  
  148.      Each scan line consists of 80 bytes of memory.  The adjacent scan lines
  149. which appear on the display are not mapped adjacently in the video memory.
  150. Below is a representation of how the memory is arranged in 320 X 200 graphics
  151. mode.
  152.     
  153.        +------------------------+
  154. B8000  |                        |
  155.        | SCAN LINES 0,2,4 ETC   |
  156.        |                        |
  157. B9FFF  |                        |
  158.        +------------------------+
  159. BA000  |                        |
  160.        | SCAN LINES 1,3,5 ETC.  |
  161.        |                        |
  162. BBFFF  |                        |
  163.        +------------------------+
  164.  
  165. 640 X 200 HIGH RESOLUTION 2-COLOR GRAPHICS
  166.  
  167.      Each data bit represents a pixel on the display.  Therefore each pixel
  168. can have 1 of two colors.  The background color is always black.  The
  169. foreground color may be any 1 of 16 available colors.  It is chosen by
  170. writing the appropriate value to the Color Mode Register at location 03D9H.
  171.  
  172.     data bit   0 = blue background
  173.                1 = green background
  174.                2 = red background
  175.                3 = intensity background
  176.                4 =
  177.                5 =
  178.                6 =
  179.                7 =
  180.  
  181.      Each scan line consists of 80 bytes of memory.  The adjacent scan lines
  182. which appear on the display are not mapped adjacently in the video memory.
  183. Below is a representation of how the memory is arranged in the 640 X 200
  184. 2-color graphics mode.
  185.  
  186.     
  187.        +------------------------+
  188. B8000  |                        |
  189.        | SCAN LINES 0,2,4 ETC   |
  190.        |                        |
  191. B9FFF  |                        |
  192.        +------------------------+
  193. BA000  |                        |
  194.        | SCAN LINES 1,3,5 ETC.  |
  195.        |                        |
  196. BBFFF  |                        |
  197.        +------------------------+
  198.  
  199.  
  200. 640 X 200 HIGH RESOLUTION 16-COLOR GRAPHICS
  201.  
  202.      Four separate data bits represent a pixel on the display.  Therefore
  203. each pixel can have 1 of 16 colors.  The 4 bits are in different banks of
  204. memory.  Each bank of memory corresponds to red, green, blue, and intensity.
  205.  
  206.      Each scan line consists of 320 bytes of memory.  The adjacent scan lines
  207. which appear on the display are not mapped adjacently in the video memory.
  208. Below is a representation of how the memory is arranged in 640 X 200 16-color
  209. graphics mode.
  210.  
  211.  
  212.             INTENSITY BANK                        BLUE BANK
  213.        +-----------------------+              +-----------------------+
  214. B0000  |                       |       B4000  |                       |
  215.        | SCAN LINES 0,2,4 ETC  |              | SCAN LINES 0,2,4 ETC  |
  216.        |                       |              |                       |
  217. B1FFF  |                       |       B5FFF  |                       |
  218.        +-----------------------+              +-----------------------+
  219. B2000  |                       |       B6000  |                       |
  220.        | SCAN LINES 1,3,5 ETC  |              | SCAN LINES 1,3,5 ETC  |
  221.        |                       |              |                       |
  222. B3FFF  |                       |       B7FFF  |                       |
  223.        +-----------------------+              +-----------------------+
  224.  
  225.            GREEN BANK                              RED BANK
  226.        +-----------------------+              +-----------------------+
  227. B8000  |                       |       BC000  |                       |
  228.        | SCAN LINES 0,2,4 ETC  |              | SCAN LINES 0,2,4 ETC  |
  229.        |                       |              |                       |
  230. B9FFF  |                       |       BDFFF  |                       |
  231.        +-----------------------+              +-----------------------+
  232. BA000  |                       |       BE000  |                       |
  233.        | SCAN LINES 1,3,5 ETC  |              | SCAN LINES 1,3,5 ETC  |
  234.        |                       |              |                       |
  235. BBFFF  |                       |       BFFFF  |                       |
  236.        +-----------------------+              +-----------------------+
  237.  
  238.  
  239.                        VIDEO CONTROLLER REGISTERS
  240.  
  241. 6845 CRT INDEX REGISTER (03D4H / 03B4H)
  242.      You set this register equal to the number of the data register into
  243. which you want to write.
  244.  
  245. 6845 CRT DATA REGISTER  (03D5H / 03B5H)
  246.      In conjunction with the index register, it is used to initialize the
  247. 6845 for proper mode of operation.
  248.  
  249.  INDEX               DATA REGISTER VALUE (HEX)
  250. --------    -----------------------------------------
  251.             40X25    80X25    80X25    COLOR    MONO
  252.             COLOR    COLOR    MONO     GRAPH    GRAPH
  253.             -----    -----    -----    -----    -----
  254.    0         38       71       61       38      35    HORIZONTAL TOTAL
  255.    1         28       50       50       28      2D    HORIZONTAL DISPLAYED
  256.    2         2D       5A       52       2D      2E    HORIZ SYNC POSITION
  257.    3         0A       0A       0F       0A      07    HORIZ SYNC WIDTH
  258.    4         1F       1F       19       7F      5B    VERTICAL TOTAL
  259.    5         06       06       06       06      02    VERT TOTAL ADJUST
  260.    6         19       19       19       64      57    VERTICAL DISPLAYED
  261.    7         1C       1C       19       70      57    VERTICAL SYNC POSITION
  262.    8         02       02       02       02      02    INTERLACE MODE
  263.    9         07       07       0D       01      03    MAX SCAN LINE
  264.    A         06       06       0B       06      0B    CURSOR START SCAN LINE
  265.    B         07       07       0C       07      0C    CURSOR END SCAN LINE
  266.    C         00       00       00       00      00    BUFFER START ADDRESS (H)
  267.    D         00       00       00       00      00    BUFFER START ADDRESS (L)
  268.    E         00       00       00       00      00    CURSOR POSITION (H)
  269.    F         00       00       00       00      00    CURSOR POSITION (L)
  270.  
  271.      Changing the last 2 registers will allow various pages in color text
  272. mode to be utilized.  The appropriate values are as follows:
  273.  
  274.           80 column mode                 40 column mode
  275.          ----------------                ---------------
  276.            REG C    REG D                 REG C    REG D
  277.            -----    -----                 -----    -----
  278. PAGE 0      00       00           PAGE 0   00       00
  279. PAGE 1      08       00           PAGE 1   04       00
  280. PAGE 2      10       00           PAGE 2   08       00
  281. PAGE 3      18       00           PAGE 3   0C       00
  282.                                   PAGE 4   10       00
  283.                                   PAGE 5   14       00
  284.                                   PAGE 6   18       00
  285.                                   PAGE 7   1C       00
  286.  
  287. DISPLAY CONTROL REGISTER (03D8H / 03B8H)
  288.      Allows the mode of the controller to be programmed.
  289.  
  290.    data bit  0 ----  0 = 40X25 (color only)       1 = 80X25
  291.              1 ----  0 = alphanumerics            1 = graphics
  292.              2 ----  0 = color                    1 = black/white
  293.              3 ----  0 = disable video            1 = enable video
  294.              4 ----  0 = 320X200                  1 = 640X200
  295.              5 ----  0 = disable blink            1 = enable blink
  296.              6 ----
  297.              7 ----  0 = page 0 (mono graph)      1 = page 1
  298.  
  299.  
  300. COLOR MODE REGISTER (03D9H)
  301.      Allows the default colors in graphics mode to be selected.  This was
  302. described previously.
  303.  
  304. DISPLAY STATUS REGISTER (03DAH / 03BAH)
  305.      Allows software reading of VIDEO SYNC LINES and light pen status.
  306.  
  307.       data bit   0 = + HORIZONTAL SYNC
  308.                  1 = + LIGHT PEN STROBE
  309.                  2 = - LIGHT PEN SWITCH
  310.                  3 = + VERTICAL SYNC
  311.                  4 =
  312.                  5 =
  313.                  6 =
  314.                  7 = - HORIZONTAL SYNC
  315.  
  316. RESET LIGHT PEN LATCH (03DBH / 03BBH)
  317.  
  318. PRESET LIGHT PEN LATCH (03DCH / 03BCH)
  319.  
  320. EXTENDED COLOR MODE REGISTER (03DDH / 03BDH)
  321.      Allows selection of 16-color mode and software switch for toggling mode
  322. switch on back of machine
  323.  
  324.        data bit   0 =
  325.                   1 = SOFTWARE SWITCH (COLOR/MONO)
  326.                   2 =
  327.                   3 = ENABLE 16-COLOR MODE
  328.                   4 =
  329.                   5 =
  330.                   6 =
  331.                   7 =
  332.  
  333.      When bit 1 is set to on, this has the same result as physically
  334. switching the video mode switch on the rear of the machine.  Resetting this
  335. bit again will undo the previous toggle.  Note, if this is used the
  336. controller must be reinitialized for the new mode.  Remember also the
  337. toggling the switch changes the I/O address for the controller.
  338.  
  339.  
  340. **********************
  341. *   EXAMPLE PROGRAMS *
  342. **********************
  343.  
  344.      All of the programs will be written in BASIC simply for simplicity's
  345. sake.  They can be converted to other languages very easily.  Because of the
  346. slower execution speed of BASIC, some of the programs may take a while to
  347. clear the video memory and complete execution.  Please be patient.
  348.  
  349. EXAMPLE 1:  SET CONTROLLER UP FOR MONOCHROME TEXT MODE
  350.  
  351. 1 rem clear monochrome text page
  352. 2 CLS:KEY OFF
  353. 5 DEF SEG=&HB000
  354. 10 REM set display control register to the needed value
  355. 20 REM   data bit 0 --- 1=80x25
  356. 30 REM            1 --- 0=ALPHANUMERICS
  357. 40 REM            2 --- 0
  358. 50 REM            3 --- 1=ENABLE VIDEO
  359. 60 REM            4 --- 0
  360. 70 REM            5 --- 1=ENABLE BLINK
  361. 80 REM            6 --- 0
  362. 90 REM            7 --- 0
  363. 100 OUT &H3B8,&H29
  364. 110 REM then initialize 6845 crt controller data registers
  365. 120 FOR INDEX=0 to &HF
  366. 125 OUT &H3B4,INDEX
  367. 130 READ BYTE
  368. 140 OUT &H3B5,BYTE
  369. 145 NEXT INDEX
  370. 150 REM display one character of each attribute
  371. 151 FOR ADDR=0 TO 22 STEP 2
  372. 152 READ CHAR$:CHAR=ASC(CHAR$)
  373. 153 READ ATTR
  374. 154 POKE ADDR,CHAR
  375. 155 POKE ADDR+1,ATTR
  376. 156 NEXT ADDR
  377. 160 GOTO 160
  378. 165 REM these are the 6845 register values for this mode
  379. 170 DATA &H61,&H50,&H52,&H0F,&H19,&H06,&H19
  380. 180 DATA &H19,&H02,&H0D,&H0B,&H0C,&H00,&H00,&H00,&H00
  381. 185 REM these are the characters and attributes to display
  382. 190 DATA A,&H00,B,&H01,C,&H07,D,&H09,E,&H0F,F,&H70
  383. 200 DATA G,&H78,H,&H81,I,&H87,J,&H89,K,&HF0,L,&HF3
  384.  
  385.  
  386. EXAMPLE 2:  SET CONTROLLER UP FOR MONGRAPHICS MODE AND USE PAGE 1 OF MEMORY
  387.  
  388. 1 REM clear second page of monochrome graphic memory
  389. 2 KEY OFF:DEF SEG=&HB800:FOR ADDR=0 TO &H7FFF:POKE ADDR,0:NEXT ADDR
  390. 10 REM set display control register to the needed value
  391. 20 REM     DATA BIT 0 --- 0
  392. 30 REM              1 --- 1=GRAPHICS
  393. 40 REM              2 --- 0
  394. 50 REM              3 --- 1=ENABLE VIDEO
  395. 60 REM              4 --- 0
  396. 70 REM              5 --- 0
  397. 80 REM              6 --- 0
  398. 90 REM              7 --- 1=PAGE 1
  399. 100 OUT &H3B8,&H8A
  400. 110 REM then initialize 6845 crt controller data registers
  401. 120 FOR INDEX=0 TO &HF
  402. 125 OUT &H3B4,INDEX
  403. 130 READ BYTE
  404. 140 OUT &H3B5,BYTE
  405. 145 NEXT INDEX
  406. 150 REM draw scan lines 0,4,8 etc
  407. 151 STADR=0:DEF SEG=&HB800
  408. 152 FOR X=1 TO 45 STEP 2:ADDR=STADR
  409. 153 FOR T=0 TO X
  410. 154 POKE ADDR,&HFF
  411. 155 ADDR=ADDR+1
  412. 156 NEXT T
  413. 157 STADR=STADR+90:NEXT X
  414. 160 REM draw scan lines 1,5,9 etc
  415. 161 STADR=0:DEF SEG=&HBA00
  416. 162 FOR X=1 TO 45 STEP 2:ADDR=STADR
  417. 163 FOR T=0 TO X
  418. 164 POKE ADDR,&HFF
  419. 165 ADDR=ADDR+1
  420. 166 NEXT T
  421. 167 STADR=STADR+90:NEXT X
  422. 170 REM draw scan lines 2,6,10 etc
  423. 171 STADR=0:DEF SEG=&HBC00
  424. 172 FOR X=1 TO 45 STEP 2:ADDR=STADR
  425. 173 FOR T=0 TO X
  426. 174 POKE ADDR,&HFF
  427. 175 ADDR=ADDR+1
  428. 176 NEXT T
  429. 177 STADR=STADR+90:NEXT X
  430. 180 REM draw scan lines 3,7,11 etc
  431. 181 STADR=0:DEF SEG=&HBE00
  432. 182 FOR X=1 TO 45 STEP 2:ADDR=STADR
  433. 183 FOR T=0 TO X
  434. 184 POKE ADDR,&HFF
  435. 185 ADDR=ADDR+1
  436. 186 NEXT T
  437. 187 STADR=STADR+90:NEXT X
  438. 190 GOTO 190
  439. 200 DATA &H35,&H2D,&H2E,&H07,&H5B,&H02,&H57
  440. 210 DATA &H57,&H02,&H03,&H0B,&H0C,&H00,&H00,&H00,&H00
  441.  
  442.  
  443. EXAMPLE 3:  SET CONTROLLER UP FOR COLOR 40 X 25 TEXT MODE
  444. 1 REM clear color text page
  445. 2 DEF SEG=&HB800:CLS:KEY OFF
  446. 10 REM  set display control register to the needed value
  447. 20 REM     DATA BIT 0 --- 0=40X25
  448. 30 REM              1 --- 0=ALPHANUMERICS
  449. 40 REM              2 --- 0
  450. 50 REM              3 --- 1=ENABLE VIDEO
  451. 60 REM              4 --- 0
  452. 70 REM              5 --- 1=ENABLE BLINK
  453. 80 REM              6 --- 0
  454. 90 REM              7 --- 0
  455. 100 OUT &H3D8,&H28
  456. 110 REM then initialize 6845 crt controller data registers
  457. 120 FOR INDEX=0 to &HF
  458. 125 OUT &H3D4,INDEX
  459. 130 READ BYTE
  460. 140 OUT &H3D5,BYTE
  461. 145 NEXT INDEX
  462. 150 REM display one character of each attribute
  463. 151 ATTR=0:FOR ADDR=0 TO 510 STEP 2
  464. 152 CHAR=ATTR
  465. 154 POKE ADDR,CHAR
  466. 155 POKE ADDR+1,ATTR
  467. 156 ATTR=ATTR+1:NEXT ADDR
  468. 160 GOTO 160
  469. 165 REM these are 6845 register values for this mode
  470. 170 DATA &H38,&H28,&H2D,&H0A,&H1F,&H06,&H19
  471. 180 DATA &H1C,&H02,&H07,&H06,&H07,&H00,&H00,&H00,&H00
  472.  
  473.  
  474. EXAMPLE 4:  SET CONTROLLER UP FOR COLOR 80 X 25 TEXT MODE AND
  475.             USE PAGE 2 OF MEMORY
  476.  
  477. 1 REM clear color text display
  478. 2 DEF SEG=&HBA00:CLS:KEY OFF
  479. 10 REM  set display control register to the needed value
  480. 20 REM        DATA BIT 0 --- 1=80X25
  481. 30 REM                 1 --- 0=ALPHANUMERICS
  482. 40 REM                 2 --- 0
  483. 50 REM                 3 --- 1=ENABLE VIDEO
  484. 60 REM                 4 --- 0
  485. 70 REM                 5 --- 1=ENABLE BLINK
  486. 80 REM                 6 --- 0
  487. 90 REM                 7 --- 0
  488. 100 OUT &H3D8,&H29
  489. 110 REM then initialize the 6845 crt controller data registers
  490. 120 FOR INDEX=0 TO &HF
  491. 125 OUT &H3D4,INDEX
  492. 130 READ BYTE
  493. 140 OUT &H3D5,BYTE
  494. 145 NEXT INDEX
  495. 150 REM display one character of each attribute
  496. 151 ATTR=0:FOR ADDR=0 TO 510 STEP 2
  497. 152 CHAR=ATTR
  498. 154 POKE ADDR,CHAR
  499. 155 POKE ADDR+1,ATTR
  500. 156 ATTR=ATTR+1:NEXT ADDR
  501. 160 GOTO 160
  502. 165 REM these are the 6845 register values for this mode
  503. 170 DATA &H71,&H50,&H5A,&H0A,&H1F,&H06,&H19
  504. 180 DATA &H1C,&H02,&H07,&H06,&H07,&H10,&H00,&H00,&H00
  505.  
  506.  
  507. EXAMPLE 5 :  SET CONTROLLER UP FOR 320 X 200 COLOR GRAPHICS MODE
  508.                USE COLOR SET 3 AND BACKGROUND OF BROWN
  509.  
  510. 1 REM clear all of color video memory
  511. 2 KEY OFF
  512. 3 DEF SEG=&HB800:FOR ADDR=0 TO &H3FFF:POKE ADDR,0:NEXT ADDR
  513. 5 REM  set color mode register
  514. 6 OUT &H3D9,&H26
  515. 10 REM   set display control register to the needed value
  516. 20 REM        DATA BIT 0 --- 0
  517. 30 REM                 1 --- 1=GRAPHICS
  518. 40 REM                 2 --- 0
  519. 50 REM                 3 --- 1=ENABLE VIDEO
  520. 60 REM                 4 --- 0=320 X 200
  521. 70 REM                 5 --- 0
  522. 80 REM                 6 --- 0
  523. 90 REM                 7 --- 0
  524. 100 OUT &H3D8,&H0A
  525. 110 REM  then initialize 6845 crt controller data registers
  526. 120 FOR INDEX=0 TO &HF
  527. 125 OUT &H3D4,INDEX
  528. 130 READ BYTE
  529. 140 OUT &H3D5,BYTE
  530. 145 NEXT INDEX
  531. 150 REM draw scan lines 0,2,4 etc
  532. 151 STADR=0
  533. 152 DEF SEG=&HB800:FOR X=1 TO 45 STEP 2:ADDR=STADR
  534. 153 FOR TO=0 TO X
  535. 154 POKE ADDR,&H0:POKE ADDR+1760,&H55:POKE ADDR+3520,&HAA:POKE ADDR+5280,&HFF
  536. 155 ADDR=ADDR+1
  537. 156 NEXT T
  538. 157 STADR=STADR+80:NEXT X
  539. 160 REM  draw scan lines 1,3,5 etc
  540. 161 STADR=0
  541. 162 DEF SEG=&HBA00:FOR X=1 TO 45 STEP 2:ADDR=STADR
  542. 163 FOR TO=0 TO X
  543. 164 POKE ADDR,&H0:POKE ADDR+1760,&H55:POKE ADDR+3520,&HAA:POKE ADDR+5280,&HFF
  544. 165 ADDR=ADDR+1
  545. 166 NEXT T
  546. 167 STADR=STADR+80:NEXT X
  547. 190 GOTO 190
  548. 195 REM  these are the 6845 register values for this mode
  549. 200 DATA &H38,&H28,&H2D,&H0A,&H7F,&H06,&H64
  550. 210 DATA &H70,&H02,&H01,&H06,&H07,&H00,&H00,&H00,&H00
  551.  
  552.  
  553. EXAMPLE 6:  SET CONTROLLER UP FOR 640 X 200 2-COLOR GRPAHICS MODE
  554.                   AND USE FOREGROUND COLOR OF LIGHT MAGENTA
  555.  
  556. 1 REM clear all of color video memory
  557. 2 KEY OFF
  558. 3 DEF SEG=&HB800:FOR ADDR=0 TO &H3FFF:POKE ADDR,0:NEXT ADDR
  559. 5 REM  set color mode register
  560. 6 OUT &H3D9,&HD
  561. 10 REM   set display control register to the needed value
  562. 20 REM        DATA BIT 0 --- 0
  563. 30 REM                 1 --- 1=GRAPHICS
  564. 40 REM                 2 --- 1=BLACK/WHITE
  565. 50 REM                 3 --- 1=ENABLE VIDEO
  566. 60 REM                 4 --- 1=640 X 200
  567. 70 REM                 5 --- 0
  568. 80 REM                 6 --- 0
  569. 90 REM                 7 --- 0
  570. 100 OUT &H3D8,&H1E
  571. 110 REM  then initialize 6845 crt controller data registers
  572. 120 FOR INDEX=0 TO &HF
  573. 125 OUT &H3D4,INDEX
  574. 130 READ BYTE
  575. 140 OUT &H3D5,BYTE
  576. 145 NEXT INDEX
  577. 150 REM draw scan lines 0,2,4 etc
  578. 151 STADR=0
  579. 152 DEF SEG=&HB800:FOR X=1 TO 45 STEP 2:ADDR=STADR
  580. 153 FOR TO=0 TO X
  581. 154 POKE ADDR,&HFF
  582. 155 ADDR=ADDR+1
  583. 156 NEXT T
  584. 157 STADR=STADR+80:NEXT X
  585. 160 REM  draw scan lines 1,3,5 etc
  586. 161 STADR=0
  587. 162 DEF SEG=&HBA00:FOR X=1 TO 45 STEP 2:ADDR=STADR
  588. 163 FOR T=0 TO X
  589. 164 POKE ADDR,&HFF
  590. 165 ADDR=ADDR+1
  591. 166 NEXT T
  592. 167 STADR=STADR+80:NEXT X
  593. 190 GOTO 190
  594. 195 REM  these are the 6845 register values for this mode
  595. 200 DATA &H38,&H28,&H2D,&H0A,&H7F,&H06,&H64
  596. 210 DATA &H70,&H02,&H01,&H06,&H07,&H00,&H00,&H00,&H00
  597.  
  598.  
  599. EXAMPLE 7:  SET CONTROLLER UP FOR 640 X 200 16-COLOR GRAPHICS MODE
  600. 1 REM  clear all of video memory
  601. 2 KEY OFF
  602. 3 DEF SEG=&HB000:FOR ADDR=0 TO 65535!:POKE ADDR,0:NEXT ADDR
  603. 5 REM  set extended mode register
  604. 6 OUT &H3DD,&H8
  605. 7 REM  set border color to white
  606. 8 OUT &H3D9,0
  607. 10 REM   SET DISPLAY CONTROL REGISTER TO THE NEEDED VALUE
  608. 20 REM       DATA BIT 0 --- 0
  609. 30 REM                1 --- 1=GRAPHICS
  610. 40 REM                2 --- 0=COLOR
  611. 50 REM                3 --- 1=ENABLE VIDEO
  612. 60 REM                4 --- 1=640 X 200
  613. 70 REM                5 --- 0
  614. 80 REM                6 --- 0
  615. 90 REM                7 --- 0
  616. 100 OUT &H3D8,&H1A
  617. 110 REM then initialize 6845 crt controller data registers
  618. 120 FOR INDEX=0 TO &HF
  619. 125 OUT &H3D4,INDEX
  620. 130 READ BYTE
  621. 140 OUT &H3D5,BYTE
  622. 145 NEXT INDEX
  623.  
  624. 147 STADR=0
  625. 150 REM if bit set in COLOUR then fill 6 scan line in appropriate bank
  626. 151 FOR COLOUR=0 TO 15
  627.  
  628. 152 REM  test BLUE bit
  629. 155 IF COLOUR AND 1 THEN 156 ELSE 160
  630. 156 DEF SEG=&HB400:FOR ADDR=STADR TO STADR+239:POKE ADDR,&HFF:
  631.     POKE ADDR+&H2000,&HFF:NEXT ADDR
  632.  
  633. 157 REM test GREEN bit
  634. 160 IF COLOUR AND 2 THEN 161 ELSE 165
  635. 161 DEF SEG=&HB800:FOR ADDR=STADR TO STADR+239:POKE ADDR,&HFF:
  636.     POKE ADDR+&H2000,&HFF:NEXT ADDR
  637.  
  638. 164 REM test RED bit
  639. 165 IF COLOUR AND 4 THEN 166 ELSE 170
  640. 166 DEF SEG=&HBC00:FOR ADDR=STADR TO STADR+239:POKE ADDR,&HFF:
  641.     POKE ADDR+&H2000,&HFF:NEXT ADDR
  642.  
  643. 167 REM test INTENSITY bit
  644. 170 IF COLOUR AND 8 THEN 171 ELSE 175
  645. 171 DEF SEG=&HB000:FOR ADDR=STADR TO STADR+239:POKE ADDR,&HFF:
  646.     POKE ADDR+&H2000,&HFF:NEXT ADDR
  647.  
  648. 175 STADR=STADR+240
  649. 185 NEXT COLOUR
  650. 190 GOTO 190
  651. 195 REM these are the 6845 register values for this mode
  652. 200 DATA &H38,&H28,&H2D,&H0A,&H7F,&H06,&H64
  653. 210 DATA &H70,&H02,&H01,&H06,&H07,&H00,&H00,&H00,&H00
  654.  
  655.                  ****  END OF DOCUMENT ****
  656.