c=hacking06.txt

(111 KB) Pobierz
                   ########
             ##################
         ######            ######
      #####
    #####  ####  ####      ##      #####   ####  ####  ####  ####  ####   #####
  #####    ##    ##      ####    ##   ##   ##  ###     ##    ####  ##   ##   ##
 #####    ########     ##  ##   ##        #####       ##    ## ## ##   ##
#####    ##    ##    ########  ##   ##   ##  ###     ##    ##  ####   ##   ##
#####  ####  ####  ####  ####  #####   ####  ####  ####  ####  ####   ######
#####                                                                    ##
 ######            ######           Issue #6
   ##################            Sept. 5, 1993
       ########

------------------------------------------------------------------------------
Editor's Notes:
by Craig Taylor

  School, 2 jobs, a play, and other work has seriously restricted the amount
  of time that I am able to devote to Commodore Hacking. What I am looking at
  doing now is to stop writing articles for Commodore Hacking and hoping that
  I'll still have enough time to write these notes, and organize and pull all
  the other articles by other contributors together. The two articles I
  had hoped to include in this issue : the one about multi-tasking and
  about the 1351 have again been delayed. I've decided to go ahead and
  release issue 6 and hopefully will have them in the next issue.
  (Remember: You get what you pay for.. *smile*)

  As always, Commodore Hacking is constantly looking for articles, notes,
  short little programs, what-not on any side of the Commodore 64 and 128 -
  primarily on the technical or hardware side. If you think you have something
  in mind, or already written then feel free to drop me a line letting me
  know.

  In regards to several queries recently about reprinting individual articles
  that have appeared in Commodore Hacking. You may reprint Commodore Hacking
  and redistribute in whole, freely. For use of individual articles you _must_
  contanct the individual author as they still retain rights to it. Please see
  the legal notice / mumbo below.

  I recently recieved some mail from wolfgang@halcyon regarding a disk
  magazine that he was in the process of starting and he has written the
  following preview of a disk magazine that looks to be exciting:

    "_Scenery_, a new disk-magazine focusing on the american and
    european demo scenes, will soon be available for download at a
    site/BBS near you! With articles on everything from coding to
    instrument synthesis to art, _Scenery_ will be the definitive word
    when it comes to creating a demo, or simply coding in general.
    Articles are being written by some of the top names in the scene,
    and promise to help everybody from the Basic Baby to the ML Mogul!
    Set to be released mid-August, _Scenery_ will hopefully be a worthy
    edition to the likes of Coder's World and C=Hacking.  I am making
    the magazine available on various Internet sites, so look for it. We
    are always on the lookout for art, music, and coding talent, and if
    you'd be interested in submitting an article for publication, or
    simply have a question or comment, please mail me at
    'wolfgang@halcyon.com'. Thanks.. and see you on the Net!"

================================================================================

  Please note that this issue and prior ones are available via anonymous FTP
  from ccosun.caltech.edu under pub/rknop/hacking.mag and via a mailserver
  which documentation can be obtained by sending mail to
  "duck@pembvax1.pembroke.edu" with a subject line of "mailserver" and the
  line "help" in the body of the message.

================================================================================

  NOTICE: Permission is granted to re-distrubte this "net-magazine", in
  whole, freely for non-profit use. However, please contact individual 
  authors for permission to publish or re-distribute articles seperately.
  A charge of no greather than 5 US dollars or equivlent may be charged for 
  library service / diskette costs for this "net-magazine".

================================================================================
In This Issue:

DYCP - Horizontal Scrolling

DYCP - is a name for a horizontal scroller, where characters go smoothly
up and down during their voyage from right to left. One possibility is a
scroll with 8 characters - one character per sprite, but a real demo coder
won't be satisfied with that.

Opening the borders

VIC has many features and transparent borders are one of them. You can not
make characters appear in the border, but sprites are displayed in the
border too.

A Heavy Duty Power supply for the C-64

This article describes how to build a heavier duty power supply for your
Commodore 64 computer and includes a full schematic in GeoPaint format.

LZW Compression

