Plotting in Screen 12

Old PC memory configuration (for DOS) had a small window at segment &HA000 (position &HA0000 from total memory, that is, at 655360 bytes from the beginning, i.e. after your first 640K which measured 64K and were used to access the video card memory. If you do some calculus, 640x480/2 (size of a 640x480x16colour display) doesn't fit in 64K.

The trick is to have four separate bitmap planes (where each pixel is only represented with a bit). You have a plane for blues, another plane for reds, another plane for greens and a last plane for brightness. If you look at the colours, 14 (bright yellow) is bright+red+green, that is, 8+4+2 (bitwise 1110); dark blue is blue, that is, 1 (bitwise 0001). That way, writting a bit in a pixel position of each plane you make that bit to have an actual colour.

You have to tell which plane do you want to write on (using ports, i.e. OUT), and set the correct pixel (tricky, 'cause you can only POKE/PEEK a full byte, so 8 pixels).

Here it is some code which does the action:

```
DEFINT A-Z
DECLARE SUB pix12 (vertical%, horizontal%, c%)
DIM SHARED bitfield(7) AS INTEGER
bitfield(0) = 128: bitfield(1) = 64: bitfield(2) = 32
bitfield(3) = 16: bitfield(4) = 8: bitfield(5) = 4
bitfield(6) = 2: bitfield(7) = 1

SUB pix12 (vertical%, horizontal%, c%)
IF (vertical% < 0) OR (horizontal% < 0) THEN EXIT SUB
IF (vertical% > 479) OR (horizontal% > 639) THEN EXIT SUB
DEF SEG = &HA000: OUT &H3CE, 4: OUT &H3C4, 2
P& = vertical%: P& = P& * 80 + horizontal% \ 8
bit% = bitfield(horizontal% AND 7): bitmask% = 255 - bit%
OUT &H3CF, 0: OUT &H3C5, 1: B% = PEEK(P&) AND bitmask%
IF (c% AND 1) <> 0 THEN B% = B% OR bit%
POKE P&, B%
OUT &H3CF, 1: OUT &H3C5, 2: B% = PEEK(P&) AND bitmask%
IF (c% AND 2) <> 0 THEN B% = B% OR bit%
POKE P&, B%
OUT &H3CF, 2: OUT &H3C5, 4: B% = PEEK(P&) AND bitmask%
IF (c% AND 4) <> 0 THEN B% = B% OR bit%
POKE P&, B%
OUT &H3CF, 3: OUT &H3C5, 8: B% = PEEK(P&) AND bitmask%
IF (c% AND 8) <> 0 THEN B% = B% OR bit%
POKE P&, B%
END SUB
```

(code written by Kurt Kuzba).

Hope this makes it correctly :D

PlottingInScreenTwelve - page last edited 2003-04-04 11:19:27 by 81.203.196.11 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster