<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://c64mags.untergrund.net/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://c64mags.untergrund.net/wiki/index.php?action=history&amp;feed=atom&amp;title=DT_91_16</id>
		<title>DT 91 16 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://c64mags.untergrund.net/wiki/index.php?action=history&amp;feed=atom&amp;title=DT_91_16"/>
		<link rel="alternate" type="text/html" href="http://c64mags.untergrund.net/wiki/index.php?title=DT_91_16&amp;action=history"/>
		<updated>2026-05-17T04:40:35Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.0</generator>

	<entry>
		<id>http://c64mags.untergrund.net/wiki/index.php?title=DT_91_16&amp;diff=6080&amp;oldid=prev</id>
		<title>Nyquist at 20:35, 17 May 2011</title>
		<link rel="alternate" type="text/html" href="http://c64mags.untergrund.net/wiki/index.php?title=DT_91_16&amp;diff=6080&amp;oldid=prev"/>
				<updated>2011-05-17T20:35:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[http://translate.google.com/translate?hl=de&amp;amp;ie=UTF-8&amp;amp;sl=de&amp;amp;tl=en&amp;amp;u=http://c64mags.untergrund.net/wiki/index.php%3Ftitle%3DDT_91_16&amp;amp;prev=_t  English Translation]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           EXTENDED TEXT MODE&lt;br /&gt;
           EXTENDED TEXT MODE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
               ON THE C64&lt;br /&gt;
               ON THE C64&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
             BY IMRAN NAZAR&lt;br /&gt;
             BY IMRAN NAZAR&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
I  sometimes  wonder  what it would take&lt;br /&gt;
for  a  computer  of 80s vintage to be a&lt;br /&gt;
viable  work  terminal in today's world.&lt;br /&gt;
After  some  thought, I came up with two&lt;br /&gt;
things  that an old computer would need:&lt;br /&gt;
INTERNET ACCESS&lt;br /&gt;
Getting  data to an old computer without&lt;br /&gt;
the    Internet  is  a  thankless  task,&lt;br /&gt;
involving  microcassette  recordings and&lt;br /&gt;
funky  formats  of floppy disc which are&lt;br /&gt;
unreadable  in  a  PC.  Getting the data&lt;br /&gt;
back  off  the  computer  in question is&lt;br /&gt;
even  more  of  a  problem;  it's simply&lt;br /&gt;
orders  of  magnitude  easier to connect&lt;br /&gt;
to   a  standard  network  and  transfer&lt;br /&gt;
through that.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DISPLAY COMPATIBILITY&lt;br /&gt;
Coputers    of    such  vintage  as  the&lt;br /&gt;
Commodore  64  and  the  Spectrum have a&lt;br /&gt;
variety  of  display  modes, but none of&lt;br /&gt;
them  put a great deal of information on&lt;br /&gt;
the  screen.  to viably communicate with&lt;br /&gt;
a  computer of a different type, such as&lt;br /&gt;
a  linux  server,  it's  a  prerequisite&lt;br /&gt;
to  extend the text mode capabilities of&lt;br /&gt;
the    computer,    and   get  something&lt;br /&gt;
approaching a usable terminal.&lt;br /&gt;
This article is intended to be part 1 of&lt;br /&gt;
a  series,  in which a Commodore 64 will&lt;br /&gt;
be  set  up  to  act as a standard Unix-&lt;br /&gt;
compatible  terminal.  The first step in&lt;br /&gt;
that  ambitious programm is to provide a&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a    reasonable   text  display  on  the&lt;br /&gt;
Commodore 64.&lt;br /&gt;
&lt;br /&gt;
THE C64'S VIDEO MODES&lt;br /&gt;
The    Commodore    64   has  a  display&lt;br /&gt;
resolution  of  320  by  200  pixels,  a&lt;br /&gt;
resolution which will be familiar to any&lt;br /&gt;
PC programmer who has dealt with the VGA&lt;br /&gt;
display  modes.  The  C64  provides  two&lt;br /&gt;
basic  types  of display mode: bitmapped&lt;br /&gt;
and tiled. Each of these has the ability&lt;br /&gt;
to  display pixels in one colour against&lt;br /&gt;
a  background of another colour. In both&lt;br /&gt;
modes,    the    display  is  broken  up&lt;br /&gt;
logically  into  8x8-pixel  &amp;quot;tiles&amp;quot;; the&lt;br /&gt;
difference  is  in how these are handled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
and  how  graphics  are drawn in the two&lt;br /&gt;
modes.&lt;br /&gt;
In  tiled mode, also called &amp;quot;text mode&amp;quot;,&lt;br /&gt;
the  screen  has a tile-resolution of 40&lt;br /&gt;
wide  by  25  high,  and  the display is&lt;br /&gt;
built    in    the    following  manner.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                                      =&amp;gt; &lt;br /&gt;
                                      =&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ####    $78  ####    $78     ##   $0C&lt;br /&gt;
##  ##   $CC ##   ##  $CC    ###   $1C&lt;br /&gt;
##       $C0 ##       $C0   ####   $3C&lt;br /&gt;
##       $C0 ######   $F8 ##  ##   $CC&lt;br /&gt;
##       $C0 ##   ##  $CC #######  $FE&lt;br /&gt;
##  ##   $CC ##   ##  $CC     ##   $0C&lt;br /&gt;
 ###     $78  ####    $78     ##   $0C&lt;br /&gt;
         $00          $00          $00&lt;br /&gt;
&lt;br /&gt;
   /\           /\           /\&lt;br /&gt;
   ||           ||           ||&lt;br /&gt;
   03           54           52&lt;br /&gt;
   03           54           52&lt;br /&gt;
&lt;br /&gt;
         Display in tiled mode&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The  tile-address  buffer,  often called&lt;br /&gt;
&amp;quot;Screen  Memory&amp;quot;,  is a 1000-byte region&lt;br /&gt;
of  memory  where each byte refers to an&lt;br /&gt;
8x8  block  on  screen.  in order to get&lt;br /&gt;
the  bitmap  data  for  the display, the&lt;br /&gt;
video  circuit  uses the value in screen&lt;br /&gt;
memory  as  a pointer into the tile-data&lt;br /&gt;
buffer,  called &amp;quot;character memory&amp;quot;. when&lt;br /&gt;
the  computer  is  first  started,  this&lt;br /&gt;
memory  contains  the  shapes of letters&lt;br /&gt;
and  numbers  which  can be used to draw&lt;br /&gt;
text  on  the  screen;  for this reason,&lt;br /&gt;
tiled  mode  is  often  referred  to  as&lt;br /&gt;
&amp;quot;40x25 text mode&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Tiled  mode allows for each 8x8 block of&lt;br /&gt;
pixels  to  have  a different foreground&lt;br /&gt;
colour;  any  bits in the tile which are&lt;br /&gt;
set    to  &amp;quot;1&amp;quot;  will  be  drawn  in  the&lt;br /&gt;
foreground  colour  for  that tile. Just&lt;br /&gt;
like  screen  memory, a 1000-byte region&lt;br /&gt;
is  set aside for the tile-colour buffer&lt;br /&gt;
called  &amp;quot;Colour  Memory&amp;quot;, which provides&lt;br /&gt;
the  foreground  colours  for each tile.&lt;br /&gt;
the  background  is  the same across the&lt;br /&gt;
whole  screen,  and any &amp;quot;0&amp;quot; bits will be&lt;br /&gt;
drawn  in  the global background colour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Bitmapped    mode    skips    the  tile-&lt;br /&gt;
addressing  step in the display process,&lt;br /&gt;
opting  instead  for a unified buffer of&lt;br /&gt;
bitmap  data. an 8000-byte region is set&lt;br /&gt;
aside  for  the display of 320x200 bits,&lt;br /&gt;
with blocks of 8x8 still being addressed&lt;br /&gt;
as a tile.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                                      =&amp;gt;&lt;br /&gt;
                                      =&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ####    ####       ##    $78 $78 $0C&lt;br /&gt;
##  ##  ##  ##     ###    $CC $CC $1C&lt;br /&gt;
##      ##        ####    $C0 $C0 $3C&lt;br /&gt;
##      #####   ##  ##    $C0 $F8 $CC&lt;br /&gt;
##      ##  ##  #######   $C0 $CC $FE&lt;br /&gt;
##  ##  ##  ##      ##    $CC $CC $0C&lt;br /&gt;
 ####    ####       ##    $78 $78 $0C&lt;br /&gt;
                          $00 $00 $00&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       Drawing in bitmapped mode&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Just  as with tiled mode, each 8x8 block&lt;br /&gt;
can  have a different foreground colour.&lt;br /&gt;
in  the case of bitmapped mode, however,&lt;br /&gt;
a    block    can   also  have  its  own&lt;br /&gt;
background  colour,  which  will be used&lt;br /&gt;
instead  of  the global background if an&lt;br /&gt;
&amp;quot;0&amp;quot;  bits are encountered in the bitmap.&lt;br /&gt;
&lt;br /&gt;
THE OPTIONS&lt;br /&gt;
So  we  have  two options for drawing to&lt;br /&gt;
the    c64's  screen.  Either  of  these&lt;br /&gt;
could  be  used  for  the  rendering  of&lt;br /&gt;
an  80x25 text mode, but there are a few&lt;br /&gt;
arguments   against  the  use  of  tiled&lt;br /&gt;
mode:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IT'S MORE COMPLEX&lt;br /&gt;
Drawing    to    a    bitmapped   screen&lt;br /&gt;
involves  writing  the  appropriate bits&lt;br /&gt;
to  a  piece  of  the  bitmap buffer. In&lt;br /&gt;
tiled  mode,  a  tile  has to be written&lt;br /&gt;
into    character   memory,  and  screen&lt;br /&gt;
memory  has  to  be  updated  to reflect&lt;br /&gt;
the   new  tile.&lt;br /&gt;
&lt;br /&gt;
IT'S SLOWER TO WORK WITH&lt;br /&gt;
Because of the above complexity of tiled&lt;br /&gt;
mode,  more memory has to be worked with&lt;br /&gt;
to  set a tile up correctly, which means&lt;br /&gt;
it  takes  more  time  to write text out&lt;br /&gt;
to screen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
IT'S NOT BIG ENOUGH&lt;br /&gt;
By   placing  an  80x25  &amp;quot;extended  text&lt;br /&gt;
mode&amp;quot;  into  40x25 tiled mode, each tile&lt;br /&gt;
can  hold  two  characters.  In  theory,&lt;br /&gt;
there    are  over  65,000  combinations&lt;br /&gt;
of  two-character  tiles,  any  of which&lt;br /&gt;
could    show    up   on  screen;  tiled&lt;br /&gt;
mode  can  only  deal  with 256 of these&lt;br /&gt;
combinations on screen at the same time,&lt;br /&gt;
before  some  hacks have to be employed.&lt;br /&gt;
&lt;br /&gt;
For  these  reasons, it's simpler to use&lt;br /&gt;
bitmapped  mode  to draw the characters.&lt;br /&gt;
What's  required  now is a readable font&lt;br /&gt;
that   can  be  used  by  the  rendering&lt;br /&gt;
system.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
THE FONT&lt;br /&gt;
Most    terminal  systems  use  a  mono-&lt;br /&gt;
spaced    font,   primarily  because  it&lt;br /&gt;
makes    calculations  easier  regarding&lt;br /&gt;
text  placement  and size. This extended&lt;br /&gt;
text mode will be no exception: in order&lt;br /&gt;
to  fit  an  80x25  text  screen  into a&lt;br /&gt;
320x200    graphical    display,    each&lt;br /&gt;
character  must  be 4x8 pixels: in other&lt;br /&gt;
words, each of the 8x8 tiles must be cut&lt;br /&gt;
down  the  middle and a character placed&lt;br /&gt;
in each half.&lt;br /&gt;
&lt;br /&gt;
What  this  doesn't take into account is&lt;br /&gt;
the  need to seperate characters: if the&lt;br /&gt;
font  is  made  up  of 4x8-pixel glyphs,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
each character in a line of text will be&lt;br /&gt;
joined    to    the  next,  without  any&lt;br /&gt;
seperation.  What is instead needed is a&lt;br /&gt;
pixel  of seperation between characters:&lt;br /&gt;
this means that the font will consist of&lt;br /&gt;
3x7-pixel    glyphs    in    4x8  boxes.&lt;br /&gt;
On  such  a  small  scale,  designing  a&lt;br /&gt;
legible  font  is tricky: distinguishing&lt;br /&gt;
between   zero  (0)  and  capital  O  is&lt;br /&gt;
difficult  at  the  best  of  times, and&lt;br /&gt;
the  difference between one (1), small L&lt;br /&gt;
and  the  vertical pipe can be even more&lt;br /&gt;
of  a  problem. I'm not a designer, so I&lt;br /&gt;
opted  instead  to  use  the font glyphs&lt;br /&gt;
from  Novaterm,  a  terminal program for&lt;br /&gt;
the C64.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In   order   to    use    this      font&lt;br /&gt;
programmatically,  each character has to&lt;br /&gt;
be  broken  down  into  its  constituent&lt;br /&gt;
bits,    and    reconstituted  as  data.&lt;br /&gt;
Because  the  glyphs  are 4 pixels wide,&lt;br /&gt;
the  resultant data will be 4 bits wide.&lt;br /&gt;
&lt;br /&gt;
THE PROCESS&lt;br /&gt;
With    a    font  and  a  bitmap  mode,&lt;br /&gt;
we  can  now  draw  text  to the bitmap.&lt;br /&gt;
Unfortunately,      it's    not    quite&lt;br /&gt;
as easy as writing one character to each&lt;br /&gt;
tile,  because  there are only 40 tiles'&lt;br /&gt;
worth    of  space  across  the  screen.&lt;br /&gt;
instead,  two  characters have to be put&lt;br /&gt;
inside  one  tile-space.  This  involves&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
shifting   the  bitmap  values  for  the&lt;br /&gt;
&amp;quot;left&amp;quot;  character  across, and combining&lt;br /&gt;
them    with    the  &amp;quot;right&amp;quot;  character.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  # #  $A      $0      # #      $A0&lt;br /&gt;
  # #  $A      $0      # #      $A0&lt;br /&gt;
  # #  $A  #   $4      # #  #   $A4&lt;br /&gt;
  ###  $E # #  $A  mn  ### # #  $EA&lt;br /&gt;
  # #  $A ##   $C  mn  # # ##   $AC&lt;br /&gt;
  # #  $A #    $8      # # #    $A8&lt;br /&gt;
  # #  $A  ##  $6      # #  ##  $A6&lt;br /&gt;
       $0      $0               $00&lt;br /&gt;
&lt;br /&gt;
  Drawing two characters in one tile&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In BASIC code, this could be represented&lt;br /&gt;
as  follows, assuming that the FONT two-&lt;br /&gt;
dimensional  array  represents  the  3x7&lt;br /&gt;
Novaterm font:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
LET CH1 = 72: REM &amp;quot;H&amp;quot;&lt;br /&gt;
&lt;br /&gt;
LET CH2 = 101: REM &amp;quot;e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FOR A = 0 TO 7&lt;br /&gt;
&lt;br /&gt;
 OUT(A) = (FONT(CH1)(A)*16)+FONT(CH2)(A)&lt;br /&gt;
&lt;br /&gt;
NEXT A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
By  using  a  &amp;quot;cursor&amp;quot;  position to keep&lt;br /&gt;
track  of where on the screen tiles must&lt;br /&gt;
be       filled,      it's    relatively&lt;br /&gt;
straightforward  to  use  the  technique&lt;br /&gt;
above  for rendering text two characters&lt;br /&gt;
at  a  time.  The  problem arises when a&lt;br /&gt;
string  of  text  contains an odd number&lt;br /&gt;
characters:  not  only does the renderer&lt;br /&gt;
have  to  fill  half a tile instead of a&lt;br /&gt;
full  tile,  but  the  next  string will&lt;br /&gt;
start    halfway  through  the  tile  in&lt;br /&gt;
question. Because of this, the rendering&lt;br /&gt;
function     becomes    more    complex:&lt;br /&gt;
&lt;br /&gt;
*  Check  whether we're starting halfway&lt;br /&gt;
through  a  tile.  if  so,  fill  in the&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right  half  of  the  existing on-screen&lt;br /&gt;
tile with the first character bitmap. if&lt;br /&gt;
not,    skip    this   step  altogether.&lt;br /&gt;
&lt;br /&gt;
* The main rendering loop; For each pair&lt;br /&gt;
of  characters  in  the string (starting&lt;br /&gt;
with  the second character if step 1 was&lt;br /&gt;
performed), build a tile and draw it the&lt;br /&gt;
screen.  Do  this until there are either&lt;br /&gt;
1   or  0  characters  left  to  render.&lt;br /&gt;
&lt;br /&gt;
* if there's one character left, fill in&lt;br /&gt;
the  left half of a blank tile, and draw&lt;br /&gt;
that    to   screen.  If  there  are  no&lt;br /&gt;
characters left to draw, skip this step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The  top  and bottom pieces of algorithm&lt;br /&gt;
are  extensions  of  the  main rendering&lt;br /&gt;
loop,  and won't be covered here in much&lt;br /&gt;
detail.    Instead,    I'll  provide  an&lt;br /&gt;
interpretation  of  the  insides  of the&lt;br /&gt;
main loop, in pseudo-C++.&lt;br /&gt;
BYTE *bitmap;&lt;br /&gt;
// 8000-byte bitmap to render to&lt;br /&gt;
BYTE *font;&lt;br /&gt;
// 2048 bytes font data,&lt;br /&gt;
// 8 bytes per char&lt;br /&gt;
char t1, t2;&lt;br /&gt;
// Text to render (two charatcers long)&lt;br /&gt;
int X, Y;&lt;br /&gt;
// Current cursor position&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Calculate position of destination&lt;br /&gt;
// tile in th bitmap&lt;br /&gt;
// Each tile is 8 bytes long&lt;br /&gt;
BYTE *tile = bitmap + ((Y*80+X)*8);&lt;br /&gt;
for(i=0;i&amp;lt;8;i++)&lt;br /&gt;
{&lt;br /&gt;
 // Retrieve font data for this line of&lt;br /&gt;
 // the bitmap&lt;br /&gt;
 BYTE ch1 = font[t1*8+i];&lt;br /&gt;
 BYTE ch2 = font[t2*8+i];&lt;br /&gt;
 // Calculate final tile contents&lt;br /&gt;
 tile[i] = (ch1*16) + ch2;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In  the case of the top and bottom parts&lt;br /&gt;
of  the  algorithm, either ch1 or ch2 is&lt;br /&gt;
not  used  in the final tile; otherwise,&lt;br /&gt;
the  code  for  these parts is as above.&lt;br /&gt;
&lt;br /&gt;
THE IMPLEMENTATION&lt;br /&gt;
There  are  a few things that need to be&lt;br /&gt;
considered when taking this algorithm to&lt;br /&gt;
the  Commodore 64, in order to cope with&lt;br /&gt;
the    restrictions  of  the  plattform.&lt;br /&gt;
&lt;br /&gt;
FONT DATA&lt;br /&gt;
The  algorithm  outlined above takes two&lt;br /&gt;
characters   from  the  font  data,  and&lt;br /&gt;
shifts  the  &amp;quot;left&amp;quot;  one  over by 4 bits&lt;br /&gt;
before    tacking   it  to  the  &amp;quot;right&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
character.  This  step can be eliminated&lt;br /&gt;
by  keeping  a  pre-shifted  copy of the&lt;br /&gt;
font  data  as  a separate buffer to the&lt;br /&gt;
original,  which  means  that building a&lt;br /&gt;
cell  is  merely a matter of finding one&lt;br /&gt;
character  in the original font, and the&lt;br /&gt;
other  in  the shifted font, then adding&lt;br /&gt;
the two values.&lt;br /&gt;
&lt;br /&gt;
INITIAL SCREEN COLOUR&lt;br /&gt;
As  mentioned above, each tile in bitmap&lt;br /&gt;
mode can maintain its own foreground and&lt;br /&gt;
background  colour.  The values for each&lt;br /&gt;
tile's  colours  are  stored  in  Colour&lt;br /&gt;
Memory,  one  byte  for  each  tile: the&lt;br /&gt;
background colour code (between 0 an 15)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
is stored as the lower half of the byte,&lt;br /&gt;
and  the  foreground  code  as the upper&lt;br /&gt;
half.&lt;br /&gt;
For  the  purposes  of  this article, we&lt;br /&gt;
won't  be dealing with different colours&lt;br /&gt;
of  text  or  other  attributes,  so all&lt;br /&gt;
that's  required  is  to  initialise the&lt;br /&gt;
Colour  Memory: setting all the bytes to&lt;br /&gt;
reflect  &amp;quot;grey  on  black&amp;quot;  allows for a&lt;br /&gt;
simple monochromatic output.&lt;br /&gt;
&lt;br /&gt;
MULTIPLICATION&lt;br /&gt;
The  6510  CPU  used by the Commodore 64&lt;br /&gt;
doesn't  have  a  multiply  instruction,&lt;br /&gt;
which means we can't simply &amp;quot;multiply by&lt;br /&gt;
8&amp;quot; to get a font-data position. Luckily,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
we  can  use  a basic property of binary&lt;br /&gt;
powers    to   prform  the  calculation:&lt;br /&gt;
&lt;br /&gt;
MULTIPLICATION BY BINARY POWERS&lt;br /&gt;
x * 8 = x * (2 ** 3)&lt;br /&gt;
x * 8 = x &amp;amp;lt; 3&lt;br /&gt;
&lt;br /&gt;
By  shifting  the  value  left,  we  can&lt;br /&gt;
simulate  multiplication.  In this case,&lt;br /&gt;
however,    that's   not  quite  enough.&lt;br /&gt;
Shifting  a  value left pushes the left-&lt;br /&gt;
most  bits  off the end of the register,&lt;br /&gt;
discarding  the  higher  portion  of the&lt;br /&gt;
result:  we need that higher portion, so&lt;br /&gt;
some    more  calculation  is  required:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
MULTIPLICATION BY BINARY POWERS IN A&lt;br /&gt;
DOUBLE-WIDTH RESULT&lt;br /&gt;
x = 01101101b&lt;br /&gt;
LOBYTE(x * 8) = 01101101 &amp;amp;lt; 3&lt;br /&gt;
              = (011)01101000&lt;br /&gt;
HIBYTE(x * 8) = (011)&lt;br /&gt;
              = 01101101 &amp;amp;gt; (8-3)&lt;br /&gt;
LOBYTE(x * 8) = x &amp;amp;lt; 3&lt;br /&gt;
HIBYTE(x * 8) = x &amp;amp;gt; 5&lt;br /&gt;
The  above  sample  demonstrates  a more&lt;br /&gt;
general    rule:   a  1-byte  by  1-byte&lt;br /&gt;
multiplication  will  generate  a 2-byte&lt;br /&gt;
result,  both  parts  of  which  can  be&lt;br /&gt;
calculated by appropriate shifting. This&lt;br /&gt;
rule can be used by the 6510 code of the&lt;br /&gt;
implementation.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
THE RESULT&lt;br /&gt;
In    the    result,    the   additional&lt;br /&gt;
algorithm  for  handling  newline  chars&lt;br /&gt;
have  been  added  to  the 80x25 display&lt;br /&gt;
system,  allowing  the  text  to contain&lt;br /&gt;
line  breaks. This is simply a matter of&lt;br /&gt;
moving  the  cursor down to the start of&lt;br /&gt;
the  next  line when a newline character&lt;br /&gt;
is encountered.&lt;br /&gt;
The  system  does  not  currently handle&lt;br /&gt;
scrolling of the text buffer: if text is&lt;br /&gt;
to  be  drawn below line 25, it will not&lt;br /&gt;
appear  on  the  display. scrolling, and&lt;br /&gt;
other    control    sequences  including&lt;br /&gt;
character  colour,  will  be  covered in&lt;br /&gt;
part 2 of this series.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Note:  This  article  was taken from the&lt;br /&gt;
superb homepage of Imran.&lt;br /&gt;
www.imrannazar.com&lt;br /&gt;
&lt;br /&gt;
Thanks  Imran! We would love to see more&lt;br /&gt;
of this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nyquist</name></author>	</entry>

	</feed>