Canada $4.25 USA$3.50
• Micro-Lisp 2.5: a Lisp interpreter for the Commodore 64! • Report on CoN IX- a Unix-style enhancement for CP/M 3+ • Great Assignment: Add expression evaluation to BASIC • Understanding BRK - get debugging duty from the zero byte • Fast mnemonic-to-opcode conversion • An update to "Shiloh's Raid" • Stabilizing Tl$ for long-term timing applications • Memory swapping routines for screens and programs
0
'
ver se
I
OGIC
We've
ade talk cheap
By making available the new Avatex 1200e and SupraModem 2400 we will introduce you to high speed communications without a high speed price.
NEW!
AnDITIONAL FEATlJH E
A\'atex 1200e
• Udl 1IH/212A. cern V,'/.2 and CC 1'1 I' V.21 l'Uillplltihlc • Pn!Kflllll rnnhle sp~ukt•r vulumt! • Full/hnlf tluplcx
• 300/1200 lMud opcr.tliun
only
•
• llaycs cumtMiible • Huih in $pcakcr
• Coli prngr css monitoring • 2 yenr wnrrnnty
$139.95
• TOTAL ll uyt·~ rn!IIJl.ltibility • Include& frt•e hour and package on line trnw and rntrodut'lory liubsrription to CompuServo In $29 .99 vnlue)
npt•rntion • CSA/ FCC nppr uvt·d • l•'ull "S" ll'f(tStN suppnr t • l'ulflt• or tum• tlialin~ • Cnmpad cuw • All status LED's • 1110% UllliJlltlthlc with tmlu&lry $1111Hinrd ''AT" cumrn1uHI set • t:xternal power supply
SupraMtxlem"· 211DD only
$249.95 • :\00/1200/2.100 baud operation
• I Yl'<lf warranty • Non volatile memory stores user conflgurntion ,md last diuled numbl•r even when turned off
I ree terminal liOftware with ench rumleru pure hu t'
Onmitronix Ol'luxt• RS·232 lnlcrfucc
RS-232 CABLES
• lt•r u r ~ 1llo ( """""dwt ~I IlK Vtr lU SX ~~ illl•l l'lu 4 cnmpulrn ~ rluuu~h R, IJ ~~~. 2l • SuJ'Jllolil • lm l~~<lra I fu<ll 1 ohle • l'1111op 111hlr w11l1 ••II ~~~lllldt il KS lll
• Hast! pr kt• of $15.00 plus $t no Jll'l fool • Spt•t lfy computer connector
only
I""'
$49.95 1~ 1'1 'I J ( 1111/Ul •1'
r•luipnu·nl
gt•nder typt•
ll S
• Kr~otlllllrn•lo•l loy l'ullilllllliutc· •ntl Avoolrk wllh pullhd r • hu U>t• wllh loulh [II I! und llt'l ~~~~~·~ I; "'; "";•·•~~~~~~;:;~~~;!
1'1 ,1\ASI! MAim SU IW Al.l INH>RMA'l'ION IS I NCI.liUtm I N HHIH OltUI H .
SEND TO
I Ill I II 1\Mli\AI bflll\HRI \IIIII PUll \IUIIf\1 1'1 I'll "I I !>IIIII All 111\ll'l II K I) Pr AMiliA l om modo rr 6l I II od ,. IZI 111\1 PC
127 H11lsmount t'res. London, Onturin Cnnoda NfiK IV!i
15191 b57·71H I BBS: 519 472·535·l
Tel.·
I~UOI<I
I I II • lo
~~~~
At1!1ST M~<:lrolo h
t,!TY
AMill NT CA!-IAillAII
diver s e
LOGIC
Klll.\~1
115
1199)
fl
llllt • I 119. . • I l l9fl• l
DO
I 10 • I
11-IU Ullntflf• r iublrltl 110 DO f I U h nr lA ' pur lu I'Uh 11100
1ft H
auJt•ba
1ft I
llj
til 00 • II 00 Jlfl II C'A~ I II~ oo • I 10 It U I J1f It mu or I • fllr JIUI r tnd
I"'
I
I
5vhT" I 7' Onl
letlll l T ttl I
No AdJr
,,.. C' ly
p
I' ..1C
N
I'A\MI!N I ( ' AN Bt; \1ADf, M n y Ord
1
l ..d.
<'• Jho lei
\II A hprry 01 t
r 1 NAnlr
thff
All pwduc Iii •hipped from lnvc·ntm y within 2•1 huu1 111, ShlpphlK I" Jolt HI ,.
e Potpourri Disk [
Helpl
_.,.r
-This HELPful utility gives you Instant
I ~
I
I
Loan Helper
r= r-
AI lastl The mod philosopher. llelgo von Googol. brings her own brand of wisdom to the small acreonllf this Is 'AI', then It just ain' t naturoll
How much Is thai loon really going Ia cost you? Which Interest rote con you afford? With Loon Helper. tho answers ore as close as your friendly 641
[
[
Learning how to ploy the plano? This handy educational program makes It easy and fun to learn the notes on the keyboard
[
...
Flledump
-
[
Anagrams lets you unscramble words for crossword puzzles and the like The program uses a recur slve ML subroutine for maximum apeod and efflcloncy.
[
I [ Sovo the money you spend on Newe
[ r-
The ultimate In easy -to uso data bose programs WRD lets you quickly and simply create, examIna and edit just about any data. Comes with samplo fllo.
Trivia fanatics and atudonts alike will hove fun with this program. which gives you mulllplo choice testa on motorial you hove ontored with the WRD program. '-
I I
Life
r·
A FAST machine language version of mathematician John Horton Conway's classic simulation. Set up your own 'colonies' and watch them growl
-
•
AHAI Lander
=:1
AHAI's great lunar Iandor program. Use either joystick or keyboard to compete against yourself or up to 8 other players. Watch out for space mlnesl
-
I-
Ghoul Doge
J
Arc ade maniacs look cull You'll need all your dexterlly lo handle this wic ked joystick buster! Those mod dog- manstors from apoce ore not for novices!
I
Quiz
J
File Compare
Which of those lwo files you just created Is the most recent veralan? With this greal utility you'll nover be left wondering
]
Wrd
I l
Anagram•
I
Blac kjack
lhe most floxlblo blackjack almula l ion you'll find anywhere. Set up your favourite rule variations for doubling. surrendering and 5plltling the deck
those aupermorkot tabloids - this program will gonerote equally convincing headlino copy for rroel
J
Examine your disk files FAST with this machine language utility. Handles six formats. Including hex. decimal. CBM and true ASCII. WordPro and SpoedScrlpt.
I [ '-
I
Keyboard
Von Googol
~I
lag thellvee
A cute lillie arcade style gamo; capture the elves In the bog as quickly as you con but don' t gat tho good elfl
Shoot down thoso evil Nazi War Balloons with your handy Acme Connon! Don't let them got owoyl
menu- drlvon occoss to text flies at tho touc h o f a koy while any prOQrom Is running! •
I L
War lalloone
[
I
Octagon•
.
Jusl the thing for you Mensa typos Octagons Is a challenging pulllo of tho mind Four levels of ploy, and a tough 'memory' varlotlon for roal experlsl
'-
[
lac ketreete
-:J-
A nifty arcade game, 100% ma chino language. that helps you learn the typewriter keyboard while you playl Unlike any typing program you've seen!
All the above programs, just $17.95 US. $19.95 Canadian. No, not EACH of the above programs, ALL of the above programs, on a single disk. accessed Independently or from a menu, with built- In menu-driven help and fast- loader.
The ENTIRE POTPOURRI COLLECTION JUST $17.95 US!! Soe Order Card at Center
c.,
THE MICROCOMPUTER SHOW FOR EVERYONE
'
Transactor Volume a1ssue 6 Start Address
Bits lie!d1 \\<ldl\,MI.d>lt [ 12!1 1>1 Muir AUII~U·• 1 ( 'iwiUIU~ ~~· ~'l"kel\i.viiLII• \tt ,.,g,• ~ llllk·t
3
AS•w•ull\h•u">
Cellular Automata
16
AM.uh.·n•h.·""'lh•m
('(>1JU}'.Il< ~ l\wtf~l4l\lkWI
'-rlk'"'"' "'111'1 IU111"tl(t k••h <•·mini IU\ RHutl(t inoJtln~ Mm• CPK fl.lyid•lk·•
CP/M + CoNIX = CP/M PIUS+ Att'/~•hnlm··nk·nl
I .bt Lmd "Ilk 1 f udc Out (hll~' lnlt Dl'~ l .iphtl •lnll~a. 1 Rt ""~' ''' ' lit<• Ntunh·•
27 32 34
Letters
10
Oh. h• dtd •uti tt.ll~t)'
ll'/\1 S."it.•u• R.uhn Dnn•l n•n< ''""k"l ~·lid .. RS '12 htlnl ... ••'
I nn•r.. ~ • '>11< l.ll.'t<nil'l! 1\~ .. ) f'lr... y dl.'t~h•tc '"dun'!! In l'r.ll.« ·~ (' I~~" hJl •••I d.. MCIIII•
Mictu-Lisp Version 2.5 "' t-phnpknli1••·~··•"••"~'~t.t'
38
An Algorithm for 6510 MnernoniC'i
46
"'"''k'lt"'""1!
50
''•llli~<tlnlulnwni(J.all.l
1\11 n•Ch h
Olsen's Raid
54
An uptl.lf<' ln "'iluk••'•l{.iJ<I"
56
15
Transbloopur1. hnt••w"l hllk~·nlilk'llllkMII h&J'ill/<> /t~
61
News 8RK
;\btJUI 'llle Cu~('r: lnl\ IJ.IUph~<.
Nt'" lJ'K( >M ·~1\!JlUIIIIk'l
1<111 wu, t:l\tiiL~I With tl_. ll'.l.: :'~XIIllll 1!1 n l.ul AtLUll ltMIUtll.,lh • \\>Jy j\.l\\<'r1W
~"'
R•••ll•1 l\t>~tan < .v11kl
pnl<llk.ul "''~' ltut A•Lu11'~ ' l'dlul.u Autnnalit' jMU)Uwn (1"''1U1idc.• lllj~lj!\' 16) I hi\ [\lltltlll.lfJlll
n.e Su~~ <1111"' <l'l h• dk'l' l !II IIA'II( ' lur I •I I l'l SlK1k-, S.~l"'"' 1\H.itht I ,Inom... <<d.tk'll R.'i :L\2 uiltlr..... "• Pi 1 kl 1\•ntn.ll~ llllt'tl.~a.e 'II•IIC ,..11 •[!l~nullll'n "'' tut llll' Sitlll<'j!l'ol m.ll\.cl hlllalj! I"
"''L'
llllll1ll• IUtllll
Md hun ulltr~~:tm~•LI<It1 o1
litis''""' llte uuu.tll~tll'~JL\1lllk.~gn•u•l gi\CS w.ty tn lit>li<llt'll, II\< tllkl ll)' bl~a.l..th 111:••~•1 tw•l hiLt<' tmndung llllllllll'-" llte
lur th• tll\<'1 11.<'11' ct...c 111 lVI Anug.t 2(U I, !WILl 1}1~'1 wtlh lilt' utll' t'ljllljllk,.l u~<>l h• II•' 11'!>1 ul II~
I£"'"'
n>l«111 k1lUollUI\
" " • Vllk'
Tronsoclor
I
Moy 1988, Volu me 8,111Ue 6 --'
Subscription and Order Information
Transactor
A~ all orders. queries and other correspondence to;
11w ~ uto •lor Corrmodcle l'lo\l<l•orows
Trmsactor 85 West Wtlmot Street, Unit I0 Richmond Hill, Ontario. Canada LAB IK7
Publisher Richard Evers
Or. in the U.S.:
Editors
Tr.msactor P.O. Box 338, Station C BuOalo. NY 14209
Nick Sullivan
Chris Zamara Editorial Assistant/Adverti<;ing
In the U.K.. Europe. South Ireland and Scandmavoa: Tronsactor (UK) Limited 2 Langdale Grove Bongh:un, ooingham England 1'\G 13 SSR Phone 011 44 ~9 39380
Moya Drummond
•
Customer Service Renannc Turner
=•
Note that all mail to our Buffalo P.O. box is forv.ardod to our Rkhmond Hill offoce: for fa.'.l~t delivery. mail directly to the Rkhmond Htll OOdre.\ above.
Contributing Writers lanAdam David Archibald Jack Bedard Paul Blair Glen Bodie Bill Brier Anthony Bryant Jom Butterlleld Dale Ca9ello Tom Collopy Richard Cwcio Don CUrrie Roben Davi!. Elizabeth Deal Frank DiGioia Ouis Dunn Paul Durrant Michael Er..k.ine Jack Frurdh Mark Fanis Jim Fro51 Miklos Gamms7.eghy Eric Germain David GodshaiJ Michael Graham Eric Giguere Thomas Gurley Patrick Hawley Adam Herst Thomas Henry John Houghton Roben Huehn Thm Hughes David Jankowski Clifton Kannes Lome I<.Jasl,en
Knight On:gory Knox David Lathrop James Lisowski Richard Lucas Scou Maclean Steve M<:Crystal Chri~ \1iller
)C',<,e
For VISA and Mastercard phone orders of sublcrip«ion' or 0~1cr Transactor products. call our new
TOLL FREE ORDER LINE (ln the U.S. only) 1-800-248-2719 Exten9\ln 911 Plea<>e 1101e that the toll-free number is for orders 01111.
Keath Milligan Tcny MontgotnCI) RaiJitMoml
:
In Can.'l<i1. call our office directly a1 (416) 7~5273 on "'.xMJay, 9-5 (FSI). For quene. aboul ext<oting subscriptions or orders. plea....: call on \,1onda}"· \\~)~ and Frida)'~ only. For prices. produc1s and bock I'\Ill!\ m \lod.. CIC. 'ice order card m the centerl'okt
DJ. Moms.~
Michael Mossman Bryce Nesbin Ocmld 'eufeld Noel Nyman Heier~ Ol!.en Mauhew Palcic Richard Penit Steve Punter Raymond Quirling Doug Re>enbeck Tony Romer Uerl>Rose EJ. SclunahJ David Shiloh Darren Spru)1 Aubrey Stanley J>.IVod StidoiJil Richard Stringer Amon Tn:uenfels Audrys Vilkas Nicholas Vnis Jack Weaver Geoffrey Welch Evan Williams
Authors: Write to the above address for a copy of our wntcr·~ guide. Submit articles to the above addres.~. prefembly on disk along with any aso;ocimed programs. Just about any foomat is acceptable, but articles 1>hould pn:fcr.tbly be \traight ASCil texL witl1out contrOl characters or formauing code;. Minimum payment for atticles is $40.00 per pointed page. Manuscripll> should be typewritten (or computer-printed), double >JXICCd. wi~1 •pecial chardC\er.. or formatting clearly marked. Photos should be glob>y blacl. and white prints. Olustrations should lle on white paper with bL'lCk inl. only. All material accepted becomes the propcny of Tran...a..'1or. unl~ a :,pecial agreement os m.'lde for the au:hor to retain copyright. Othc:N-i...:. all material is copyright by Tran~ Publishing Inc Quantity Orders In Canada: Ingram Software Lul, 141 Ades.w Drive, Coro:ord. Ontario LAK 2W7. Phone (416) 738-1700
In the U.S.A: IPD {International Periodical Di,trilllotor..), 11760-B Sorrento Valley Road. Stm Diego, California 9212 1. Phone (619) 48 1-5928. A'I. for !>.we Brue~>Cber. Copyright Polk:y The contcnL' of this magllZine are copyright by Transactor Publi~hing Inc .. excep« where othcrwio;e 1101ed. and may 1101 be distributed or duplocated without pennissm The dtl>tnbution of individual Transactor program> for (lC1'oOO:ll w.e L' seneraJI> ac-
Production In-house with Amiga and Professtonal Page Final Typesetting by Vellum Print & Graphic Services Inc.
ceptJblc:. but rn:l'C\ duplication of collections of Tr.n.actor progr.tm. (such as Transactor~) requm:s thai an agreement be made wtth T~'lor Publi<;hing Inc. Call u.\ tf you are in doubt about distributing aTr.lrl!>actor JlrOllllllll.
Printing Printed in Canada by
The opon1011" expre.\...ed in contributed articles are notncce<.i>arily those of Transactor. Although OCCUI"JCY is a major objective. Transactor cannotll~MJillC liability for errors in anicle~ or progmms. Transactor Publishing Inc. i~ a wholly owned subsidiary of Mamru Communications Inc .. 95 Lawrence Ave.. Richmond Ifill, Ont .. I.AC lZ2.
MacLean Hunter Printing
Tnonsaaor is published bo·IOOO\Ihly by TI'M>.-.ciOr PllbiL_.,ong Inc., 85 Wesa Wilmet Sen.~ Un11 10. Rlchmond HolJ. On~ LAB IK7. Canadun S...ul<l Class mail n:gislr.ttion IIJillbcr 6.l U IJSPS 725-050. Second Class~ pood at Bull.to. NY ror U.S. wb11:ribcr>. U.S. Acldrc::s.. 127 Reed St Burralo,!I.'Y 142t2 U.S.~ <cnd~thonl\<>IOTr.onsacwr. P.O. Bod38.StooonC. BuJT.to,NY, 142ll9.1SSN#0827·25JO
Transactor
2
May 1988: Vo lume 8, Issue 6
'
1
Signs of Maturity â&#x20AC;˘
You may have noticed that this issue is a little thinner than usual - 64 pages instead of the customary 80. This feature is available for thi~ issue only, and will not be repeated again in the near future. You may have abo noticed that this issue is a few weeks late. This relatively minor glitch in the course of the magazine's seven year history comes as a result of some not-so-minor internal changes.
spoke PostScript and plug it in to any output device that understood it. To our delight, we found PostScript to be powerful and high-level enough that many complicated images can be created quite easily directly in the language. After learning a bit about PostScript and buying a laser printer came the big step: software. Our choices were limited to PostScript-compatible programs available on the Amiga, which left one obvious choice: Gold Disk's Professional Page, just released. Fortunately, that wasn't a severe limitation, because the quality of the copy it produces is close enough to a professional system that it isn't an issue (although a 300 DPI laser printer doe~n 't do justice to its capabilities). Just as important. the program is extremely easy to learn and use. which was a major factor in us getting up and runmng so soon.
Every Transactor since Volume 4 Issue I almost five years ago has been produced using professional typesetting equipment, with all the typesetting work done by Karl Hildon, founder and long-time Editor-In-Chief of Transactor. This issue is the first created without the benefit of Karl's assistance: he has recently left the company to pursue other interests. Events leading up to Karl's resignation happened quickly, and all of a sudden we had a late issue on our hands, with no apparent way to produce it.
The only hurdle left between our quick'n 'dirty homemade type-shop and a professional system was the laser printer's less-than-perfect resolution. This hurdle was jumped quite easily by making an arrangement with a local shop that had a PostScript-driven phototypesetting machine: we supply PostScript fi les generated by Professional Page, and they pump them through the machine and deliver camera-ready film for a reasonable charge per page.
The fact that you are reading thil. now gives away the happy ending to this tale, but the story is still worth telling, because our leap from editing to typesetting and final production is a success story that says a lot about the maturity of present microcomputer technology. The ease with which we made this leap would have been unheard of just a few years ago, and it's worth looking at what made it possible in the current technological climate.
So what does all of this say about the maturity of the technology? Well, we (the user) started without knowing anything, except how to work an Amiga and create the contents of a magazine. We bought a printer and just plugged it in to our Commodore equipment with the enclosed cable; we bought a program from another manufacturer and ran it. Everything worked. Not by accident, but because developers of computers, software, peripherals, languages and standards are working together more tightly to make these things work.
At the time we were faced with creating the magazine, we knew nothing about "Desktop Publishing.. programs or laser printers, and were only vaguely aware of a standard protocol for output devices called PostScriptÂŽ. Within 24 hours of that terror-filled moment, we were creating pages as you see them here (almost), using our friendly 3 1/2 megabyte Amiga 2000 at the office. Not only can we set text as well as before, but we are able to do things that were previously difficult or impossible, or things that our printer had to do for us.
We hope you enjoy this special extra-lite issue, with new home-made production goodness. You can expect future issues to grow to regular size, .and expect the production to get slicker and the number of diagrams and photos to increase as we get more comfortable with the new system. Ironically. Karl's traditional sign-off is more appropriate now than ever: "There's nothing as constant as change."
When we learned a bit about PostScript, we started realizing how little we would have to give up in the quality of the magazine. PostScript is a language that Desktop Publishing programs can use to speak to output devices. like laser printers and phototypesetters. The initial appeal of PostScript to us was that it was a standard. so we could get any program that Transactor
3
Moy 1988: Volume 8, Issue 6
Using "VERIFIZER" The Transactor's Foolproof Program Entry Method PET/CBM VERI FIZER (BASIC 2.0 or 4 .0) VERI FIZER should be run before typing in any long program from the pages of The Transactor. It will let you check your work line by line as you enter the program, and catch frustrating typing errors. The VERI FIZER concept works by displaying a two-letter code for each program line which you can check against the corresponding code in the program listiflg.
Cl CF Ll HC OH GK OG JO AF IN ON
10 rem• data loader for -venf1zer 4.0 • 15 rem pet vers1on 20CS=0 30 for 1= 634 to 754 .read a poke 1,a 40 cs = cs +a next 1 50 : 60 1f cs<>15580 then pnnl'.... • data error .. • .. ·: end 70 rem sys 634 80 end 100 . 1000 data 76, 138, 2, 120, 173, 163, 2, 133, 144 18 1010data 173, 164, 2, 133, 145, 88. 96, 120. 165 CK 1020data145, 201, 2,240, 16,141,164, 2,165 EB 1030data 144,141,163, 2, 169,165,133,144, 169 HE 1040 data 2, 133, 145, 88, 96, 85, 228, 165, 217 01 1050 data201, 13, 208, 62, 165, 167,208, 58, 173 JB 1060data254, 1, 133, 251,162, 134,253, 189 PA 1070 data 2, 168, 201 , 32, 240, 15, 230. 253 HE 1080 data 165, 253, 41 , 3, 133. 254, 32, 236. 2 EL 1090 data 198, 254, 16, 249. 232. 152. 208, 229. 165 LA 1100data251 , 41 , 15, 24. 105 193. 141 0, 128 Kl 1110 data 165. 251 , 74. 74, 74 74, 24 105, 193 EB 1120data 141. 1. 128, 108, 163 2, 152 24, 101 OM 1130 data 251 . 133. 251 96
There are five versions of VERI FIZER here; one for PET/CBMs, VIC or C64, Plus 4, Cl28, and 8128. Enter the applicable program and RUN it. If you get a data or checksum error, re-check the program and keep trying until all goes well. You should SAVE the program, since you'll want to use it every time you enter one of our programs. Once you've RUN the loader, remember to enter NEW to purge BASIC text space. Then turn VERIFIZER on with: SYS 634 to enable the PET/CBM vers1on (off: SYS 637) SYS 828 to enable the C64NIC vers1on (off: SYS 831) SYS 3072,1 to enable the C128 version (off: SYS 3072,0)
Note: If a report code is missing (or " -") it means we've edited that line at the last minute which changes the report code. However, this will only happen occasionally and usually only on REM statements.
VIC/C64 VERIFIZER KE JF Ll BE OH GK FH KP AF IN EC EP OC MN MG OM CA NG OK AN GH JC EP MH BH
With VERIFIZER on, just enter the program from the magazine normally, checking each report code after you press RETURN on a line. If the code doesn't match up with the letters printed in the box beside the listing, you can re-check and correct the line, then try again. If you wish, you can LIST a range of lines, then type RETURN over each in succession while checking the report codes as they appear. Once the program has been properly entered, be sure to turn VERlFIZER off with the SYS indicated above before you do anything else. VERIFIZER will catch transposition errors like POKE 52381,0 instead of POKE 53281 ,0. However, VERI FIZER uses a "weighted checksum technique" that can be fooled if you try hard enough; transposing two sets of 4 characters wil l produce the same report code but this should never happen short of deliberately (verifizer could have been designed to be more complex, but the report codes would need to be longer, and using it would be more trouble than checking code manually). VERI FIZER ignores spaces. so you may add or omit spaces from the listed program at will (providing you don't split up keywords!). Standard keyword abbreviations (like nE instead of next) will not affect the VERI FIZER report code.
Technical info: VIC/C64 VERI FIZER resides in the cassette buffer, so if you're using a datasette be aware that tape operations can be dangerous to its health As far as compatibility with other utilities goes, VERIFLZER shouldn't cause any problems since it works through the BASIC warm-start hnk and JUmps to the original destination of the link after it's finished. When disabled, it restores the link to its original contents. The Transactor
o.
o.
Once VERI FIZER is on, every time you press RETURN on a program line a two-letter report code will appear on the top left of the screen in reverse field Note that these letters are in uppercase and will appear as graphics characters unless you are in upper/lowercase mode (press 1 shift/Commodore on C64/ VIC).
10 rem• data loader lor ·venf1zer' • 15 rem Vlc/64 vers1on 20 cs=O 30 for 1= 828 to 958 read a poke 1,a 40 cs = cs + a:next1 50 : 60 if cs<>14755 then pnnl'• .... data error ..... ·: end 70 rem sys 828 80end 100: 1000 data 76, 74, 3 , 165,251 , 141, 2, 3, 165 1010data252,141, 3, 3, 96.173, 3, 3,201 1020 data 3, 240, 17, 133,252. 173, 2, 3, 133 1030 data251, 169, 99, 141, 2, 3, 169, 3, 141 1040 data 3, 3, 96, 173, 254, 1. 133, 89, 162 1050 data 0, 160, 0. 189, 2, 240, 22, 201 1060data 32,240. 15, 133, 91,200, 152, 41 , 3 1070 data 133, 90, 32, 183, 3. 198, 90, 16, 249 1080 data 232, 208, 229, 56, 32, 240, 255, 169, 19 1090data 32, 210, 255, 169, 18, 32, 210,255, 165 1100data 89. 41 , 15, 24, 105, 97, 32, 210, 255 1110data 165. 89, 74, 74, 74, 74, 24, 105, 97 1120 data 32. 210, 255. 169. 146, 32.210. 255, 24 1130data 32, 240, 255, 108 251 , 0. 165. 91 , 24 1140 data 101 , 89, 133, 89 96 .
VJC/ 64 Double Verifizer
o.
Steven Walley, Sunnymead, CA
When using 'VERIFIZER' with some TVs, the upper left corner of the screen is cut off, hiding the verifizer-displayed codes. DOUBLE VERI-
4
'
May 1988: Volume 8, Issue 6
I
'
I "
FIZER solves that problem by show1ng the two-letter verrflzer code on both the f,rst and second row of the TV screen. Just run the below program once the regular Venf1zer IS activated KM 8C 01 GD IN EN KG KO FM • LP
MG HE LM JA El KJ DH JM KG EF CG EC AC JA
100 for ad 679to 720 read da poke ad,da.next ad 110 sys 679 pnnt pr nt 120 pnnt'double venflzer act1vated':new 130data 120, 169 180,141 20, 3 140 data 169, 2. 141, 21. 3, 88 150 data 96, 162, 0, 189. 0. 216 160data 157, 40, 216,232.224, 2 170 data 208, 245 162. 0, 189. 0 180data 4, 157 40, 4, 232,224 190 data 2, 208. 245. 76. 49, 234
VERIFIZER for Tape Users
cc
80
Tom Potts, Rowley, MA
PO The following modifiCations to the Verifizcr loader will allow VIC and 64 ownt>rs w1th Datasettes to use the Verihzer directly (without the loader). After running the new loader. you 'II have a SJX.'Cial copy of the Verifizer program which can be loaded from tape without disrupting the program m memory. Make the following additions and changes to the VIC/ 6·1 VF.RI FIZER loader: NB AL 18 -OC MO EG BD KH GL DC IP
Introducing
The Standard Transactor Program Generator If you type in programs from the magazine, you might be able to save yourself some work with the program listed on this page Since many programs are printed in the form ol a BASIC ..program generator", which creates a machine language program on disk, we have created a ·standard generator" program that contains code common to all program generators. Just t}'J)e this in once, and ~ve all that typing for every other program generator you enter'
30 for~= 850 to 980: read a: poke i,a 60 11 cs<>14821 then print • • · ••data error• .... '. end 70 rem sys850 on. sys853 oH 80 delete line 100 delete line 1000data 76. 96 3, 165,251, 141, 2 , 3, 165 1030 data 251 169 121 141 , 2 , 3, 169, 3, 141 1070 data 133 90 32 205, 3, 198, 90. 16,249 2000 a$ • 'veflhzer.sys850(space)' 2010 for 1= 850 to 980 2020 a$= a$+ chr$(peek(1)) next 2030 open 1, 1, 1,a$; close 1 2040 end
Once the program is typed in (check thr verilizer codes as usual when entering 1t), save it on a disk lor future use. Whrnt"ver you type in a program generator (for example listings 5 and 6 from the article " Interfacing two Commodore 61s" in this issue), tht" listing will refer to the standard generator. Load the standard generator you've saved, then type thC' tines from the listing as shown The resulting program will include tht> gt>nerator code and be ready to run
Now RUN, pressing PLAY and RECORD when prompted to do so (use a rewound tape for ea~ future access) To use the spec1al Verilizer that has just lx.'t'n created, first load the program you "bh to verify or review into your computer from either tape or disk. I\ext insert the tape created abo\e and be sure that it is rewound . Tht.>n enter in direct mode: OPEfl<l.CLOSEI. Press PLAY when prompted by the computer, and wa1t while the ~pecial Verilizer loads into thr tape buller Once loaded, the screen will show FOUND VERIFIZI::RSYS850. To activate, enter SYS 850 (not the 828 as in the original program). To de-activate, useSYS853.
When you run this new generator, it will create a machine language program on disk that can be loaded (load 'lilename',8,1) and executed with a SYS com mand The machine language program is described in the related art1cle and the generator IS JUSt an easy way lor you to C'reate it usmg the standard BASIC editor at your disposal. After the machine language file has been created the generator is no longer needed. The standard generator, however, should be kept handy lor all future Transactor type-in program generators. The standard generator listed here will appear 111 cvrry 1ssue Irom now on (when necessary) as a standard Transactor utility like Verilizer.
If you art> going to use tape to SAVE a program. you must de-activate (SYS 853) since VERI FIZER moves some of tht> internal pointers used dunng a SAVF. operation Attempting a SAVE without turning oil VERIFIZER first will usuall} result in a crash If you wish to use VERI FIZER again after using the tape you'll have to reload it with the OPf:N I CLOSE I commands
1MG EE LK KO EC F8 DE CM CH HM NA KD HE JL MP MH IH
C128 VERI FIZER (40 column m od e) fPK]1 000 rem · data loader lor 'venlizer c128 ti! AK 1010 rem· commodore c128 vers•on JK 1020 rem • use 1n 40 column mode only! NH 1030 cs - 0 OG 1040 lor j = 3072 to 3214 read x· poke J,X ch = ch + x: next JP 105011 ch<>17860 then print 'checksum error·: stop MP 1060 pnnt 'sys 3072,1 : rem to enable' AG 1070 pnnt ·sys 3072,0. rem to d1sabte' ID 1080 end GF 1090data208 11 . 165. 253. 141 , 2 , 3,1 65
I
The Transoetor
1100 data 254 141 3. 3, 96, 173, 3, 3 1110 data 201 12.240. 17, 133, 254, 173, 2 1120 data 3. 133.253. 169, 38, 141, 2, 3 1130 data 169. 12. 141 3, 3 96. 165, 22 1140 data 133. 250. 162. 0 . 160. 0. 189, 0 1150data 2 . 201 48.144 7201 58, 176 1160 data 3 . 232, 208, 242 189. 0 , 2. 240 1170 data 22, 201, 32, 240. 15, 133, 252, 200 1180data 152, 4 1, 3, 133, 251 , 32, 135, 12 1190 data 198. 251, 16, 249, 232, 208, 229, 56 1200 data 32, 240, 255, 169, 19, 32, 210, 255 1210 data 169 18, 32, 210. 255, 165, 250, 41 1220 data 15 24, 105, 193, 32, 210, 255, 165 1230data250 74 74 74 74, 24, 105, 193 1240 data 32 210. 255 169 146, 32 210, 255 1250 data 24 32. 240 255 108, 253 o, 165 1260 data 252 24 101 250 133, 250, 96
5
I 100 rem
transactor standard program generator 110 n$ ='filename·· rem name of program 120 nd 000 sa= 00000. ch = 00000 130 lor 1 to nd· read x 140 ch = ch-x: next 150 11 ch then pnnt'data error'. stop 160 pnnl'dala ok, now creat.ng file ' 170 restore 180 open 1,8, 1,'0 • +n$ 190 hi= lnl(sa/256): lo = sa- 256•hl 200 pnnt#1,chr$(1o)ch r$(hi); 210 fon= 1 to nd: read.x 220 pnnt.¥ 1,chr$(x);. next 230 close 1 240 pnnrprg file ":n$;' created .. : 250 pnnt'th1s generator no longer needed • 260 :
May 1988: Volume 8, Issue 6
·
·
;, ,,
b -'
•
Got 011 imerestinf? prol(ramming tip. short rnwine. or an unknown hit of Commodore trtna ? Se11d it 111- if we use it 111 the hits column. we'll credtt \'OU i11 the col11m11 u11d send yo11 a free o11e-year's suhlcriptwll to The Tramactor
Header With Variables Ken Garber, Windsor, Ontario
$8004. If it finds this, it executes the ML pointed to by locatiOns $8000 and $800 I. The ML there initialitC\ as the Kemal would until it'l> ready to go to BASIC, but before it does that, it puts a '10" ",8,8' and a shifted RUN/S r'OP m the keyboard buffer. After BASIC has taken over. 11 goes to the ready prompt and dumps thoM! characters. TI1e onl) comphcauon is that when you hit the RESTORE key on the 64. it abo ched.~ for the ~arne mask at $8004 and of course 11 finds 11. Then it jumps to the location pointed to by $8002 and $8003. I didn't want the RESTORE key to reset the computer, so I had it point right back into the Kemal. Here's the program that does i1 all.
The example m the Cl28 user guide (page 265) on using HEADER ha~ an error. A syntax error will occur if one attempts to assign the disk ID to a variable name (e.g. l(A$)). This is confirmed by the BASIC 4.0 Reference Manual. However, by mampulating the stnng variables, the ID can be successfully set from within a program. As the ·Are you sure?' prompt is suppressed in program mode, the 'escape' prompt in line 40 has been added. Line 30 allows for a short NEW.
IB
10 input"diskname";a$: input"disk id";b$ 20 c$=aS+","+b$ 10 if b ="" then cS=a$ 40 mput"are you sure ";q$:if qS<>"y" then end 50 header(c$) 60 pnntd~
KA GL BC 10 CE DO I Ill
CJ28 64-Modc Autobootcr Aaron Spangler, Everett, Washington
LD EF
PL You've heard about all those auto ~tan programs for the C64 that 'save you keystrokes·. Well, this one beats them all - you don't have to hit any keys until your program is loaded. There's one catch - it only worl.s on the 128.
AH lM KA OC
AP It works hke th1s: First it sets up an autostan program at track
LC MC PO 10 EJ BM
I sector 0. When the 128 powers up, 1t checks for the uppercase characters 'CBM '. If it find~ it, it executes the machine language following. My machine language program transfers pan of its progmm to $8000 in bank 0. nips to bank 15 and then goes to 64 mode.
AD
When the 64 resets, it checks for 'CBM' then the byte $80 at Transactor
6
100 print'' ·autoboot 64' - by: lthe wolverine!" II 0 print"this program put~ an autoboot program" 120 print"at track: 1 sector: 0. upon reset, the" 130 print" autoboot program i<. loaded by the 128," 140 pnnt" the program sets the 128 mto 64 mode," 150 print" loads the first program on disk," 160 print" and executel> 11." 170 for x= I to 91: read a: b=b+a : a$=a$+chr$(a): next 180 for x= I to 164: b$=b$+chr$(0): next 190 if b<> I0230 then print"duta error": stop 200 data 67, 66, 77, 0, 0, 0, 0, 0 210data 0, 120. 32, 132.255, 169, 0, 141 220 data 0. 255. 120, 162, 128, 189, "\7, II 230 data 157, 255, 127. 202. 208. 247. 169, 0 240 data 141, 0, 255. 76. 77. 255. 9, 128 250 data 94, 254. 195, 194. 205. 56, 48, 142 260 data 22, 208, 32, 163, 253, 32. 80, 253 270 data 32, 21, 253, 32, 91, 255, 88, 162 280 data 10, 189, 42, 128, 157, 118, 2, 202 290 data 208. 247, 169, I0, 131. 198, I08. 0 300 data 160, 76, 207. 34, 42. 34. 44, 56 310data 44, 49.131 320 print: print"insen new fom1atcd d1~k & press retum." May 1988: Volume 8, Issue 6
MP JO IJ
All NM GC 00
330 get z$: 1f 1S<>chr$( 13) then 250 340 open 15,8.15,"b-a:O,I,O" 350 open5.8,5,"#" 360 print#l5,"b-p:5,0" 370 prinr#5,a$;b$; 380 print# 15,"u2:5,0.1 ,0" 390 closeS: clo-.e 15
5 rem the message wnter program: I0 a=O: print chrS( 147); 20 get a$: print a$;: if a$<>"@" then 20 30 b=pcek( I 024+a): pol.e 49408+a,b : if b<>O then a=a+ I: goto 30
C64 J O)'ltick Port Protection Gar) M . Collins, Bonner Springs, Kansas Ordering Information For Commodore Hardware Service Manuals Ted Evers, Richmond Hill, Ontario •
Device
The notorious susceptibility of the C-64/C-128 joystick pons to Malic ";.aps" (and re~ul t ing severe damage to the computer) can be avoided in many ways. Evan Williams (Transactor Vol. 8, hs. 3, p. 25) solve~ the problem by l.illing the static charge before contact with the pins. As he says in hi~ excellent article, however. the pms should nor be touched a1 all. One very cheap and simple method is to •amply slap a piece of vin) I electrical tape acros<. the unused openmg('>).
Commodore Part 'umber
#3 1400 I -02 C64 8050/8250 #314011 ·03 1540/1541 #314002 01 2031 (Identical to 1541 long board except for input circuitry.) # 1540039 sheet number~ I and 2 for 203 1 schematics.
Another method, equally cheap, involves one of those scrapped joysticks that everyone accumulates. Simply cut the wire flush with the bacl. end of the plug. Dab a bit of 5mmute epoxy on the e;~tposcd wire ends, and pr~sto! -a dummy plug for the unused port. (I leave a stick plugged into Port 2 all the time.) This mal.e~ it easy to move the plug as needed, doesn't gum up the pins as tape might. and elunmates the necessity of opening the computer.
Message Scroller Nick Barro" man, St. J ohn\, 1\ewfoundland Me:.su~e
b an interrupt driven routine to ~croll a message acros~ the bottom of the 64\ ~creen. It allow~ huge message~ (which can be composed u'>ing writer, a short bu~ic program included) to scroll acro~s at any speed you choose. You can set the colour (and change it at any time) by POKEing it into 1023. To ~et the '>peed, POKE 780.speed (the lower the faster) and then SYS 49152
OM liM CB AM N JM Jl PK CL JO PH KG IJ
IIJ JG EE PB GL JH GB CJ DL EM OH ON
Seikosha Printer Ribbon Reloads Robert V. Davis, Salina, Kansas
10 rem •• interrupt message scroller + 20 rem*"' by nicl. barrowman ** 30 read a: if a> I then ch=ch+a : poke 49152+b.o: b-b+ I: goto 30 40 if ch<> 11439 then print "check.,um error!": end 50 print "poke 780,speed" 60 print "poke 1023,colour" 70 print "poke 780,255 to halt" 80 print "sys 49152 to activate" 90 print "note: alway~ poke 780 before the sys" I 000 data 120, 20 I, 255, 208, 14, 173, I07 1010 data 192. 141, 20. 3, 173, 108, 192 1020data 141. 21, 3, 88, 96, 141, 61 1030data 192. 173, 20, 3, 141. 107, 192 I~Odata 173, 21, 3, 141, 108. 192, 169 1050 data 54. 141. 20, 3, 169, 192, 141 1060data 21. 3.169, 0,133,251,169 I070 data 193, 133. 252, 88, 96, 238, 19 1080 data 3. 173, 19, 3, 201. 0, 144 1090 data 42. 169, 0, 141, 19. 3, 160 II 00 data 0, 177, 251, 208, II, 169, 0 1110 data 133. 251, 169. 193, 133. 252, 76 1120 data 106, 192, 153, 192, 7, 173,255 1130 data 3, 153, 192,219,200, 192, 40 1140 data 208, 227, 230, 251, 208, 2, 230 1150 data 252, 76, 0, 0, -I
Transactor
The Se1kosha printer'i, SP-IOOOVC and SP-1 ROVC, plug directly mto the Commodore C-64/ 128 ~enal bus and provide reasonable print quality at a very low price. But the replacement ribbons cost about $10 each. Users with a masochistic Mreal. or a desire for economy can reload their ribbon cartridges for about $4.50 each. My first reload tool. an hour and m) hands became very inky. Experience help'>. Be very carerul opening the plastic cartndge to avoid breal. mg the pins which hold it together. Follow precisely the directions for installing the reload so the highly compressed ribbon will not spring out of the plastic housing (per:.onal experience). Reloads for the Tandy DMP 130 printer, packed three to a box. are exact replacements for the Seil.osha printers. The Radio Shacl. part number I'> 26- 1238. Save money!
Gemini lOx Ribbon Refreshing Dashim Shah, Republic of Singapore Murray Kalisher's rip on ribbon rejuvenation in BITS (Issue Nov. '87), prompts me to write in with th1s up for users of STAR\ venerable Gemini IOx series of printer-.. These printers, very popular with 64 users, use spool-type ribbons, similar to tho~e used in typewriters, but with one very 7
May 1988: Volume &, Issue 6
Since the error calls itself 'unimplemented'. I have to a~sume that Commodore had plans for the~e t\.\0 commands but de· cided against using them (at lea'>! for now). Actually. any command Manmg with the tellers QL IT or OFF w11l cause the above result. I wonder if there are any others? ...
imponant difference. On either end of the ribbon are 1\.\0 eyelet~. These eyelets trigger a mechamcat lever when either ~pool b empty. caw.ing the spool to tum the other \.\ay. thus allowmg the full spool to unwind. Well. after using my original STAR ribbon for almost two years (that's right. two years!). I d1scovered that STAR does not supply these ribbons any longer. Since it looked like a typewriter ribbon anyway, I thought it would be available at my nonnaJ !>lationer.
Fast Load Killer Michael T. Graham, Hopatcong, New J ersey Some C64 games and applications that read or write to disk don't operate properly when the> arc loaded using EPYX's FAST LOAD or similar cartridges. The trouble 1sn 't with the load operation lt~elf; the problem~ occur because FAST LOAD i'> .. ull enabled .... hen the program i'> executing. Somethmg 10 rAST LOAD causes drive erro~ \.\hen non-load d1~l l/0 i., attempted. One y.ay around thi-. is to &,able the cartridge before loading tbe program. but thi., means you·u have to put up with the lethargic pace of the una.,sisted I 541. There is, however, a better way.
Here is problem number one. It is pracucally impossible to locate ribbons with eyelets at the ends. m Singapore anyway. Problem humber two is that most typewriter <;pool<; are not configured wuh the correct number or !>pacing of holes to fit the printer. The !>Olution is rather obvious, if a lillie mes!.y. Unwind the new ribbon from its original spool and wind it onto the printer's old spools (having removed the old ribbon first of course). As for the eyelets, I simply used a couple of staples. vertically stapled to the new ribbon where the eyelets should have been. It worked beauufully! However. for tho e who prefer a more elegant approach. you can U'>e a couple of those bull eyeleL'> that legal firms are -.o fond of U'>mg to hold a bunch of papers together b} their comer~. Simply punch them into po'>ition.
You can load the program using FAST LOAD and then disable the cartridge by inserting the following lines in the program·., loader or at the beginning of the program itself: I0 ~Y'> 58451: '>YS 65418 20 open 15,8,15."ui": print# 15."i0": clo\c 15 The fiN line resets the vector table\ u\ed by BASIC and the Kemal. effectively disconnecting the cartridge\ hooks into the ~yMem. The ~econd line reset!. the d1~l drive, nu~hing any ~pecial code that was uploaded during the load operation.
Finally, you can extend the life of your nbbon by just flipping the spool around. This will automatically position the unused half of the ribbon on top. giving you the u~e of two ribbons for the price of one.
TI1i., technique aJso disables 'The Final Can ridge· and should work on other fast-loaders as well. It will al.,o work when no canridge is m~talled, making it more univer..al than caJhng the can ridge\ built in disable routine.
More C-128 Mysteries... AJ. Saveriano, Sparta, New Jersey
Fade Out (Fade In?) Geoff Seele.), Bridgewater, No~ a Scotia
Lool at these two sentences and decide what the response of the C-128 would be if you typed them in direct or program mode (type them in exactly as sho\.\n):
The following screen daz;der wm, written for only one reason, to sec it work. Be forewarned though. prolonged exposure to this progrnm could freak-out your optic nerve! The program is written completely in machine language and is IRQ driven. Type SYS 49152 to start and to stop the progran1. (For C64 only).
QUIT THAT! OFFEN, WORDS ARE SPELLED STRANGELY Ok... now that you have made your decision. type the fiN sentence in direct mode and hit RETUR . Do the same for the .,econd sentence. Hmmm ... d1d )Oll get the old faithful SYNTAX ERROR? Surprise! A new error code appears (new for me, at least). UNIMPLEMENTED COMMAND ERROR is your reward. Why? Well, I'm not reall> sure. However, 1f you scan the BASIC ROM in Bank I) from addresses 18089 to 18111 you will see that two keywords appear that we (I) didn't know about. They are QUIT and OFF.
FJ EA DL CF MN AO EE DC LF JH BF
This one-liner will let you see them: 10 bank 15:print chr$(14):for i=l8089 to 181 II ·pnnt chr$(peek(i));:next TronsociOf
8
I00 x=49152: ck=O II 0 read a: if a=- I then 130 120 poke x,a: ck=cl+a: x-x+ I: goto II 0 110 if ck<> 16891 then print"crror in data" 140 print"sys 49152 to start/Mop":cnd I000 data 173. 20, 1. 20 I. 49. 240, 13 IOIOdata 120.169, 49.141, 20. 3, 169 1020data234, 141, 21. 3, 88. 96, 120 1030data 169, 33,141. 20, 3, 169,192 1040 data 141, 21, 3, X!l, 96, 24, 173 I050 data 125, I92. I05. 128, 141. 125. 192 Moy 1988: Volume 8, Issue 6
'- --
OE IH BK II
IL PI Fl
OK HN FK
FM LL PA LA KL CJ
I060 data 20 I, 0, 240. 3, 76, 49,234 1070 data 173, 126, 192,201, 19,240, 10 I080 data 238. 126. 192, 173. 126, 192, 168 1090 data 76. 71, 192, 169. o. 141. 126 1100 data 192. 168. 185. 128. 192. 141. 127 I I 10 data 192. 169. 0. 133.254,169,216 1I20 data 133. 255. 160. 0. 173. 127. 192 1130 data 145. 254. 230. 254. 208. 247. 230 1140 data 255, 169.220. 197,255,240, 3 1150 data 76, 86. 192, 169, 0, 141, 32 1160 data 208. 141. l1. 208. 173, 127. 192 1170 data 141, 134. 2. 76, 49, 234, 0 1180 data 0. 0. I. I. 15, 15, 12 • 1190data 12, I I , I I , 0. 0. o. 0 1200 data II , I I , 12. 12. 15. 15, I 1210 data I' - I
was lots of data that required random access, but keeping it in arrays would have consumed too much memory. Some BASICs have a RESTORE [line number) statement to do the job. So does the 64 '!. BASIC 2.0. according to some smartie at Commodore (see user'!> guide, page 176, 'RESTORE line number'). Unfortunately. my 64 never read the user's guide and reported a ?SYNTAX ERROR when put face to face with this version of RESTORE Matcmcnt. To make up for its ignorance. I wrote thb short ML program as a substitute: I
OF OJ EF OK IC Bl GG ND LF BA
Disk Light Flasher Jeff Spangenberg, Zephyr Cove, Nevada ''
Thi!> program !lashes the disk light as a 'trobe on the 1541 and 1571 drive~. It work~ on the C64. or a C 128 in 64 mode. The program abo monitor!> the line so that if a disk command is sent the program exits and executes the command. LF NM EG ML 01 Dl EB AD Ml NH HD MO KK MF FE AE HA FO EA CG DK PK CM LM DL
I00 rem nash dt~>k drive LED on 1541 110 ck=O 120 for x=49152 to 49290: read z: ck=d.+z 130 poke x.1: next 140 if d.<> 18154 then print"error": end 150sys49152 160: 170data 160, 62. 169, 8, 32, 177,255. 169 180data Ill. 32. 147,255, 169. 77, 32, 168 190 data 255, 169, 45, 32, 168,255, 169, 87 200 data 32, 168. 255. 152. 32, 168. 255. 169 210 data 5. 32, 168.255. 169, I. 32, 168 220 data 255. 185. 77, 192, 32, 168, 255. 32 230 data 174, 255, 136. 16, 205, 169, 8, 32 240 data 177,255, 169, Ill, 32, 147,255, 169 250dattt 85, 32, 168,255, 169, 51,32,168 260 data 255, 32, 174, 255, 96, 120, 41, 0 270 data 14 1, 0, 24, 169,254, 170, 32. 38 280 data 5, 32, 38, 5, 202, 224, I. 208 290 data 248. 32. 38. 5, 32, 38, 5. 232 300 data 224. 255, 208, 248, 173, 0. 24. 240 310 data 232. 88. 96, 138, 72, 73, 255. 168 320 data 169. 248, 141. 0, 28,202,208.248 330 data 169. 240, 141. 0, 28, 136. 208. 248 140 data 104. 170. 96
i
I00 hi::dl/256: lo=dl-mt(hi)*256 I05 poke 63.1o: poke 64,hi· syo; 49152 To relocate RESTORE-r to a dtfferent address in memory. change line 5 ('s · ill the Marting addre~'>) and line 50. The last two numbers of line 50 arc equal to s+8 in the lo"' byte/high byte format. Change these to corrc.,pond to your new Marting addresl> plw.. eight. RESTORE-r uses tero-page locations $FB-FC and SFE (251252 and 254 decimal). ro usc other locations, make changes wherever you encounter a 251, 252 or 254 in the data ~tate ments. Also, for the sa\..e of shortness, RESTORE-r lacks error trapping. It gets stuck on non-c>.istcnt line numbers. Use RUN STOP - RESTORE in this case. And one more thing. Wi th the following changes, RESTOREr becomes a computed GOTO routme: Line 25: 57 instead of 63 Line 30: 58 instead of 64 Line 35: 56,233.1.133,122 instead of 24,105.4,133.65 Line 40: 233 instead of I05; 123 instead of 66 To use 11. pol\e the hne number mto locations 57-58 decimal (low b) te fir.;t), and SYS 49152. Control i'> then transferred to the line specified. Example:
Restore to Line Number Oleg Smirnov, Moscow, U.S.S.R.
100 input "wluch hne number should I GOTO":g LIO hi=g/256: lo=g int(ht) 256: 120 poke 57.lo: poke 58,ht 130 sys 49152
I was recently making a MONOPOLY game for my 64. There Transactor
;
Here i11 how to u~>e it. Poke the line number to be RESTORED to into locations 63-64 decimal in the ~tandard low byte/high byte fom1at. and then SYS 49152. Example (dl stands for data line number):
Best-BiJ-From-Moscow Departme11t
l
I rem 64 restore-r- olcg smimov 5 s=49152 I0 for t=s to s+54: read a: poke t,a: next 20 data 165, 43, 133, 251 165, 44, 133, 252 25 data 160, 2, 177, 251, 197, 63, 208, 21 30 data 200, 177, 251, 197, 64, 208, 14, 165 35 data 251, 24, I05, 4, 133, 65, 165, 252 40 data 105, 0, 133, 66, 96, 160, 0, 177 45 data 251, 133, 254, 200, 177, 25 1, 133, 252 50 data 165. 254, 133, 251, 76, 8, 192
9
May 1988: Volume 8, Issue 6
T
s
e
L
e
t
R
•
Oh, For t he Good O ld Days ... Today, I recetved the last issue of my subscription. I have carefull y considered my deci-.ion regarding renewal.
avid C-64 fans who crave the arcane knowledge found only in the old T. Now, you seem to be trying to grasp the beginncr·., market but, all of them are gone.
Two years ago. A friend of mine lent me hi~ Transactor. At that time, I bad ju~t about ab~orbed all the pablum to be bad in Compute! 's Ga1ette "'hich seemed to repeat the same old stuff over and over, always directed to the rank beginner. God! was I happy to lind T Because it went to the very heart of my computer. telling me all the hidden secrets which I could never have discovered on my own at that stage of my development
It b very much like watching the slow death of a dear friend and with deep regret that I must decide not to renew my l>Ubscription.
I have eagerly awaited every issue since that lir~t one because I knew there would be a choice piece of information and/or a terrific program I needed. As I once wrote to you, "It seems that every time I need a program to do a certain job. the very next i~sue of T provides exactly what I need!" It was eerie at times ... For the last two or three i~~ues, however. the quality of the maga7ine print has soared to new height1. but the qualit)' of the words (whkh 1!. all that matters) has dropped lO the level of Compute! 's Gazette. T is now full of empty words. Who needs reviews? Who need~ opinions? I mis!> the interesting cover~ and I hate the !>lick paper. The very reasons for my lovmg T so much are almo~t all gone. I '>'ish you well with your new "look" but from now on, I will just buy a copy of Compute!'s Gat.ette in the grocery store when one interests me. Someone there at T should realite that the old maga7ine was directed to super-intelligent,
P.S. f failed to mention I'm NOT interested in Amiga, Apple, 12!!, orB-Series- only C-64. If you ever become a ·•special" maga;tine again, please let me know! Wayne Gurley Will~ Point, Texas, USA
C P/ M Saviours: Once ngnin Transactor come!> to the rescue. I hnd just purchased my new 1581 drive and could hardly wall to get it up and running. when I dtscovered that the current CPM+ !.ystem wouldn't ~upport it. I played with it in the BASIC 7.0 mode and it was great! But I really couldn't wait to get dBASE and WordSrar over to one or tho~e "linle square" disks. Then Mike Garams;eghy saved me with hi<; CPM+.SYS patch. Now r can PIP to my 158 I all day long. Thanks Mike! Thanks for the arttcle~ on CP/M and thanh to wnters like Mr. Garamszeghy, Adam Herst, Clifton Kame~ and Aubrey Stanley for sharing their knowledge with other Commodore CP/M users. And thanks to Transactor for offering a place for this sharing to take plnce.
___t_o_r _______________________________________l_o____________________________M_ay~l_9__ 88: Volume8,1uue6
L-_ T_ ra_ ~
That one is~ue was wonh the price of the sub~ription. It is a ~hame that Commodore couldn't have supplied the 1581 system with the drive (but I've been a Commodore u\er long enough to know all about Commodore Customer Suppon).
Che s, Anyone? I recently purchased a C- 1280 based largely on all prior repons that C-64 software runs OK on 11, without exception. That's not the case! Colossus Chess I\~ from Silver llouse, England, will not run on my C-1280. It works fine, as it always has, on my C-64. I'd appreciate l.nowing if others with a C-128 or C-128D have had the same problem. I have tried, but am unable to get a response from Commodore in this regard.
P.S. Mike Garamszeghy is fast becoming the CP/M "Jim Butterfield". Dr. Ken Aippo \1ilan. Tennessee, USA
P.S. My C-1280 works fine, otherwise. It even works OK with Superkit 1541. which I was never able to get to work correctly with my old C-64/1541 !? Except, despite claims to the contrary. Superkit 1541, will nm copy itsel r.
Comrasting letters like the abm•e two keep U.} walking an editorial flghrro1Je around here No matter how we fill these pages, we're hound w gl'l horh pratse and criticism; as long as rite former prevails (and our sales don't dip dramatically). ll e figure 11 e' redoing somerhmg nghr. Wayne Gurley's leTter, rlwugh. is worth a clmn look because his perceptions of rite muf.ia:ine's "slow death" ha1•e been 1•oiced by one or two others. Compared against the fact~. though, they just aren't true.
John R. Menke, Chessoft Ltd. Mt. Vernon, Illinois, USA
Other than slight differences which rary among all C64 \'ersiolls. we were not aware of any compatibility problems with the 128 or 1280. At this sftJf:e, we know lillie about the 1280 other tha11 the fact that it i:, a repackaged C/2H. E1'ell subtle differences in hardware or software ca11 break a program lwwerer, especially one that uses cle1·er copy protection methods, or code that reltes 011 undocumented quirlw in the system. (we don't know if Colossus is one of the:.e ). If anyone knows of a commercial program that runs on the 128 but not the 1280. we would ltke to hear about it - let's see if there's a problem. and how widespread it is.
The intere.Hing thing ahout a maga::ine like the Tis that people read 11, to a large errem.[or the parts they don't understand. We're heard from m manr readers. "llm·e your maga:me, e1·en though I don't understand anylmmtlsome of it". that it's a standing JOke around here. These people hope to /cam by e1·entually gra.}ping more of the maga:ine's content, so that the parts they don't understand become less with each passing issue. If we' \'e done our jobs well, you should be findIll(/ less (in Wayne's words) ''hidden secrets which I could nerer hal'e discowred on m\· Oll'n at that stage of my development " Why is that surpnsing. if your whole purpose is to increase your stage ofdevelopmem? lromcally, the beuer we do our job of educating and informing, the more we remove the Transactor magic from the minds of long-time readers, and it i.1 possible that we may e1•en lose some aiOIIf.l the way. (Mr. Gurley's reaction of going back to the "pablum to be had in Compllle!'s Ga:eue" is one whose logic escapes us, /1011 e~·er.)
Belie1·e it or not, we hare made working COI>IeS of SuperKit using SuperKit itself- 011 a brand-new 1571. The program is slick and 1•ery high-performance, bill, like a high!) wned racing eng me, just a bit too finicky for e1•eryday use in lhf' real world. Perhaps that has something to do with why SuperKit publisher Prism Software is now out of business.
Random Drhe Errors Corrected: It h:u. been noted that a 1571 disk drive without ROM update!> wiU produce random '?device not present error' messages. I encountered this error several times while reading a relative file, and upgraded my 1571 ROM to get rid of this bug. Well, this did not get rid of the error~. I asked Commodore in the United States, a software company in the U.S. and a few store owner-. in the areamy question was still unan~wered. I had deduced that the erron. were being caused by a 1 ery low voltage at sporadic times. A C-128 power supply can only handle M> much at one time: two disk drives, a modem, a Mach- 128 camidge, a printer, and a printer interface with a 16k print buffer. In my last breath I asked a very l.nowledgeable 'guru' on a local bulletin board if he had a solution to my problem. I le felt that if I changed my printer interface I would solve the problem. So. I changed from a TurboPrint GT with the buffer to a Super Grafix Jr., and it worl.ed.
If you take a good look at the ream issues, you'll find jusr as much technical info as always (if not more), and I'm sure many will testify that much of it is incomprehensible to them at this stage. No Amigo content appears in this maga:.ine any more. and Apple collfent ne1·er did; a.pect cm·erage of the C64 and C 128 e.xc/usirely, with a tiny smauering of PET' SuperPf..l VIC! Plus 4 B series related material If \l'e were gomg after the begmner's market, the pre1•ious tssue wouldn't ha1'e articles on a communications interface for software developers, hacking the POWER C function library, a detailed look at C 128 ROM code w investigate a liule-know11 but deadtv bu,~. bank-switching rollli11es for C1 28 flwchine code, und other material that would guarantee installf death in that market. To address Dr. Flippo's /euer. '''e appreciate the support for Mike Garamszeghy's articles. Feedback like tl11s helps us determine what to put imo the magazine: your lel/ers do make a dijference! Transactor
Here's the reason: the interface that I had w:ts drawing too much amperage from the ca~sette port, especially with the 16K printer buffer hanging off of it. I was able to narrow the 11
May 1988: Volume 8, Issue 6
problem down by turning off the printer and finding that the errors did not occur. If you are having the same problem as I was please check the interface that you are using. Duane E. Barry Cambridge, Ontario, Canada
accepted our subscription, and began to supply us with software. Therefore, this Club and your magazine have entered into a contract, and as with all contracts, unless otherwise agreed in advance, the terms and conditions of that contract remain in effect for its duration.
Thanks for the tip! Accordingly, the Club expects to receive Transactor software, as agreed, and will continue to copy but not resell, as agreed. Where's the RS232 Interface? I've heard that one of your issues had construction directions for an RS232 interface for modem connection. Could you please answer a few questions for me? • I. Willlhis interface work on an SX64? 2. What issue has this info in it? 3. Will the VIC/C-64 Verifizer work on the SX64? (It doesn't seem to work for me.) Looking forward to my new subscription.
Our Club consists of members who, having paid a membership fee, are free to copy the software in our library without charge. This Club policy is a factor in detennining to which magazines we subscribe. We know of no other magazines adopting this type of policy and feel rhat it is a seriou~ mistake which will. in future limit the circulation of your product. In clo!.ing, we would ask you to reconsider your policy, since it will influence our future decisions. and, frankly, we like Transactor.
Isidro G. Nilsson Marysville, Washington. USA
Bob Laws Software Librarian. Fundy C64 User's Group.
First, the answers: I: Yes; 2: Volume 8/ssue 3; 3: Yes. Our copyright policy as primed on page one of the magazine was changed recently to pre1•ent eXllctly the kind of thing your user group is doing, because it is difficult to sell Transactor Disks when anyone can get them for free at their local user group. Our attitude regarding Transactor programs has not changed: use them for whatever you wish: use our routines in your own programs; give them to your friends. What we are trying ro prevent is mass-distribution of Transa('tor Disks. which we put considerable effort into producing, and we would like to avoid having ro compere with our own product supplied by others.
Now for some explanation.\ ... Other than some differences that vttry on different versions of the 64 itself, the SX is 100% software-compatible with the regular 64 and 64C. It is theoretically hardware compatible as well, but since the unit's physical construction is differem, it is wise to verify, as you are doing, that a plug-in piece of hardware will fit in the slot on the top of the machine. Most simple boards that plug illlo the expansion or user ports willas is the case with our RS232 intetface project that appeared in Volume 8 Issue 3
The copyright policy in this issue remains the same. but we added a short note about our attitude toward indMdual copying of our programs. Nore that !his does not affect our copyright, but just stares that we ~:enerally don't mind copies of individual programs being given away, but you should get special permission for mass-distribution or for distribution of collections of Transactor programs (like a Transactor Disk). For user groups, our site-licensing arrangement of $3 per copy made is the standard deal.
As far as the Verifizer goes, we have used it many times on our SX without a hitch - double-check your program against the listing (you don't have the benefit of the Verifizer to do this, of course!), or better yet, load the Vic/64 verifizer from any Transactor disk. If that's where you got your Verifizer, suspect a bad disk. If Verifizer from a good Transactor disk gi1•es you the same trouble, you've got bad hardware, or you've discovered a problem we don't know abow -please let us know!
You're correct in stating that no other magazine has a policy similar to ours. but for the wrong reason: no other magazine has a policy as liberal as ours. Ask Compute! how they feel about people giving away their programs.
Transactor Site Licensing Policy - We. the Fundy C64 User's Group are in receipt of the reference letter, clarifying the Transactor copyright policy. However, we sec this as a change in your policy and must protest.
I
If you no longer wish to subscribe to the Transactor Disk as a result of oitr change of policy. then you may cancel your subscription and get a refund for the remaining disks. Alternatively, you can start charging your members a small fee for obtaining our disks withow having ro order them from us (for
In October 1987, we entered into a subscription with your maga1ine under the clear understanding that Transactor software was available for copy but not resale. For your part, you Transactor
12
May 1988: Volume 8, Issue 6
more money) and wait for them 10 arrive. We heliel'e that this arrangtmelll .\till benefits your group. thm. of course, is for .\'Oil to decide.
Piracy: the debate continues - This letter is in response to your editorial in the March issue of Transartor. There is an old saymg, ·• Be careful what you wish for, you just might get it." For the benefit of the home computer industry as a whole and software game writers in particular, I hope you don't get your wish in the Weaver vs. Doe case. There are ~cvcral statemenls in your editorial "'hich arc incorrect as far as OS law is concerned. If judgement is found for the plaintiff, the defendant will not be convicted of anything. This is a civ1l suit. Secondly, you can most assuredly collect damages from aminor if he has anything. Also, a judgement is good for seven years. By that time your minor is a young adult and you can get thm which he had hoped would be his college tuition or business stake too. Third!). judgements are not expensive. US copyright law grants the plaintiff actual damages plus all legal fees if he prevails. Let your lawyer collect hi'> fee and your damages from U1e defendant. I hold u copyright to a book and sympathite with Weaver to the extent that Weaver wishes to recover from the pirate himself. My sympathy diminishes rapidly as Weaver tries to pull the parents, the phone company, the fire department and anyone else he thinks may have some money, into his suit. Parents normally are not held liable for damages caused by the1r children, only for their own culpable negligence. To attempt to extend liability to parents who know little or nothing about computers and have no interest in learning or in constantly monitoring what their child does with his computer can only result in parents refusing to huy computers for their children. This will tend to maximize protection for copyright holders, but it will also minimize the market for games, computers and maga7ines. l would not want that.
and users to report violations which come to their attention. Perhaps holders of software copyrights need an organization to momtor and protect their rights as BMI does for the music industry. I wouldn't know how to contact a copynght owner if I did see his work being distributed illegally. Interestingly, the US copyright law grants certain c;o..press rights to the owner of a copy of copyrighted material. These include the right to sell or otherwise dispose of his copy, to make copies for archival purposes. to re arrange the material to suit his purposes, to study the copynghted matenal in depth, and generally, to enjoy all the benefits of ownership except d1stnbution. Federal court in Louisiana has just ruled that State\ "shrink wrap license" law illegal. lf you buy the pacl..age, you own that copy and the right to use it as you please, period. This comes as no surpnse since the ·'shrink wrap license" was originated as an effort to deny copy owners the rights that U1ey were intended, by Congress. to have. Congress has been repeatedly lobbied to reduce the rights of the owner of a copy, in the case of tape recorders, video tape decks and, most recently, digital tape recorders. They have steadfastly refused to do so. I don't e\pect them to change their posttlon just for software. The use of copy protection schemes obv1ously is intended to deny the copy owner certain of his nghts and is probably an actionable cause. Further, they only harm the legitimate software user. The pirate has ample tools, provided by a segment of the industry solely supported by their usc, to effectively negate such schemes. Last year's best seller list is topped by "Print Shop Graphics Library #I" at a quarter of a million coptes '>Old. h has not one whit of protection. GEOS, on the other hand, i-. g1ven away with ever) C64 sold. It ts of intereM mostly to users who want only to plug it in and push the button. It is so loaded with protection that progr..unmers have shown little intercM except to prove that they can cruel.. the protection. I ask you, why protect a program you intend to give away? I suggest their interests would be bener served by making the shell disk wide open and protecting, if really necessary, the additional programs for it, which they do sell.
I don't want to stan holding Ma Bell rc~ponsible for misuse of modems on regular home phone lines at thi~ time, either. She has ju\1 barely accepted the idea of permitting such activity mstead of confining it to the special computer lines which are more c;o..pcnsive. There goes Q-Linl.., all the BBS's, and the other serv1ces whose make or break point depends on the home computer user.
I feel that we all, ~.oftware users and creators, need to begin co-operating to protect each other's righb, not just our O\\n. Working together, we can run the pirates out of the game. Working at cross purposes we only harm each other and cause them to nouri'>h. Nothing so discourages me as scemg a letter from a no\ ice who hasn't mastered BASIC )Ct, 'ecking a way to hide his work. If the rest of us hid our worl... he would have no chance to learn. Programmer~ are not hom, we all learned most of what we know from other~. If Johnnie von Neuman and Grace Hopper had hidden their l..nowlcdge. we would all have had to pursue other hobbies or livelihoods. Yet he, somehO\\, expects nn experienced programmer to teach him ho"' he can avoid teaching others Thm io, the atmosphere that ha'> been created and I abhor it!
No, I can't support your position on that. I can support going after the violator with all vigor. Get hi~ equipment, for now, and don't let up until your judgement is paid in full or the ume limit has expired. I can also support a strong request to all Transactor
re~pons1ble
owners 13
May 1988: Volume 8, l»ue 6
L---------------------------------------------------------------------
Co-operation and a commitment to protecting all parties right~ are the only solutions I can ..ee. I cenainly don't want to ~ee "b1g brother" deciding to do for us what we should have done for ou~elves.
gram is up and running, there is a loop which checks for the presence of the dongle, apparently during the IRQ (at least, the cur<.or '>tops blinkmg if the dongle " removed, and startc; blinking again if you reinsert it).
Rus!>ell K. Prater Parker, Florida, USA
Alas the decoding phase appear~ to usc undocumented op code:. (at lca~t. they are not officially documented in MOS Technology spec sheet<> although they have been documented in Raeto West's books and in several other places). Of cour!.c it is precisely these undocumented codes which the 65816 family u!>es for its extra instructions. It would be as if you used undocumented 8080 codes which undoubtedly exist in one form or another and then wondered why the resulting code would not run on a Z80. The 65816 does have a 6502 emulation mode but this, I believe, only affecb the width of the registers. Thus INX would work differently if the xregister contained $FF depending on whether the X-register were 16 bits or, in 6502 emulation mode. 8 bits. In any case, it would have had to choose between MOS/Commodore, Rockwell and Synenech 6502's, and I believe the trend for both Rockwell and Synertech has been to treat undefined op codes as NOPs in their 65C02':. which ha-. the advantage that you can pass these through to a co-processor.
In praise of C - You guys are reading my mind. The March issue'~> shift towards using C on the 64 and 128 shows a very 'man ~hift of focus on your pan. I vote for continued attention to th1s language because of the language\ popularity on other machine~ (and of the usefulness of familiarity with C when moving up to the Amiga). Since it is so fru.t, C provides a wonderful world to explore between the two languages you have promoted thus far, BASIC and ru.sembly language. How about some graphics routines in C? I bought Power C a month ago and am intrigued. If Transactor focuses on using this package (with forays into other implementations like Super C by Abacus) the attention will promote the popularity of the language among the Commodore community. The use of some kind of Mandard is important. as you have proved b) promoting PAL as an assembler.
I suppose the moral is that programmers shouldn't be too
Bes1des. even though you consi~tently u'>e the same software, there i'> always room in Transactor for other products. You have proved that by publishing assembly language from MAE. French Silk, the Commodore As,embler and other!>. It is nice to sec alternative implementations, just to know what the other guys are up to. Keep it up. My vote is for continued focus on C. One more thmg. Since moving from Minnesota to Alabama to work at the University of Alabama-Birmingham. I have become heir to four 8032 CBMs. two 8050 dhk drives, a 4023 printer and cables to connect them all. TI1e only thing missing is decent software and the manuah. Without the last few year!> of Transactor and the Inner Space Anthology. I wouldn't be able to do anything with them. Do you have any advice as to where to find a word processor and database for these things at a reasonable price? Since the university is a nonprofit organization, donations from readers who have moved on to bigger and better things would probably be tax deductible. r would appreciate it if you would publish this letter along with my address so that interested reade~ could contact me. Craig Ede. An Dept., I 0 I Honor~ House, Univ. of Alabama at B1rm1ngham. Alabama, USA 35294 Paperclip and the 6SC816 - Re the review of the Turbo Processor for the C64 on page 56 of Tmnsactor V8i4: T think I know why Paperclip won't run on a 65C816. A!. you may know. Paperclip is not DOS copy protected but is dongle protected. Th1s dongle protection seems to consist of two phases. FiN. when you run the program, the program is decoded using value~ from the dongle a<> a key. Secondly. once the pro-
smart with their tricks. If possible, and 11 isn't always possible. keep with "official" methods. If you don't need blinding speed or decent graphics let your MS-DOS programs use MSDOS 1/0 inl>tmctions. Assume your 68000 u1.ers are going to insert a 68030 board one of these days. Unless you're being paid by the company that built the computer, try to let your users get away with a not altogether 100% compatible clone. And, unless you want a lynch mob outside your door. make sure your 1541 DOS copy protection docsn 't only work on 1541-. made on alternate Thursday~ in June 1984. Joel M . Rubm San Francisco. California, USA Product Info from Readers - I juM received the March Transactor and rend the Letters column. I think r can help a couple of my fellow readers. Patrick Demets wants a book. Specifically he needs a book which covers cartridge addressing. May I -.uggest Easy lmerfacmg ProJects for the Commodore 64 b) Downey. Rindsberg and Isherwood. It is available from Prentice-llall or from Don Rindsbcrg. The Bit Stop, 5958 S. Shenandoah Road, Mobile. AL.. 36608. This book is 200 pages of goodies ranging from the bas1cs to constructing speech synthesizers, IEEE serial and pamllel interfaces. a modem, 8-line multiplexed ADC and a ton of other goodies. with the driver programs where needed. It also ha~ a chapter on building an BPROM bumer/reader and covers address range selection a~ well as any book I have seen. The C64 supports cartridges at $8000, $AOOO, $EOOO, $DFEO, $DFFO or any combination thereof by proper manipulation of the E}CROM, GAME. ROMII. ROML. UO and 1/0 lines and the address register at $000 I.
-
..__ Tr_o_nsoc __tor _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _1_4_ _ _ _ _ _ _ _ _ _ _ _ _M _oy ....:...._ 19_88: Volume 8, Issue 6
Da\ id Kuhn needs a real-time clod. for hi!> C 128. Everyone who is interested in computers and knows what a soldering 1ron looks like ~hould write for a catalog from JAMECO Electronics, 1355 Shoreway Road, Belmont, CA 94002. They have all the chips, connector; and supplies that you just can't lind anywhere. They do have a $20 minimum order, but T have trouble keeping my orders down to that. On page 30 of the current catalog i!. a real time clock module, a complete 12 or 24 hour clock in a 16 pin Dl P with four bit data line access for computers at only $7.95. It is easy to interface through the user port and serves very well if powered from a battery and 7805 regulator. Don't forget to order the specilic:uion sheet with it. â&#x20AC;˘
I too have a need. Does anyone know where I can get a schematic and ROM program for a print buffer? I would prefer 8-bit Centronics. but Commodore serial would serve.
accomplish the erasure. The max1mum venical '>creen displacement between the most recently drawn line and its Immediate predecessor is calculated for two points on each line segment connecting the precalculated and stored net points. Because these points are calculated and indexed using the integer variables x and y they do not lie along vertical lines on the screen. Th1s 1s because each line is offset to the left from the previous line to achieve the 3-D illusion. The quantity K2 represents the vertical screen di!>tance between a precalculated point on the previous line with the interpolated point on the newly dmwn line having the same horitOmal screen coordinate. K3 is the same quantity using the precalculated (stored) point of the new line and the corresponding interpolated point from the previous line. If the new line lies entirely below the previous line, no lines arc drawn. I hope this may help other reader'> experiencmg s1m1lar hid-
Russell K. Prater Parker, Florida, USA
den line problems. The effort certainly helped me understand the original program more completely.
More Clocks - In response to the mquiry ''Clock Setting" (V815) as a hacker who also like~ to dabble in hardware, I use my C64 and C 128 for real world interface and control applications. About a year ago I purchased a CCSZ Clock/ Calendar with 8K CMOS RAM (both battery backed up) from Jason-Ranheim ( 1805 Industrial Drive, Auburn CA. 95603).
J. Milton Andres Palos Verdes, Cahfomia, USA
1850 rem mask hidden lines 185 I b.I=O 1852 for x=O to m-1 1853 k2=r(x.y+ I )-r(x.y)+(r(x,y)-r(x+ l.y))*ys/xg 1854 if k2>k I then kl =k2 1855 k3=r(x+ I ,y+ I )-r(x+ l,y)+(r(x,y+ I )-r(x+ l,y+ I ))*y~/xg 1856 if k3>k I then k l=k3 1857 next x 1858 k=int(k I13 )+I 1859 1fk=l then 1980 1860 for j=l to k 1865 for i=-1 to I 1870 locate g(O,y)+i. r(O.y)+3*j 1880 for x= I to m 1890 draw to g(>.,y)+i, r(x,y)+3 j 1900 next x. i, j 1910 locate g(O,y), r(O.y)+ I 1920 for x= l tom 1930 draw 0. +0, +0 to g(x.y). r(x.y)+ I 1940 next x 1950 draw 0. +0. +0 to +8, +8 1955 for j= 1 to k 1957 for i=-1 to I 1960 paint 0, g(m,y)+i, r(m.y)+3*j 1970 paint 0, g(O,y)+i, r(O.y)+3*j 1971 next i,j 1975 for i=-1 to I \tep 2 1976 locate g(O,y)+i, r(O,y)+ I 1977 for x=l torn 1978 draw 0, +0, +0 to g(x.y)+i. r(x,y)+ I 1979 next x, i 1980 locate g(O.y). r(O.y) 1990 return 2000:
The cartridge has proven very useful for my purposes, such a<; mamtaining system time and protecting data integrity during power losses. The operating modes that are provided in linnware (easily called from BASIC) are too extensive to cover in this letter. The documentation is quite decent and the imaginati\e programmer can make the thing serve many purposes! The cost a year ago was $50 US. Case H. Marsh Columbia , Maryland, USA
TransbloopurL - The Cl28 version of "l11e ProJector, Part II " which is listed on pages 23-25 of the January, 1988 Transactor does not seem to remove the hidden lines properly. On my Cl28 the line 1960-1970 PAINT 0 statements do not era-.e previously drawn lines whtch are a large di~tance below the newly drawn ltne. The enclosed hidden line subroutine, if substituted for the existing lines 1950-2000 seems to work satisfactonly as a substitute. Instead of drawing onl) 3 lines below the most recently drawn horitontal line. the substitute progmm draws a sufficient number of spaced, off~ct lines to co,er the previous lines lying below this new line. The erasure accomplished using the PAINT 0 command then crases a swath ~>uflicicntly wide to eliminate all unwanted portiOn\ of the previous line. Line!. 1851-1859 in the sub titute progrdJll are intended to limit the number of offset lines to the minimum necessary to Transactor
15
May 198a: Volume 8, Issue 6
Cellular Automata Mathematical Artforms For The C64 and CJ28 â&#x20AC;˘
â&#x20AC;˘ by Ian Ada m, P. Eng. Copyright (c) 1987/an Adam There has been a great deal of mathematical exploration over the past few years of the concept of cellular automata. These are arrays of cells with specified states; each cell's state changes from generation to generation, in accordance with a fixed set of rules operating on its neighbours. The accompanying programs implement a particular variety, 4-state linear cellular automata, on the Commodore 64 and 128. You may want to use the resulting plots as an aid to academic investigation of the phenomenon; on the other hand, you can just run the program and enjoy the endlessly varying graphics it produces.
The earliest references to mechanical automata date all the way back to the 4th Century BC in ancient Greece and China. and include such artifacts as moving models of birds and animals. Many interesting variations have appeared over the centuries. Of particular interest is the 'magician box' of a hundred years ago: in a curious portent of the computer age, a disk engraved with a question is inserted into a slot in the box. A tiny figure of a magician then comes to life, and poinL~ with a wand to where the answer appears (on a tiny monitor, no doubt!)
r
More recently, the term automaton has been applied to robots and androids, and to other automatic devices that emulate human behaviour. Collier's Encyclopedia extends the tem1 to include computers undertaking such human-like activities as playing chess.
Background
The program, I promise you, will provide some stunnin g By comparison, the cellular graphic images. Unlike other forms of display such as automaton has a considerably abbreviated history. The games or art programs, this Figure 1: Code 1011303003, seed Random one generates graphics intergrand-daddy of modern computers, John von Neumann, nally in the computer, and it Borh red and blue are rapable of asserring rhemselves as selfbegan exploring is amazing that applying a background colours. The re.1ult is a class 2 image witlt replicating automata about simple algorithm can create intricate l'ertical structures. The srable strucwres are esrablished quickly in spite of a random start. Cycle len11ths 1950. His explorations led to such a wide variety of reare 7 and 23. the concept of an infinite sults. These images are more checkerboard and a set of than just prerty faces, however: they have brains, too. So that you can appreciate them ful- transition rules acting on each of its cells, resulting in a moreor-less independent machine that could transmit information, ly, please stay tuned for some history and philosophy. or even duplicate itself. TI1e Encyclopedia Britannica, 15th Edition, lists an automaton as any of various mechanical objects that are re latively A popular implementation of this concept is John Conwa)(s self-operating once set in motion. It notes that automata are invention of the game of 'Life'. This game is played on an designed to arouse interest through their visual appeal. and unbounded two-dimensional grid playing field; if you don't then to inspire surprise and awe through the apparent magic have one of those handy. you can approximate it with some of their seemingly spontaneous movement. Although written sheets of graph paper. In the initial state (that is, on the first with a different application in mind, that description fits this sheet of paper), some cells are 'on', or coloured in, while the rest are 'off', or blank. The next sheet of paper represents the program very well. Transactor
16
May 1988: Volume 8, Issue 6
second generation of this lifefonn, and the ~tate of each cell is indu~trial applications uses a linear representation of its opergoverned by a fixed rule which operates on the fi~t genera- ating ')pace, divided into cells or block~. Vehicle;. are repreuon. A ne"" cell is 'bom' if exactly three of it~ eight neigh- sented a.s 'on' cells. and their progress through the system is boUTh are occupied: an traced through '>Ubsequent generations by a complex set of safety existmg cell survives if rules. two or three neighbours are occupied. In all other cases, the cell dtes of eiThese model~ are fairly direct ther lonelinesl> or overand straightforward: by comparicrowding. The game was son, some of the recent interest at academic leveb ranges from abexplained 10 the public by Martin Gardner in the stract to abstruse. Both Sciemific Scientific American of American and Nulllrt' carried extensive discussion~ of cellular auOctober 1970. By the February 1971 issue, tomata in 1984, by Bnan Hayes Gardner was already and Stephen Wolfram. After 14 able 10 report on a numyears of development, the plots ber of intcre~ting patwere begmnmg to resemble some tern~ and cycles that had of the images you i.ce here. PosFigure 2: Code 0023010110, seed 2 ...3 been developed for this tulated applications included in1ht da.wc Irinll!/lllnr hrn11ching palltm i.\ seen 01 thl' top A new procedure. Because fonnation processing and transseed of2 crc(l(e.\ a !lree11 structure (left). ••hile tl seed of 3 the playing field is cellumission, simulation of crystals, gn·e n h/111' smtcl/lre (right). The col/isin11 area is marJ..ed by and a betler understanding of bilar. and because each cell red dendmic mlfltfinns. and blue pre~·ai/s a\ tlrr prttlnmmant ological proces<,e;. (which are behave' autonomously ~tructurt•. once set m motion, the based on mtllions of cells each following '>imple rules, after all). Beyond thi'>, '>uggestion tenn cellular automata "'as coined. that cellular automata could be applied lO model languages Linear Cellular Space could onl) be described as metaphysical at be~t. In December 1986, Kenneth Perry presented an algorithm in Bytr magazine Of course, many differem sets of rules could be developed for computer display of linear cellular automata, with a more and applied to Conway's game - different neighbourhoods, realistic main objective of creating graphics. multiplc-stmc cells, and so on. Gardner also touched very briefly on a one-dimensional variation of cellular space, used The linear algorithm creates a display on a htgh-res screen. The first row of pixel in hi~ application to identify a palindrome. I Iere the initial ceUs represent\ the initial Mate occupy one line of the graph paof the celh. each of which can have one of per: ~ubsequcnt generations are four value~. 0 through 3, usually plotted on successive line\. Thi~ results in a tworepresented by different dimen\lOnal plot in which each colours. A\ the array generation\ data is linear, and evolve~. a new cell's the second dimension (down the state is determined by its page) ill time. three parents - the cells immediately above. above left, and above Cellular automata inhabit a simright. These three are plified umverse 111 which space is added, resuhmg in a sum reduced to an array of cells, and ume become~ a <,erie~ of discrete from 0 to 9. Figure 3: Code 00230101 I I , seed 3 113 \lep~. Thi'> degree of abstracuon The characteristic signapcnnits modelling to tale place, Onl) a single digit has been added Ill the mtle in photo 2, yet ture of each automaton b and automata do closely resema much more compte.\ ima!le result,\ . This includes a contained in itl> inheri- . ble a number of modem computtwo-colour background a11d 1111111erous short-cycle structures. Add1tio11al symmetrical pal/ems nf cnnsiderah/e complexity tancc rule, a ten-digit er applications. Computer chess are IJI'erlaid. code that governs the was prcviou~ ly mentioned, and evolution of cell\. Each of course it is played on a 'bounded 2-dimen\ional cellular space'. or checkerboard. digit in the code corresponds to one value of the sum, the first Some other comparisons are linear. such a\ milroad block digit repre'ientmg a urn of 0. the second a Mlm of I. and so control and computerized traffic ~ignah. Each of these major on. For example, if the parent celh have values of I, 3. and 2. Transactor 17 May 1988: Volume 8, Issue 6 ~------------------------------------------------------------------~
then the sum is 6. With a prevailing rule of '0 120123123 '. the new cell gets a value of 3. As subsequent generations evolve, a two-dimensional plot is created on-screen (remember that the second dimension is time, nor space). The Program
I promised we'd get to this eventually. and here we are. The
program includes considerable improvements over previous incarnations, probably the most important of which is speed. lt is fairly easy to write a BASIC program to implement this linear cellular algorithm. particularly in BASIC 7 .0. There are 200x 160 multicolour points to plot, however, and about a dozen calculations for each, so the plot takes well over 15 minutes. With all the peeks and pokes of BASIC 2.0, it would take much longer. No wonder the pace of scientific progress can be so slow! Watching a universe unfold at this rate generates suspense that would make Alfred Hitchcock proud, but it is not conducive to productive research. The solution in this case is machine language, which plots the screen in less than four seconds, a considerable improvement. The program includes a number of other features. You specify the code and the seed value for the initial generation. If you wish, either can be supplied randomly. If the plot is developing nicely, you can continue it for another screen. For when you get it just right, a simple screen dump is included.
more selective, the procedure is different for the 64 and 128. On the 64, you enter a value for one byte, I to 255. This byte will be poked into position on the first row, representing 4 cells. If you enter I, then a single cell with that value is created. A value of 255 creates 4 adjacent cells each containing 3. You also supply the column for this byte, Ito 40. On the 128. the seed is much more flexible. You enter a string of cell values, each 0 through 3, up to 160 digits if you wish. You also enter a pixel position 0 to 159, with 79 suggested as approximately the centre. All the cells are plotted, starting where you specify. The Menu
As the image is drawn, 200 generations of the automaton arc revealed to you. There will be a short pause to view the result, then a menu will be printed. To make a selection from the menu, just press the key shown (don't press return): S (new seed) You will be returned to the prompt for the seed for the first generation. The image will then be redrawn with your new seed and the same code.
R (r andom seed)
Figure 4: Code 0103220121, seed Various
Random cells will be created for the first generation, and the plot will be redrawn with the same code.
Seed is selected to generate a 1â&#x20AC;˘ariety of propagating strucwres. This code supports a variety of angled and \'ertical structures; one diagonal also spawns new verticals. When diagonals reach an edge or other obstacles. nlley may be llbsorbed, reflected, or generate other structures.
M (mor e) The same evolution will be drawn for another screenful ( 199 more generations, since the last line will become the first one displayed on the new screen).
Before you can enjoy these features, you will have to type the program in, choosing the 64 or the 128 version. Be sure to save a copy to disk before running it. Two special notes apply to the 64 version: this program modifies some pointers, and should not be saved after running. In addition, because the machine code follows BASIC, be careful not to add to its length when typing it in.
C (new code) You get to enter a new 10-digit code, followed by a new seed value. The new plot will then be drawn.
When you run the program, it starts by giving a brief description of cellular automata, and some instructions. While you are reading, the machine language is poked into memory. The program uses the digits 0, I, 2, and 3 to correspond to black, red, green, and blue respectively. Your first input is the 10digit code for inheritance, each digit being 0 to 3. At startup a sample code will be suggested, so just press return to accept it. In subsequent loops the previous code will be printed, which you can accept or replace with another from the table.
P (print) The current image will be sent to your printer, unfortunately not in colour.
The next input is the seed value for the tirst generation. Just press R and return to get a random seed. If you want to be
Q (quit) End the program.
Transactor
A (automatic) Auto-pilot! Make this selection, and the computer will choose both random codes and random seeds. Random automata will be displayed one after another, every 4 seconds, until you press any key to get back to the menu. â&#x20AC;˘
18
May 1988: Volume 8, Issue 6
chaos, others start from a random condition and qutckJy establish order. Still others seem to symbolize the eternal struggle between good and evi l, never quite resolving their ultimate personality. But then, of course, we should limit our!>elves to discu~ston of their scienltfic merit.
Any alphanumenc key not listed here wilt return you to the graphic for a few more second'>, following which the menu will return. T he Screen Dump Since it is impos'>ible to anticipate all printer and interface combmations, thts program is designed for a Cardco interface and Gemini, Panasonic, or Roland printer - popular combinalton~. It wilt \\.Orl unmodified with many other !.Y!.terru.. If it doesn't worl right at liM, you may be able to make some ad justments:
The images defy ca::.y classificatton. With 4 value'> for each of I0 digits, there arc 4g I Oe, or 1,048,576 possible codes. Many of these turn out to be trivial, but moM produce usable results. Wolfram d" ides the pauerns into four general groups, according to their performance after many generations:
• Set the interface for transparent graphics mode, no line feed. Ltne 490 give~ a !>econdary address of 5 to achieve this... change it to suit your interface if necessary (eg the Tymac need!. a 6).
Class I automata produce plots that very quickly die out, and arc basically of no tnterest.
Figure 5: Code 0100132332, seed Random
• Two commands in the program are 27,65.R to ::.et linefeed LO Sn2 inch. and 27,75,64,1 tO call for 320 grJphic!. character!.. If your printer uses different codes, change these values in line 1210.
A random .veed produce:.
'"ery disrina re(!imes rluu coexisr side-hy-side. This pallern is srable and n mainrained rlzrou~h mum Rt'nerarions. Repeririw• ,-errical \/rue lllfes are I ~~so mpporrt'd Thert• is a ~:radual ll'lldency Ill reduce the Ltmbtr of dtstinct :ont's. an maeau in em ropy.
• If after all this the printout i'> double-spaced, change the DATA item 10 to a 1ero in line 12 10.
/11'0
Class 2 code~ quickJy evolve to very stable structure!., moM ly stripes and cyclic structures, regardless of thetr starting configuration (of very linmed intere'>t).
Clas!> 3 automata produce patterns that appear to be chaotic (but note they are not random!). These '>tructures typically grow indefinitely.
• Tf your printer i), one of those tJ1at print each row of graphic'> up!>ide down, change the value 118 tn line 1230 to 54.
I
Clas' 4 codes have a complicated balance so that they neither grow indefinitely, nor contract and die. They generally include complex structures that are C) chcal 10 nature, and often propagate across the field.
• Finally. if you Mill have a Commodore I 525 or such... my condolences. However, you wiII see listed some replacement lines to get a printout.
Perry considers only Class 4 to be worthy of further mvestigation: certainly the..e code!. offer ample latitude for experimentation and mathematical study, lending themselves to considerable formalization of their structure. However, per'>onally 1 The Results Fig art 6: Code OJ10133232, seed 331...1...133 find that Class 3 automata offer Thi.f codt is only sltj~lttly changed from phoru 5. The at leaM as much potenttal for exAft I hope you can infer 11/tu•-ween rl'gimr has a l't'l)' diffaelll chnrocter as a rrsulr. from the accompanying ploration. One Clas!. 3 code will cmtlnow supersedr.1the red area in only 2-300 generat1011.1. illustrations, the graphics often !>Upport ~everal different patterns: depending upon seed tmages arising from these automata can be amazingly beautiful. With mmor adjust- values and boundary conditions, the results rna) range from ments to the code, you can get images that are 'imple. com- h1ghly ordered structures, to seemingly random textures, to plex, bright, !.Ombre, or confounding. While some decay to cellular battlefields where rival patterns fight over territory.
Transactor
19
May 1988: Volume 8, Issue 6
Because of th1s variety, in fact, it becomes very difficult to place these automata definitively into one category or another. For this reason. I am inclined to group them further according to the types of panern observed, although even this is not always definitive. The table g1ves a number of examples of different re~ults.
with ~o many automata. These are the minimum requirement~ for the branching to occur:
The Source Of Patterns
Since the digits marked 'x' don't matter, it is apparent that there are many codes supporting this pattern. at least 4096 for each colour. Many of these will support other ~tructurcs as well. leading to some interesting dual pauerns. It i~ also clear that the green and blue patterns can co-exist with one another (10 the form Ox230x0xx0). Figure 2 use~ this approach. adding a touch of red where the two Mructures collide.
You will have more success creating images with a little observation of how patterns are generated. The fi~t digit of the rule governs the background: it is commonly a Lcro. cau~ing blad. to prevail as background. If a different digit appears. then another colour will be generated. In order for this second colour to be sustained as the background, however. it must also be able to inherit from itself This requires that sums of 2 and 3 umes the background colour also produce the same state (e.g. for green to prevail as background, the digit 2 must result from sums of 0, 4, and 6): sum values blacl- bacl.ground red background green background blue bacl-ground
01234 56789 Oxxxxxxxxx lxllxxxux 2xxx2x2xxx 3xxux1xx1
It i'> apparent from this that red i!> at lea\t partly compatible
wnh the other colour backgrounds. so code~ hke I011303003 will result in red and blue duelling over bacl-ground rights. Blue wins in this case, but because of the fine balance between the two, a Class 2 image is created quickly from a random seed, with red \tructure' of cycle length 7 through 23 sustained on a blue bacl-ground (see figure
red triangles green triangles blue triangles
OIOOxxxxxx Ox2x0x0xxx Oxx3xx0xx0
Complex Patterns Greater complexity can be introduced through at least three measures. The first of these is the rule itself, and many examples arc given in the table. Once you become familiar with the operation, you will probably want to try creating your own rules: for example, adding a single I to the simple code of figure 2 produces the complexity of figure 3. Second, there is the seed, or first generation. The program will suggest starting with a single cell 1n the centre, but you can choose seeds more spec1fically 1n order to draw our special feawres from an automaton. In the alternative, a random seed will usually display many of the capab1h11es very quickly, and introduce a great deal of complexity in the process.
The third form of complexity is somewhat artificial, and that i-. the border condition. In principle at lea<,t, the automata \hould be viewed on an inlinne field. Our screen is I ). considerably less than infinite, being 160 pixels wide, The simplest spreading patso some mathematical imputerns are those in which a rity is mevitably introduced. single colour propagates itDifferent pattems react to the self; for example, if the digit border in different ways: the I appear~ in the code corretriangular pauerns we have sponding to a sum of 1. then Figure 7: Code/031 102332, seed 1 I seen simp!)' stop there, but red will spread across the This automamn supports a "ide mriety cif dijfert'nt pauerns even thb alters the overall field 10 both directions at a and \lfllftUrts. 8/ac/.. stripes. wandcrmg red pauems and pattern. As shown in figure 4. rate of one cell per generablul' grl'tll triangles all compttt¡ for ttnitm)â&#x20AC;˘ No clear some pattcms will bounce or tion. This IS the fastest rate win!ltr mn be declared after thousands cif genera/tans. otherwise modify themselves that any mformation can be when meeting an obstruction. transmitted, and is generally referred to as the 'speed of light'. Furthem1ore, if teroes are and you can position the seed carefully so as to create specific present for sums of 2 and 3, then a branching algorithm is effects. In most cases, however, the disturbance renecting created. As the pattern spreads from a single point, it grows from the edge eventually serves to tran~mit chaotic conditions branches back in toward the centre. As these meet. sums of right across the entire field. This is a primary source of disortwo and three are created, and the1r 1erocs guarantee that the der in Wolfram's Class 3 automata. branches will cancel one another out. This results in the characteristic triangular pattern seen 1n photo 2. and occurring In theory, th1s disturbance could be 3\0ided by establishing a
Transactor
20
May 1988: Volume 8, Issue 6
p-.eudo-playing field in memory. much wider than the screen. A field v. idth of. sa). 1000 paxels, v.ith only the centre portion copaed to the screen, would not be a burden on the computer's RAM. This approach would pennit most pattern~ to be followed for at least 800 generations before a renection moving at the !>peed of light could return to the visible area. (This exercise is left to the reader!) It j., aho left to the reader to explore the many patterns con-
tained in the table. as well as the million or so other possibilities. I will ju!>t express my pcr!.onal fascination with the many automata having two distinct regime!>. of which figure 5 is but one example. Sometimes these regimes coexist peacefully sade by-side; some fight bad. and forth, po!>sibly producing a victor; sometimes one pa11em gradually infuse!> the other, ruther hke 'invasion of the body-snatchers'. Each is unique and fascanaung.
Figure 8 ("Stingray"): Code OJ10310301, seed 22
In Conclusion...
A .1preading blue line spawns blue bars, which 111 turn gil·e nse 10 a red triangular pallern This pallem is trrminated by the edging, gi1•ing rise to this charaaeristic slwpl!.
TI1e patterns produced by these automata can be both fascinating and beautiful. Their beauty is more than skin deep, however, as they are valid mathematical phenomena in their own right. This program v. ill offer you hours of experimenting and promi'>e'> rewarding result'>, whether your interest IS academic or otherwise. Send in your beM results: I'd be very interested to o;ee what you come up with. And when you get tired of all that intense experimentation... put the program on auto pilot, relax, and enjoy the video wallpaper! As for me, I'm going to try some of these seeds in the garden, to see if I can grow an infinite crop of cellular au tomatoes.
A Table of Sample Rules
Code
Seed (R = Random)
Product
0003232012 R,33 0230210313 II
Chl s~
I (Decay quickly) 031 1302133 ll, R
0201023002 R
extinct
10
a few generation,,
~tructures
33000 I I 033 R 0 I 03002233 I ,R,33 1110330111 R
Class 2 (Organize to stable ~al e) 1011303003 R
organtLCS mto cyclic red \lructure\ on blue (tig. I) 0331122210 R immcdimc fonnation of red & green stripes 0330112233 R evolves to green & blue stripes. vertical red Mructurcs (seed 3) 0102223130 R chaos organizes to striped wallpaper, cyclic paucms (try ~cd I I) 020 1300003 R evolve' to long-cycle multicolour structures 0003111003 R.3.33 red/blue tnangular: broad geometric panerns 2233020233 R,l,ll ice noes . blue/green block~ & pauerns; rapid evolution to stripes 3032112333 R instunl self·organization a~ blue stripes, red/green patterns
0123310203 1,3,11 3333020331 R
0023010111 3,R 022 1213321 R
3
Transactor
metallic crystal structure 10 red & blue. blue/black pauerru.. red top; blue/green stnpes (a palindrome!) red/blue dendritic structure over red/black blinds blue triangles, red/green dendritic structure blue/green diagonal Mructure~> on red/black
C l:t!.S 4 (Complex Structures) 0103220121 R.ll 2221213321 0201103212 200 1313120 0300123302
Class 3 (G rowing, chaotic) 0023010110 2.3. 23
multicolour spreadc~. green/black vertical stripes, evolves chaos blue shapes on multicolour. gradually expnnds for 600+ generations irregu lar red ar~. blue overlay. vertical
0230332101 0210133310 0311301203 0230323130
blue & green triangular. red dendnuc in combmcd areas (tig. 2) complex tratling pattern~ on red & blue wallpaper (tig. 3) blue and green patterns over red blocks. same paucrn. but ordered
0020130211
21
ventcal. angled structure\ (\eeds 22.233023, 10202,2220123; tig. 4) 3,R blue/green vertical & angled structures on red 3,33,R red/green long-cycle s tructures on black R,ll , black dtagonals. red diamonds, blue striped 22,3 background (cover) 1.33.1 01,232.3132,2331 ,etc wide variety of venical and diagonal structure~. pendants 2,22 multicolour pauem, black tnangle\ R,ll,2 vertical & angled structures organia into grid 1,11.22 blue/green struciUres and pendant\ on red R.ll ,232,23303,313,etc wmtery structures. inti II, pendants. etc. 22,2.23, red, green triangular: overlays; vertical 322, 131 and angled structures Moy 1988: Volume 8, Issue 6
02300 Ill 33 1,11; amorphous mulucolour \lructure that may survive or not (from Wolfram) 23 at 100 0120133230 1: ~preading red 'roof', ~pawnmg many vanou~ blue/green ~Lructure~ Clrom PelT)) T"o-regime images coexistence: red triangular; green tri's on blue; venicals (fig. 5) 0110131232 R, non-coexistence of same regimes (fig. 6): 232.etc many variations I 031 I02332 R.I. red stripes, blue/green tnangles, red/black 22.33 dendritic, long cycle~> (lig. 7) 0001231232 R multicolour ha~h: black; long-cycle structures 0321200311 R,22 ,3 green triangular, mfusion of red/blue dendritic 0233100120 R,ll ,22 blue triangular. infu.,ion or red/green dendriuc 100 IJJ021 ~ R.I. red triangles, blue dendritic infu~1on with 2222 green blue, green patches on red stripes. ~enical 1300122313 R,2
0100112332 R
structure~
3303022133 R,33 3100323120 22,1 0120123123 1,202.R 203321020 I I ,33 0132000120 2,3,1, 2003 0033220 II 0 233.22. 222 0103310132 11,22.3 0122022331 R.l,33
blue & green blocks, strong diagonals many black & blue textures; ~>eed I adds green dendritic stanup screen; red/green triangular, blue/black stripes green jumble; red/blue stripes; some vertical structures blue, green triangular pattern\, joint occupancy of space fight for temtol) between blue triangular. green/red herringbone joint occupancy of red/blue wallpaper, black dendriuc structure green/black tnangles: blue/green regime struggles, but loses
Devolution IO primordial chaos 0130312131 I II
strong red triangle pattem, devolves to chaos retains structure, cycle length or 168 (on 64: ~ed 20 at posuionn 19) 0113233102 11,3,33 regular stripel> and patterns, decay to random 0223320100 2,3 blue or green tnangular; green decays blue triangular, l<hes to red/green invasion 0331210300 33,3 Suitable for framing 0 II 031030 I 22 0132320233 1233233320 0332221003 0020133020
stmgray: red tnangular. blue bars and edging (fig. 8). R, ll,33 ice palace: blue blocks, green crystals II,R mach waves: green venical, red/blue stripes, blue waves (fig. 9). 33,1,22 green/red window bhnds, blue/black dendritics; eventually stable II caves: green/red gnd above, blue caves and triangular pattem below
More 0112002100 6201310313 3002110310 3103020001 3102033003 1200020231 2310131211 3011300332 3131120030 3132230102 (seed: 11,22) 0023320 I03 (seed: 11 ,33,R)
1132230002 0233000001 0021233023 3012022322 3201032322 0213131022 3320003011 3320010231 1102023102 (seed: 1,11,2.R) 0111212323(i>Ced: 133 1) 33200 12010(sccd: 13)
• Not~· Seed values ar~ for the 128 11:5 22:10 23:11 202: 34 222: 42 232: 46 1331 125 2003: 131 2222: 170
Hert• are equfl•aleTJis for the 64: 33:15 101•17 131:29 233:47 313:55 322: 58 233 1· 189 3132:222
Lis ting I : "Automata 128" OM I0 rem automata 128 by ian adam EN 20 g~ub 650 CJ 30: GM 40 do:rem mam conrro11oop GK 50: CN 60 prinrtab(6) r$"(up]":input"codc";r$ KG 70 a=5887:for i=l to 10 011 !10 poke a+i,val(mid$(r$,i,l )) and 1 OF 90 next IN 100: LM 110 prim '\eed value l[lefl)[lcfllllefll":·input b$ MP 120 ifval(leftS(b$,1))=0 Lhen 250 D 110 a= 160-len(b$) OK 140 print "po\ltion ( 0 -"a") 79[lefiJ[Icfl)lleftJIIcfl)"::input a MM 150 gmph1c 3,1 CP 160 locate a,O:for i=l to len(b$) NB 170 draw va1(midS(bS.i,l)) and 3.+0,0 El 180 locate + I.O:next CD 190: HK 200 I rap 230:~>ys 5900:rem plot routine GE 210: AF 220 !>1=200 CC 230 fori= I to sl:if peek(208)=0 then next:print"~ new seed r random seed m more":print"c new code a automntic p prim q quit";:graphic 4.,23 II 240 get key b$:print GJ 250 on mstr('\rmcapq".b$) goto 280.:\00,:\40,360.380.490.610 IK 260 graph1c 3:sl=700:goto 230 C1 270: JO 280 graphic 4,23:goto llO:rem new l>eCd GJ 290: II F 300 r=255:graphic 3,1 :rem random seed J I 310 for i=8192 to 8504 step 8 LF 320 poke i,md(i)*r:next:goto 200 OL 330: NO 340 graphic 3:sshape sS,0,199,159,199:gshape s$.0.0: goto 200:rem copy last line c 350: JG 360 graphic 4.,23:1oop:rem next code GO 370: MK 380 gro~phic 3 r=255:do:rS="":rem automatic codel> GM 390 for i=5888 to 5897:a=md(1)*4 CJ 400 poke i,a:rS=r$+chr$(48+a):ne>.t OA 410: HP 420 for 1=8192 to 8504 step 8 JC 430 poke i,md(i)*r:next:rem l>eed MC 440: BB 450 l>Y~ 5900 AE 460: CJ 470 loop until pcek(208):poke 208.0:goto 230 EF 480: PE 490 graphic 3:open 4.4,5: rem secondary address= 5 for graphic\, no line feed AC 500 aS=chr (I O):cmd 4:pnntaS:sys 6060:pnnta$ LG 510 printchr$(27)chr$(64):rem reset KG 520 pnntaSchr$( 14)"code: "rSaS Bl 530 pnntll.t:close 4:goto 230:l>crecn dump MM 600: GB 610 graph1c O:end AO 620: PK 630 :rem ,ran-up sequence EP 640: OM 650 bank 15:color 0,1 :color 1,11 :color 2. 14:color 3, 1'i:color 4.1 lA 660: EC 670 pnnt"[clr)[white] cellular automata for the 128 PG 680 print"[down]this program create~ ~omple' GL 690 print"geometric artforms on the ~creen.
Transoctor 22 May 19&&: Volume 8, Issue 6 ~ ----------------------------------------------------------~--------~----~
OH 700 pnnt''the tmage is generated line-by-line, OJ 710 prim"according to these rules: FD 720 print"( down I[ yell a pixel has a colour value of 0, I ,2,3 PH 730 print"- the values of 3 adjoining pi'(els FF 740 print" in a line are added. DG 750 pnnt''- the sum (0 to 9) is used to select a KG 760 pnnt" new colour from the code you specify. ME 770 print"- this new colour i\ plotted ar, the MB 780 print" pixel in the line below. LG 790 print"- the code ha' 10 digits. corresponding AC 800 print'' to the 10 value~ of the sum (0 - 9). PD 810 pnnt''(down](wht(automata were tntroduced in scientific JM 820 print"american in 1971 & 1984, nnd a version PO 830 print" appeared tn hyte maga7ine tn 1986. thir, GO 840 pnnt"enhanced vef\ton for the 128 "'by LH 850 prinJ 'ian adam & uan,actor magume. 1987. DE 860 if peek(5900)-160 then gosub 1100 DO 870 print"[down]tycl) press a kcy!":getkey a$ EO 880: MA 890 print"(clr][down] tn~tructions: DC 900 print"(down)(wht]>ou enter a 10-digit rule, using only ~ 910 print the digib 0. I. 2, and 3. EB 920 print"[down]next, enter a seed value, which Dll 930 print"is plotted a.' the top line. AN 940 print" if you enter r. a random seed as used. HP 950 print af )OU enter \ccd number;, you must G.\ 960 print"also ~upply their position on the line. DA 970 print"[downlfyel)aftcr plotting, pressNO 980 print" s to enrcr a new seed NM 990 print"- r for a random seed CB 1000 print"- m more of the ~e plot LF. 1010 pnnt'- e enter new code OL 1020 print''- a automatic code generation DM 1030 print"- p send pattern to printer 13C 1040 pnnt"- q to quit. J B 1050 print"[down][whl(the current code will be printed like HC 1060 pnnt"thas. make an) changes. & press return:(dov.rn} FA 1070 r$="0120123123 F.F I080 return GL 1090: EM II 00 for i-5900 to 6132:read a:poke i.a next CH lliO return F.N 1120 ¡ OA 1130 data 160. 32. 132, 251. 132. 253, 160, I PK 1140 data 132,252, 136, 132,250, 162, 199, 134 EA 1150 data 166, 162. 39, 134, 167. 132, 169, 177 OL ll60duta 250, 133, 168. 165. 167.240, 4. 160 KM 1170data 8,171.250, 10, 38,168, 42,38 DN 1180datu 168, 42. 41 , 3. 133, 170, 160. 4 KA 1190 dma 169, 0, 38. 168, 42, 38, 168, 42 IN 1200data 72.101.170,101,169.170,165,170 CE 1210data 133,169, 104. 133, 170, 189, 0. 23 HN 1220 data 6, 254, 6. 254. 5, 254, 133, 254 ~ 1230datll136, 208,221, 145,252, 24, 198,167 CH 1240 data 16, 40, 162. 2, 181, 250, 41, 7 KP 1250 data 20 I, 7. 240. 15. 56, 181, 250. 233 AM 1260data 55, 149,250, 181,251.233, I, 149 PP 1270 data 251. 208. 6, 246. 250. 208. 2. 246 08 1280 data 251,202,202, 240, 223, 198, 166,208 DB 1290 data 144, 96, 162, 2. 181,250, 105, 8 NH 1300 data 149,250, 144, 3, 246.251, 24,202 IC 1310data202,240,241, 76. 35, 23, 27.65 KL 1320data 8, 13, 10, 27. 75. 64. I, 0 KK 1330 data 160, 32, 132,251, 160, 0, 132,250 NM 1340 data 160, 25, 132, 252, 160, 0, 185, 162 PB 1350 data 23, 32,210,255,200, 192, 9, 208 JP 1360 data 245, 160. 40, 132,253, 160, 7. 177 FG 1370 d:ua 250, 162, 7. 42, 118, 166,202. 16 HM 1380 data 250. 136, 16.243. 169. 7. 170, 56 Transactor
KF 1390 data EM 1400 data 80 1410data FB 1420 data U~i ng
I0 I. 250, 133. 250, 144, 2, 230, 251 181. 166, 32, 210, 255. 202. 16. 241! 198,253,208,217, 198,252,208. 196 96
2: "A u toma ta 64"
KM CC CJ LH GK CN KG DH OF IN LM CG L:-.1 PH GL EB JP IC PL MN DF GN NG PF CL Ll DD
10 gosub 650 20 automata 64 by ian adam 30: 40 : main loop 50: 60 pnnttab(6)r$"(up]":inpot"code";r$ 70 a=5887:for i=1 to 10 80 poke a+a,val(mid$(r$,a,l)) and 3 90 next I 00 : 110 print "seed value lllehj[leftl!lellj";:anput b$ 120 if vul(b$)=0 then 250 130 print "position ( 1-40) 20fleft][leftJ[left}[left]";:mput a 140 gosub 540:for i=8192 to 8504 Mep 8:pole i.O:next 150 poke Rl84+8*a,val(b$) and 255 160: 170 sys 5900 180: 190 for i"'O to 999:if pcck(l) then 240 200 ne).t.gosub 590:prinf'm more of thas p print tha'> 210 print"~ new seed r random seed 220 print"c new code a automatic codes 230 print"v vie\\- plot q quit"; 240 ""a at k,7:get bS 250 for i=l to 7:if mid>( \rmcapq",i,l) <> bS then ne~t 260 on 1 goto 290,310,330,370,390,490,610 270 go~ub 540:goto 190 Ml 280: FE 290 gosub 590:goto IIO:new seed AK 300: CK 310 r=255:def fns(x )=md(x)*r:goto 340:random seed EL 320: FM 330 r=7687:def fns(:<)=peek(r+x):rcm copy last line HK 340 for i=8192 to 8504 step 8 HE 350 poke a.fns(i):next gosub 540:goto 170 MN360: CG 370 gosub 590:goto 60:ncw code AP 380: MO 390 go~ub 540:r=255.for j=O to I :rS="":rem automatic CO 400 for 1=5888 to 5897:a=rnd(1)*4 FK 410 poke l,a:rS=rS+<:I\rS(48+a):next IB 420 : KA 430 for 1=8192 to 8504 step 8 DB 440 poke 1,rnd(l)*r:next GD 450: LB 460 sys 5900 BC 470 j=peek(k):next:poke k,O:goto 190 EF 480: GK 490 gosub 540:a$=chr$( IO):open 4,4,5 :rem 2nd addrs grafix. no If EF 500 cmd 4:sys 6060 OD 510 printa$aSchr$(14)"eode: ''r$aSaS JM 520 print#4:close 4:goto 190 Gl 530: LN 540 if peek(v)=59 then return MC 550 poke v,59:poke v+5.216:poke v+7.24:rem hare~ PP 560 pnnt"[home)[lt. blue]";:for i=l to Ill :print "[ rvs )---------";:next DK 570 poke 2023,173:poke 56295, 14:retum:color.. IL 580: IN 590 poke v,27:poke v+5.200:poke v+7,21 :print:retum:text MM600
23
May 1988: Volum. 8, Issue 6
-
â&#x20AC;˘
~ -
LL AO FL EP
61 0 sys 65409:end 620: 630 : stan up
640.
FB 650 poke53280,0:poke5328l.O:poke46,64:clr:k= 198:v=53265 lA KM PG GL KP 01 HF LC KN LF KG ME 01 LG AC PO JM
660: 670 print"[clr][white) cellular automata for the 64 680 pnnt"(downjthls program creates complex 690 print"geometric an form~ on the screen. 700 print"the lm3ge 1s generated line-by-line 710 print"according to these rules: 720 pnnt"(down)(yello" l 3 p1xel has a colour value 0.1 ,2,3 730 pnnt"- add the values of 3 adjoining pixel\ 740 print" in a line. 750 print"- the sum (0-9) 1s used to select a 760 pant" new colour (rom the code you specify. 770 pnnt" th1s new colour 1s plotted as the 780 pnnt" pixel d1rcctly below. 790 print"- the code has 10 digits, corresponding 800 print" to the I 0 values of the sum (0-9). 810 print"[downj(whi te]automata were introduced in scientific 820 print" american in 1971 & 1984, and a version PO 830 print"appcared in byte magaLine in 1986. this MF 840 print"enhanced version for the 64 is by LH 850 print"ian adam & tran~actor magazine, 1987. DE 860 if peek(590())-160 then gosub I I 00 PE 870 print"(yellowjpres)> return!":input a$ EO 880: MA 890 pnnt"[clrlldown[ in~tructions: AP 900 print"[down](white]you enter a 10-digit rule, using NN 910 print"the d1gih 0, I, 2, and J. Bl 920 print"[down]next, enter a seed value which HH 930 pnnt"is plotted on the top line AN 940 print"if you enter r, a rd.lldom seed I)> U)>Cd. E l 950 print"1f you enter a seed II, you must NH 960 print"al~o ~upply it~ po~ition on the line. DA 970 pnnt"[downJ[yellow)after plotting, press: 10 980 print"- s enter a new ,e«J NM 990 print" r for a random seed CB 1000 pnnt"- m more of the same plot LE 1010 print"- c enter new code OL 1020 print"- a automatic code generauon OM 1030 print"- p send pattern to printer GM 1040 print"- q quit BE 1050 print"[downl[whllelthe current code will be ~hown like JO 1060 print"this. make any changes & press rerurn:[down) FA 1070 r$="0120123123 MK I 080 goto 60 GL 1090: EM 1100 for i=5900 to 6 132:rend o:poke i,a:next CH 1110 return EN 11 20: OA 11 30 data 160, 32. I 32, 251, I 32, 253, I 60, I PK I 140 data 132,252, 136, 132.250, 162, 199, 134 EA 1150data 166,162, 39,134,167, 132,169,177 OL 1160data 250, 133, 168, 165, 167,240, 4. 160 KM 1170 data 8, I 77. 250, 10, 38, 168, 42, 38 ON 1180 data 168, 42, 4 I. 3, I 13. 170. I 60. 4 KA 1190 data 169, 0, 38, 168. 42. 38, 168, 42 N 1200data 72. 101, 170, 101, 169, 170, 165, 170 CE 1210data 133, 169, 104. 133, 170. 189, 0, 23 HN 1220 data 6, 254, 6, 254, S, 254, 133, 254 NP 1230data 136,208.221.145.252. 24,198.167 CH 1240 data 16, 40, 162, 2. 181.250, 41, 7 KP 1250data201. 7.240, 15, 56.181,250,233 AM 1260 data 55, 149,250, 181.251.233, I. 149 PP 1270 data 251, 208. 6, 246, 250, 208, 2, 246 OB 1280 data 251, 202, 202, 240, 223, 198, 166, 208 DB 1290d3ta 144. 96. 162, 2. 181,250. 105, 8 Transoc:tor
NH 1300 data 149. 250. 144, 3. 246, 251, 24, 202 IC 1310data202.240.241, 76. 15. 23. 27.65 KL t320data 8, 13. 10, 27. 75, 64, I, 0 KK 1330data 160. 32,132,251.160, 0, 132.250 NM 1340 data 160. 25. 132,252. 160, 0. 185, 162 PB 1350data 23. 32,210,255.200.192, 9,208 J P 1360 data 245, 160. 40. 132.253. 160, 7, 177 FG 1370 data 250. 162. 7, 42, I 18, 166,202, 16 HM 1380 data 250. 136. 16.243, 169, 7. 170. 56 KF 1390 data tOt, 250, 133,250. 144, 2, 230,251 EM 1400 data 181. 166, 32.210,255,202. 16,248 BO 14 10data 198,253,208.217. 198.252.208. 196 FB 1420 data 96 L isting 3: " Lines for 1525" GA GL GM CF GP IB MF KP CB OP
I rem tines for 1525 490 gosub 540:a$=ehrS( IO):open 4,4:rem cbm 1525 1100 for i=5900to6134:read a:poke i,a:next I3 I0 data 202, 240, 241. 76, 35, 23, 13, 8 1320 data 0, 0, 0, 0. 0, 0. 0, 0 1350 data 23, 12, 2 I 0. 255. 200, 192, 2, 208 1370 data 250, 162. 7, 42, 54, 166,202. 16 1400 datu 181. 166, 9, 128. 32,2 10,255,202 1410 data 16,246, 198.253.208,2 15, 198.252 1420 dmu 208. I 94, 96
Lis ting 4:
" a utomata .~rc"
KB tOO ; ............. ,.,.,.,.,.,.,.,.,. I 10 ; •• •• I 20 ; •• cellular •• I 30 ; •• automata •• 140 ; •• •+ ~ 150 ; •••••• G B 160 : AC 170 ; KC 180 ; PN I 90 : geometric computer CN 200 ; anforms IE 210 ; HP 220 ; for the PO 230 : commodore 64 & 128 GG 240 ; AA 250 ; by ian adam GL 260 ; vancouver be El 270 ; LD 280 ; march I 987 IJ 290 ; C K 300 ; • FB 3 10 ; the sc reen image i<, plotted I CM 320 ; line at a time. C(tch pixel PJ 330 ; depend~ on the sum of the 3 NJ 340 ; pixeh above, using a preset FH 350 ; code supplied by the user. ON 360 ; =$a6 ;8 bytes temporary JC 370 zp GM 380 rows •$a6 FB 390 column =$37 OJ 400 bi~ =$a8 El 410 avat =Sa9 lK 420 bvat =Saa KF 430 3dread =Sfa ;read addre\s JF 440 3dwrit =Sfc ,\\-rite address MO 450 output =Sfe MA 460 ~n:en =$2000 11 470 bsout =$ffd2 GF 480 : :same for both MN 490 •= S I700
MJ PH PL KL
24
•* ••••••••
May 1988: Volume 8, Issue 6
:
'
KG CG lA lJ GO EF CB TG OA EM BI L'l AE MO NN HM DG FC KI NG BM
MD EK
DK KF TA
OG
500 510 520 530 540
S50 560 570 580 590
600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830
GB AB 1\11 JC OE LP EL OF 840 I'vt 850 JN 860 'vtN 870 ME 880 MD890
·=
codes
*+10
.•
BB CL HJ GM IC OE
;these are the rules : for plotting pixels ( 10 bytes)
••••••••••••••••••••••••• • •• ; · • 'tan plonang here •• •• • .••• .......... ••••••••••• .• •• ••
co
..
·= •
PF BM GH BC
:friendly address (5900)
$170c
•
F1
: 'iel up poantef\ . • ldy #>screen sly adread+l • \1) adwrit+ I ldy #$01 "Y udwrit dey My ad read
JL
•
•
ldx ll$c7 SIX rows
KJ TK
:set addresses
NF KC NC HA MD EO IJ DB CA DL HL AC
:write 10$2001 :read $2000 ; 199 rows to do
; setu p for each row Murtr
.•
ldx 11$27 'I~ column
:40 bytes per line
OI
ED PO TE CF BD Ml AH MA
: aval as paxel above & left • bval reprcsenh paxel above ; eva! as pixel above & nght
.•
sty aval
:aval =0 to stan row
: prepare one byte at a time
El
.•
SIUTIC
PH U PF LM DO JL 1D EN GF AE EN CJ PI HJ BO DE
Ida (adrcad).} :get byte above \Ia bit'
KP 900
TP LH CP NO BA BE IL Gl EF PE FL PO MH LG AK
910 920
KJ
1060
Pl FA EE JC DN DA GP KO CA OP GF AH
1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180
930
940 950
960 970 980 990 1000 1010 I020 1030 1040 1050
Transactor
Ida column beq ~el hi ;note: "-C need the fir~l pixel :from the next byte 10 the nght. ;to be cvol for the 4th paxel of :tha~ hyte. on the last screen ;block of n row, counter 'column' ;wall he 7Cro. in th i~ case. ;u 0 wall be put into vuriublc ;eva! for the last pixel in the :row. af not the laM block. then ;get a paxel from the next block: ; ldy #8 Ida (adread),y get! st
.
as! rot rot rot rot and
oc LF PB FP GF FM LK EK OH NH
a
bits a bat\ a 113 Mn bval
;extra pa"tel into bits :and Isl paxel roll~ :into a. lhen ;.. .into bval
MJ
CB GK OB KL KK
•
, pixel loop for one byte
. •
ldy Il-l P'-loop Ida 110
:-1 pi "tel~
25
11 90 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 13-10 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820 1830 1840 1850 1860 1870
rot rot rot rot pha
bits
;get one pixel
a bits a ;th~
pixel i> cval
ade bval adc aval lOX
:form 'um of 3 pixels ;(carry is clear)
Ida bval Ma aval pia :.ta bval
:shift records over
; :get eva! back
; Ida us! as I ora SIU
codcs,x output output output output
dey bnc pxloop
:get new colour value ;make room in byte, & ;put pixel in stream ;move to next pixel
: fina~hcd paxel loop for ; byte, so ou tput the resuh: ; sta (udwrit),y ; : update addrc:.ses: : ck ;where on screen'l dec column bpi oldrow ; : here bccau..e end• or ro"-. 'o : : update poamer~ to 'tan ne"tt ro": ldJt #2 :do adwnt first newrw I Ida adrcad,Jt and #7 cmp#7 :check if bonom of block beq newlin
'cc Ida
.•
sbe stn Ida she SlU bnc
new! in
:next pixel row, subtract 311 adread,x #$37 adread,x adread+ l ,x Ill adreud+ l.x newrw2
•
adread,x ;if bottom of bne newrw2 ;block, JUSt add I me ad read+ 1.~
lllC
newrw2 dex de" beq newrwl dec rows
;no"' do adread
:ready for next ro~
bne stanr ns . : here becauo;e an middle of ro"' ; \O
move 10 next byte Moy 1988: Volume 8, Issue 6
OM 1880 ; PB 1890 oldrow ldx #2 ;start with adwrit 1900 ; MO 1910 oldrw2 Ida adread,x ;mid column so adc #8 LN 1920 ;move over one byte OJ 1930 sta adread,x FK 1940 bee oldrw3 inc ad read+ I ,x NL 1950 OB 1960 clc JC 1970 MO 1980 oldrw3 dex NH 1990 dex JO 2000 beq oldrw2 ;now do adread jmp startc Ml 2010 ;start next column KF 2020 ; EO 2030 •; KL 2040 ; ************************* AD 2050 ; ** ** Dl 2060 ; ** screen dump here ** EE 2070 ; ** ** 2080 ; ......................... AK 2090 ; FO 2100 rowout ad writ HO 21 10 colout adwrit+l OL 2120 ; JO 2130 messag .byt 27,65,8,13,10,27,75,64,1 CN 2140 ; KM 2150 ; 27,65,8 sets graphics linefccd HH 2160 ; 13, I0 is carriage return & If CK 2170 ; 27,75,64.1 for320 graphics bytes KD 2180 ; change these for other printers EA 2190 OA 2200 ; FC 2210 ; printer is already accessed a!. MF 2220 ; CMD file by BASIC program MC 2230 ; OD 2240 ; BP 2250 *=$17ac ;6060 is a friendly stan KE 2260 ; PF 2270 ; set up pointer OF 2280 ; EB 2290 ldy #>screen ;set screen address JD 2300 sty adread+l JJ 2310 ldy #$00 EH 2320 Sty ad read EM 2330 ldy #$19 OJ 2340 sty rowout ;25 rows to do EK 2350 HD 2360 ; set up for row of 320 bytes IL 2370 ; CE 2380 oprow ldy #0 AH 2390 linmsg Ida messag,y CL 2400 JSr bsout .my KE 2410 DO 2420 cpy #9 NN 2430 bne linmsg OP 2440 BC 2450 ldy #$28 ;output 40 columns AK 2460 sty colout MB 2470 LA 2480 block ldy #7 ;one block of 8 bytes OK 2490 bytelp Ida (adread),y KD 2500 ON 251 0 ; reorient bytes 90 degrees OE 2520 ; KD 2530 ; screen bytes are horizontal PO 2540 ; printer bytes are vertical MG 2550 ; FF 2560 ldx #7
EO DH EA OF fK DP lL OM FB IP EO JI DP CA PI LO LC MG CM PB BJ CF
co
co
•
Transactor
co
GO FL OF FM KL IJ PO MK MF KO KM NJ
co
10 10 MP AD FA KB Kl
2570 rotate rol a ;one bit into each 2580 ror zp,x ; of 8 bytes 2590 ;change rorto rol if your 2600 ;primer does graphics inverted 2610 : 2620 dex 2630 bpi rotate 2640 ; 2650 dey 2660 bpi bytelp 2670 ; 2680 ; move pointer 8 bytes 2690 ; for next screen block 2700 : 2710 Ida #7 2720 tax 2730 sec 2740 ade adread 2750 sta ad read 2760 bee oploop 2770 inc adread+ I 2780 2790 ; output 8 bytes 2800 . ' 28 10 oploop Ida zp,x . 2820 JST bsout 2830 dex 2840 bpl oploop . 2850 2860 ;' update counters 2870 . ' 2880 dec colou t ;next column bnc block 2890 . 2900 ' 2910 dec rowout ;next row 2920 bne oprow . 2930 ' 2940 ns 2950 2960 ; BASIC takes care of unlistening 2970 ; and closing printer tile. 2980 ; 2990 .end
Figure 9 ("Mach Wa ves"): Code 1233233320, seed 11 The background consists of red and blue lines. The repeating green cemral pattern creates a series of blue imerferencc wa1•es rhat create a strong image. The pallem cominues indefinitely. 26
May 1988: Volume 8, Issue 6
CP/M Plus + CoNIX -- CP/M Plus+ A CP/M enhancement with a Unix fla vour •
by Adam Herst • Copyrixht (c) 1987 Adam/lew
The 'Plus' in CP/M Plw. holds the promh.e thatthi& version of CP/M 1s more than JU~t a retread of the time-~om operating ~y.,tem. It suggests the prec;ence of new idea., and enhanced capabilities. But the reality is a mere shadow of the 1deal. CoNIX, an operating ~o.ystcm enhancement for computers running CP/M-80, make~ good on the promise of CP/M Plus. The combination of the C-128. CP/M PILL' and CoNlX proves a powerful combination. The CoNIX package implements a programming em-ironment around CP/M that in many ways surpac;ses thar of CP/M 's supplanter, MS-DOS. Its name sugge<,t comparisons with the popular minicomputer operating sy~tcm, Unix. After working with CoNIX these last few months, I can say that the comparison is apl.
an operating system becau~e " ... it is in total control of all system hardware and software, and all program~ must pass through it when lhey are running." CoNIX replaces the CP/M Console Command Processor (CCP) with the CONlX.COM program. It i~ through this new command processor that CoNTX is able to provide scores of internal utilities, a customi1.ablc u<;er environment, additjonal command li ne functionality, an assortment of variables, and enhanced file managemenl. The CCP provided with CP/M Plus comes with a \mall number of internal or re~ident commands. The CoNTX command processor has over 20 mtemal command&, inc.luding aU the functions provided in the CCP of CP/M Plus. Some of these are: BDEC and DECB
CoNIX is not a CP/M replacement. Instead. it adds functiOil!> and capabilities to the operating system. maintaining compatibility for existing CP/M programs. No aspect of CP/M operalion i'> left unenhanced. New system calls, more command hne utilities, a system level Command Language and a library of utilities written in the Command Language are just some of CoN IX's features. CoNIX was developed and is distributed by Computer Helper l ndustne~ lnc. CHI distributes the CoNlX em. ironment in three packages: the Co IX Operating S)<,tcm, the CoNlX Programming System and the CoNlX Library of XCC Utilitics (XCC is the CoNIX Command Language 'interpreter'). l lowever, the three package~ are intimately Intertwined in their operation and the divi'>ions between them appear to be mostly in name. Nonethele.,s. for the purpol>es of th1s article, the di\tinctioo bet~een the packages ~w be maintained.
CIIR ECIIO EXAM FILL riND FLUSH INDEX MOVE OPT UDfR WRITE ZAP
convert binary values to decimal values and vice versa convert ASCll value.. to hex print the argument~ to \Creen examme memory lill memory lind file in the search path empty the print spooler lind a string in memory copy memory !>et environment option list files through u:.cr areas write memory to a file modify memory
•
You may have noticed a few utilities that perform function-; that have no place in a normal CP/M 'iystem Flu.,hing the print ~pooler? Searching the file path? Setung the environment? All of these arc p<>l>!)ible with CoNI X.
CoNIX : The Operating System The heart of CoNlX is the CoNTX Operating System. Neither of the other packages can be run without it. CoN IX is called
The most powerful of the utility commands is OPT. lr allows the customization of most of the capabilities of CoNTX. (The number of definable feture\ is too great to cover exhaustively
L_~ Tr.: o.:.:. nsoc .:.:.::.:.tor:.___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _....:2.:.:.7_ _ _ _ _ _ _ _ _ _ _ ___:M .:.:.::.:..._19_ o y 8:.:8: Volume 8,
Issue 6
- only tho~e I use most will be mentioned.) A print spooler can be enabled on any d1sl up to the maximum size of the di,k. Printer output b sent to the printer dunng keyboard polling. The ~pooler can be nu~hed and overridden. Other cu~tom11able options include the ~pccification of !.izcs and locations of internal stacks, buffer!> and pointer!>, the location of temporary files and data files used by the CoNTX system, the definitton and enabling of path searching, and the default setting for memory management. These last rwo items deserve further elaboration. Cor>.IX improves on the file manipulation capabilities of CP/M Plu ~ in 1.everal ways. U~er areru. are more accessible - a program many u!>er area can now be executed from any other user area. File location i:, designated with the syntax:
..
D:U/
where D i., the drive Jetter and U is the user area number. The command~ and utilities provided with CoN IX accept tllis syntax for their arguments. allowing access to data Iiles in other user arcus as well as command files.
CP/M, the CoNIX command proce~sor prov1des great freedom and variety in the forms of allowable mput. A particularly useful example is the use of the backsla.,h (\) a\ a mask or 'non-mterpret' character. Th1s allow' all ASCII characters to be entered at the command line. even tho'e with ru.signed special functions. Other examplel> include a variety of character case mappings and data type conversion'>. CoNIX provides a variety of variables, all accessible at the command line. These include: disk-based variables, hexadecimal variables and memory variables. The 52 dbJ...-based variables are referenced a\ Sa to $z and SA to $Z. They are set with the internal SET command and their Yalues stored in a dis!.. file. \Vhen one of these variables is used, the d1sk file is read and the value sub~tituted. These variables each can hold strings of up to 255 characters in length, includmg references to other vanables. The I6 hexadecimal variables are referenced ac; $$0 LO $$F. They are used primarily to pass values to and from resident commands. They are pivotal in the execution of CoNIX Command Language programs.
When a command is issued under CP/M Plus, both the current user area and user area 0 of the default drive, the on I> location'> from "'hich files can be executed, are searched. CoNIX extends the search path to include any drive or user area. Tilere is no linlit to the eAtent of the -.earch. To allow non-CoNlX programs to find their overlay, help and oilier run-time files. a list of file extensions in addition to .COM files can be added to the search. To allow programs to look for their data files in other user area\ in the search path automalic file searching can be mvoked. (This require'\ the data file name to be prepended with a colon, thereby reducing the effective file name length to seven characters.) Finally, me CoNlX environment is equipped w1th an archive manager. ARM.COM. This program collect!> many files into a manageable ~ingle file, reducing disl storage overhead, a major problem with CP/M. Commands can be executed directly from these archives, which can be udded to the search path.
The most interesting (and potentially most useful) variables provided by CoNTX, are the memory variables. Memory variables are referenced b) a $@' "gn followed by a 16-bit hexadecimal address. The content'> of memory staning at that address, and usually terminated by an Fl路 (this, as with so many other features of CoN IX. is user definable), is then substituted. If no address is given, the contents of CoNIX's internal, I 28 byte memory buffer is used. As may have been guessed, the number and size of memory variables are system and application dependent. Through it\ command proce sor CoNI X al-.o prov1des a very rich unplementation of l/0 redirection. In a recent anicle I talked about the PUT and GET commands of CP/M Plus and complained that they were non-standard and 'untrue' implementations of redirection. CoNlX provides true T/0 redirection for both devices and files. Input and output can be redirected, respectively from and to the 'raw' console keyboard, the 'null' device, the console keybo:~rd, ll u-.er defined device, a user defined memory address and u memory 'file', as well a., the eApccted disk file.
Finally. one environment option sets the default memory management level. This option defines the 路level' of the CoN IX program that remains resident in memory. As you ma} have gue~sed from the functionality provided by CoNI.X, n is not a small program - 28K to be exact. U all of the CoNIX program were to remain in memory at all times, it would leave linle room for the execution of other programs. To avo1d this restrictive condition. the CoNIX program has been d1vided mto a number of functional levels. The full 28K is U'>Cd when all of the levels are res1dent. A minimal I/2K is used when the lowest level is resident. CoNIX functionality decreases with the number of levels resident in memory. The default memory management level can be set with me OPT command and individual commands can set the memory management level for the duration of their execution.
In add1tion, printer output can be redirected to other devices. memory files or disk files. A variet) of command-line redirection options are available to control and process the data stream. finally, CoNIX implements command PIPES (the direct use of the ourput of one command a~ the input to a second command), the logical extenc;ion of redirection. II is one of the few microcomputer operating systems 10 do so. CoNIX : The Programming Language Earlier I smd that the divisions between the three packages in the Co IX environment appear to be abirrary. This is most
A' the primary interface to Co IX, and by extension to Transactor
28
May 1988: Volume 8, ls.sue 6
i
pronounced with the divi,ioo between the CoNIX Operating Sy\tem and the Co IX Command Language. The CoNIX Command Language is little more than a programmmg manual and the 'interpreter' to tum CoNIX Command Language programs into .COM rtlcs. executable only under CoNTX. All of the commands used in the programs are available under the CoNIX Operating SyMcm. However. without the manual to tell you what they are. and the XCC program to tum them into runnable form, the~e commands are usele~s. The value of documentation to today's complex programs should not be undereMimated.
II The CoN IX Programming Manual detaib the use of the XCC interpreter. the flow of control commands, the many programming variables (yes, Virginia. there are more variables). the operating system command line options (mentioned onJy in pas<,mg in the Operating System Instruction Manual), the general programming commands, the programming utilities and the added CoN IX ~ystem calls.
tion of two-byte data aoy\l.here in memory. Finally. Environment Variables allow for the testing and monitoring of many system functions. These include: the BOOS error status, the default disk drive, the current user area, the end of file status, the current nest level, the column position of the cursor on rhe screen, the column position of of the last character output on non-screen devicel. and. of course. the eJtit status. Included in the Command Language manuaJ i., a chapter on the more than twenty programming commando,. The introduction to the chapter states that these commands are accessible on the operating system command line as well as in Command Language progn1ms. If you had bought only the operating sy'>tem, you would never know they were there. The programming commands generally fall mto two categoric!> by function: system interface and Mring manipulation. Examples of the system interface commands are: BOOS
The CoNIX Command Language provide!> the facilities of any :.tructurcd programming language. Unlike moM programming languages, which are de!>igned to operate in ~lation, the CoNIX Command Language is designed to interact with the operating system and the programs and commands which run under it. Used simply, the CoNJX Command Language can automate repetitive tasks, similarly to the CP/M Plus SUBMIT command that it replaces. Used to its fullest, the CoNIX Command Language can join disparate and distinct commands and progmm!> tnto ne\1. and unique software tools. The CoNIX Command Language contain!> the no\1. of control constructs expected in modem programming languages. Simple conditional evaluations (AND and OR) are possible. More complex conditional evaluations arc possible with IF-THENELSE and SWITCH constructs. Branching is possible using any of GOTO, GOSUB or WHILE constructs. These command' are accessible only through CoNIX Command Language programs. All appropnate construct!> can be nested (it's hard to nest a GOTO) to a default value of 255 levels. As with most other CoNIX parameters, these values can be individually tailored to suit your needs within the restrictions of your system's resources. Each of the constructs has an associated command to break out of any specified number of nested level\.
FNAME PUSII, POP
The string processing commands are greater in number and include: GETC,GETL ISC, ISN, ISX
LEN SCMP SUBSTR STRIP SUM, SUB TEST
read a character/line from the Mandard input check if a !>tring is a character, numeric or hexadecimal wing. respectively print a string length compare strings return a c,ubstring stnp leadmg character\ from a c,tring add and ltubtract two numbers test two numbers f01 equality
Additional programming utilities, omitted from CoNTX proper to minimize program siLe, arc distributed wtth the CoNIX Command Language. Only two will be mentioned here. Of most general use is the utility program EXPR. an expression analyter. The CoNIX command lnaguage, oriented tOwards string processing, performs only the most rudtmcntary mathematical operations. EXPR can be used to supplement these resources when the need arises.
Construct tests are based on the exit statu!> of commands and programs. OoJy Co:--nx commands and user-written programs designed to run under CoNrx will set the exit SLatus. Only these programs can be ul.ed directly in con!.lntet test!>. However, other methods, outlined in the documentation, exist for the indirect use of standard CP/M commands and programs.
The second utility is MKREL - make a rclocatable program. Relocatable programs are one part of another great tdea from the developers of CoNIX. Using MKREL. and following a simple prescribed methodology, user progmm' can be written that load into and execu1e from any point in memory. Since programs normally load into memory at IOOh. loading a program causes the previou' one to be di~placed from memory.
An assortment of programming variables tS available for use with CoNIX Command Language program!>. Command Line Argument Variables, referenced as $0 to $255, allow the passing of parameters to Command Language programs. Memory Address Variables, referenced a~o $&<address>, where <address> is a hexadecimal memory address, allow the manipulaTransactor
execute a system call or accessible user routine with the loading of registers process a filename into tts component!> push and pop strings onto and off a user-defined stack in memory
29
May 1988 Volume 8, Issue 6
~~------------------------------------------------------~--
To rcpearedly execute a program requires that it be repeatedly loaded from disk. Stonng and executing multiple relocatable programs promise~ a s1gmficanr reduction 10 disk 1/0 and its as~oc1ated overhead.
file display utility, and more. Space constraint'> prevent a fuJI description of these but '>Uffice it to say that many of them singly are worth the pncc of the XCC L1brary package in total.
Supponing the many feature!> of CoNIX are 23 new system cal b. These system calls are documented in the CoNIX Command Language Manual and are accc!>sible to user written programs. From the description of the CoNIX operating system and Command Language, you can imagmc the breadth of the new system calls. I won't list them. Obv•ously, programs accessing these calls will not run under standard CP/M.
CoNIX: The Documentation
•
The CoNIX command~. constructs and uulitic~ described above, along "'ith any U'>er commands or programs, can be brought together in Command Language programs. Command Language programs are ASCil text files, prepared with any text editor, typically with the file extension .xcc. The XCC Command Language Interpreter must be used to tum the \Ource files into eXecutable Comm:md Code, with an extension of .com. Error checling is performed during 'compilation· and a number of XCC debugging opuon'> are accessible through the command line. While XCC programs have a .com extension, they are not hke regular .com files. First, they will not run on a standard CP/M system. Second, unlike standard .com Iiles, X<;C programs do not load into memory to execute. Instead, " ...execution take~ place on disk, with CoNIX reading 128bytc records into an internal area of memory from which the program is proces!>ed". This allows XCC progr.uns to be iC> large as a\ ailable disl space, removing program sue limil'> imposed by system memory. CoNI X: The XCC Libra ry The CoN!X programming environment il. a<; <;ophisticated and versatile as that found on man> mini and mamframe computcn.. Al> such it prc!>cnb. a foreign and potenuall> frustrating environment for new u... crs. The Co;-.m( Library of XCC Utilities, distributed as ready to run programs, include the XCC source code as tutorial examples of XCC programming. The printouts of these programs total over 100 pages and reveal many of the tricks of XCC programming.
Each of the three CoNIX paclages, Operaung System, Programming Language and XCC Libntr), comes with a plastic!>piral bound manual in total almost a rival in !>iLc to the Digital Research Inc. CP/M Plus manual. Chapters are well organi7ed and, more importantly, well written. Concepts arc presented from first principles. Little, if no, prior knowledge of operating systems or programming language~ •'- assumed. Examples abound. Each manual has a comprehen\ive index. A truly professional atutudc i~ evident throughout - a quality all too often lackjng from computer software documentation. If all of the commands and options sound like too big a handful to keep hold of, and the documentation too cumbersome to usc with your hand-. full. on-line help and a simple but effective menu program to configure the Co IX environment are included in the package. These file'> require a lot of dhl !>pace and are best stored in the C-128's RAM di.,l if you expect to receive help in real time. This overhead makes the help systems impractical mo.'.t of the time, but in the first few weeks of using CoN IX they will be the fint tiles you load. CoNIX: The Support CoNIX and Computer I Ieiper lndustnes are an oaJ>is in the CP/M softy.are desen. finding !>upport for most CP/M software packages is an insurmountable problem. Manufacturen. have either gone out of business or (and this i'> the case with the manufacturer of CP/M Plus, Digital Research Inc.) have discontinued support for the product. CoNIX, whose current ver~1on is numbered 22.x. evolves with the computers it can run on. A call to Computer Helper lndu!>tnes (at my expense they do not provide toll free service) yielded a speedy fix to my bug report (U1ey called me back) and the information that a C 128 was now their in house system. (Other ~>urprises, currently under development and spcciftcally for the C-128, were alluded to - I will keep you infonned.) CoNIX: The Search
The functions of some of the XCC utillue ... are wonh mentioning in themselves. U.'.ing XCC programs, CoMX implements a system of hierarchical directorie!> and provides a complement of utilties to manipulate tl1e file system. These include utilities to make and remove directories, list directory paths and file contents. move. copy and link Iiles across dircctones and a shell to process path name\ for other progrJm~. All this is performed through the mampulation of text file.., by the XCC programs. There is an 1/0 overhead from the extra disk access but U1e system performs ~urprbingly well. Other utilities are an interactive file un-erase utility, a utility to do simple formauing of a file and send it to the printer, a
The search for CoNIX will not lead you far. In one of the moM savvy marketing moves I recently have come across. Computer Helper Industries releases the previous version of the CoN IX operating system as share"' arc. This is not a crippled version - it is the full implementation of the previous generation of the software. You are free to use the \hareware package for a period of up to six months; at that time you are a-.led to become a registered user or to de'>troy the package (This was my inu·oduction to CoNIX - downloaded from the CP/ M library of the CBMPRG forum on CIS. It took only two months to convince me to place my order.)
___t_o_ r _______________________________________JO ____________________________~ M~ o~ y_1~ 9~ 88:V~ume8,1~6
L-_T_ ro _~
The co~t of the complete, mo&t recent version of the CoNIX package, including media and shipping via air mail to Canada, was $83.95 US. Various combinations of the CoNIX packages arc available for less. Delivery was prompt, under four weeks, a rarity when ordering by mail. The product was well packaged and suffered no damage in transit.
Two features of CoNIX, Expandisk and BOOS patching, must be disabled during installation in order for it to run on the C-128. The procedure for disabling them i~ clearly explained in the interactive tn~tallation program. Without going into their functions, l will say that I have not nottced them in their absence.
More infonnation on the CoNIX environment can be obtained from: Computer I Ieiper Indu~tries Inc.. PO Box 680, ParkcheMer Station, Bronx, NY, I 0462. (212) 652-1786.
I must admit that the number of system crashes hJs increased ~tnce I have begun to use Co\flX. Thi'> ts to be expected with the opportunities CoNIX provides for the uniniti:ued 10 ride roughshod over their systems. Fortunately, the C- 12R's nonvolatile RAM disk reduces the damage a cra'ih can do and makes reboot\ fast and easy.
You Win Some, You Lose Some Not everythtng is perfect wuh Co~ IX. Most annoying is the loss of even the limited command line editing provided with the CCP of CP/M Plus. A recall-last command command is available but cursor movement commands are limtted to a de!>tructive bad,space - barbaric! A more serious problem b the overhead involved in CoNIX use. The many support files, option Iiles. and temporary ftle~ need lots of d"k storage space. If you arc using a single drive system, CoNI X may be your best reason to buy a second storage device. A high-speed, high-capacity storage device like the 1581 3.5 inch disk drive or the 1571 RAM Expansion (used a~ a RAM disk.) is recommended. If you aren't ready to expand your system to thts C'l(tent, CoNIX iso 't for) ou.
Its faults notwithstanding. I would recommend the CoNIX Operating System to anyone who usc~ the CP/M ~ide of the C-128 with any regulanry. If you are using CP/M as your business sy~tem. or programming for personal or commercial interesL~. you will wonder how you got by without the complete CoN IX package. The redundancy of some Coi\1X capabilities -when run on the C-128, and the superiority of those C-128 capabilitie!> (redefinable keys, function keys, virtual drives, command line editing), illustrate the power of CP/M Plus on the C 128. Howev er, the addlltOn of CoNIX to this team makes for a truly un bearable combination.
UNLEASH THE DATA ACQUISITION AND CONTROL POWER OF YOUR COMMODORE C64 OR C128. We have the answers to all your control needs.
SERIOUS ABOUT PROGRAMMING? SYMBOl. M ASTF:R MULTI-PASS SYM-
NEW! 80-LINE SIMPLIFIED DIGITAL 110 BOARD
OUR ORIGINAL ULTIMATE INTERFACE
Crntt )Our o .. n •utostan dedicated
• Uru-er;aJJy appbcable dual 6S22 \'maule I ntcrfa.:e Adapler (V lA) board. • lndU<triaJ control and morutoring. Grc:ll for laboratory daxa acqui\ltion and instrumental ion aPilhcations. • Intelligently control almO'>I any device. • Perfonn automated tC51UlJ. • Ea.<> to PfOilam >~ e>arcmd} I)OI'erful • Ea.ily Ultcrfaccd to hl(!h·perf011l31l(% \. 0 ..nd
ron troller without rd) ing on dislo. drhe. • Sod.ct for !landard ROM canridge. • 40 scpanue buffered dtgilal output Une; can each directly switch 50voh\at SOO mA. • 40 <;eparatc digital input lillC'< (ITL). • 110 lines controlled throUj!)l Wtlple mcmor) mapped port> each aa:eo..>Cd via a \inile StaJemcnt in Basic. No antcrf~~tt could be ca~ to use. A total often 8-bit pom. • lndudtd M I . driver progmm Ol'fionally called as o 1ubroutine for fast convenient ~~CCC'>~ to individual I/O lines from Basic. • PILJi.'> UltO computer'> o.po.nsion port. ~or both C64 &. <:128. I 0 conncctiOO\ are throuah a pwr of ~Pfll profes.wnaltype strip header.. • Order Model SSIOO Plu•. Onb $119! ShiPJ'II1i paJd USA. Includes c•tcn'i'c documcruallon Wld prosramdisl. Each additional board $109. v-·c talC' Pf1'k an our intnf~ hc\wd dc~:ummuuon ,.nd
>Ofl·--·'"'*"'""'-.cpll>(d) '"' ... crat.t ...-n,,. ordtr n.anun~~
SSIOO l•tua, Ul.
MUll & AOOJtil(>. ilO
NEW ADDRESS~ Ar pnc:estnUS dolt..a.
0 A COO\erttfS.
• Four 8-bat fuUy bidarectionall/0 pon~ & eight hand~hake lines. Four 16-bil timer/counters Full IRQ intcrrupl capability. Expandable 10 four bootrls. Order \lodd 641F22 . Sl69 pastpaal USA Include. e.rmsi-~ docummtation and ~ oo da,k. Each addnaonal board $149. Quanmy pricinga~ailab~. For both C64 and Cl28.
A/ 0 CONVERSION MODULE Fast lfKhannd.8·bll . Reqwresabove. lca,esall VI\ port~ a\11ilablc for bolh C64 and C128 Oni.T \lodd641FIADC0816. Only$69.
SCHNEDLER SYSTEMS
BOLI C OtSASSEMBl.ER. Learn to prosram li~e the experu! Adapt existing progranu to your needs! D~mble> any 6S0216510' undoc. 6SC02· 8502 machme code proaram mto beautiful wurce Outputs source code file« to disk fully compatible with your MAE, PAL. CBM, Dcvclop-64, LADS, Medm or Panther assembler, ready for re-ru.~nably and tdaung. Include> both C64 & (.128 name mode \crsions. IOO"o ma.:hiM code and e"~mely fast 63·p&JC manual. The oriainal and~ i~ now e-en better wath Vcr<.ton 2.1! Ad,anced and wphaslicattd feature> far too numerous 10 detail here. $49.95 poMpaid USA. C64 SOU RCE COOt.. Mo.t complete nailable reconstrUCted, «tensi,ely commented and cro ~·referenced a~~embly lan~uage wurce code for Basic and Kemal ROM~. all 16K. In book form, 242 pages. S29.95 postpaid USA. PT~IO
SYMBOLIC
Ot.BUGGtR ror
C64. An extremely po"'erful tool "'tlh capabllittcS far beyond a ma.:hmdanauage monnor. IOO.paie manual. E\-ential for a~scmbly-language programmer,. $49.95 po~t poid USA. MAE64 •ersion 5.0. full) profe-\aonal 6502.. 6SC02. macro edatortas.emblcr. I!(). page manual. S29.95 po-.tpaad USA.
NEW
Dept. 86, 25 Eastwood Road, P.O. Box 5964 Asheville, North Carolina 28813 Telephone 1-704-274-4646
ADDRESSt •
Transactor 31 May 1988: Volume 8, Issue 6 ~------------------------------------------------------------------~
l
Great Assignment! Easy in-program expression evaluation for the C64 and Cl28 by Paul Durrant
On the .C64, the amount of additional housekeeping required to make this work is minimal. On the C 128, things aren't quite so simple. Most of the difference revolves around the issue of where to place the routine. Let's stan with the C64, first. There are no internal jumps or subroutines in "great assignment.,. so it can be easily located anywhere in memory. On the C64, the tape buffer will work. So will that ever popular area starting at $COOO, and it can even be placed in the BASIC program memory area (if proper adjustments are made to keep BASIC and variables from over-writing it). The program cannot be located "under" BASIC or the Kemal, however, since it uses routines comained therein.
Enter and rtm the following program on your C64 or C 128:
LO input"Enter an arithmetic expression";a$ 20a=a$ 30 print a At the prompt, enter something like '(13+2)*46', or 'sqr(4)' (without the quotes). You get a '?type mismatch error', right? I developed a series of inventory control programs which required entering thousands of numbers. Sometimes they were things like: •'13 dozen plus 5 plus eight-and-a-half more dozen." Not being able to enter those numbers as an arithmetic expression resulted in considerable frustration- and •·great assignment". After enabling this routine (by changing the ERRO R vector... more later), an arithmetic expression in a string variable can be solved and assigned to a floating point variable. The method of use couldn't be simpler: just execute ·a = a$' (or 'item(x) = entryline$(7)', or...). H the string variable comains a legal arithmetic expression, it will be solved, and its value assigned to the numeric variable. An empty string will be assigned a value of zero. And, the routine stays active, even after doing a 'Run-Stop Restore'.
On the Cl28, principles are the same, but location is more complicated. The C I 28's many memory configurations include several that are used heavily by the BASIC interpreter. Moreover, because the new error handling routine must handle all errors, it must be robust enough to take them on, no matter what memory configuration exists when the error occurs. Only the Common RAM (from $02 to $3FF) can do it, and there isn 'l room there for even a relatively short program such as this. The solution involves using six free bytes near the end of Common RAM ($3E4 to $3E9). Thal's exactly enough room to set the desired memory configuration (RAM 0, BASIC and Kemal) and then jump to the remainder of the new error handling routine (which I've placed in the cassette buffer, from $BOO). There's more trouble ahead, though: 'crunch', 'frmeval', and the two routines that save and restore the 'txtprr' require RAM 0, BASIC and the Kernal, but MOVE$ uses routines which leave us in RAM I. BASIC and Kernal. Fortunately, those routines are located in RAM, so "great assignment" can change those routines a bit before doing MOVE$, and then restore them to their normal condition when done. The program listing shows it all.
How it works Normally, trying to assign the value of a string variable to a numeric variable resu lts in a '?type mismatch error'. In addition, the numeric variable is on the left side of the mismatched equation. So, the new error routine starts by checking for that condition (a '?type mismatch', numeric on the left). If this is not the current error, then it jumps to the normal error handling procedure. If this is the current error, then some additional information is available. The error was recognized after finding the addresses of both variables (numeric on left, string on right). "great assignment" uses this information to move the text string into the BASIC input buffer (BBUFF) where CRUNCH can convert the text into executable, tokenized form. Then it calls 'formula.evaluate' to solve the crunched expression and put the result in Floating Point Accumulator #I (FAC #I). Finally, the assignment statement is completed. using the address of the numeric variable which has been waiting patiemly ever since the original error condition. Transac tor
How to use it To enable "great assignment'', you must change the ERROR vector to point lO the new routine. The ERROR vector is in locations 768 and 769 ($300/301) on both machines. Tf you place "great assignment" at $COOO in the C64, then 'poke 768,0: poke 769,192'. If you use the cassette buffer then 'poke 768,60: poke 769,3'. For the C 128 - remembering the six bytes in Common RAM- 'poke 768,228: poke 769,3'. (Or use the Monitor to set $300 to $E4 and $301 to $03.) The BASIC loader programs listed will do everything for you: just run the 64 or 128 version, and start your great assignments! 32
May 1988: Volume 8, Issue 6
Annotated Monitor Lis ting for C-64 •'gr eat assignment"
cOOO c002 c004
c006 cOOS cOOa
cOOd cOOf cOil cOl) c015 c017 c0 19 cOlb cOld c020
c021 c023
c025 c027 c02a c02b c02c c02f c031
c033 c035 c037 c039
c03b c03d c03f
c042 c045 c048 c().t9
c04a c04b c04e
bO 08 bcs eO 16 cpx dO 04 bnc 24 Od bit bmi 30 03 4c Sb e3 jmp a9 00 Ida 85 35 sta a9 02 Ida 85 36 sta a5 64 Ida 85 6f sta a5 65 Ida 85 70 Ma 20 7:t b6 jsr <lB tax bl 6f Ida dO 06 bne a9 30 Ida 9d 00 02 ~ta e8 inx 98 tya 9d 00 02 sta Ida n5 7a a4 7b ldy 85 3d stn 84 Je sty a9 00 Ida aO 02 ldy 85 7a sta 84 7b sty 20 79 a5 jsr 20 73 00 jsr 20 9e ad JSr pia 68 68 pia 68 pia 20 72 ab jsr 4c dO bb jmp
ScOOa ;Check for ; '?type m1~march error'. ScOOa ; with FLPT on left. ; string on right. SOd #$16
ScOOd $c38b #$00 $35 #$02 $36 $64 $6f $65 $70 $b67a
;Normal ERROR routine. :Prime to MOVES contents ; of S vnr to began ; ofBBUFF. :LET erred here with $64/65 ; pointing to header of S var.
;MOVE$. :=end of$ entered tn bbuff+ I. ($6f),y ;(y) = 0 here. $c02b .Branch 1f not a null \Iring. #$30 .Else enter ASCII "0". S0200,x
00b2f 00b32 00b33 00b34 00b37 00b3a 00b3c 00b3c 00b40 00b42 00b45 00b.t8
9d 00 02 e8 98 9d 00 02 20 34 4b n9 ff aOO J 85 3d 84 3e 20 Oa 43 20 80 03 20 cn7
OOb.tb 00b4e 00b4f 00b50 00b51 00b53 00b56 00b59
20 68 68 68 a9 8d 8d 4c
Sta
$0200,>.
: if empty Mnng
lOX
tya Sill
jsr Ida ldy sta
sty j~r
jsr jsr
79 57 jsr pia pia pia 04 Ida b4 03 ~ta bd 03 sta fa 53 Jmp
;(>) = 0 after MOVE.
$0200,x $4b34 #$ff #$01 $3d S3c S430a $0380 $77ef $5779
#$04 S03b4
S03bd $53 fa
;End BBUFF with null b}tC. ;Save BASIC\ TEXlPTR. ;Now set ; TEXTPTR to ; BBUFF- I. :CRUNCH the \Uing. ;Usc CHRGET to ahgn ptrs. :'frmeval' \OI\e' e~tpre\\IOn : (result in FAC #I). ;Restore TEXTPTR. ;Clean the ; stack from the :MISMATCH ERROR. ;and : re"ore "RAM I fctche\" ; to normal opcratton. :Do assignment; carry on.
BASIC loader for the C64 version of "Gr eat Assignment" $0200,x $7a ;Save $7b ; TXTPTR. $3d $3e 11$00 ,Set TXTPTR 11$02 ; to BBUFF. $7n $7b Sa579 ;CRUNCH. $0071 ;chrget (set txtptr to bbuff). $ad9e ;FRMEVAL. ,Clear Mad. ; from ; TYPE MISMATCH. $ab72 ;Restore TXTPTR. $bbd0 :MOVE FAC#l to var.
Annotated Monitor Lis ting for C-128 "great
FB GG KO AB OG LO All EE
BJ LO MO JA 00 OJ CJ KL
I 00 rem "Great A~~ignmcnt" for the C64 I I 0 for x=49152 to 49232· read a 120 poke x,a: check=checl+a: next 130 data 176, 8, 224, 22, 208. 4. 36, 13 140data 048, 3, 76, 139,227,169, 0, 133 150data053.169, 2,133, 54,165.100.1H 160 data Ill , 165, 101. 133. 112, 32, 122, 182 170 data 170, 177, I ll, 208, 6. 169, 48. 157 180 data 000. 2, 232, 152. 157. 0. 2. 165 190 data 122. 164. 123, 133, 61. 132. 62. 169 200 data 000. 160, 2, 133. 122. 132. 123, 32 210data 121,165, 32. I 15, 0, 32, 158, 17~ 220 data I Q.t. I 04, I 04, 32, 114. 171. 76. 2CIR 230 data 187 240 if check<>8575 then print"You goofcd!":cnd 250 poke768,0: poke769, 192: print"OK!"
~ignment"
BAS IC loader for the C l28 \Cr&ion 003e4 8d 03 ff sta Stffi:l :Enable ram 0. 8:1\IC, Kemal. 003e7 4c 00 Ob jmp SObOO .Jmp to new ERROR routine.
()()bOO eO 16 00b02 OOb04 00b06 ()()bOll OObOb OObOd OObOf OOb I I 00bl4 00h17 00bl9 OOb I b ()()bId OOb I f 00b21 00b23 00b25 00b27 00b2a 00b2b 00b2d
dO 24 30 4c a9 85 a9 8d 8d a9 85 a9 85 a.'i 85 a5 85 20 aa dO a9
cpx 04 bne or bu 03 bmi 42 4d Jmp Ib Ida 18 sta 03 Ida b4 03 ~ta bd 03 \ta 00 Ida 37 sta 02 Ida 38 ~ta 66 Ida 70 sta 67 Ida 7I sta 4e 87 J~f tax 06 bne 30 Ida
#$16 SObOl! $Of $0b0b $4d42 #Sib $18 #$03 $03b4 $03bd #$()() $37 #$02 $311 $66 $70 $67 $71 $874e
:Check '?type mi~tmatch error' ; with numeric on left. ;Found? : No: do normal ERROR. ; Ycs: reset ptr to : "temp smng stack· , make " RAM I fetche~" ; return to RAM 0 ; during MOVES. ;Set MOVE$'~ dcsunnuon ; to BBUFF ($0200). ;Set up MOVES'.!> source: ; LET erred with ptr to • ~tuing in S66/67. ;MOVE suing IntO BBUFF. ;(x) holds length of string.
$0b2f #$30 ;Place ASCil "0" in BBUFF
GO KN KJ IH BC £L BD IN FN NE IM MO CE EJ FC FA OM L1 BO NL
110 Nil
100 rem "Great A\\Jgnment'' for the Cl28 I 10 for x=dec("3c4 ) to dcc("3e9"). readaS 120 pokex,dec(a$):check=chcck+dcc(a$): next 130 data 8d, 03, ff, 4c, 00, Ob I 40 for x=dec("bOO") to dcc("b5b"): reada$ 150 pokcx,dcc(a$):check=chcck+dcc(a$): next 160 data eO, 16, dO, 04, 24, Of. 30. 03, 4c, 42 170 data 4d, a9, I b. 85. I8, a9, 03. 8d. b4. Cl:\ 180 data 8d. bd, 03, a9. 00. 85, 37, a9, 02.85 I 90 data 38, a5, 66, 85, 70, a5. 67, 85, 71, 20 200 data 4e, 87. aa. dO. (16, a9, 30. 9d, 00.02 210 data e8, 98. 9d, 00. 02. 20. 34. 4b, a9. ff 220 data aO, 01, 85, 3d. 84, 3c, 20, Oa, 43, 20 230 data 80, 03, 20. cr. 77, 20, 79, 57. 68, 68 240 data 68, a9. 0-t. !!d. b4. 03, Sd, bd. 03. 4c 250 data fa. 53 260 data e4, 03 270 read loS: check=check+dec(loS) 280 read hi$: checl=chcck+dec(hiS) 290 if check<> 9554 then print"You goofed!":cnd 300 poke768,dec(lo$): poke769,dec(hi$) 310 print"OK!"
Transactor 33 May 1988: Volume 8, Issue 6 L---------------------------------------------------------~--
~
--
Give Me A BRK! Invisible subroutines on the C64 and C128 •
by Tom Hughes
I don't think I'd be exaggerating in
fflb ffl c ffl f ff20 ff22 ff25 ff26 ff29 ff2b ff2d ff30
~aying
that BRK is the least used 65xx instruction. In fact, BRK is usually associated with disaster - your machine language program wanders off course, slam~ mto a BR~. and your computer ends up in never-never land. It doesn't have to be this way. BRK can be u~ed to call subroutines that will be ''invisible" to all the 65xx registers except the program counter (PC). In a way, BRK can be used as
ph a Ida ph a Ida sta tSX Ida and beq jmp . Jmp
$ff00
;also save current bank on stack
#$00 $ff00
;and force bank 15
#('f()()()J(){)()()
;current stack pointer to .X ;use it to load old <;tatu<; register ;test the brk bllm the SR
Sff30 ($0316) ($0314)
;if th1s bll = I. then this ;otherwise, an IRQ
SO I05,x
ll>
a BRK
a 6502 equivalent of the 68000's TRAP in~truction. Sifting through the Stack BRKing on the C64 and C l28 The BRK entries above are nearly identical for both machines. So why list both? Well, if you're kmd of fuay on stack operations during an interrupt. then h~ting both will sho-w you exactly how to get at the .A .. X and .Y registers, the SR. and the PC that have been pushed on the Mack - necessary information in order to use BRK effccuvely.
First, let's sec how the Commodore 64 and 128 react to BRKs. When a BRK occurs in the C64 or C 128, the PC is loaded with the vector at SFFFE/FFFF, which al o serves as the IRQ vector. Since this vector se rve~ a dual function, the computer first mu~t determine what son of mterrupt occurred - an IRQ or a BRK. (Yep. BRK i~ an interrupt.) The BRK entrie~ for both machines are listed below:
Notice that the C64 does a 'Ida $0104,x', but the Cl28 uses a 'Ida $0 I05,x '. What's going on? Keep the following in mind:
C64: ff48 ff49 ff4a ff4b ff4<: ff4d ff4e ff51 ff53 ff55 ff58
ph a txa ph a tya ph a t >. Ida and beq Jmp Jmp 0
• the 65XX stack lives between $0 IFF and $0 I 00. • when values are pushed on the ~tack. the ~tack grows downwards in memory. • the ~tack i~ organized in UFO ("last in, first out'') order.
;** c64 brk/irq entry **
;save .A, .X and . Yon stack
Here's an example of what happens to the stack on the C64 during a BRK. assuming the SP wa~ $F6 when the BRK instruction happened:
;current ~tad. pointer to .X $0 I04,x ;use it to load old status register #lh-00010000 ;test the brk bltm the SR $ff58 ($0316) ;if this bit I, then this is a BRK ;otherwise, an IRQ. ($0314)
=
$01f6 $01 f5 $0 1f4 $0lf3 $0lf2 $01 fl $01ffi $0lcf
Cl28: ffl7 ffl8 ff19 ffla
ph a txa ph a tya
Transactor
;save .A, .X and .Y registers
34
PC II PCL SR
.A .X .Y
<-old stack pointer <-program counter high byte <- program counter low byte <- processor status register <- data registers
<- SP (= $ef after the entry routine) May 1988: Volume 8, Issue 6
I
The C 128 stack would look like this (again assuming the SP was at $F6): $01f6 $0lf5 $01f4 $01f3 $01f2 $01fl $01f0 $01ef
<- old Stack pointer PCH PCL SR
.A
;subroutine or "trap" #
<- Program counter high byte
<- Program counter low byte <- Proces!.or status register <- Data registers
The sample source code listed after the anicle does just that uses a value after BRK to execute a panicular routine or trap.
.X .Y
68000 Traps
BANK
Before presenting a sample BRK routine, it might be interesting to look at the trap functions of the 68000 machines, such as the Amiga and the Macintosh .
<- SP i~ SEE after the entry routine
SO lee
Note: The â&#x20AC;˘program counter (PCII and PCL) and the statu~ register (SR) were 1.avcd by the CPU itself when the BRK or IRQ occurred. Remember that both the entry routine' must determine what really happened- a BRK or an IRQ. So both must test the SR saved on the stack. On a C64 the 'Ida $0 I04.x' fetches the old SR from the Mack. Since the SP at the end of our entry routine is $EF. juM add 4 to this, and 'Ida $0104.~ â&#x20AC;˘ really becomes "Ida $01F3'- the SR. The Cl28 u!.es 'Ida $0105,x' because it must add 5 to get paM the saved bank value. Anyway. u~e the ~arne technique to get at the other pushed values and \\.here .X i' the SP: For the C6-l. to find ...
For the C 128, to find ...
PCH PCL SR .A .X
PCH PCL SR .A .X .Y BANK
.Y
$1002jsr $ffd2 $1005 brk $1006 .byte #$05 $1007 jsr $ffe4
usc usc use usc use use
LOA $0 I 06,X LOA SOI05.X LOA SOI04,X LOA $0103,X LOA $0102,X LOA $0101,X
The 68000 has an instruction called TRAP that allows a programmer to create up to 16 routines that can executed from within a program that generate exception~ or Interrupts. (The 68000 also allows something called A-traps and F-traps that are in a sense closer to our usc of BRK. but this is beyond the scope of this anicle.) Traps allow you to interrupt the microprocessor from software - handy if you need '>Omething done in a hurry while at the san1e time preserving important program values, and the trap will ~eem invisible to the execution of your program. Our BRK routine will be invisible because the .A, .X,. Y registers, the SP and, in the case of the C 128, the bank value will be unaffected.
use LOA $0 I 07 .X use LOA $0 I06.X usc LOA $0105,X usc LDA$0104,X usc LOA $0103,X use LOA $0 I02.X use LOA $0101,X
A BRK Demonstration Program
The following PAL assembler source code for the C64 consists of three parts: (I) A routine to diven the stand.1rd BRK vector at S0316/0317 to our custom routine.
Once these pushed values are located. they can be changed one method of passing parameter:. through BRK.
(2) A BRK handler thai shows how to incorporate BRK in a machine code program. One small note: this pan of my program contains self-modifying code because TRPNM is changed each lime you type I, 2 or 3. This is not good programming practice (try u~ing the code in an EPROM!) and was only done to shonen the example. If you wi!.h to make use of the concept described in the antcle, I suggest fixed trap numbers following the BRK instruction.
A word on PCH and PCL: the program counter on the stack has had 2 added to it. This i~ very imponant to keep in mind while using BRK. The following example shows what happens to the PC afer a BRK:
SIOOO Ida #SOd $1002 jsr $ffd2 $1004 br~ $1006 nop $1007 j!.r Sffe4
:($1007 saved as PC on stack)
I. 2 or 1 to the screen depending on which trap was used. The TIDYUP routine pulls the registers from the stack and does an RTT.
(3) The BRK routine itself simply print
;we land here after BRK
From the example above, you can see that the PC ~kips right over the NOP instruction. So it could be any value. In fact. instead of the NOP. we could place a value that our BRK routine could uJ.c as some !.on of parameter - like a subroutine number. For instance, the code below could be used to call subroutine #15: $10001da Transactor
Final Notes
Interrupt prioriry: traditionally, only the NMI and IRQ are mentioned during any discussion of interrupts. Actually, the interrupt priority, from highest to lowest. is as follow.,: NMI, BRK, IRQ. A BRK supersedes an IRQ becau.,e IRQs are disabled by the SEI inJ.truction, but not BRKs.
#SOd 35
May 1988: Volume 8, Issue 6
BRK to BRK? Though I haven't tried it. I suppose you could write a program u~ing BRKs instead of JSRs. However, watch nesting BRKs ins1de of BRKs because each will need 6 (or 7 for a CJ28) slot<; on the stack. and there's only 256 srack locauonc; to work with before the ~tack wraps around and obliterates some vital parameter. Keyboard scanning: l>ince the Kemal's IRQ routine is responsible for scanning the keyboard. you will have to use the SCNKEY Kcmal routme if you want keyboard input to be read while inside a BRK. Here's how to read and print a character in thiS cascw: loop
jsr scnkey jsr getin beq loop j~r chrout
:scan keyboard ;read it :print it
PAL-format source code to demonstrate simulating a trap with the BRK instruction:
GO OB MB
Mil DE KD EE HN IL FF MG GH BM
KT AK KO
OJ OP JJ CL PN AF BD
EK 10 Bl
LP BN CK
FO HJ EG EJ PC MC AD FC
I 0 sys 700: .opt oo 1000;••······························ 1010 ;• * 1020 ;* simulating a trap with brk 1030 ; • ................ ----· ........................... 1040;* 1050;* 1060 ;* brk vector is d1\ened so I 070 ;* that "invi'>ible" subroutines • 1080 ;*can be called. • 1090 ;* 1100 :• 1110 ;* - by tom hughes v0222871120 ;* 1130;******************************** 1140; 1150 ;c64 equates 1160; 1170 cbinv = $03 16 ;brk vector (2) 1180 chrout = $ffd2 ;output a char 1190 clrchn $ffcc ;i/o to defaults 1200 getin Sffc4 ;input a char 1210 memory $8d ;temp storage (2) 1220 oldbrk $8b ;storage for standard brk (2) 1230 ~tack $0 I00 ;65xx stack location 1240 tidyup $febe :recover from interrupt 1250 *= $c000 ;~ys 49152 1260 :-·--··--- ......................._ ........... . 1270 ;set brk vector to our routine 1280 ;...................................................................... . . 1290 ;in actual u'>e, this would be a subroutine 1300 ;called once to d1ven the brk vector. 1310 ; . 1320 JSr clrchn . 1330 SCI :disable interrupts 1340 ld~ cbinv 1350 ldy cbinv+l
Transactor
• • • •
AD FM AM BJ KK PJ OG MA FI KP
1360 MX oldbrk ;save old brk vector 1370 sty oldbrk+l ldx #<newbrk ;then set new vector 1380 ldy #>newbrk 1390 1400 SIX cbinv 1410 sty cbinv+ I 1420 ;enable interrupts eli 1430; 1440 ;................................................................. 1450 ;demo brk handler
JJ
1460 ; .............................................................. .
ED
1470; 1480 ;th1s is JUSt an example of how you 1490 ;would use brk from within a program 1500; 1510 demoS ldy #0 1520 demo I 0 Ida prompt.y ;print "number?'' 1530 beq dcmo20 1540 jsr chrout 1550 iny 1560 bne demo I 0 :check the keyboard 1570 demo20 j~r get in ;(if stop key, quit) 1580 cmp #3 1590 beq quit 1600 cmp #1" 1" ;for numbers I thru 3 161 0 bee demo20 1620 cmp #"4" 1630 bee, demo20 1640 jsr chrout :make # hex I - 3 1650 and #$OF 1660 !tta upnm :save in our own prog ;print a carriage gosub 1670 Ida #13 1680 jsr chrout ;execute trap 1690 brk 1700 trpnm .byt 0 :(trap#) 1710 jmp demoS ;(arter brk, prg contmues here) 1720; 1730 quit sci ldx oldbrk 1740 1750 1dy oldbrk+ I 1760 ~LX cbinv 1770 sty cbinv+ I 1780 eli 1790 ns :back to basic 1800; 1810 prompt .byt 13.13 1820 .usc "number (I - 3)?" 1830 .byt 0 1840:== ======-==--== 1850 ;new brk routine 1860 ---1870; 1880 ;entry (I) interrupts disabled (except nmi) 1890 : l>O jiOy clock is ofT. 1900: 1910 ;(2) on entry stack looks like this... 1920; (assuming old sp was at $f6)
cc AD CF NE HN EB LN 00 MB
oc
HL DP ID
GC Ml KH PO LE EA NC HG
• • • • •
JB
EF HL
oc EH DO
DA CB HA Cl
= = = = = =
01
OH DC Kl AG
AD NA
EE EM Cl FO
co
HG
GO 36
---·.-=============
May 1988: Volume 8, Issue 6
•
AA 1930; BJ 1940; PM 1950; MN 1960; IIL
IB FD
MD
Gr KF Oil
JP
FE Cl DK CH
OJ CJ
DO BB NK BB BL \1H
BN IK
FE Lll 811
JF
KH AK GK
ID KE OF
JD CH
FC LM
HN KJ
NK LM BM
CM BH liD MB KO
PJ
PF JF CB
NM HI AI AK
$0 If6 $01 f5 $0lf4 $01 f3 $01 f2 $01fl $011'0 $01ef
pch pel sr .a .x .y
<·old sp (stack+6) (stack+5) (stack+4) (stack+3) (stack+2) (stack+ I) <- current sp
New! Improved! NSBASIC2!
1970; 1980; 1990. ' 2000; 2010; 2020; 2030 ;(3) expect<, trap# after brk 2040 ; (this location can be found by 2050 ; using the pc saved on stack · I .) 2060 :· 2070 newbrk tsx ;get current sp to .x 2080 Ida <;tack+6,x ;to find pc-high 2090 sta memory+ I 2100 Ida stack+5,x ;and pc-low on stack sta memory 2110 ;save this address bne ncwiO 2 120 ;and subtract · I from it 2 130 dec memory+ I ;so we can locate trap# 2140 newJO dec memory 2150 ldy 1#0 2160 Ida (memory),y;get trap # 2170 tay ;adjust it so 1-3 2180 ;is now 0-2 dey 2190 tya 2200 a~ I a :multiply this #by 2 22 10 tay 2220 Ida table.y ;and use it to look up <;Ia memory 2230 ;trap addrc,.,es tny 2240 2250 Ida table.y \la memory+ I 2260 . 2270 Jmp (memory) ;go to a trap routine 2280; 2290 ;trap addresses 2300; 23 10 table .word trap I 2320 .word rrap2 2330 .word trap3 2340; 2350 ;///1////////////////////////// 2360 ;demo trap routine!> 2370 :////////////////////////////// 2380; Ida #"I " 2390 trap! 2400 JSr chrout • 24 10 ;must end with this Jmp tidyup 2420 ; 2430 trap2 Ida #"2" 2440 JSr chrout . 2450 Jmp ltdyup 2460; 2470 trap3 Ida #"3" . 2480 JSr chrout . 2490 Jmp tidyup 2500.end
Tronsoc:tor
r
00
"'-'• c " I used to be so ashamed of my dull, messy code, but no matter what I tried I just couldn' t get rid of those stubborn spaghetti stains!" writes M rs. Jenny A. of Richmond Hill, Ontario. " Then the Transactor people asked me to try new TransBASIC 2, with Symass~. They explained how TransBASIC 2, with its scores of tiny ' tokens', would get my code looking clean, fast! "I was sceptical, but I figured there was no harm in giving it a try. Well, all it took was one load and I was convinced! TransBASIC 2 went to work and got my code looking c lean as new in seconds! Now I'm telling all my friends to try TransBASIC 2 in their machines! "
• • • •• • • TransBASIC 2, with Symass, the symboliC assembler Package conta1ns all 12 sets of TransBASIC modules from the magazine, plus full documentation. Make your BASIC programs run faster and better with over 140 added statement and function keywords •
Disk and Manual $17.95 US, $19.95 Cdn. (see order card at center and News BRK for more mfo)
TransBASIC 2 ..Cleaner code, load after load!" 37
Moy 1983: Volume 8, Issue 6
~==~~------------------------=-------------------~
Micro-Lisp Version 2.5 ----------------A public domain Lisp interpreter for the C64! •
by Nicholas Vrtis
would allow you to son the data and print a fancy report without a lot of worl...
Lisp is a language designed to worl.. with lists (its name is a contraction of LISt Processor). It is one of the primary languages used in the study of Artificial Intelligence. Micro-Lisp is a subset of this language that you can use to learn more about its capabilities. Although there obviously isn't space in this article for a complete cour<>e in Lbp and AI, I would like to mtroduce you to the language and to my Micro-Lisp implementation 111 particular. At the end of the article you'll find some suggestions for further reading if you want to know more.
Lisp was designed to handle more complicated situations where you can't know in advance all the combinations and questions you might want to ask about the information you have. One example (which I'll be us10g throughout this article) would be a family rree. A List sho'>' ing the name, sex. and parents of each individual in your family would be a good ~taning point. Each item on thi\ Li\1 i\ made up of two Atoms (name and sex) and one List (Father·~ name, Mother's name). Notice that there is no item in the LiM concerning the individual's relationship to you, or to moM other members of the family. We can get this information, however, by applying some simple rules; for instance: a hrother of r is any male whose parents m·e the same as rhe parents of r. Before we discuss how Lisp lets us extract this kind of implicittnformation, however, we need to ma~ter a few of the language's technicalities.
Why bother with a version of Lisp that runs on a slow 8 bit computer? Because it is an easy, inexpensive way to become familiar with the language, and to get a feel for what it is like. Why buy a model rocket? It can't go as fast or as far as the Space Shuttle. but you can still have fun and learn from it. Lisp's World View
Lisp Fundamentals Lisp divides the world into two clas~s of 'things·. On one side there is a List. and on the other is things that aren't Lists. Things that aren't Lists are called Atoms. As in physics, an Atom can't be broken down into something smaller (though you will find that you can explode and 1mplode an Atom, just as in physics atoms can be taken apart if you know how). A word is an Atom, so is a number. lf I take some Atoms, and collect them, I end up with a List (similar to taking atoms and collecting them into molecules). I can also take Lists and group them together, either end-to-end to make a longer List, or ao; a List of Lists.
Lists in Lisp are enclosed in parentheses. For in<>tance, while nick i-; an Atom, (mck) is a List that has one Atom, {nick m) ha.\ two, and {nick m {jim marion)) has two Atoms and a List (which itself has two Atoms). By the way, one of the hard parts about Lisp, especially for beginners, is keeping the parenthesc~ balanced in the right places. Micro-Lisp has a couple of features to help with this. The command prompt shows the current number of unbalanced parentheses (the nesting level). Also, when you display a List. you can use a fearure called pretty print to stan each new level on a new line, and 10dent one space for each level.
B1g deal - what good are lists anyway? Actually, if }OU think about 1t, almost all the information we usc is in the form of liMs. Your checkbook for example, is a list of three or four items of information about each check (the check number, the amount, who it is to, the date written, and possibly a budget category). To get the amount I have spent on a given category, I ju~t go through my list of checks and add up the amounts for those checks with that category. That 's a relatively simple Lisp application, and maybe not a very appropriate one - a good database program would probably be ~uer. since it Transactor
Another concept you need to understand about Lisp is how it represents 'nothing·. Since an Atom can be either a number or a word, Lisp can't use 0 for numbers the way we do. Instead, Lisp uses an entity called nil. Nil is special, because it can be either a List or an Atom depending on the situation. If you want to input the Atom nil, just enter the word nil. If you want to 10put a List with nothing in it, enter(). Whenever Micro-Lbp dbplay~ an empty List. it will al'>' ays display nil instead of (). 38
May 1988: Volume 8, Issue 6
r 1
We also need to understand how to get Li~p to do something how to give it a command. Commands arc given in the form of Lists (not surprisingly). A command List is no different from any other List, except that the first entry mu~t be an Atom that I'> a command. For example, add is a command that sums the numbers in the rest of the List; the List (add I 2 3) would add the numbers I, 2 and 3. A List docsn 't have to have a command as the fir..t entry unless you want to execute it (called rl'aluating it in Lisp). The documentation accompanying th1s article show1. the built-in commandl> available in Micro-Lisp. One of these - define - lets you create your own commands, which work just hke the built-in commands. We'll male u~e of th1s ab1ltty when we work on our family• tree project. C reating the family tree
tree-name is unchanged but, as expected, family-trer has the new value 10. Programmers who have used languages like assembler. C and PROMAL will recogm;e here an example of mdirection; this application of it is fundamental to L1sp and you should make sure you under..tand the above example th oroughl y. Since you end up using the quote command a lot in Lisp. there is a ~honhand ver~ion. It is a o,ingle quote marl ('). It eliminates the word quotr and a set of parenthese!'>. We can thus wri te our original statement more concisely as: (set 'family-tree nil) Go ahead and try it - Lisp is very interactive. If you ever want to know the value of a name, just type 11 on the command line \\ ithout parentheses.
Let's begm that now. To start Micro-Lisp, just enter:
A new command with define load "micro-lisp" ,8 run You·u see a title message and a flashing cursor. Now type: >0 (set (quote family-tree) nil) nil
Now Jet's define a command of our O\\n to add a person to our databac;e. We use the drfine command for thb, and we'll keep it simple for now. Later you will probably want to add some check ~ to this command to guard against duplicate entries and to determine if the parents of a newly-added person arc already defined. But l>tart with:
The computer will respond by typing out nil (note: the examples in this article use bold type for the computer's prompts and responses, and regular type for your input). Set is a command that sets the value of the second Atom in the L1st equal to the value of the third (similar to a BASIC statement like FT$ = ""). Now we have a 'database' named FAMILY-TREE with nothing in it.
0> (define 'add-person '(person) b '(progn 3> (setq family-tree (cons person family-tree)) 4> 3> person)) Micro-Lisp l>hould rel>pond with add-person. If not. male sure you haven't missed any quotes or parenthe,cs (hint: if you have a number greater than zero in front of the > prompt. that is the number of parentheses you are missing). You don't have to indent as shown above, though it help~ l>how each level of the definition.
You might be wondenng why you had to use the strange construction (qume family-tree) instead of just family-tree. This renects LISP's desire to use the value of a name in most cases. Consider the BASIC statement FT$ = AS, wh1ch assign'> the value of AS toFT$. If we really wanted to asJ.ign the characters "A$" to FT$, we have to use quotes. The quote command in LISP performs the same function as the pair of double quotes m BASIC. If that is still confusing, try this:
There are a number of new items in this definition, but most are pretty simple. Define is the command that defines new commands to Lisp. It needs to kno\\ three thjngs. The fir..t is the name of the command (we are calling it add-pt!r.~on); the second is a List of the arguments (only one in th1s case -person); and the last is the body of the function. Note that quote marks are used, since we want the literal statements we typed in, not their value.
O>(set (quote tree-name) (quote family-tree)) family-tree 0> (set tree-name L0)
10 0> tree-name family-tree 0> family-tree
The first command in the function body is fJI'OR"· All this command docs i~> tell Lisp to evaluate aJJ the other items in the List. Normally, Lisp expects a command to be in the form (Command Argument Argument...). Progn lets you string a set of commands into one List in the form (progn (Command Argument ... ) (Command Argument ... ) ... ). We need to do th is in add-person because we want to do two thing!>. The first I'> setq. This is a special version of set, which we used earlier. Setq allows you to skip the first quote. The variable we are
10 e~ample,
we begin by creating a new Atom - treename - whose value is the name family-tree. When we now say (set tree-name 10), we are asking for tbe value 10 to be assigned to the Atom \\hose name is found by evaluating tree-name. After this operation, we discover that the value of In thjs
Transactor
39
May 1988: Volume 8, Issue 6
J
setting is family-tree, our database. What we want to set it to is a List consisting of all the things already in family-tree plus the new person data. We use the cons command to do this. Cons creates a List formed from the first argument followed by the second argument. Note that J put person first, and family-tree second, thus adding the new information to the front of the database instead of the end. For technical reasons this turns out to be faster than the other way around. but either way will work. The second item is not a command, just the word person. Notice that it is not enclosed in parentheses. When Lisp sees just a variable nStme without parentheses, it just takes the value of that variable, and leaves it as the return value. Everything in Lisp leaves some sort of return value: whenever Lisp has finished processing the commands you have given it, it prints out the final return value. Well, it turns out the return value from setq is the value to which the variable was set. In our case, this is the whole database. Since it could get lengthy to have it print out every time we add a new person to familytree, we add the word person by itself; now our new command has as its rett1m value the information about the person we just added. We could have used a special variable called I, or nil, but person might be more useful if we want to combine add-person into some other command. Let's test out what we have so far. Issue the following: O> (add-person '(nick m (jim marion)))
(nick m (jim marion)) 0> family-tree
3> 3> 2> 1>
(eq temp nil) (eq name (car (car temp)))) (setq temp (cdr temp))) (setq person (car temp)))
There are more new commands here, but it is sti ll pretty simple. Defun is another version of define. Like setq, it is a shorthand that eliminates the need for quoting its arguments. Defim also supplies an implicit progn. so we don't have to bother with that e ither. We've seen setq before. Here we are using it to set a temporary variable to our database because we are going to have to check each item in it to see if the first Atom of the sublist is the name we are looking for.
Dountil is a looping command. Until the first argumen t returns a true value (in Lisp, true means anything that isn't nil), this command will execute the remaining commands in the List. In our case, we will want to terminate the loop when either we have run out of person entries in the database, or we have found the person entry whose first Atom is the name of the person we are looking for. Conveniently, Lisp has an or command to express this sort of requirement. Or evaluates each of its arguments until it either finds a non-nil, or runs out of arguments (in which case it returns nil). The first argument is ( eq temp nil). The eq tests to see if its two arguments are identical, so if temp is equal to nil, this command will return /. If temp is not nil, or goes to the next argument. This means there is a person List left, so we want to compare the first Atom in that List with the name we are looking for.
((nick m (jim marion))) To do this, we use the car command. Car returns the first part of its argument (which must be a List). Since temp is a copy of family-tree, the car (first item) of temp is the first 'person路 List in temp. The name is the first Atom in the List, so we take the car of the car of temp, and compare that to the name we're looking for. If they are the same, the eq will return 1. and the doumil is done. Otherwise we need to do something to look at the rest of the person Lists in temp.
The last should produce a List of Lists showing everything in our database. Since it is all scrunched together, enter (setpretty t), then family-tree again. This will indent each level of parentheses and make the Lists a little easier to read. Now build up the database a little by adding some more people with the following lines (this time. Lisp's responses are not shown): (add-person (add-person (add-person (add-person family-tree
This is where cdr comes in. Cdr returns the tail of a List - everything but the car. Since or told us that the current first List in temp isn't the one we want, we simply setq temp to everything but the first List, and repeat the process. Eventually. the dountil either runs out of Lists in temp (temp equals nil), or the car of temp is the person list corresponding to the name we want. When the dountil terminates, we return the car of temp. Note that the car of() is nil, so find-name returns either the person List of the name we asked for, or nil if the name is not found. Try (find-name 'nikki); you should get back ( nikki f
'(maryelna f (frank dorothy))) '(nikki f (11ick maryelna))) '(mike m (jim marion))) '(matt m (nick maryelna)))
Notice that the database has become larger.
Interrogating the database
(nick marye/na)).
Now let's defme some new commands that will help us find things in the database. The first is a command to find somebody's name and parentage:
Now for another simple. but useful command:
O>(defun find-name (name) 1> (setq temp family-tree) 1> (dountil (or Transactor
0> (de fun parents-of (name) 1> (cond 2> ((find-name name) (setq parents (nth 3 person)))
40
May 1988: Volume 8, Issue 6
2> (t (setq parent~ ntl)))) parents-of Pretty easy. right? Only two new commands this time. Cond ts the Lisp version of if, but a little more complicated. Basically, the arguments for Cond are the members of a List of if statements. Each argument Ltst is a pair of commands. The fir't command in the pa1r is the condition pan. If it returns non-ml, then the second command is evaluated. If the first command returns nil. then the next condition is examined. There is a requirement in Micro-Lisp that at leru.t one of the conditions in a cond suuement must return non-nil, or it is considered an error.
• In parems-oJ, the first condition is (find-name name). Recall that find-name returns the person List entry if the name is found, or nil if it is not. If (find-name name) return'> non-nil in the present case. we will want to set a variable called parems to the third item in the pcr~on Listthatfind-name returned. To do this we use nth, a command that returns the nth entry from the third argument (a List). where n is specified by the second argument. In ca<;e the first condtt1on returns ml (the name was not found). we need to make \ure that at leru.t one condition is true (non-nil). Lisp ~upplies a variable called 1 that is guaranteed to return non-nil; we use this for the 1>ccond condition, and set parems to nil because we can't identify the parents of \omeone not in the databa-,e. Note that Lisp sl..ips condition tesung after the first true condition is found, so the second setq tn the above defimtion is never executed if the name we are lool..ing for is found. Try (parems-of 'nick): you should get back (j1m marion).
Where to go from here I could continue with more examples, but the~e ~hould give you an idea of what Li~>p is. Purists will probably be upset that I did not use recursion techniques in the examples. Li~p handles these very well, but I find them difficult to follow and harder to explain; I purposely kept the example~ ~traightfor ward. As you can see by examming the list of built-in command1., there are a lot of Li~p words that I d1dn 't even cover. Experiment with them. Even more than BASIC, Lt<;p IS Interactive. Try some things and see what happens. After you have some experience, try the command called set· dehug. This turns on a trace facility that traces what is going on. Then use haku·ack to sec all that went on to get to where you are (with our •ample family-tree, grand-parl'flts-nf goes through over I00 Lisp !>tatements to get the an\wer). There IS abo a trace command that prints out the level\ a~ they are being executed. If setdehu}!, is 1 and there are symbohc variables (as name was in our examples) you get an opportunity to display their values before Lisp restores them (enter nil to get out of this mode). There 1s an editor (entered with the edtt command) that allows you to mput and save M1cro-Lisp source \tatements: you use the Micro-Lisp command source to load them into your Lisp 'environment'. To Micro-Lisp. your ·environment' is all the Lists and Atoms you have defmed. Use the commands sa1·e and load to keep and restore copies of your worl... A \eparate program ("sae.lisp") is a spectal ver-,ion of the Micro-L1sp edit command. This program runs without MicroLi'>p to let you create Micro-Lisp source program\ larger than would be possible with Micro-Lisp running (smce Micro-L1sp and all your working Lists take up memory).
One more short example:
Meanwhile, if Lisp interests you enough that you would like to know more about it, you might want to read some or all of these books and articles:
0> (de fun grand-parents-of (name) I> (setq grand-parents 2> (list 3> (parent!>-of (car (parents-of name))) 4> (parents-of (car (cdr (parents-of name)))))))
Pro}!,rammer's Guide To Li~>p, by Ken Traction (Tab Books) Undersumding Lisp, by Paul Gloess (Alfred Publishing) Lisp. Basically Speaking (80 Micro, May 1983) Design Of AN M6800 Lisp Interpreter (Byte, August 1979) Three Microcomputer Ltsps (Byte, September 1981)
Only one new command in the whole thing, and it is pretty easy to figure out what it does. List takes all its arguments and returns a List (s1mple, isn't it?). Think about what is gotng on. Grandparents are parents of a person's parents, so all our new command has to do is create a List of the parents of the parents of the person in name. Parems-of returns a List with the two parents' names. The car (first part) of this List is the name of one of the parents. If we now call parems-of with this, we will get one set of grandparents. The cdr (rest of) the original parent List is a List (cdr always returns a List) that has only one entry, the other parent. The car of that is the name of the other parent, and the parents-of that is the other set of grandparents. It take'> a long time to explain, but it really isn't complicated - just follow it through. Try (grandparents-of' mau); you should get back ((jim marion) (frank dorothy)). Transactor
••••• Editor 's Note: Unfortunately, with a !OK ohject file size. there is just no room for a pm11ram listing of Nick Vrtis' Micro-Lisp imerpreter in the maJ!.azine. 1/owel•er, Micro-Lisp. some sample Lisp code and the SAE.Iisp stand-alone editor will he 0\'ailab/e on the dtsk for this issue, and will also be posted to Data Library 17 on CompuSerw's CBMPRG Forum. In the near future, Tram actor wt/1 also he releasing a special disk containing the MAE assemhler soura to MicroLisp. a/on}? with programming notes for those who wish to expand or modify the imerpreter for their own needs. 41
May 1988: Volume 8, Issue 6
•
Micro-Lisp Built-In Functions (ABORT msg)
ABORT
Stops current processing, displays the message that msg evaluates to, and returns to the top level processing. This function can be used to define additional error processing.
ABS
COND
Evaluates rl and executes rl if rl returns non-nil. If tl returns nil, cond proceeds to evaluate t2. Note that t2 will not be evaluated if rl does not evaluate to nil. An error is issued if all tests evaluate to nil.
CONS
(ABS n)
â&#x20AC;˘
(ADD nl ... nn)
Returns the sum of the numbers nl through 1111.
AND
DECIMAL
(ANI) xt ... xn)
DEFINE
(APPEND 1112)
(APURGE atm) DEFUN
Purges the Atom atm from memory and frees the space for reuse. Any references to atm in Lists are changed to reference nil. Apurge removes the value, definition, and property Lists of built-in functions, but does not remove the built-in definition or free the space.
ATOM
DISKCMD
(ATOM x)
(BAKTRACK n )
DISKST
(CAR list) DISK$
.__
(CDR list)
(COLD)
DIVIDE
Restarts Micro-Lisp from the beginning. All options and parameters are reset to the way they were when RUN was issued.
Transactor
(DISK$)
Reads the disk directory and returns a List of Lists about the disk. Each entry is a List of 3 Atoms. The first Atom is the number of blocks, the second is the file name. and the third is the file type. The first entry is the disk name. and the last entry is the number of blocks free.
Returns the rest of list after the ftrst part (the car) is skipped.
COLD
(DISKST)
Reads the disk status via the command channel. The function opens and closes the command channel.
Returns the first part of lisr. CDR
(DISKCMD msg)
Issues the disk command msg. This function opens and closes the disk command channel.
Displays the Last n functions that were executed. Only valid if debug has been previously activated (see setdebug). CAR
(DEFUN fn arg x)
Same as define, except thatfn, arg, and x are not evaluated. It is a more convenient form when entering a function from the keyboard since quotes are not needed.
Returns t (true) if x evaluates to an Atom; returns nil otherwise.
BAKTRACK
(DEFINE fn arg x)
Create a function calledfn that has arguments specified in the list arg. The body of the function il> specified in the list x. In define,Jn, arg, and x are evaluated. A defined function has an implied progn before the body.
Returns the List created by appending /2 to the end of II.
APURGE
(DECIMAL)
Sets the current number base to decimal and returns the number I 0.
Evaluates xl and, if it is not nil, proceeds to evaluate the following arguments until nil is returned. or the end of the argument List is encountered. Note that and does not evaluate the following arguments if nil is returned from any argument
APPEND
(CONS xl x2)
Returns a List that has xl as its first part (car) and x2 as its rest part (cdr). If x 1 and x2 evaluate to Aroms, a special List called a 'Dotted Pair' is returned.
Returns the absolute value of n.
ADD
(COND (tl rl)(t2 r2))
(DIVIDE nl n2)
Returns the integer result of nl divided by n2 . 42
May 1988: Volume 8, Issue 6
(DOU~TIL I
DO UNTIL
xl ... xn)
A looping function. The test 1 is evaluated and, until it is tnte (non-nil), the expressions xl through xn are evaluated (using an implied progn). Dmmtil returns the non-nil value returned from the expression t.
(DOWHILE I x l ... xn)
oowmLE
A looping function. The test/ is evaluated and, while it IS still true (non-nil), the e:~.pressions .d through ¡'" are evaluated (using an imphed pmxn). Do11lule returns nil always. â&#x20AC;˘
EDIT
(EDIT)
Exit~
Lisp to the BASIC screen editor. You rna) enter a Lisp program as you ~ould a BASIC program. The only keywords that will function are LOAD, SAVE, LIST, NEW and END. END returns you back to Micro-Lisp, the other~> operate as expected.
EQ
(EQ x1 >.2)
Returns t if xl is identical to r2. Not very useful if comparing Lists.
EQ UAL
(EQUALd xl)
Returns 1 if x/ is the same as r2, otherwise returns nil. This will properly test Li~ts.
EVAL
(EVAL ~)
GETPROP
(GETPROP a pn)
Returns the property value stored under the property name p11 under the atom a. ReiUrns nil if pn is not defined under a.
GREATERP
(GREATERP nl ... nn)
Returns r if the numbers nl through m1 are in de~ccnding order. Note that equal is not considered descending.
HEX
(HEX)
Set the current number conversion base to 16 (hexadecimal). Returns the value I 0 hex (decimal 16).
IMPLODE
(IMPLODE I)
Takes a List of numbers representing ASCH characters and returns an Atom whose print name is that series of ASCTI characters. lf any number is greater than 256. the ASCII character is taken from the MOD 256 \alue. If the pnnt name resulting from imploding the List re~ults 10 a vahd number. then it will be converted to a number.
LAMBDA
((LAMBDA (x) (b)) y)
A method of e>.ecuting a function without defining it. The current value of .\ i!> !>aved, then 1t i!. assigned the value of y and the body b is evaluated (with an implied proxn). After b is evaluated, xis restored to its previous value. Note that there may be more than one Atom specified in the argument list, and that there must be a one to one correspondence between the number of arguments and the number of values supplied.
Evaluates the List that revaluates to. (EI'al'(car ' (a b))) will produce the same results as (car '(a h)).
LENGTH
EXIT
Returns the number of elements 10 the list x.
(EXIT)
(LENGTH X)
(LESSP n l ... nn)
Leaves Lisp and returns to BASIC.
LESSP
EXPLODE
Returns r if the numbers n1 through nn are in ascending order. Note that equal is not considered ascending.
(EXPLODE a)
Returns a L1st of numbers thai represent the ASCII value of the name of the Atom a. If a evaluates to a number, it is converted according to the current base and the ASCII values of the digits are retumed.
GC
(GC)
LIST
(LIST x1 ... xn)
Returns a List containingx/ through rn.
LISTP
(LISTP x)
Forces garbage collection to take place. Returns r.
Returns t if x evaluates to a List, nil if x evaluates to an Atom.
GETDEF
LOAD
(GETDEFa)
Returns the definuion of the function specified by a. Returns nil if a has not been previously defined. Tranaoctor
(LOAD fn)
Loads a previously saved environment from file ji1. This muM be executed from the first level. May 1988: Volume 8, Issue 6
I LPAREN
(LPAREN)
Outputs the left parenthesis character. MEM
PROGN
Successively evaluates the specified function expression~. xI through xn.
(MEM) P UTPROP
Prints out the number of free object entries, the number of free List entries and the amount of unallocated memory (in bytes). Returns the amount of unallocated memory. MULTIPLY
(M ULTIPLY nl ... nn)
Returns rh,e product of nl times n2 ... ti mes nn. Note that no check is made for overflow. NEW
(PUTPROP a pn pv)
Puts the property value pv as the property pn of Atom a. If the property pn already exists, the old value is replaced by the new value.
QUOTE
(QUOTE x)
Returns the unevaluated expression x.
(NEW) RATOM
Clears memory or any user defined Atoms, Lists. and functions without changing settings such as pretty print, echo, o r number ba~e.
NlL
(PROGN (xl) ... (xn))
NIL, (NIL), or ()
(RATOM)
Waits for a single Atom to be entered from the renninal. :
:.
READ
I
(READ)
Reads an expression from the tenninal. This is the Lisp specification o f 'nothing'. As a val ue it returns nil; as a function it also returns nil. It is also considered both an Atom and a List. NTH
(NTH n I)
RPAREN
(RPAREN)
Outputs a right parenthesis to the tenninal. (SAVE fn)
Returns the nth element of the List I.
SAVE
NULL
Saves the current environment (including all objects and Lists) to file ji1.
(NULLx)
Returns 1 if x evaluates to nil, returns nil othe rwise (perfonns a logical NOT function). NUMBERP
SET
(NUMBERPx)
Causes the value of x to be assigned to the Atom a.
Returns r if x evaluates to a number. nil otherwise. OR
SETBASE
(OR xl ... xn)
SETDEBUG
(PATOM a )
(PRINT x)
Prints the expression x evaluates to, followed by a carriage return. Print returns the value t. If the pretty print flag is set, each parenthesis level will be started on a new line, and will be indented. Transactor
(SETDEBUG x)
If x evaluates to nil, debug mode is turned off; if it evaluates to non-nil, debug mode is turned on. Debug mode is useful for problem detennination. If debug mode is on, Micro-Lisp will track up to the lasr 128 functions. This tracking can be reviewed using the baktrack function. Unlike trace, which displays the actual input arguments to a function, debug only tracks the unevaluated arguments. Debug mode also gives you an opportunity to print any Atom values before lambda and function arguments are restored in error processing. This is sometimes useful in detennining what caused an error condition to occur.
Prints the Atom a. PRINT
(SETBASE n)
Sets the number base used for conversion for both input and output. Note that n is converted and evaluated with the current base before the new number base is set.
Evaluates xl and if it is nil, or proceeds to evaluate the following arguments until a non-nil value is returned, or the end of the argument list is encountered. Note that or does not evaluate the following arguments if non-ni/ is returned from any argument. PATOM
(SETa x)
44
May 1988: Volume 8, Issue 6
SETECHO
(SETECHO x)
Used to control the echo of source mput to the terminal. (Setecho t) will cause all source input to be echoed (thi., is the defaultl>etting). (Serecho nil) will eliminate the echo. SETPRETIY
UNDEF Remove~
the function definition from the Atom ll If a was a nattve func tton that had been redefined, the nauve definition will be restored. ZEROP
(SETPRETIY x)
(+ nt ... nn)
+
Shorthand for add. (- nl n2)
(SETQ a A)
Causes the value of x robe assigned to the Atom a (similar to set, except that for serq, a is not evaluated).
Shorthand for subtract. (* nJ ... nn)
* SOURCE
(ZEROPn)
Returns 1 if 11 is equal to zero; returns 11il if it is not.
Used to set the pretty print flag. If r is non-nil, pretty printing will be turned on and expressions will be printed with each parenthesis on a new line and indented for ea'lier reading. lf x is nil. the flag i., turned off. • SETQ
(UNDEFa)
(SOURCE fn)
Shorthand for multiply.
Directs that input is to come from the disk file fn instead of the keyboard. Input is obtained from there until the end of the source file. The source file may contain another source statement. Th1s w1ll close the current source file and open the new source file for input.
(/ nl n2)
Shorthand for diride.
Special Input Characters SUBTRACT
(SUBTRACT nl n2)
" Used to start and end a comment. All characters between the first " and the second " are ignored. (Note: this character prints on your C64 screen as an up-arrow.)
Returns the value n I - n2. (SYS adr x y a f)
SYS
' u..ed as a shorthand for (quote ... )
(qume t) can be shortened to · \. Note the dropping of the word quote and a set of parenthe<.es. 'X will print out as (quote \ ).
lnvokel> a machine language routine at address adr. The values for the .t, ,., a and f (flag) reg1sters are optional and specified by the corresponding arguments. This function will not allow the IRQ flag to be set, but any other processor flags can be set wuh the f argument. This function returns a List of numbers consisting of the values of the X, Y, A and FLAG registers after the return from the machine code call.
" Used to allow special characters and spaces to be included in an Atom name. Any characters between the double-quotes will become part of the Atom name. The double-quotes themselves will not become part of the name. Used to specify a base 16 (hex) number regardless of the current ~cuing of hose. Must precede any digits.
$
T
T, (T )
to ~pecify a base 10 (decimal) number regardles~ of the current selling of bas~. Must precede any digits.
Tis one method of specifying a non-nil value. As a function. 1 return\ 1. TERPRI Cau~e\
•
U~ed
Used to specify a base 8 (octal) number regardless of the current selling of base. Must precede any digits.
%
(TERPRI)
a carriage return to be output. Additional notes
TRACE
(TRACEx)
AJI number~ are stored as 24-bit signed integers. This allows a range of +8,388,607 to -8,388,608.
Causes each function level and its arguments to be ourput to the terminal as it is evaluated. Note that the actual evaluated arguments are ourput. Transactor
Cursor control keys work as they do in BASIC. 45
May 1988: Volume 8, Issue 6
An Algorithm for 6510 Mnemonics The challenge: to f ind the ideal mnemonic-to-opcode algorithm •
by Glen C. Bodie
by the base to some power, that is, by I, I0 or 100. We can do the same thing with letters by multiplying each position by I, 26 or 676. If we do that, the results are guaranteed to be unique, but the range is now 0 to 17576 and we need to map that into 0 to 255.
In the March 1987 issue of Transactor, Chris Miller wrote a very interesting article entitled "Assembling Assemblers". ln his discussion of command look-up tables, he challenged "anyone to come up with an algorithm that will generate a unique, one byte value for every standard 6510 mnemonic.·· I Before we get carried away with trying to find some maplove a good challenge! At first I thought it trivial, but it soon ping, think about how this will eventually be coded in the asproved more complex than it first apsembler. First of all, it will be written in machine language (ML). Multiplypeared. In general terms, the problem ' ... why not use the ing by 26 in ML is a little awkward is to derive an algorithm that maps 56 and time consuming. Instead of using unique three-character alphabetic computer for what it is 26 as the base, why not use 32 as the strings into a unique value between 0 best at - dumb, repetitive base since multiplying by 32 is the and 255 inclusive. • searching.' same as shifting left 5 times. The reThere arc all sorts of simple algorithms sults will still be unique, but now the that quickly come to mind. As an exrange is 0 to 32768! ample, why not just add up the ASCII equivalents of each letter in the mnemonic? For all the examples, I' II use the We can try to map 32768 into 255 by simple techniques (such mnemonic "LOA". as ANDing with 255) or more complex techniques (such as XORing the high and low bytes), but these all turn our unique code= asc("l") + asc("d") + asc("a") CODE into something tl1at is no longer unique. It seems Lhat the straightforward approaches just aren't going to work. A That is simple enough, but the CODE is not unique since mathematical, analytical approach is beyond me, so why not "ADC" and "BCC" would produce the same result. AJso the use the computer for what it is best at - dumb, repetitive value of CODE ranges between 195 and 270 so it still needs searching. What we want it to do is try a lot of alternative some scaling. The easiest way to get CODE within range is to combinations of multipliers and transformations unril it tinds make each letter a value relative to "A". Now our algorithm one that generates unique codes in the range 0 to 255. looks like: What Computers do Best code= (asc("l") - asc("a")) + (asc("d")- asc("a")) + (asc("a") - asc("a")) To limit the problem, let's first make two simplifications: Now the range is 0 to 75. That's great, but the CODE is still not unique. So how are we going to make it unique? That's where it stans to get weird!
I)
2)
Base 10 aod Base 26
For the transformation, there are only 14 possible first letters, 18 possible second letters and 15 possible Lhird leuers. AU the combinations of these result in a CODE between 0 and 3780. The first step is to get the ASCII value of each letter, make it
Think about normal decimal numbers. In the value 444, the 4 has a different value in each position because it is multiplied Transactor
Only use power of 2 multipliers Use a transformation of the letters to reduce the combinations
46
May 1988: Volume 8 , IS$U& 6
t
Program 1: This is the proxram that was u~cd to f,t>nerale the tah/es and constams so that the formula to find CODE (su trn) would generatr a unique m/ue for f!ach of the 56 opcode mnemonics. It takes 30 hours to find the solution.
The program ran for over 30 hours before finding this answer.'
PG MI FL AK PL KF EK OJ CH FA EK BL LM PN EF JK BD PM IO AE EN Kll 10 BL GJ JM PP MF BF PG PH JF HK BE CD DE NE FJ BD DA AA OP I Il l BF CA CG AA AD EF NE AL
relative to "A", then usc that in a table look-up to get a value between 0 and 14, 0 and 18 or 0 and 15. One key benefit of th1s IS that we will d1scover very quickly 1f the mnemonic is invalid. Now our algorithm looks like this: code= (.(table l("l"-"a") i<J,. I + table2("d"-"a") • k2 + table3("a"-"a") • lJ)) and 255 Without juggling the tables around and usmg K t-K2=K3= 1, the code was not unique. ~o a little bit of searching was required. Program I does this. There are probably other answers and maybe even better ones, but thil. one works! The program checks through 13 different sets of multipliers and shifts all three table!> through all the combmations. Thb comes out to a total of 49140 situation~ to check, calculating the CODE for each of the 56 mnemonics until it finds a duplicate or 'uceeds. The program ran for over 30 hours before finding this answer. Progrm11 2 is the resulting algorithm coded in BASIC and program 3 is the same thing in ML. The re~ulting CODE is a value between 0 and 255 which can be used in a table look-up to route the assembler to the correct proce~1.ing, where the operand field could be par~cd, the addres!.ing mode determined, etc. Invalid mnemonics are found whenever the table results in a transformed value of zero. It is possible to input an invalid mnemonic that can be transformed without error into the J>ame CODE as 'orne valid mnemonic. This will have to be caught in the procel>!>lllg routine for each mnemonic by checking when you get there if the mnemonic really was what you were expecting. There are rwo obvious alternatives to this solution: a binary ~earch tree 2) a hashing algorithm I)
The binary search is a classic programming technique for searching through ordered lists in the minimum number of comparisons. And though this program is a hashing algorithm of sorts, a rrue hashing algorithm would deal with duplicate codes, in case several mnemonics "hashed" to the same CODE. I don't know if Mr. Miller ended up using either of these. Both would work for sure, might be fal>ter than this algorithm and have one large advantage . what if another mnemonic needs to be added to the list! So, there it is · an algorithm to generate a unique code for each 6510 mnemonic. I ~ure love a good challenge. TransoctOf
FA 47
I00 rem----- program I ----------------IIOrem 120 rem- find the right algorithm-130 rem 140 n=56: dim op$(n),op(n) 150 fori= I ton: read op$(i): op(i)=O: next 160 data adc,and,asl,bcc,bcs,beq,bit,bml 170 data bne.bpl,brk,bvc,bvs,clc,cld,cli 180 data clv.cmp.cpx,cpy.dec,dex .dey.eor 190 data inc,inx,iny.jmpJsr.lda.ldx,ldy 200 data lsr,nop.ora,pha.php.pla.plp,rol 210 data ror,rti,n!>.~bc.~ec.~ed.~ei.~ta 220 data StJt,~ty,tax,tay,tsx,tx.a.txs.tya 230 def fnh(x)=int(x/256) 240 def fn l(x)=x-fnh(x)*256 250 dim tr(2.25) 260 for i=O to 2: for j=O to 25 270 read tr(iJ): next j,i 280 data I. 2. 3. 4, 5. 0. o. o. 6. 7 290 data 0, 8. 0, 9, 10, 11, 0. 12, 13. 14 300 data 0, 0. 0, 0, 0, 0, I, 2. 3, 4 310 data 5, 0, 0, 6, 7, 0, 0, 8, 9, I0 320 data II, 12, 0, 13, 14, 15. 0. 16, 0. 17 330 data 18. 0. I, 0, 2, 3. 4, 0. 0, 0 3-lO data 5. 0. 6, 7. 0, 0. 0. 8. 9. 10 350 data 11, 12. 0. 13. 0. 14. 15. 0 360 dim k( 12,2) 370 for i=O to 12: for J=O to 2: read k(i.j): next j.i 380data 1,1,1, 1,2.4. 1,4,2 390 data 2,1,4, 2,4,1, 4,2,1 400 data 4,1.2, I,4,16, 1,16,4 410data4.1.16,4.16,1, 16,4.1, 16.1,4 420 for kk=O to 12 430 ~..l=k(kk.O): k2=l(U.l ): k3=l(kU) 440 for aO=O to 13 450 for bO=O to 17 460 for c0=0 to 14 470 print "k l/k2/k3/a0/b0/c0-"k I :k2;k3:uO;bO;cO 480 gosub 2000: rem execute algo 490 next cO. bO. aO. kl 500 print "nothing worked!" 510end 2000 rem-----------------------------20 I 0 rem execute the algorithm 2020 rem 2030 xx=asc("a") 2040 for i= I to n 2050 aS=IeftS(op$(1),1) : a=asc(a$)-xx 2060 b$--rrud$(op$(i),2,1 ): b=asc(b$)-n 2070 c$=right$(opS(i),l ): c=asc(c$)-n 2080 al=tr(O,a)+aO: a2=al-int(al/14)•t4 : if a2=0 then a2= 14 2090 b l=tr( l,b)+bO: b2=b 1-int(b 1/18)*18 May 1988; Volume 8, Issue 6
L-------------------------------------------------------------------~--
: if b2=0 then b2= 18 GA 2100 c I =tr(2.c)+e0: c2=c 1-int(c 1/15)* 15 : if c2=0 then c2= 15 U 21 10 x = a2*k1 + b2*k2 + c2*k3 DA 2120 op(i) = fnl(x) MB 2130 if i=l then goto 2170 FD 2140 for j=l to i-1 DF 2150 if op(i)=op(j) then gosub CF 2160 nextj JF 2170nexti Nl 2180 print"it works!": end Progra m 2: This is a BASIC implemelllalion of the algorithm calculated.by Program I. It prints each mnemonic along with the code generated; each 路code is unique, and could be used to direct an assembler to the appropriate parsing routine for the opcode. KA MI LK GL AJ PH OF BP AJ NJ HL AP GH F1 10 BE DO AL HF DB
1D LN EE DC OE MH EF AK IK EK DA DE EB OH CK U CE IL JE HG
I00 rem ------- program 2 ---------110 rem 120 n=56: dim op$(n),op(n) 130 for i=l ton: read op$(i): next 140 data adc,and,asl,bcc,bcs,beq,bit,bmi 150 data bne.bpl,brk,bvc,bvs,clc,cld,cli 160 data clv,cmp,cpx,cpy,dec,dex,dey,eor 170 data inc,inx,inyjmpjsr.lda,ldx,ldy 180 data lsr,nop,ora,pha,php,pla,plp,rol 190 data ror,rti.rts,sbc,sec,sed,sei,sta 200 data stx,sty,tax,tay.tsx,txa,txs.tya 210 rem 220 m=25: dim tl (m),t2(m),t3(m) 230 for i=O to m: read t I (i): next 240 data 6, 7, 8, 9, 10, 0, 0, 0. II 250 data 12, 0, 13, 0, 14. I, 2, 0, 3 260 data 4, 5, 0, 0, 0. 0, 0, 0 270 for i=O to m: read t2(i): next 280 data 10, II, 12, 13, 14, 0, 0, 15, 16 290 data 0, 0, 17. 18, I, 2, 3, 0, 4 300 data 5, 6, 0, 7, 0, 8, 9, 0 310 for i=O to m: read t3(i): next 320 data 4, 0, 5, 6, 7, 0, 0. 0, 8 330data 0, 9, 10, 0, 0, 0,11, 12,13 340 data 14, 15, 0, 1, 0, 2, 3, 0 350rem 360 rem --- execute the algorithm 370 rem given an opcode mnemonic in 'op$', 380 rem this routine puts a corresponding 390 rem code in 'x '. the code is guaranteed 400 rem to be unique for each 65 10 mnemonic. 41 0 for i=l ton: op$=op$(i) 420 a=asc(left$(op$, I ))-asc("a"} 430 a=tl(a): ifa=O goto 1000 440 b=asc(mid$(op$,2, 1))-asc("a") 450 b=t2(b): if b=O goto 1000 460 c=asc(right$(op$,1 ))-asc("a") 470 c=t3(c): if c=O goto I000 480 x=(a* I + b* 16 + c*4) and 255 490 op(i) = x: next
Transactor
CB AI GC DL OE CM OB IH IJ KM GE CG EM
500 rem 5 10 rem--- print results from array 520rem 530 print" 65 10 Mnemonic Algorithm" 540 print 550 for i=l to 54 step 3 560 for j=i to i+2 570 print op$(j)"="right$(" "+str$(op(j)),3)" "; 580 next: print: next 590 prim op$(55)"="right$(" "+Str$(op(55)).3)" " 600 prim op$(56)"="right$(" "+str$(op(56)),3) 610 end 1000 rem--- invalid mnemonic
Program 3: The machine-language implementation of the opcode algorithm in Program 2. NA Ml GL AK IC HG BL LJ CI ED KK IE JC DP JL DP MP PC 01 LD CK NG GL ON KM OK OL HB JL GI DO HD DP JB lL IB OC NA ID AG LA 48
100 rem-------- program 3 ---------110 rem 120 rem pal64 fom1at ~ource 130 rem 140 open 2,8, I,"O:output" 150 sys 700 160 .opt o2 170 *= $c000 180 jmp begin 190; 200 ; table of mnemonics 210; 220 mnem =* 230 .asc "adcandaslbccbcsbeqbitbmibnebplbrk" 240 .asc "bvcbvsclccldcl iclvcmpcpxcpydecdcx" 250 .asc "deyeorincinxinyjmpjsrldaldxldylsr" 260 .asc "noporaphaphpplaplprolromirtssbc" 270 .asc "secsedseistastxstytaxtaytsxtxatxstya" 280; 290 ; resulting op-codes 300; 310 ops *= *+56 320; 330 ; tables for transformations 340; 350 table I =* 360 .byte 6, 7, 8, 9, 10, 0, 0, 0, 11 370 .byte 12, 0. 13, 0, 14, 1, 2, 0, 3 380 .byte 4, 5, 0, 0, 0, 0, 0, 0 390 400 table2 =* 410 .byte 10, II. 12, 13, 14, 0, 0, 15, 16 420 .byte 0, 0, 17, 18, I, 2, 3, 0, 4 430 .byte 5, 6, 0, 7. 0. 8, 9, 0 440 450 tab1e3 =* 460 .byte 4, 0, 5, 6, 7, 0, 0, 0, 8 470 .byte 0, 9, 10, 0, 0, 0, II , 12, 13 480 .byte 14, 15. 0, I. 0. 2, 3, 0 490; 500 ; execute the algorithm May 1988: Volume 8, Issue 6
Ell
510; PII 520 begin AG 530 GJ 5401oopl
HK 550 AP 560 FA DA EI
IIC KK NO GD LF LE KM IJH
Bl Ll FJ MD
PC GO
oc PG IL
NM
PM ME
JP DA KK ML
EF 10 10 AL Af
570 580 590 600 610 620 610 640· 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 850 860 !!70 880
KF 890 EG 900 PG 910 CG 920 FD
cc Mil
GD KK KE DG
OF
NC CH EP
Gl AE
AJ NB EB
ldy #() sty opsx Ida mnem+O,y sec sbc asca tax Ida table l,x beq error sta temp ; (left-)*I Ida mnem+ l,y sec sbc asca tax Ida table2.x beq error lsr lsr lsr lsr
he 1
is
~send p\eCes
'
eooli.
'*' Olsli. • 1 ..,
r"""' \...
'
clc
adc temp ; +(mid-)+ 16 sta temp Ida mnem+2.y sec sbc asca tax Ida table3;< beq error lsr lsr clc adc temp ; +(right-)*4 ldx opsx sta ops,x . mx stx opsx . .my my . my cpy #168 bneloopl beq cont I
930 940; 950 ; error routine 960; 970crror 980: 990 : print resultl;/process code byte 1000· ' 1010 COnti 1020; I030 ; data areas 1040; 1050 opsx .byte 0 1060 asca .a~c "a" 1070 temp .byte 0 1080.end
Tronsactor
Bits & Pieces 1:
=·
'
l j
.l
j
r
j j
I I
j
j
I
J J
J
I
) ~
'
-------
--
J
J
From the famous book of the same name, Transactor Productions now brings you Bits & Pieces 1: The Disk/ You'll thrill to the special effects of the screen dazzlers! You'll laugh at the hours of typing time you'll save! You'll be Inspired as you boldly go where no b1ts have gone before! " Extraordinarily faithful to the plot of the book. . . The BAM alone Is worth the price of admission/"
Vincent Canbyte
"Absolutely magnetldl" Gene Syscall
" If you mount only one bits disk m 1987, make it this one/ The fully cross-referenced mdex IS unforgettable/
=*
Recs Read, New York TIS BITS & PIECES I THE OISK, A Mylar F1fm, 1n assooa1kln Wllh Transac1or ProducllOrls Plily.ng at a drl~ near you I
Disk SS 95 US, S9.95 Cdn. BookS 14.95 US, S 17 95 Cdn. Book & D1sk Combo Just S19 95 US, S24 95 Cdnl 49
Moy 1988: Volume 8, Issue 6
An Accurate Tl$ \
Long-term timing accuracy f or the C64 and C128 â&#x20AC;˘
Tl$, and its companion numeric variable Tl , are handy for timing applications. Tl$ is easily reset and it's always there in BASIC. T l can also be read or set through the kemal RDTI M and SETIIM routines in machine language programs.
even to the ponderous I MilL clock in the C64, so 1t's easy to monitor or control many machines at the same time with a very inexpensive, easily programmed computer. For more information on control and monitoring applications, see Practical Interfacing Projects With The Commodore Computers, by Robert LuetLow (TAB Books).
Tl ,., mcremented from the IRQ. or hardware interrupt routine. IRQ occurs about Mxty times each !.econd. IRQ adds l to Tl each time it occur!.. So. Tl coums l/60ths of a second. often called 'jiffies'.
Tl$ wru. not accurate enough for our client. The TOD (Time Of Day) clocks in the CIA chips seemed like a good choice to him. But reading and using them is much more difficult than using T l or TIS.
by 'loell\yman
Tl is only as accurate as the IRQ frequency. Routines that halt The TOO keeps time acc urate to one-tenth of a <;econd in four interrupts also stop the TI/TIS clock. Disk and tape accesses addresses or registers (.,ee figure I). The infom1ation is held in BCD (Binary Coded Decare the common cau<>e., of an 2 Bit 7 6 5 4 1 0 3 ima!), a compact way of maccumte jiffy clock. But AM X X H H H H 56331 H storing decimal digits. BCD any machine language that PM T Hours u u u u complicates the task of using contain., an SEI (SEt InterMM M M M M M M 56330 rupt mask), will have the the time numerically. Minutes T T T T u u u same effect. 56329 Our client was monitoring T T T Seconds T u u u u the 'on time' of various plant There are two very accurate 56328 X X X X machinery, and counting clockc, m the Ct>.t and Cl28, N N N N Tenths produced parts. I lis software one in each CIA (Complex AM/PM Flag: AM=O, PM=1 combined time and counts in Interface Adaptor) chip. The T "'tens digit U=units digit x=unused several statistical ways. He'd clock~>' timing is maintained by the power line frequency, intended to use the T l Bit Functions in the TOD Clock counter, simply holding in and i~> accurate to a few millionths of a second each day. memory the staning Tl and As the power load increa-.es during the day, the freq uency the ending Tl. Subtracting the two gives the total machine drops -.lightly. Your fnendly power com pan)' monitor!. the fre- "on time" in jiffies. quency changes closely. Then. during non-peak hours, it increase'\ the frequency a bll to compensate for the earlier To do that using the TOO requires extmcting seven BCD digits und the AM/PM flag. Then the digits must be converted inchange:.. to tenths of seconds and added together. A different converThe C64/C 128 operating syo;tems do not make use of either of sion is required to display the digits as time on the screen. What was needed was a way for the TOO clock to keep T l the CIA clocks. and Tl$ accurate. One of our chents wanted to use a C 128 for mdu~tnal process control. The C64 and C 128 are excellent co~t effective choic- Maintajnjng An Accurate Tl e~ for this type of applicution. They have an "open architecture", which means you can get at all the intcmal signals eas- Our approach was to modify the IRQ routine to monitor the ily. Most industrial events occur in " real time", very slowly TOO clock in CIA #I.
s
s
s
s
s s
I ~~ s s
s
s s
I
TronsociOf
50
May 198&: Volume 8, Issue 6
Since our client needed accuracy over a long period, we update Tl{fl$ only once every hour. The new rouune looks for minutes. seconds, and tenth-seconds in the TOO to all equal zero. When that occurs, the routine reads the TOO and update~ the three bytes in zero page memory that make up TI. BASIC generates TI$ from Tl whenever reque~ted, so an accurate Tl means an accurate Tl$.
the starting address in decimal. If there are errors in the DATA statements, you'll get an error mc~sage. Scratch "New-IRQ", correct the DATA errors, and run "Create" again. "Create" is a complex generator because the ''New-IRQ" routine is not relocatable. There are several addre~~es and vector. that will change. dependmg on where you decide to place the code.
The "New-IRQ" routine gets the data for the Tl update from three 25-byte rabies. A value m each table corresponds to the value found in one of the three bytes of Tl at the start of each hour. The routine detennines the hour from the TOO hours byte and uses that value as an index to each of the three ta• bles.
You need this flexibility. "New-IRQ" will work on either a C64 or a C 128. But the 'safe' places to store machine language code vary between the two machines. "New-IRQ" use& 186 byte~. Anywhere 1n the area between 49152 and 53247 (SCOOO-$CFFF) is good on the C64. On a C 128, the area starting at 4864 ($1300) may be safe. The tape buffer and RS232 buffers are good choices, if your software doc~n't use them. In any case, keep the code below 16384 ($4000), so the new routine will be 'visible' regardless of what bank you're in when an IRQ occurs.
If you needed more accur.1cy, you could update Tl each minute. That would requtre three tables of 1500 byte~ each, much too large. You could u~e an algorithm to calculate the three values for Tl. But in practice, an update every hour is accurate enough for real time applications. Quirks in the TOD
Line #Ill 0 compensates for a bug in the 65xx/85xx family of proce~sors. Once "New-IRQ" IS finished, the standard IRQ routine is executed by an indirect jump, JMP (SCOFF) in machine code. The actual addre% jumped through w1ll depend on where you located the "New-IRQ". The indirect vector may span a page boundary. In our example above, the vector sits at $COFF and SCIOO. When this happen~. the indirect jump will not work properly (see 6502 Assemhly WIIJ:uuge Programmmg, by Lance Leventhal, pages 3-13).
There are only twenty-four hours in a day. A 25 byte table is needed because of an anomaly in the TOO clock. The TOD uses a twelve hour format, with an AM/PM flag, see figure #I. For example, II a.m. is represented by the value 17 ($11) stored in the hours regi~tcr. Bit #4 is set for the IO's digit, for a value of 16. Bit# 1 is set for the l's digit. For II p.m., the value i~ 145 ($91). Bits #4 and #0 are set. Bit #7 is set for PM, value 128. That's all very straightforward. The problem arises with 12 o'clock.
Line #Ill 0 checks for this pos~ibility and. if found, adds a NOP code to the start of "New-IRQ". This makes the code one byte longer, but avoids the bug under all circumstances.
In twenty-four hour format. the time just after midnight is called '()()' hours. In twelve hour forma4 we call it 12 a.m., so 12 noon ( 1200 hours) become!> 12 p.m. to us. The TOD. however, will clear the AM/PM bit if you try to set tt ~ith a 12. If you poke the hours regi~ter with a 146 to set 12 p.m., the TOO will change it to 18, its normal representation for 12 a.m.! If you POKE an 18, the TOO happily changes it ro 146, orl2a.m.
LOAD "New-IRQ",8,1 either before you run your main program or from within the program itself. u.,e SYS xxxxx (where xxxxx is the dec1mal starting address you used with "Create") to initiali7e the routine. The program " BASIC Time" setc; Tl$ and the TOD to the current time, taking care of the 12 o'clock anomaly. Add "BASIC Time" as a subrouune to your program, and call it early.
To set the TOO properly, we have to poke '00' for 12 a.m., and '18' for 12 p.m.. But when we read the TOO, an '18' in the hours register means twelve a.m., and a "146" means twelve p.m.
You can also use "New-IRQ" as a stand-alone program to keep Tl$ accurate in direct mode. Be sure to use " BASIC Time" to set t11e clocks, changing the RETURN in line #50 150 to END.
So, there are two possible values for 12 a.m., '0' if we've just set the TOO, and '18' if it's counted to a new day on its own. These added to the other twenty-three hour values make up tables of 25 bytes.
In either progrMn or direct mode, pres ing the ReSTORE J...ey will d1sable "New-IRQ". A SYS to the starting address will re-enable it. Although you can call "BASIC Time" again, it's probably not necessary. Unless the computer is shut off, the TOD and Tl will continue running after RESTORE is pressed.
Using the New IRQ Routine F1rst, run the BASIC program ··create". A program named "New-IRQ" will be created on device #8. You can change the name or device number in line #1050. When prompted, enter Transactor
51
•
May 1988: Volume 8,1ssue 6
~-
---
Listing I : " BAS IC Ti me" subroutine MP BL LE ON AN NN Cll HO JE EC GM EH GA KE GG EL MO IN OA FO HC CN BH
'iOOOO rem ~ubrouune to get ume from
50005 rem u~r and cooven for tiS and 500 I0 rem the tod clock in cia If I 50015 : 50020 rem by noel nyman 50025: 50030 rem called as a subroutine 50035: 50040 rem ~• the following variable~ 50045 rem ap - am/pm flag, am~ pm= I 50050 rem ht- hours, used for tod 50055 rem mt - mmute~. used for tod • ~c - seconds. ~d for tod 50060 rem 50065 rem n- temporary vanable 50070 rem 11%- temporary variable 50075 rem ht$- hours for tiS 50080 rem mt$- minutes for tiS 50085 rem st$- seconds forti$ 50090 rem u$- temporary for 11$ 50095 rem up$- temporary variable 50099: 50100 print "current ume is" left$(ti$.2) ":" midS(ti$,3,2) ":": 50110 print nghtS(tiS,2) FD 50120 print print "enter new time, or [rvs) (rv• off) to quit" 10 50110 pnnt· prim "enter new hour<; (0-23): ": GP 50140 open 9,0: mput#t9,htS: closc9 MJ 50150 tf ht$:"" then return Ml 50160 ht=val(ht$): ifht<O or ht>23 goto S0130 Ml 50170 ap:O-(ht> 12) IH 50180: EC 50200 print: print "enter new minutes (0-59): "; GE 50210 open 9.0: input#9.mt$: closc9 IP 50220 mt=val(mt$): if mt<O or mt>59 goto 50200 OL 50230 if len(mt$)<2 then mt$="00"+mt$ EL 50240: HE 50300 prim· pnnt "enter new second\ (0-59): ": GL 50310 open 9.0: inputlf9,stS: close9 GA 50320 sc=val(,t$): if sc<O or sc>59 goto 50300 LO 50330 if len(st$)<2 then stS="OO"+stS IB 50340: AO 50400 if ap goto 50500 GJ 50410 print: tf ht< 12 goto 50460 B I 50420 print "am or noon (a/n)?": OH 50430 get ap$: if ap$="" goto 50430 lL 50440 if ap$<>"a" and ap$<>"A" and apS<>"n" and ap$<>"N" goto 50430 FE 50450 ap=O-(apS="n")-(apS="N"): goto 50500 HB 50460 prim "am or pm (alp)?": OK 50470 get ap$: if ap$:"" goto 50470 GP 50480 if ap$<>"a" and apS<> A" and 11pS<>"p" and ap$<>"P goto 50470 TK 50490 ap=O (apS="p")-(apS="P") JB 50500 ht=hr+l2•((ht=l2) and (ap=O)) NC 50510 ht=ht- J2*((ht<l2) and (ap=l)) AM 50520 ht$=str$(ht): ht$="00"+right$(ht$,1cn(ht$)- l) IF 50530 ttS=right$(ht$,2)+right$(mt$,2)+right$(st$,2): ti$=11$ KH 50540 tt=O: if ht> 12 then ht=ht-12: II= 128 U 50550 tt%=ht/IO: 11=11+(16•11%)+{ht-IO•u%) FP 50560 poke 56335,pcek(56335) and 127 HA 50570 poke 5633 I ,n PO 50580 tt%=mi/IO: u:(J6•u%)+(mt- IO"tt%)
Transactor
IB AB FE AI CO
50590 poke 56330.11 50600 u('~=<>c/10: n=(l6•n%)+(sc- IO•u~) 50610 po\..e 56329,11 50620 po\..e 56328.0 50630 pnnt: goto 50100
Listing 2: "Create" CN OJ IH JK El HG JK GB KC EO 10
PH GA EB II B KC HE DC AJ KG AF NJ EG BK NK Ml PN HG OJ
I000 rem •• this program will create a I 0 I 0 rem u machine language program I020 rem ,... which modifies the irq 1030 rem •· routine to set tiS=tod eta# I
1040: 1050openl5.8.15: open8,8,1,"0:neow trq" ckr;() I 060 mput# 15.e.eS.b.c: if e then close 15: print e:eS:b:c:stop 1070 mput Manmg address: :~$ 1080 ~ val(s$). if&< I gotol090 1090 def fnh(x)=int(x/256): def fnl(x)-x-256•mt(x/256) 1100 print#8,chrS(fn1(s));:print#8,chr$(fnh(s)); 1110 if fnl(s+25)=255 then print#8,chrS.(234)::s-'s+l 1120 for x= I to 5: read a: ck=ck+n: print#8,chr$(a);: next 1130 pnnt#8,chrS(fnl(s+25));:prinr#8,chr$(fnh(s+25)}: 1140 for x= I to 4: read a: c\..=ck+a: pnnt#8,chr$(a):: next 1150 print#8.chrS(fnl(s+26))::print#8,chr$(fnh(s+26)); 1160 pnnt#8.chrS(I69);chr$(fnl(s+27)): chr$( 141 ):chr$(20);chr$(3 ); I 170 pnntlf8.chrS(I69):chrS(fnh(s+27)); 1180 for x= l to 66:read a; c\..=cl..+a: printlf8,chrS(a)::next I 190 pnnt#8,chr$(fnl(s+l12))::pnntlf8.chr$(fnh(s+ll2)): 1200 for \=I to 3: read a:• c\..=c\..+a: pnntlf8.chr$(a);:next 1210 pnnt#8.chr$(fnl(s+ l37));:print#8,chr$(fnhb+ 137)); 1220 for x= I to 3: read a: ck:ck+a: pnntlf8,chr$(a);:next 12~0 print#8.chr$(fn1(s+ 162});:prim#l!,chrS(fnh(s+ 162}); 1240 for x=lto 12: read a: ck=c\..+a: print#8,chr$(a);:next 1250 print#8,chr$(fnl(s+25));:printlf8,chr$(fnh(H25)); 1260 for\= I to 75: read a: ck=c\..+a: print#l!,chr$(a);:ncxt 1270 clo,e8:closel5 1280 tfck<>l8314 then print"---error in data statcmen~! ---":
end JJ 1290 prim · •••irq module created• • •"· end II 1300 . KB 1310data 120. 173, 20, 3. 141, 173, 21, 3 10 1320 data 141, 141. 21, 3. 88. 96. 0. 0 GO 1330data 165,251, 72, 165,252, 72. 173. II Oil 1340 data 220, 133, 251, 173, I0, 220, 208, 57 JC 1350 data 173, 9, 220, 208, 52, 173. 8, 220 DO 1360data 208. 47. 165,251. 41, 1~. 133.252 OG 1370data 165,251, 41. 16,240, 7. 24. 169 HK 1380 data 10, 101,252, 133,252. 165.251. 16 LH 1390data 7, 24, 169, 12. 101,252. 133.252 MM 1400 data 164. 252. 185, 133. 160, 185. 133. I 61 l\.11 1410data 185. 133. 162. 173, 8, 220. 104. 133 CJ 1420data 252, 104. 133,251, 108, 0. l 6 AJ 1430 data 9. 13. 16, 19, 23, 26, 29. 12 GO 1440 data 36. 0, 42, 46, 49, 52, 56. 59 KP 1450 data 62. 65, 69, 72, 75, 39, 0, 75 Ll 1460data 15 1,227. 47, 122, 198, 18. 94. 169 JA 1470 data 245. 65, 0, 216, 36, 112, 188, 7 JP 1480data 83,159.235, 54, 130,206, 141. 0 JA 1490 data 192, 128, 64, 0, 192, I 28, 64. 0 DB 1500 data 192. 128, 64. 0, 192, 128. 64. 0 B 1510 data 192. 128. 64, 0, 192, 128. 64. 0
52
May 1988: Volume 8, Issue 6
: ;
I
Lil.ting 3:
"Ne~- IRQ"
••••••••••••••••••••••••••••• • thl\ routtne is added to the • • normal m1 to reset the • • 'Y'tcm clock (ti and ti$) • • to the ttme-ot-day clock • • in cia Ill. • • • • the ti/ti$ clock is subject • • to accumulated errors. • • c~pcciall:r during disk • • and l!lpc IICCeS\. the tod •
•
• • • • •
clod. accurac:r tS mamtained by the power line frequency.
• • • •
•
•
tht' routtne <.eh the tt/tiS clock= to the tod clock on the tod hour (minutes and ~ccondb all= lero).
........ ..
•
~················
: $0:ll4
;addres~
hourl! minute., \CCOnds tenth\
- $dc0b : $dc0a =$dc09 = $dc08
;cia Ill ;cia Ill ;eta #I ;cia #I
= Sib
• • • •
*
.trqvec
tempi tcmp2
• •
..
=$fc
=SaO
•..
"' .."'
;first b:rte of ti :temporary ~torage. original value unchanged :temporary Momge, original value unchanged
II
•
•
noel nyman 8/87 ,
• • • •
• •
~kipten
• •
of trq vector
hours rcgtMer minutes reg ister seconds reg ister tenth\ sec regi\ter ~ktpap
• routine can he placed at any convement locatton orgScOOO • get the current trq vector and store it in • 'holdirq.' place the vector to the added • coc.lc at the 1rq vector address . . start \el Ida irqvec sta holdirq Ida irqvcc+ I \Ia holdtrq+ I Ida ll<ne" irq sta trqvec Ida #>newirq \Ia irqvec+l ch
• • • • •
exit
m holdirq ncwtrq
hex 00,00 ;code added Ida temp I pha Ida tcmp2 pha Ida hours sta temp I
Transactor
• •
to irq routine stan~ here :store current values of ;temp 1 and tcmp2 on \tack ;~owe can restore them in case ;the interrupted apphcatton u>es them :reading the hours rcgtMer :halts the clock, we \tore
table I table2 table)
53
;the value in temp I. JUM :in case it's umc to usc 11 Ida minutes :check for minute\ 1ero bne exit ;tf not 1.ero. not ttme to update Ida ...econd!> :check for Lero second\ bne exit :and skip update if not 1ero Ida tenths ;check for 7ero tenths of a \econd bne exi t ;and skip update ot not 1.ero ;the update routine converts the ;value in the hours regiMer Jrom bcd/am-pm format mto ;a bmary number in the range ;0-25, where 0 or 12 equah 12am, :I= I am, 13= I pm, and 25-noon . :the convened number ·~ u'ed a' an :111dex to a table to store the :proper values in the three byte\ of ti Ida tempt ;hours reghter value and #$Of :mask out upper bed dtgll, am-pm \tU tcmp2 ;~tore lower hour~> digit Ida temp I :get hours value agum and liS. I0 ;mask out all but the upper bed digit. ;this can only be Lero or one. bcq sktpten ;if zero, don't add I 0 to tcmp2 etc Ida ll$0a :if high hours digtt wa' one. adc temp2 :add I 0 to temp2 ta temp2 Ida tempi ;get hours value again bpi ~kipap ,if high bit clear ;time is run, sktp the ruuune :that adds 12 for pm ume~ clc ' tcmp2 Ida ll$0c ;add 12 to ode tcmp2 ;if time is pm \Ia temp2 ldy tcmp2 :put index to table in y Ida table I,} ;get values from ~ta 11 ;three table\ Ida table2.} ;and store 111 the ~ta ti+ I :three byte~ Ida table3,y ;of ti \til ti+2 ;restart display, :restore the previous value~ in ;tempi and temp2, and jump ;through the ~tored irq vector to ;complete the irq routme . Ida tenths ;read tenth~ to restart display pia \La temp2 pia sta tempt jmp (holdirq) the following three table~ hold the values normally found 111 the three bytes of 11 at the ' top' of each hour. hex 00,03,06,09,0d,l 0,13.17,1 a,l d,20,24 hex 00,2a,2e,31,34,38.3b,3c,41.45.48.4b,27 hex 00,4b,97 ,e3,2f,7a,c6,12,5e,a9.f5.41 hex OO,d8,24,70.bc ,07,53, 9f.eb.36.82,cc.8d hex OO.c0,80,40,00.c0.80,40,00,c0,80,40 hex OO,c0,80,40,00,c0,80,40.00.c0.80.40.00 May 198&: Volume 8, Issue 6
Olsen's Raid An Update to the "Shiloh's Raid" Relative File Bug Fix
7:
Volume Issue 4 of Transactor contained an article by David Shiloh called "Shiloh's Raid" that claimed to eliminate the dreaded relative file bug: it showed under what circumstances the bug occurred, and took extra precautions when writing to the tile under those conditions. Since that article appeared, we heard from Helen Olsen, who found a flaw in Shiloh's explanation of when the bug occurs. Helen sent us several programs to illustrate her point. and after hearing from her, and again from David Shiloh, we think it's time to clarify things a bit.
Shiloh explained that the bug occurs under the following conditions - refer to the diagram below to illuminate the explanation: data is written to a relative file record, "spilling over" from one sector to another. This is write number I in the diagram, spanning sectors A and B. Write number 2 then takes place, to a record residing wholly within the next contiguous sector - sector B. According to Shiloh, the bug is now waiting to happen, and if a write (3) now occurs to the next sector (C), the data is instead erroneously written to sector A, potentially spiUing into sector B as well.
First, let's back-track a little. A generally-known bug in the 1541 causes problems under rare conditions when writing to a relative file. The fix (also generally known) is easy -just position the record pointer rwice before writing a relative file record. The extra point (and some say a short delay as well) seems to eliminate the bug, so most experts advise to handle relative files in this way and eliminate the problem. David Shiloh took the extra step of finding under exactly what conditions the bug occurs. and applying the fix only under those conditions. The program he presented along with the article was supposed to prove that the fix works by checking for errors in a long random-write test both with and without the "Shiloh's Raid " routine in place.
Shiloh's solution was to detect when this condition was about to occur and apply the standard fix, to position the record pointer twice and pause before writing. The advantage to Shiloh's Raid is that the double-point need only be done on the rare occasions when the above circumstances occur. saving time for typical relative file access. Enter Helen Olsen. Her main point was that the conditions that Shiloh sets for the bug to occur are too strict; only writes I and 3 (referring to the diagram again) need to take place to trigger the bug. She suggested that positioning an extra time (without the delay) after writing to a split record (I) is the best solution.
Consecutive Sectors
A ' IIIJIOIOIIOIIIOGCI1001 180110010
I
c
B I
I IOIIOOIOIJOlOOOIIOIOOIIUOOIOtiJ
I
Ill HIOIOIIOIOIOOIUIItoiiOllOOII
I
1
i
''
Write spans sectors A and B
Transactor
Write contained within sector B
54
Write to sector C
May 1988: Volume 8, Issue 6
•
As it turns out, David Shtloh's explana11on of when the bug occurs is too exacting, but the 'Shiloh 's Raid' program works properly, that i'>, it senses trouble and does the extra pointer po:.itioning even when onl) writes T and '3' occur. David Shiloh told us this, and shortly thereafter. Helen Oben ~cnt us a letter that concurred. Here is part of that letter:
Super 81 Utilities is a complete ulrlllles package for the Commodore 1581 Orsk Drrve and Cl28 computer Copy whole drsks or rndrvrdual files from 15<11 or 1571 format 10 1581 partrllons Backup 1581 drsks Contains 1581 Oosk Edotor, Orrve Monrlor, RAM Writer. CP/M Ulllotoes and more lor only $39.95.
"To sum up my position on Shiloh's Raid: His description of the causl' of the bug is wrong - ht~ l, 2. 3 sequence, with 2 settmg up the bug ts wrong. The bug happens with I followed by 3. I was wrong about his fix not working because I assumed that it wa~ applied only in response to the I. 2. 3 sequence. lie may not realue it. but his :.ubroutine repeats the J)ositioning command often outside that !>equcnce, including the I, 3 ~equence, which may be why he's unaware that it causes the bug, a l ~o ... His fix is also applied when it is not necessary... In mndom use of a relative file. my ftx, which repeal'> the po'>llion command after every write to a ~plit record, will surely be used unnecessarily more often than Shiloh's nx, but since I don't t-.now the cause of the bug (nor docs he), l feel ~afer using it."
15<1111571 Orrve Alignment reports the alignment conditoon of the disk drrve as you perform adjustments. Includes features for speed adjustment and stop adjustment Includes program dtsk. calrbratron disk and rnslructron manual Works on C64, C128, SX64. 1541, 1571 Only $34.95. excellent. elftctent program that can help you save both mo.~ey and downttme Compute•·s Gazelle. Dec 1987
Excrtrng space explorallon game fro the C64 Search for lrfe forms among the 200 billion stars in our galaxy Scientifically accurate Awesome graphics• For the serious student of astronomy or the causal explorer who wants 10 boldly go where no man has before $29.95.
Stalisllcs·based baseball game. Includes 64 aiHrme groat ma1or league teams Reahsrlc strategy Great sound & graphocs' Apple II systems $«.95, C.~ & Atarr systems ·$39.95.
Helen presented programs along with her letters that proved her point, ~howmg that only writes I and 3 were required to cause the bug, and showing that her fix worked.
Order woth check, money order."VISA, MasterCard. COO Free shippi ng & h1nd ll ng on US. Canadran. APO, FPO orders COO & Foreign orders add $4.00 Order from:
Free Spirit Software, Inc. 905 W Hollgrove. Sutle 6 LaGrange. IL 60525 (31 352· 7323
So where doe!> that leave us at the Trctn~actor? Well. wtth a certain amount of egg on our face, to begin with, for not verifying that Shiloh's program was doing exactly what the text of the article said it was supposed to do. It may be even \.\Orse than that (for us). because the version of Shiloh's Ratd that was pnnted was much tmproved cosmetically from the original - expanding from nineteen lines of tightly packed, unreadable code. to a page and a half of commented BAS IC that had a chance of being under..tood. Perhaps something was lo~t in the tramlation that accounted for the application of the extra point and wait when it was unnecessary, i.e. outside of the " l , 2, 3" and •· 1. 3" conditions. In any case, we perhaps got carried away a tad in presenting the last word on the relative file bug, and we're glad that Helen brought us down to reality, though "glad" may not be the most appropriate word all around.
Announcing a unique new product for the C128
Jugg'ler - 128 By M. Garamszeghy
This program provides read, write and formatting support for more than 130 types of MFM CP/M disks on the C128 in CP/M mode with a 1570, 1571, or 158 1 disk drive.
So. to summarize: The original Shiloh·~ Raid program was correct, in that it prevented the bug from occurring, and only applied the fix on a very small percentage of writes to the file. Shiloh's explanation of when the bug occurs doesn' t cover all ,ituations. so ts only parttally correct. Helen Olsen is right about the naw tn Shiloh\ explanation, and her soluuon also 'ccms to MOp the bug from occurring. There is )till no proof that there are no other ways in which the bug can occur, but it \cems that you arc safe if you usc Shiloh'!> Raid, Olsen's fu, or if you just position twice before every write to a relative file.
It is compatible with all current versions of C128 CP/M and all C128 hardware configurations including the 128-D. All normal CP/M me access commands can be used with the extra disk types. Jugg' ler is available by mail order for $19.95 Canadian or $17.95 US from Transactor. Order from the card at the centre of this magazine.
l'hus closes the tile on Shiloh's Raid: as lie len Olsen ended her letter after announcmg that it wa' to be her la'lt on the 'ubject, "Did I hear a heartfelt 'amen"!'' Transactor
55
May 1988: Volume 8, Issue 6
-
-
~-
--
· ----
--
Three Movers for the C64 Relocatable utilities to save and restore programs, screens and colour data
by Richar(l Curcio
... will change all characters on the screen to black by filling color memory with 7eroes.
Many video effects are poss•ble on the C64 by quickly movmg large blocks of memory. The routines presented here are designed to do just that. These routines are relocatable; simply change the variable SA in the associated Basic loader to the desired address. The FOR-NEXT loop value in each loader indicates the length of the ML. Although relocatable code is often longer than non-relocating, this can be justified by the ability to place it wherever there is enough room, without modification.
Character ROM b not affected by the ma'>k value. To copy character ROM into RAM requires almost as much code as doing it in BASIC. It happens several hundred times faster. though:
' 100 poke 56334, peek(56334) and 254 : rem disable interrupts 110 poke 1, peek( I) and 251 : rem switch in character rom 120 sys MOVE, 53248, 12288,2048, 0 : rem move upper ca~e/graphics character set to ram 130 poke I, peck( I) or 4 : rem switch out character rom 140 poke 56334, peek(56334) or I : rem enable interrupts
Move.Plus The first routine is not limited to moving video or graphic information. It can move any chunk of memory to any location. This routine has the ability to retrieve data stored in RAM .. under" the BASIC or Kernal ROMs. The '>yntax for calling the routine is:
Funher pokes are nece!>sary to protect the new cttaracter set from Basic variables and to tell the VIC chip where to find the characters. Consult the Programmer's Reference Guide or other sources for more information on C-64 graphics.
~ys
MOVE, source address. destination address, number of bytes, mask
.,,art
address of the routine (51200 in the where MOVE is the version listed). The last value, mask, must be in the range 0 to 255. If mask is greater than zero, interrupts are d1sabled and BASIC and the Kemal ROMs are S\\itched out, allowing the RAM beneath them to be accessed. The memory configuration in effect when the routine was called is reMored upon return. Thus, if a modified BASIC in RAM is in effect, the system stays that way. The RAM under the Kernal would still be available for storage in that case.
If the number of bytes to be moved cau~es the de,tination address to "roll over" from $FFFF to $0000. the remaimng byte~ are not moved and the routine return\ to BASIC. The value 255 is left in location 782 (SYREG) to indicate that the move was incomplete. Caution should be used when specifying addresses below 828 as destinations. Color.Move Thi~
To copy the BASIC ROM into underlying RAM: ~ys
routine will save the contents of colour memory to one of ~ixteen sections "under" the Kernal ROM. Because colour RAM conl>ists of I 024 nybbles, each color map i~ compacted into 512 bytes.
MOVE, 40960, 40960, 8192, 0 : poke I, 54
Note that mask value tero is used so that ROM may be read. Memory writes to addresses in ROM always "fall through" to the RA.\1 beneath.
To save a color map: sys COLOR. 'iection #
This routine can be used to fill memory by poking the first address with the desired value and moving up by one location.
...where COLOR is the address of the routine (51320 in the listed version) and section# is 0 to 15.
PQke 55296, 0:s:ts M0 VE, 55296, 55 2o::.:9:. .:.7_._,~ 99~9:.t.,.::: O_ _ _ _ _T.:...:oo:..:..:: re:=:ca::;:l.:l. .:a::.x:part!=""'-'cu"-'-lar=-:c:.::o~lo:.:.r..!;m~a:.t'pc:...:_ _ __ Tronsoctor
'
56
May 198&: Volume 8, l$$ue 6
1:
sys COLOR+4, section#
screen will have characters of different colors. This wamillg also applies when using section # 14 under the Kemal with 'Color.Move'.
I
To store colors under the BASIC ROM, 'poke COLOR+I9,160'. To change back to the Kemal, 'poke COLOR+ 19,224'. This makes a total of 32 colour maps avai !able. If a section were to roll over to zero page (due to poking too large a value into COLOR+ I9), the routine stops with '?illegal quantity' before any transfer takes place.
As with 'Color.Move', it is possible to change the storage area. 'Poke VIDEO+ 16, 160' will change the storage area to RAM under the BASIC ROM. ' Poke VIDEO+I6,224' to store under the Kernal. Like 'Color.Move', the routine stops with '?illegal quantity' if a section will roll over lo zero page.
It is also possible to reduce the number of storage sections.
'Poke COLOR+I2,8' would limit storage to sections zero through seven.
It is also
to copy from any given screen location. Say you have a bit-map at $6000 with its color matrix at $5COO. If for some reason you want to store the bit-map colors while maintaining text mode, poke the high byte of the bit-map colour matrix into location 648.
Video.Move This routine will save screen and color memory to one of five sections under the Kemal. All 1024 bytes of the screen are saved, including the sixteen unused bytes and the eight bytes of sprite data pointers. As in 'Color. Move'. colour ram is compacted into 512 bytes for a total of I536 bytes per section.
= =
200 TX peek(648): rem current text screen 2 10 VM 92: rem high byte of bit-map colors at $5COO 220 poke 648, VM: sys VlDEO, section#, 0 : rem use loc. 648 as org 230 poke 648. TX: rem restore normal text
To save screen and color:
This is risky. If the program should stop with an error before location 648 is restored to its previous contents, the machine will appear to have crashed. In reality, the system is printing to the bit-map colour matrix but the VIC chip is still displaying the old text screen.
sys VIDEO, section, screen org where VIDEO is the address where the routine is located (5 I456) and section is 0 to 4. The last parameter. screen org, determines where the screen, which is also called the video matrix, resides. If screen org is zero, the routine uses the contents of location 648 to detemtine where the screen is located. The operating system uses this location to determine where the screen is for text output. If screen org is greater than zero, the routine uses the contents of the VIC-II chip and data port A of CIA 2 to determine the video matrix location, which is the screen currently displayed. When the C-64 is in highresolutjon mode, each byte of screen memory contains the background and foreground colors for the hi-res bit map. The value in location 648 in trus case is irrelevant, and the value the VlC chip uses may be completely different. (Color ram is also irrelevant unless the C-64 is in multi-color hi-res.) In other words, an org value greater than zero uses the currently displayed video matrix. A value of zero uses the text screen, which may or may not be visible.
Simple Windows If you need a simple-minded Window utility. 'Video.Move' combined with a PRlNT "at" routine (that allows you to print to any given screen position) can do a good simulation. Just store the current text and colors, use PRINT@ or some other means to display a box with the desired message, then recall the screen contents to make the "window" disappear. Or store up to five screens for overlapping windows. lf it is not nece&sary to store lhe colours, 'Move. Plus' can store eight screens under ROM. One factor complicates this pseudo-window application. When printing to the screen, the system keeps track of which screen lines wrap around to the line below. This information is stored in 25 locations in zero page. When the screen is POKEd, which is what 'Video.Move' or ' Move.Pius' do, this link table is not updated. A recalled screen would have the links of the previous screen. This may or may not be a problem, depending on what you do with the recalled screen. PRINTs may not come out as expected. INPUT from the screen may be affected as well. To get around this problem, Move. Plus can be used to store the contents of the link table in some safe location.
To recover screen and color: sys VIDE0+4, section, screen org BASIC and Kemal ROMs are switched out during both storage and retrieval. Since 'Video.Move' stores information under the Kemal, section #4 should be used with caution due to the writing to RAM that takes place when RUN/STOP-RESTORE is pressed. To demonstrate, list something to screen in one color and save it to section 4. Press RUN/STOP-RESTORE to clear the screen and then recall section 4. The lower portion of the Transactor
po~sible
sys MOVE, 217, destination, 25. 0 To recall the screen links, 217 becomes lhe destination and the proper mask value should be used if the links were stored under ROM. Your program would have to keep track of 57
May 1988: Volume 8, Issue 6
which stored screen matches a ~tored link table.
FD IP PN
Other Uses
.
GB BB IG GP LD
·Video.Move' and ·color.Move' can create interesting effectS in low·re~ and even achieve pseudo animation by sroring and retrieving a number of alternate <.creens and/or colors. 'Video.MO\ e · will change the 'Prite data pointers along with the screen\ contenh. If enough RAM ts available. 'Move.Pius' can store and retrieve a number of bit-maps. 'Video.Move • will More both color maps of hi-res multi-color graphics. ' Move. Plus· can abo redefine custom characters or sprites for another form of animation. • One of the most useful applicat•ons for ' Move.Pius' is to store a number of machine language routines that need to be at the same address. Load a progmm to its designated location, then use •Move. Pi u~' to put it someplace safe. Repeat for other programs, then retrieve each routine as needed. (Don't try this with ''wedges", though.) ' Move.Pius· can even move itself and because of its relocatability it wi ll function at its new location.
Llsling 1: Assembler source code ror JO
PH Gl
KA
PA FN ED JM
AF M\1
IM AO GJ
LE EJ
MG
cc EC
NH GM BO HJ GF IF
MG MG AP b)tC AI
FF EJ M"l JH FN PM MM KB BC EO
1000 1030
........
· - $c800 move.plu\
LK FF OJ FO MJ
BM
MG GM CK
NM JD lL HM GC
DN DC
EE KD LD HH NE
' Mo~e.Pius'
IC KJ EC AE
·-··---
I().tO : 1050 frmnum = Sad8a 1060 chl..com = Saefd I 070 getadr Sb7n 1080 srce - ScJ 1090 nbytc~ = )14 1100 deM = $cl 1110 • 11:20 ; get and store ~ourcc and deMination 1130 1140 begin J~r chkcom 1150 JSr frmnum j\r gctadr 1160 sty srce 1170 1180 sta ~tree+ I 1190 jsr chkcom . frmnum 1200 JSr . 1210 JSr getadr sty de\t 1220 1230 MU dc•t+l 1240 J'r chl-.com 1250 : 1260 ; get number of bytes and mask value 1270 • 1280 JSr Sb7eb ; two bytes in $14/15. one
NC
Listing 2:
-
OB ON Gl
EC KJ
KA HD
CH 1D NP
oc GE
IC MJ OP
GK MG BH MJ pp DE PC IP lA AS N:'l OE ME EJ FN
Ill X
1290 I JOO 1310 1320 1330 1340 1350 1360 1370 1380 1390
Transactor
; : S 14- 15 has number of bytes ; txa beq calc ; if mask= 0 SCI
Ida SOl ph a and ll$fd \Ia $01
1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730
; get mem. con fig. ; ma'k basac and kernel
JN NN
; S8
; calculate end address ; calc clc Ida nbyte~ adc dest \Ia nbytes Ida nbytes+ I adc de\1+1 ~Ia nbyteHI ldy #$00 stan Ida (srce).y \ta (dest).y bump I anc srcc bne bump2 anc ~rce+l bump2 inc dest bne comp inc dcst+ I beq rollo comp Ida de~t+ I cmp nbytcs+ I bne Mart Ida dcM cmp nbyte~ bne sturt done txa bcq exit pla \Ia $01 ell exit rt\ rollo
dey bne done
; add #bytes to dest.
; S 14/15= dest.end+ I
; af dest. rolls over
; wa\ masl.. = 0 ; yeah ; restore mem. con fig.
; leave 255 in : location 782
'Color. \1o~e·
1000
·- Sc878 1030 ;-·- color.move --I().tO 1050 temp = Sc3 1060 ldy ll$ff 1070 1080 bne setup 1090 ldy 11$00 sty temp 1100 serup 1110 JSr $b7fl 1120 cpx 11$10 bcs qty I 1130 1140 lXII 11 50 a~ I 1160 clc 1170 adc liScO bcs qty I 1180 13)( 1190 111)( 1200 1210 beq qtyl 1220 ld1t IISOO \ta S25 1230 \IX $22 1240 \11( $24 1250 1260 ld11 #$fe 1270 ldy temp beq recover 1280 1290 ~avcol any 1300 ldll ll$d8 1310 \Ill S23 1320 coli Ida ($22).y 3~1 1330
; nag= \lOre ; nag = recover ; \ave entry ; \CCtion # in .x ; ch~. range 0-15 ; >SOf i!legal ; times 2 ; use aO for bas.rom : rolled over. no room ; w iII roll over. no room
; inn. addresses :counter : whach wa) ; #Sff+ I ; hb of color ram ; $22·23 = \Ource ; get a nybble
May 1988: Volume 8, l$$ue 6
'
•• HO
BP
'I
CE OJ EN LE LJ PK ID OJ AI FL AJ JG
HH
I
LH Fl OM GG PM KH HF GN OJ MF DP OA BB KA LM BE LE FF MO
E.B
I
I
MB NE DB HM OJ EA Fl
n OJ DA GL OK AK CB
1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820
3\l a~ I a~l
sta temp me S2l Ida ($22),y and#$0f om temp dec $23 \Ia (S24),y
OM GO PC PK MA OE BL CG BB EM ML HD JD AP AD AP KA PJ FC 1M
; move to hi nybble : save 11 : next pg. of col. mem. : get it : combme 'em : prepare for nc\t
10}
bne coli lOX
•
.
b<:q me me inc bnc
exit
: enough time~
S2S $23 $23 coli
; br.Jnch alwa}·S
•
qty I
jmp $b248
recover
SCI
.•
Ida ph a and sta Ida
col2
$0 I
#$fd $01 #$d9 ~ta $2:l Ida (S24),y '>ta ($22),y hr br l\r hr dec $23 Ma ($22).} inc $23 my bne col2
: 11legal quant.
cc
BA FP DE ON EF OF EM NH GO IP LF CG AC HL 01 LN GG Ml Gl LD AC BH OB GP EE DB
: get config. , masl.. out roms • pg2 of color ranl ; get a byte : 1gnore hi-nybble
: mo~c to lo nyb : ~tore 11 : pomter
lOX
rdonc
beq inc inc me bne pia ~ta
exit
rdone
$25 $23 $21 col2 $01
; get config ; and re~tore it
KH
eli m
JF OK EM PE JF DG EL FA GN LB NP GO
Lis ting 3: ' Vidc..>o. Move'. LO lK Gl EC KJ PB HD HI OK
PO
II
NC LM NL GP PJ lA JM
1000 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180
Transactor
...
Sc900 ;...... v1c.leo.move ------
.
•
temp
. •
setup
a gam
ldy bne ldy sty j\r cpx be\ Ida
$c3 #Sff setup #$()() temp $b7fl #$05 qty I #SeO
; here 10 store : here to recover
J~
: one byte in x : -.ecuon 0-4
NA CP HC CA IN GA BP OE
: u~ #SaO for bas. rom
de" bm1 cont clc adc #. 06
: no add111on
59
I 190 1200 1210 1220 1230 1240 1250 1260 1270 1280 1290 1300 1310 1320 1330 1340 1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 1550 1560 1570 1580 1590 1600 1610 1620 1630 1640 1650 1660 1670 1680 1690 1700 1710 1720 1730 1740 1750 1760 1770 1780 1790 1800 1810 1820 1830 1840 1850 1860 1870
eont
.• qtyl
.
bes bne tay adc bee
qty I again #$05 ok
; no good ; save result : enough room
Jmp Sb24R
: i llega1 quantuy
My Ida sta Ida \Ia Ma j\r txa beq Ida ror ror ror eor and Ma Ida ror ror and ora sta
SIS $0288 Saf #$()() Sac $14 $b7fl
: hi-byt of \CCI. # ; hi-byt of screen loc. ; inti addres~es
movit $dd00
; 0 = text screen ; v1d.bank from cia 2 ; bit\ 0 & I :into 6 & 7
#$ff #$cO temp+ I $dOH!
; inven : .~:ero others
•
ol..
movit
store
#$3c temp+ I Saf
Ida pha and sta ldx ldy beq my Ida sta my bne
; vid.matrix from vic-i1
; combme
SOl #Sfd SO I #$00 temp recover
cpx bee Ida Ma Ida as I as I as! as I sta InC
Ida and ora dec ~ta
; mast. out roms
: #$0+1=00 (Sae),y ($14).}
.lOX
coli
-
~e1
store IOC SIS me $af
color
; which screen org.
#$()4 store #$d8 $uf ($uc),y
temp Saf (Sae),y #$Of temp Saf ($14).y
; hb dest. : hb src.
: hh of color ram ; get a nybble
; move to hi nybblc ; ~ave n
m} bne coli 10:1:
cpx #$06 beq done IOC $15 inc Saf May 1988: Volume 8, Issue 6
If
NG
co co JP KG NM
DO FM OJ
NF GN KJ IP HJ
E BN LN FO Mll LP
rc
ED OK HF
oc JP CD NB KH
El t\J OA BF HE
EE JP
1880 IR90
inc Saf bne coli
GF PI KO HB OB
1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 2000 2010 2020 2030' 2040 2050 2060 2070 2080 2090 2100 2110 2120 2130 2140 2150 2160 2170 2180 2190 2200 2210 2220 2230 2240
recover Ida ($14 ).y ~ta (Sae).y
sny bne recover inc $15 inc $af
88 : hb ~rc. ; hb dcst.
KN
inx rcccol col2
cpx bee Ida sta Ida sta br I 'iT br lsr dec sta inc
#$04 recover #$d9 Saf ($14),y (Sae).y
: pg2 of color mm ; get a byte ; ignore h•-nybble
; move to lo nyb Saf ($ae),y Saf
sny
: store it ; pointer
bne co12
mx cpx beq inc inc inc bne
#$06 done $15 Saf Saf col2
• done
pia sta $01 cl i endrec rts
GO OJ BD FO EH PJ CP 01 GF TE Fll CE HN TF ED Kll
: enough time~ Listing 6: BASIC loader for 'Video. \1 o~e·. JK GC HN t\ E PI KO MC BC
:get con fig ; and restore it
Listing 4: ' Move.Pius' in BASIC loade r form. C ha nge the value of 'sa' in line 110 to change the locatio n of the routine. FE GA HN OE PI KO AC KK FE BI BD DO 8F
JC 08 IH LD J8 OL IH OJ ML
AJ AP CM PM OM NA NP 8P OM PE BD CB AH BN
100 rem move.plus/c64 110 sa"'51200:rcm start address 120 cJ...;;Q 130 for m;;O to 99:rcad d 140 poke sa+m.d 150 ck;;ck+d: next 160 if ck<> 13877 then pnnt"data error!": end 170 print" move. plus inMallcd":print su "to" sn+ I 10: print 180 print"to use:":print"sys" \a ",source,dest,# of bytes,mask" I000 data 32. 253, 174, 32. 138, 173, 32. 247 1010 data 183, 132, 195, 133, 196, 32.253, 174 1020 data 32, 138. 173. 32.247, 183, 132. 193 1030 data 133, 194, 32,253, 174. 32,235, 183 1040data 138.240, 8,120,165, I, 72, 41 1050 data 253, 133, I, 24. 165, 20, 101 , 193 1060data 133. 20. 165, 21. 101 . 194. 133, 21 1070data 160, 0, 177. 195, 145. 193,230, 195 IORO data 208, 2, 230, 196. 230. 193. 208. 4 1090 data 230, 194,240, 20, 165, 194. 197, 21 1100 data 208,232, 165, 193, 197, 20,208,226 1110 data 138,240, 4. 104, 133, I, 88, 96 1120 data 136, 208, 245, 0
CC JK GB BD LF JK NG FG Jli MF KH LM KN NG NL JC
Listing 5: BAS IC loader for 'Color. Move'. 'lK 88 HN
100 rem color mover 110 sa:51320: rem start addrc~\ 120ci..;;Q
Transactor
130 for m;;Q to 127: read d 140 poke sa+m,d 150 c~:cl..+d: next 160 1f ck<> 15890 then print"d:ua error!": end 170 print"color mover installed' :print sa "to" sa+ 127: print 180 print"to ~tore colors:" .print"~y~" sa ",section # (0-15)": print 190 print"to retrieve color~:" : print'\ys" sa+4 ",section # (0- 15)" 2000 data 160.255.208. 2, 160, 0, 132. 195 2010data 32,241,183,224, 16.176. 64.138 2020 data 10. 24, 105,224, 176, 57, 170,212 2030 data 240. 53. 162, 0, 133. 37. 134. 34 2040 data 134. 36, 162, 254, 164, 195, 240. 42 2050data 200. 169.216. 133. 35. 177. 14. 10 2060 data I0. I0. 10. 133, 195. 230. 35. 177 2070data 34. 41. IS. 5, 195, 191!, 35. 145 2080 data 36. 200. 208. 233, 232, 240. 55. 230 2090 data 37. 230, 35.230, 35, 208, 222. 76 2100 data 72. 178. 120. 165. I, 72. 41.253 2110data 133, 1.169,217, 113, 35.177, 36 2120 data 145. 34, 74, 74, 74, 74. 191!, 35 2130 data 145, 34,230, 35,200.208,239,232 2140 data 240. 8. 230, 37,230, 15,230. 35 2150data 208.228. 104, 133, I. 88, 96. 0
60
100 rem video mover II 0 !>a"'51456: rem stan addre~., 120 ck"'O 130 for m;;Q to 203: read d 140 poke sa+m ,d 150 ck;;ck+d: next 160 if ck<>28129 then print"data error!": end 170 print"video mover installed" : pnntl>a "to" sa+203: print 180 print"to store video:" 190 print"sys" sa ".section# (0-4), \Crecn org": print 200 pnnt"to retrieve video:· 210 print "~ys" sa+4 ",section# (0-4). -.cn:en org' 3000 data 160,255,208. 2, 160, 0, 132, 195 1010data 32,241, 183.224, S, 176. 17. 169 3020 data 224. 202. 48. 7. 24. IOS. 6. 176 3030 data 7, 208,246, 168, 105, 5, 144, 3 3040 data 76, 72, 178, 132, 21, 173. 136, 2 3050 data 133, 175, 169, 0. 133. 174, 113, 20 3060 data 32. 241. 183. 138. 240, 23. 173, 0 3070 datu 221, I06, I06, I06, 73, 255, 41, 192 3080dutul33,196.173. 24.208.106.106,41 3090 data 60, 5, 196, 133. 175, 120, 165, I 3100 data 72, 41.253, 133, I, 162, 0, 164 3110 data 195, 240. 57.200, 177, 174, 145, 20 3120 data 200, 208, 249, 230. 21. 230, 175, 232 3130 data 224, 4. 144,240. 169,216. 133. 175 3140data 177, 174, 10, 10, 10, 10, 133, 195 3150data 230, 175, 177. 174, 41. IS, 5. 195 3160data 198,175.145, 20.200,2011,233,232 3 170 data 224. 6, 240. 58. 230, 21, 230. 175 3 180data 230. 175,208.220, 177, 20. 145, 174 3190 datu 200, 208, 249, 230, 2 1. 230. 175. 232 3200data 224, 4,144, 240, 169,217, 133, 175 3210 data 177, 20, 145, 174, 74, 74, 74, 74 3220 data 198, 175, 145, 174, 230, 175, 200, 208 3230 data 239, 232, 224, 6. 240, 8, 230, 21 3240 data 230, 175, 230, 175, 20R. 226, I04, 133 3250 data I. 88, 96, 0 May 1988: Volume 8 , Issue 6
I I
I i
.News BRK
i
.
---··
Subscription Switch Remember that if you wish to switch your subscription to Transactor for the Amiga there is no charge. llowevcr, there does seem to have been some confusion: you can only switch the number of issues of Transactor Classic to which you are sull entitled. TPUG subscriber!> please remember that your sub~criprion is with TPUG. not directly with Tronmctor, and we arc therefore unable to switch issues due to you from them. Please be sure to put your name and ZIP or Postal Code as well as your subscriber number on your order card.
Transactor 1\iews Submitting News BRK Press Releases
I·
If you have a press release you would like to submit for the Nrws BRK column, make sure that the computer or device for wh1ch the product IS intended is prominently noted. We receive hundred\ of press relea..es for each i~sue and ones whose intencted reader~hip i~ not clear must unfortunately go waight into the t ra~h bin. It ~hould also be mentioned here that we only print product release!. which are in some way applicable to Commodore equipment. News of event\ ~uch ~ computer show~ \hould be received at least 6 months in ad\ance. The News BRK column is compiled solely from press relea~es and is intended only to disseminate information; we have not necessarily tested the product~ mentioned. Items for publication should be sent to Moya Drummond along with any queries about ad\ enising. ad\ themselve<. and editorial . quenes.
The 20/20 Deal still in effect: order 20 subscriptions to the mag or disk, 20 bact... issues. 20 disks etc .. and get a 20% discount. (Offer applies to regular prices and cannot be combined with other ... IS
~peciah.)
No Longer Available As mentioned in the last issue, the 1541 Upgrade ROM Kit is now discontinued. Please see Vol. 7 Issue 2 for complete inMructions on obtaining a set; disk # 13 contains the ROM image you'll need to bum your own EPROMS. However, we're reasonably sure that the ROM image is compatible "'ith the 1541 only. 1541C owners will need to create an image of their ROM set, then make the changes described in V7 12, but with minor adjustments to accommodate for what are more than likely simple address changes. We are still waiting for an update anicle from someone who has c;uccessfully done this!
Demand forT-Shirts Outstrips Supply We apologiLe to all those reader\ who sent in for T-Shms and whom we have had to dbappoint. Demand wa~ ~uch that our initial supply was sold out within a week and we arc having trouble fmding another supplier. Most of you 1>hould have received a letter from our new Customer Service Assbtant, Renanne Turner. offering a refund in the case ofT-Shins which were paid for m advance, or a Potpourri or Tran~BASIC TT di\k for subscribers who were entitled to a freebie for ordering both the Tranwctor Magazine and Disk at the same time.
I
'Moving Pictures· is also out of stock and no longer available from Transactor. If you have ordered a copy, you muy ask either for a refund or have a credit issued against further orders from Transactor Publishing - Renanne will be in touch with you. Moving Pictures is now being distributed by CDA, with new packaging and manual. Contact CDA at: P.O. Bo>. 1052, Yreka, CA 96097. Phone (916) 842-343 I.
We have had a !>imllar problem with the G-Lint... IEEE mterface. However. we now have a fresh <,upply and arc shipping these again. lf you are one of the customers who has been waiting patiently, please bear with us just a little longer.
Transactor Mail Order Nen Look For Customer Sen ice It is perhaps worth mentioning that items on order cards in
Jennifer has moved on to new paMurcs and we now have Renanne Turner doing her utmost to create order from chaos in the field of ~:oubscriptions and orders. It is a huge job and growing ever more complex now that we have two magazines and both are expanding rapidly. Renanne is wort...ing miracles and on Mondays. Wednesdays and Fndays will be delighted to resolve your queries. On Tue~days and Thursdays. however, she h~ to have time to b.eep her database and mail order depanments up to date and. therefore, the phones will be answered by a machme. We think you "'ill fmd that from no"' on delays and mistakes will be t...ept to a minimum and we hope you will appreciate the new system.
Prices for all products arc listed on the order card in the centre of the magazine. Subscribers: you can use the address label from the bag holding your magazine and just stick it on the order card in~tead of filling it in by hand! • Quick Brown Box - Battery Backed RAM for C64 or C 128. The Quiet... Brown Box cartridges for the C64 and 128 61
Transac tor -
....
back issues of the 'fi'ansactor arc not necessarily currently available: if you are unsure, plea~c call Renanne before sending in your order. To be cenain, place orders from the card in the most recent issue.
May 1988:
Volume 8, tssue 6
1:
can be used to store any type of programs or data that remains intact even when the cartridge is unplugged. Unlike EPROM cartridges, the QBB requires no programming or erasing equipment except your computer. Loader programs are supplied and you can store as many programs into the cartridge as its memory will allow. It may even be used as a nonvolatile RAM disk. Auto-stan programs are supponed such as BBS programs and sofrware monitoring systems that need to re-boot themselves in the event of a power failure. All models come with a RESET push button and use low current CMOS RAM powered by a 160 rnA-Hr. Lithium cell with an estimated life of 7 to 10 years. Comes with manual; software supplied includes loader utilities and Supermom+64 (by permission of Jim Butterfield). 30 day money back guarantee and a 1 year repair/replacement warranty. • The Potpourri Disk - A C64 product from the software company AHA! (aka Chris Zamara and Nick Sullivan). includes a wide assortment of 18 programs ranging from games to educational programs to utilities. All programs can be accessed from a main menu or loaded separately. No copy protection is used on the disk so you can copy the programs you want to your other disks for easy access. Built-in help is available from any program at any time with the touch of a key, so you never need to pick up a manual or exit a program to learn how to use it. Many of the programs on the disk are of a high enough quality that they could be released on their own, but you get all 18 on the Potpourri disk for just $17.95 US/$19.95 Canadian.
Bits that were similar in nature are also cross-referenced. And the index makes it even easier to find those quick tips that eliminate a lot of wheel re-inventing. The bits book disk contains all programs from the book and can save a lot of typing. • The G-Link Interface -The G-Link is a Commodore 64 to IEEE interface. It allows the 64 to use IEEE peripherals such as the 4040. 8050, 9090, 9060, 2031 and SFD-1 00 I disk drives, or any IEEE printer, modem or even some HewlettPackard and Tektronics equipment like oscilloscopes and spectrum analyzers. The beauty of the G-Link is its "transparency" to the C64 operating system. Some IEEE interface~ for the 64 add BASIC 4.0 commands and other things to the system that can interfere with utilities you might like to install. The G-Link adds nothing: it is so transparent that a switch is used to toggle berween serial and IEEE modes, not a linked-in command. Switching from one mode to the other is also possible with a small software routine as described in the documentation. • Transactor Disks - now with the.ir new, colour directory listing labels. As of Disk #19 a modified version of Jim Butterfield's Copy-All will be on every disk. It allows file copying from serial to IEEE drives, or vice versa. • The Micro-Sleuth: C64/1541 Test Cartridge - Designed by Brian Steele (a service technician for several southern Ontario Schools), this is a very popular cartridge. The Micro-Sleuth will test the RAM of a C64 even if the machine is too sick to run a program! The cartridge takes complete control of the machine, tests all RAM, ROM and other chips, and in another mode puts up a menu:
• TransBASIC II - TransBASIC II contains all TB modules ever printed. There are over 140 commands at your disposal; you pick the ones you want to use in any combination. It's so simple that a summary of instructions tits right on the disk label. The manual describes each of the commands, plus how to write your own commands. People who ordered TBl can upgrade to TBTI for the price of a regular Transactor disk (8.95/9.95). If you are upgrading, please let us know on the order form.
I) Check drive speed 2) Check drive alignment 3) I 541 serial test 4) C64 serial test
A second board (included) plugs onto the User Port: it contains 8 LEOs that let you zero in on the faulty chip. Complete with manual.
• Inner Space Anthology -This is our ever-popular reference book. It has no "reading" material, but in 122 compact pages there arc memory maps for five CBM computers, three disk drives and maps of COMAL; summaries of BASIC commands, Assembler and MLM commands and Wordprocessor and Spreadsheet commands. ML codes and modes are summarized, as well as entry points to ROM routines. There are sections on Music, Graphics, Network and BBS phone numbers, Computer Clubs, Hardware, unit-to-unit conversions, plus much more ... about 2.5 million characters in total!
• Transactor Back Issues and Microfiche - All Transactor~ from Volume 4 Issue I are available on Microfiche. The strips are the 98 page size compatible with most fiche readers. Some issues are available only on microfiche and are marked as such on the order card. The price is the same as for the magazines with the exception that a complete set (Volumes 4, 5, 6 and 7) will cost just $49.95 US/$59.95 CON. This list shows the "themes" of each issue. Theme issues didn't start until Volume 5 Issue I. Transactor Disk #l includes all the programs from Volume 4 and Disk #2 includes all programs for Volume 5 Issues I to 3. Thereafter there is a separate disk for each issue. Disk #8 from the Languages Issue includes COMAL 0.14, a soft-loaded. slightly scaled down version of the CO MAL 2.0 cartridge. Volume 6, Issue 5 lists the directories for Transactor Disks# I to #9.
• The Transactor Bits and Pieces Book and Disk - 246 pages of Bits from Transactor Volumes 4 through 6 with a very comprehensive index. Even if you have all those issues, it makes a handy reference - no more nipping through magazines for that one bit that you just know is somewhere ... Also, each item if forward/reverse referenced. Occasionally the items in the Bits column appeared as updates to previous bits. Transactor
5) Joystick port I test 6) Joystick port 2 test 7) Cassette port test 8) User port test
62
May 1988: Volume 8, Issue 6
•
• Vol.4 Issues I to 3 (Disk #I) • Vol.4 Issues 4 to 6 (Disk# I)- MF only • Voi.S Issue I - Sound and Graphics Disk# 2 • Voi.S lssue 2- Transition to ML (MF only) # 2 • Vo1.5 Issue 3 - Pimcy and Protection (MF only) # 2 • Vo1.5 Issue 4 Business and Eduction (MF only) # 3 • Vo1.5 Issue 5 - I lard ware and Peripherals # 4 • Vo1.5 Issue 6 - Aids & Utilitie!. # 5 # 6 • Vo1.6 Issue I - More Aids & Utilities • Vol.6 Issue 2- Networking & Communications # 7 • Vo1.6 Issue 3 - The Languages # 8 • Vol.6 Issue 4 - Implementing the Sciences # 9 • Vol.6 Issue 5 - I lard ware & Soflware Interfacing #10 • Vol.6 Issue 6 - Real Life Applications #II • Vol.7 Issue I - ROM/Kernel Routines #12 • Vo1.7 Issue 2 - Games from the Inside Out #13 • Vo1.7 Issue 3- Programming the Chips #14 • Vol.7 Issue 4 - Gi1mos and Gadgets #15 #16 • Vol.7 Issue 5 - Languages II #17 • Vol.7 Issue 6- Simulations & Modelling #18 • Vo1.8 Issue I - Mathematics #19 • Vol.8 Issue 2- Operating S)Mems • Vo1.8 Issue 3 - Feature: Surge Protector #20 • Vo1.8 Issue 4 - Feature: Transactor for the Arniga #21 • Vo1.8 Issue 5 - Feature: Binary Trees #22
The Super Chips: New from Free Spirit Inc. i-. a custom operating system for the Commodore 128. The sy.,tem consists of three 16K chips labelled Basic Lo, Basic I li and Kernal which replace U33, U34 and U3S on the motherboard of the C 128. The Super Chips add a variety of powerful ne\\ commands and functions to the C 128 operating system including: Type, (Restore) D, Combine, Merge, File, Change, Find, "' - Send monitor command to the printer. and Editor. When done, a Basic program can be compiled which can be incorporated into a program and/or saved to disk. The cuJ.tom operating system also redefines the function keys. In 80 column mode the F3/F4 keys will simultaneou~ly display the directories from devices Hand 9 in separate windows on the screen. The operating system will default to fast mode \\hen powered up or re:.et with the 40/80 d1splay button down. It wiJI default to slow in the 40 column mode. The Super Chips !>ystem is compatible with 1541/1571/1581 disk drives and virtually all Commodore software and peripherals. Similar sy~tems will be available for the 1281) and C64 in the near future. Available at $49.95 from Joe llubbard, Free Sp111t Software Inc.. 905 W. llillgrove, Suite 6, La Grange, lL 60525 (312)352-7323.
lndustr~
New Basic for GEOS: BeckerBASIC adds more than 270 new command~ and functions to the Commodore 64 and GEOS. lt has commands for screen and cursor control, h1-res graphics and sprite animation, sound and music.:, structured programming and programmers' aids. A program Mitten in BeckerBASIC runs as a GEOS application and can usc GEOS' pull-do\\n menus. dialog boxes, different fonts, hi-res graphics and fill patterns and more.
News
EPROM Programmer for the C64, Cl28 and 64C from B & B Products ic; a versatile programmer offered in an easy-toa.,~;emble kit form or as a complete and tested system. The design IS based on the article by T Bolbach featured in the January 1987 issue of Transactor and contains many enhancements, including on-board selectable programming voltages, local reset switch, power transfonner and super-fast improved software. The programmer supports 2716 through 27256-type EPR0\1s and also programs the 68764 direct replacement types for the Kernal and BASIC R0\1s. Documentation includes rhe schematic. Complete kit with all parts $59.00 (US). Completed and tested unit!>, $89.00 (US). Send cheque or money order to: T. Bolbach, 1575 Crestwood, Toledo, OH 43612.
BeckcrBASIC can be customi1ed by adding u'>er-defined commands and function ke) definitions. The BcckerBASIC package includes a free run-time version so that BeckerBASIC applications may be distributed to other GEOS u~rs. BeckerBASIC is compatible with Commodore 64 BASIC and GEOS Version 1.3. The suggested retail price of BeckerBA SIC is $49.95. Available from any Abacus dealer or distributor or call (616) 698-0330. Abacus i~ at 5370 52nd Street SE, Grand Rapids, MI., USA49508. Science Software is a series of tutorial, utility and application computer programs in the areas of Astronomy, E<lrth Satellues and Aeronautics. The Astronomy disk contams programs for determining the po~ition of the Sun, Moon, Planets and Stars. The Earth Satellite programs can be used to determine the location ofTVRO, weather, OSCAR and other earth satellites. The Aeronautics disk contains programl> for model rocketry, hot air balloons and gliders. Science Software dish are avUilable for the Commodore 64/128 (in C64 mode) and the Amiga. For addilional information contact Dav:d Eagle, Sci-
Transactor
63
May 1983: Volume 8, Issue 6
ence Software. 7370 S. Jay Street. Littleton. CO 80123 (303) 972-4020. PoM!idon Electronics announces an addendum to its catalog of di~>ls for Commodore 64/128 CP/M users. The full catalog 1~ available for $4.10 plus $0.90 SASE (please '>end a large (envelope) in limited quantities; the addendum costs $1.60 plus a $0.39 SASE. Poseidon have a large library of CP/M di.,ks; for further information contact Ralph S. Lees Jr.• Poseidon Elecrronic~. 103 Waverley Place. New York. NY 1001 I (212) 777-9515. RS-232 interface for the C64, C128 and Vic 20: Now you can connect a true RS-232 modem or printer to your 64 or I28. This interface supports all the RS-232 control lines (DTR. RTS. Sl, Rl. CTS. DSR and DCD). Abo. if you are u~ mg a C 128. the Interface doe., not obstruct the 80 column video port. It u,e., only the +5 volt line from the computer and draws 30 milliamps of current. It is packaged a., a 3 inch square PC board and terminated with a female DB-25 connector, at a co~t of $55 (CDN). PET to Centronics interface: supports all standard Cenrronics style printers and is small enough to be left mside the PET itself jumpercd to the IEEE connector at the rear of the computer. Cosh $50 (CON). Both interfaces come with a 90 day warranty. For further in· formation and orders contact Chris Czech, 227-7a Street, l'.'E., Calgary, Alberta, Canada, TIE 4E7. (403) 262-3587 Surge & Lightning Protection for datacommunicat10ns and computer interfaces described from analy!.i!> to solution. Telcbyte Technology\ expanded tine of :.urge and lightning protection product'> is described in a six-page brochure together with explanations of the phenomena and the basic techniques for protection. A selection chan is included to ~implify the process of choo'>ing the best device and custom products are available. f-or further information contact Teleby te Technology Inc., 270 E. Pula~ki Road. Greenlawn, NY.. USA. 117-lO (516) 423-3232 or (800) 835-3298. The Strategist for the Commodore 128 il> a market timing program for invcMors in ~tockl.. bonds, mutual funds and commodities. It allows the user to plot prices on the same chart as one or several market indicators so that he can pick the ones he wants to time his trades. There is an historical file which makes rcaliMic simulated trades to see how a &trategy would have paid off in real life; 11 then repeats this. varying the Mrntegy each time until it arrives at the one which give'> the highc~t payoff. The sy~tem uses high-low trading enhanced by the usc of persistence checks to confirm buy and sell signals and an exponential moving average of quote to quote volatility. The Strategi'>t master disk. an 80 page manual and 90 day money-back guarantee cost $29.95. The :.y!>lem is copyrighted and is di~tributed on a :-.harcware ba:.is. Purchasers may
give, but not sell. copie'> to other users to try; if they like the program. those with try-out copies should send $29.95 to Strategy Software in order to become registered u~crs and obtain the latest version of the program and manual. For Commodore 128 user<. with a 1541 or 1571 disk drive; a printer is desirable but not essential. Dealer inquiries are welcome. A C64 version will soon be ava1lablc at $24.95. Contact Strategy Software, 909 Carol Lane, Fairbanks, AK, USA. 99712 (907) 457-2294. New Telecommunications Soft~are from Made m America: BananaTerm! offers all the standard features expected in a terminal program along with an advanced phone book, support for up to 600 baud on standard 300 baud modems and cu~10m character graphic!.. Sy!>lem 6-l! i!> a bulletin board sy!>lcm designed to run on stan dard C64/128 syMcms. It creates an environment enabling communication between computers and modems for the exchange of files and messages. It features ALEX programming language. customi?able environment and support for up to 600 baud on standard 300 baud modems. The two system!> are complementary but arc available scpa· rately and arc compatible with other telecommunications environments. BananaTerm! coMs $24.95 and System 64! com $49.95 from Made in America. 9069 Sussex. L mon Lake. Ml., USA. 48085 (313) 698-2104. RomJet Custom Cartridges: 32K TO 256K RomJet cartridges for C64 and C 128 modes arc here. Thc\e cartridges let you access your favourite :.oft~are instantly. via menus that are also in the cartridge. RomJet will install on its cartridges any Basic, compiled, or machine language non-copy-protected program. including programs such as Paperclip. Consultant, and WordPro, for \\-hich the copyright states that you. the proven legal purchaser, can make a back-up copy for your own personal use. You must present to RomJet your original purchase receipt, or proof of purchase seal. Commercially sold programs belonging to companies or authors other than RomJet that have copy-protectiOn and/or for which the copynght states that }OU are not allowed to make a back-up copy for your own personal u:.e cannot be put on a RomJct cartridge. Prices range from $32.00 (CDN) for 8K up to $196 for 256K cartridges. Cartndges may be upgraded to the next larger sue for the difference in price. There are extra charges for cartridges that require programmer's time (e.g. mod1fying a program that load~ files from dbk to work from the cartridge exclusively). Inquire at: RomJet. 210-2450 Sheppard Ave. E. Willowdale, Ontario M2J 4Z9. Phone (416) 274-7378 or 626-5959.
Transactor 64 May 1988: Volume 8,1ssue 6 ~---------------------------------------- --------------------------~--------------~