LZW is perhaps the most widely used form of data compression today. It
is simple to implement and achieves very decent compression at a fairly
quick pace. LZW is used in PKZIP (shrink),PKARC (crunch), gifs,V.42bis
and unix's compress. This article will attempt to explain how the
compression works with a short example and 6502 source code in Buddy
format.

THREE-KEY ROLLOVER for the C-128 and C-64.

This article examines how a three-key rollover mechanism works for the
keyboards of the C=128 and C=64 and will present Kernal-wedge
implementations for both machines. Webster's doesn't seem to know, so I'll
tell you that this means that the machine will act sensibly if you are
holding down one key and then press another without releasing the first.
This will be useful to fast touch typers.

================================================================================
The Demo Corner: DYCP - Horizontal Scrolling
by Pasi 'Albert' Ojala (po87553@cs.tut.fi or albert@cc.tut.fi))
        Written: 16-May-91 Translation 02-Jun-92

	DYCP - too many sprites !?
	--------------------------

DYCP - Different Y Character Position - is a name for a horizontal scroller,
where characters go smoothly up and down during their voyage from right to
left. One possibility is a scroll with 8 characters - one character in each
sprite, but a real demo coder won't be satisfied with that.

Demo coders thought that it looks good to make the scrolling text change its
vertical position in the same time it proceeded from the right side of the
screen to the left. The only problem is that there is only eight sprites
and that is not even nearly enough to satisfy the requirements needed for
great look. So the only way is to use screen and somehow plot the text in
graphics, because character columns can not be scrolled individually.
Plotting the characters take absolutely too much time, because you have to
handle each byte seperately and the graphics bitmap must be cleared too.


_Character hack_

The whole DYCP started using character graphics. You plot six character
rows where the character (screen) codes increase to the right and down.
This area is then used like a small bitmap screen. Each of the text chars
are displayed one byte at a time on each six rows high character columns.
This 240 character positions big piece of screen can be moved horizontally
using the x-scroll register (three lowest bits in $D016) and after eight
pixels you move the text itself, like in any scroll. The screen is of course
reduced to 38 columns wide to hide the jittering on the sides.

A good coder may also change the character sets during the display and
even double the size of the scroll, but because the raster time happens
to go to waste using this technique anyway, that is not very feasible. There
are also other difficulties in this approach, the biggest is the time needed
to clear the display.


_Save characters - and time_

But why should we move an eight-byte-high character image in a 48-line-high
area, when 16 is really enough ?  We can use two characters for the graphics
bitmap and then move this in eight pixel steps up and down. The lowest
three bits of the y-position then gives us the offset where the data must
be plotted inside this graphical region. The two character codes are usually
selected to be consecutive ones so that the image data has also 16
consecutive bytes. [See picture 1.]


_Demo program might clear things up_

The demo program is coded using the latter algorithm. The program first
copies the Character ROM to ram, because it is faster to use it from there.
You can easily change the program to use your own character set instead,
if you like. The sinus data for the vertical movement is created of a 1/4
of a cycle by mirroring it both horizontally and vertically.

Two most time critical parts are clearing the character set and plotting the
new one. Neither of these may happen when VIC is drawing the area where the
scroll is, so there is a slight hurry. Using double buffering technique we
could overcome this limitation, but this is just an example program. For
speed there is CLC only when it is absolutely needed.

The NTSC version is a bit crippled, it only covers 32 columns and thus the
characters seem to appear from thin air. Anyway, the idea should become
clear.


_Want to go to the border ?_

Some coders are always trying to get all effects ever done using the C64 go
to the border, and even successfully. The easiest way is to use only a region
of 21 pixels high - sprites - and move the text exactly like in characters.
In fact only the different addressing causes the differences in the code.

Eight horizontally expanded sprites will be just enough to fill the side
borders. You can also mix these techiques, but then you have the usual
"chars-in-the-screen-while-border-opened"-problems (however, they are
solvable). Unfortunately sprite-dycp is even more slower than char-dycp.


_More movement vertically_

You might think ...
Zgłoś jeśli naruszono regulamin