The transactor vol9 iss5

Page 1

Canada $4.25 USA$3.50

• Inner GEOS - how the system fits together • A Disk Monitor for the C128

'

• The 1764 Ram Expansion Unit: Add an EPROM - internally! • Implementing a RAM disk for Abacus' Super-C • Disk drive memory-read error exposed! • Supernumbers Ill: The famous indestructible variables come to the C128 • Jim Butterfield on linked lists: a quiz program for all CBM 8-bit machines • A Shell Sort for BASIC arrays • Break GEOS's 31-icon barrier!- some icon programming tricks

-

• Product Review: Two Assemblers for GEOS - Berkeley's Geoprogrammer and Bill Sharp's GeoCOPE • Plus Regular columns by Todd Heimarck and Joel Rubin, Programming tips in Bits, and more

0

-

-

N

Firebird by Wayne Schmidt 0


UTILITIES UNLIMITED,

WORLD'S BIGGEST PROVIDER OF

Inc.

C641128

you wrst'1 !C p1ace vou· :>rOe · b~ phone ;Jleas.e ca ll 2:Q6..254-6530. Add 53 OC sh1ppi"'ii; & han~ ling . $3 00 COD on al or~ers ll1sa M ·'C

If

12305 N.E. 152nd Street Brush Prairie, Washington 98606

acce:;~t ec

DeaJe" lnoume s

UTIU TIES

1nv1t~

OYEl 5000 OlliS SOLD!!!

LOCI P1t:1 . TIE 11001S • 111r 1M Ci4 iU CUI

lhl.lilte ow am;petilon, ""' al Utili,.. U11hmited, lAc. hue beea OQPOPD· lrllti119 all 0111' ejturts Jll bxmqm.9 the newest tecbnolo9Y. Thue~ al ~ eiiarl :i5 It is far wpeow II II llle Clff J!ifjljps Ill ·llle!:t iorlwl,.!!apjoa... 'II J + Date! .Bm:st liibbler 21 Sectma Ultnbyte and any - -'- ....,.;;;._ •L-- L S •'- • L led ' •- .:..-. · other b o.;up ~1 011 ""' maael. o """ • amoy. "" .,. fiR fll JE . . , llid if !her m hack 1IJ> mau a1 lhe laie5f ~ will !hey??? In a -.a:d · "NNJ ALL SALES AliE rmAI.liJ• '!'hal .Ill their recpo•• Jl J011 wui 1D l'l!hm! B.Al4BO. B JOII hJ:!1PG to see the w em BAMBO&::d (anc;mill name h:uh). ~ cl;gm !o M cheaper. w.n, that's par!lally !me bni.as IS ""'V mostly Wse. Fil::lt JOII.IIeed 1o buy then board., Ilia ~need to ~d 'ano:ber S3U5 1m oaftorru:e to nrn then boatd. l1lil ams llle aa II "•""'If!!! ptlr Ill k illm1 SiUI. Ill lift !lie! dU r• w a 1111' Dtw.m (1riit lillslbt szr ~ llll!ir .a.m.?~ tea - . liil ~ a jal il _Iii ii il wiil! li! u 1111. wllile il's 11w lUI• em,, las tefiU!r re:w nri 116 tmllmg. llle •· -... ili!J tlrsipd ... ..• _.,... __. .-.e rotiah!r e•w •_, .-,-.. - -• w11w:.n ts· spen 1lili llll!ir IIID F.~ lUI - .... IIIII lUI llle 111!11 illlll _pdii • . . . .-... ...._ ..... ...._._ 1 111 lm; ;r•~ ~ ill'l! P il ..,...- • ft ,_,..., _...., SIIJj ~• Sl!li a 111r IIID 1M SZU5 1M lEU still YUII m IW TIIB - ~ l1eeClea to say you need a pail al lup boats to -::It tll.tooqll then clann lhat they ~ lhe best. By lhe fi}d.-~ aahue tlW bacb up a.n 11l1pmteclad dill< m 5D .acmda, -.11, il 1 - use the UWB() to 1lllli. I . , _ if Jll liilll a.i:t II a ID$MIMI E lr I Ca Hit ...... • .... slill .... !lie . .. I a

·Loci PU: 64/128 was !"11 1P91j!';:!j aax ad le'm,, u a !ool .lor that;e 1l'!w have a desire to ae the lwiilp al a para!!lf!J!m: T.he bo'Oh JPVI! J011 Slep-iy-Sl!p llsltiL'Iilm aa breaking~ lot badbzp ol 100 papular ~ biles. thes llpsw• and lutradiaJU ar.e 10 c:l..ar and pndse tha!IJI"!'OIW' can nse iL • IIIII JIJUI TID IS IIJ1 m n.JBrE • · Dl 1: lncludes Hesmaa ad a chsk WJth =Y utilitiet S1l1lb as: IEBJll WE, lt S1Jt lllSI Lilli Ill! and lots mar•. ill m ~ em d:iU.. ALmg-time ~ 111111 Z: 1M· EIUIPLES. Hesmnn em cbsk a.nd c•rtriclge phu more ohlxbes 1lo incltt~ .I '-illlnnil!ll • br II Iiiii ,.,... .," md a llisi Sm•. SlU5 IIIIi ~ BUY BOm FOR Ga.T SlUS lw rill nEE ltiMIM 128 SUPERCHIP · l. B tr C<illlk lirsll .I ---~. . .. 1m •~om om _,... -- iJ>.ere . 11 an ea:,ply .soc:i:et ......... l2B. JUs!. ".aiful9 Qip tc o;pn you 32I w.orth <II qr~ i l ~ aD iii )1111 the t.O -· il rJIII!I'. Y1111 ge1 hllilt... !eit.!m... lilr ~-.: s:. tra & Ss:lll' Ea.-, Saei!llllu.p. and even a 30011200 baud · Ptogna lhat'sl650, 16711 and Hayes c:mnpalihlr Best of alt if doesn't a:snp my .m:I!IIIOtJ. To 115e amply latlcll.a hmctioa hoy, a.nd ·u rESponds to yam mmma nd 1 - W SllPEIIl II1'JUT!ES a c:mr,plete utilily paclca 9., 1m the 1581. Copy '·'· > .•L ' · 1541" IS:,71lo lSBL •IllY u . ,.;,rt.1581 Wli.OJI! =u u.am . . or , <mat tc opbm:s IlL dlSl: ecblar, dme 11"111D ' a- wo:ter &ad Will also perl= muy CP 14 & MS-005 utility lvndvms C - 't"' IS lUI COI!IIO =d :hat'• whal yoa get.. A mpet c:mnbmalton a! both ciiJ:ps A &ad B ia cme elm>. sdcbable iii 1 qreiil sa"rings Ill you. II Clips lldJ+ 110 P......,rs lltt! CJu,p. A or B UU5 el. Clap C: S4U5 el.

s.n:m.

=

a.

.... •

,,., r•

1

-

-~ 15" " •nSW5 _...~ '"'~ • · · · •

SlipllrCIN UU-1 . • . . . . . UU5

2 ,~e nnjop .. "'"'""" , • · ' ' · ... · · • •...,. 2 dme Temca • . . . . •• • • •• $JUI

s..,.rc:a Un . . .. . . . . .. UU5

2 dme HI1ian ..... . .... . fJUI .s.,.c.nl lS41-I vemna will work lrilh 111011 compatible dnHt.. 'DII!Ie ~ iorWr lllllwm. T• . ., _. II sll!ll IIJ'• a 's wl!nrt II

SIJPEB liUPJIICS 1000 P.ACI Dlat's rig:lU! Over 1000 gnphjcs m a Ia.ww set 1m :m.ly SZU5..There ue gnplucs lot 'ritlaaZiy ~g m tho pacbqe.. These qr~ wad with P=! Shzm a.nd Prmt lla!tn.

. . il lllli

SUPER PIUJIEIIBS 500 hck #l illld #Z

5411 hci fl • SZU5 au llle ~ parameiett on tt thai no Dll1! else. has. T1tis !*'k comes in a 5--disk set. 511 hci #Z · SZUS lu ill the mas! =.enl parameters an il Aud puJ togellw as only Utilihe• Unltd. can. AD Supe: Puame!er PACks are campletely men dti.vea, !..st &ad reliahle.. lnclnrlad em both 500 Padus = s!aJ...af.the--arl 64/ llB Sa:per JObbler iil:ao extra. clouqe.

SUPEI PlUMETEIS 1000 Pa #1

Ublrt.es U.nl!d.. lw dab ll aqam!l We havuanJObd•t«l an.cllanrad the

m

m

'""''*

jJ)ll[J

Software Submissions Invited

We are looking tor HACKER STUFF: pnnt ut•htles. para mete rs . t elecom m un•c at •ons . and t he unusual .

liDIE &liUPIIICS IIJl'J DISKS

CriJIE: A -rery unsual game to be plcyod by a very llpel Jlilllrl adJ:illll in· c:ludes a Cllilt ud W..lll .,._ Please, yo. llslllt li to asdet Ei!ier 0.. D.ltl * : nis PQ kr d..sk worn w:itb PlDI S., ud Prill Jlisllrt. !!law VorsiOJI 1 + 2 . •• SZU5 s. .

We now have over 1,000

rameters in stock!

lEI! SUPEI C111'11DGE EIPIDDE! YU w,'tOI.OI OOJfP S4U:5 Inlrodm:mg lhe '~ail's rn CMr Saws 1111111 m • c:arlndQe. ~ ..• v4.1

will now S.PIIIrlllindiJ 1ma lhe scran. FOll COLOll f.~ G iar the '±' n Slli n -1111 and a1so .the tim u & zt ¢nten. ll'.l>e IIIII Piiaillllisi ~ !lid PriUor c.rtriilf pznduced Jar lhe ()()}0((). OOBE USEll s.,et Ftietlltf with the fe•tues 1110111 asked far. • S1IPil rm bailt-itl ugle dDJve B GL 9 IlLE COPY, copy files a! 1l:p :Ill 235 BLOCXS m lenqth, m less than lJ """onrls·l • SllPEI SIJ !1J WTIIIt Capture a.nd C=-1 by Sera. to IOALA ar DOODLE. • SllPEI Fm FaiiT iBSEC'S) - plats FUU D.D.S. WEDGE w'stndud format! • SllPEI F.&m.OD a.nd S.l'fE (SOk m 9 SEC'S) worlcs wJIJI aD C-'4 • C-llrs II Mi11!r Dill Tll'agrl AAd with _,51 a:Jter marho! dnves EXCEPT lhe 158l, W.JLD. 1 or 2. • SIIPIJ pili IEl lUl'DIES ••Om.-. ANY DOt W!Iill PBINIEI! even 1526/!102 lo priat Hl-BIS SCiEDlS [nsmv 16 shade GB.AJ SCALE). by Ptiller • lllrrbcp t-hivliw m be uecl with SUPER EXPLODEl v.t.l or no. • lEI • JIO'IIJVEII CIIIVEil' lstuR oJJo,.. anybody 1o cOJtten (rma IEl1') Smels iiiD DIIOiltE .- IDIU T}Jf Picbue 11 Jd Cailrl • SI1PEI FJST Sl'fE al EIPLDD£! SCBEENS as XOALA or DOODLE FILES -. ICOLOB.. • SllPfJ rm wms with e11ar IHlisflilr • -..: .. 11111.1 Wn. • SI1PEI £1ST LIW • S.IVE cu be TU.mD OFF or ON -.ntho:m AFFECTJBG the !!EST of SUPER EXPLODE'S FEATUiES. The rest :d Fxplode v4.1 • .sbll ACllft. • SIIPEI WY I BR - llliiiiiC a! ALL PBOGl!AMS 1mm the DlSI DIEECTOl!Y. • SUPEI aT41 TIB-YJY SEQ. • PK. lilr IEID£I 11Stn9 lhe 1llSI DIREC!QBJ_ • IEJlJ n1'E l EU lliiE .IWI w.hi!'JI J1011. ue SUPER EIPLODE'S llllique LOAD:EBS. • llPTliiE 40 COLllWI Car D-lZS SCXEENS! (Wllb optJrmal DISABLE SWil CH), Add $5. JlL

m IBm ru.111m. m llltllllliE!

PUIS .1 rm mm m .., Slll'fl ED'IJIIIE! vu 111E liJill C-64, 54-C • C-lll •, J.lll • SIIPEI FIST illlll WT il ue.

*-flt ************************************************** SUPEB TBAI:JI £8

r.=..:.,~~oa ~~=~ 1J.ooo";:;,:'et11heana::'wlia-~ : Uhlifies Uufiwited has done it again.. At last an easy way to find out where the protection really is nusm

I

packag• .1m jut Tius lS a oaa;p;ete 10 dis& efttY p•mzmtrr -.re :-. pmcinced.

set. ~~w~~ ~t~ctlurles

PIIMfERS IDimUmOJ SET

.

'!b _=;pny that has 'I'll! liS hr•l!us 11 aJxaU io do sometbmg ~ Wo aro gl:VUI3J!'" =rea! our li!Cli!ts. U.smg l!:is l ery £in P"CJ9%!m,. J! w:l »amly ..._ rapm &ad 11ie Pmlltltt\ ilr Ya; it .-l!l

1» :lro disk with yauz JWDe. II will JmPl:I!I'S Jl'1l M well as J011I fnenrlt. The "PmUU!r Caslndili Se!" is tib PDibmg JOII' "' eft< reo. In lad f""U c:u eveD leM Pc•wiHs th.al J"'U may have alrady 1I'DI:a;; ·l Ao by -aiag you amslmcliOJI HI rtY<tile kif rib J011I new tm.iB

We Cas.

... szus

"'-

..-

S1per Traaer ~ ...;n di . af your drive - head while you are loa,din q a p1ece · will splay the location of saf tware.. This information will he very useful, to find where the protection is. Slper T.racker has other useful

! * options such as· track and hall-track display 8 and 9 ......;;ch densily display write protect on/ off ** This incredible little tool is encased. indria handsome box that sils on top of your drive. Works with all · soldenng · will · be requrred. · * C/ 64/UB and most C/ 64 compatible ves. Some mmor ·

.._

:.::

..-

1

~nu

,

Introductory Pri.Ced a! Jusl $69.95.

.

,

.

!_.

-k -tc;:

itt

• ., -tt

.. J.

~

L.._- - - - - ----------- ****************************-********************** 4


\

The Potpourri Disk I

Helpl This HELPful utility gives you Instant menu-driven access to text files ot the touch of o key - while ony program Is running! •

I

Loan Helper

How much is that loon really g<)lng to cost you? Which Interest rote con you afford? With Loon Helper. the answers ore os close os your friendly 64!

¡''

I

Keyboard Learning how to ploy the piano? This handy educotionol program makes it easy and fun to learn the notes on the keyboard.

I

Flledump Examine your disk files FAST w1th this machine language utility. Handles six formats. Including hex. decimal. CBM and true ASCII. WordPro and SpeedScript.

I

Anagrams Anograms lets you unscramble words for crossword puzzles and the like. The program uses o recursive ML subroutine for maximum speed and efficiency.

I I'

LHe A FAST machine language version of mothemoticlon John Horton Conway's claSSIC s1mulotion. Set up your own 'colonies' and watch them grow!

I I

War Balloons

I I

Shoot down those evil Nazi War Balloons with your handy Acme Connon! Don't let them get owoyl

I I

Von Googol

News

Seve the money you spend on those supermarket tabloids - this program will generate equally convincing headline copy - tor free I

I I

Wrd

The ultimate in easy-to-use dote bose programs. WRD lets you quickly and simply create, examlne and edit just about any dote. Comes with sample file.

I I

Quiz

Tnv10 fanatics and students alike Will hove fun w1th this program. which gives you multiple chotce tests on material you hove entered with the WRD program.

l I

AHA! Lander

AHA!'s greet tuner lander program. Use either joystick or keyboard to compete ogo1nst yourself or up to 8 other ployers. Watch out for space mines!

I

I'

I'

I

Blackjack

I

The most flexible blockjock slmulotion you'll find anywhere. Set up your favourite rule variations for doubling. surrendering and splitting the deck.

I

I

File Compare

l

Which of those two files you just erected Is the most recent verSlOn? With this greet utikty you'U never be left wondenng

I I

Ghoul Dogs

I

Arcade maniocs look out! You'l need oil your dexterity to handle this wicked joystick-buster! These mod dog-monsters from space ore not for noviCes!

l I

Octagons

l

Just the thing for you Mensa types. Octagons is o cholleng1ng puzzle of the mind. Four levels of ploy. and a tough 'memory' variation tor reel experts!

I I

lackstreets

A nifty creede game. 100% mochine language. that helps you learn the typewriter keyboord while you ploy! 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 a nd fast-loader.

The ENTIRE POTPOURRI COLLECTION JUST $17.95 US!! See Order Cord at Center

I

A cute little creede-style game: capture the elves In the bog os quickly os you con - but don't get the good elfl

At lost! The mod philosopher, Helgo von Googol brings her own brand of wisdom to the small screen! If this is 'AI'. then it just ain't noturoll

I I

lag the Elves

I



•

What do you think?

Recently Tranwctor acquired two 1581 disk drives. Consequently, authors (and would-be authors) may now elect to make submissions on 3.5" disks. The little disks (call them " flappies") are perhap more likely to survive their journey through the postal system. Make certain that your floppy is clearly labeled as a 1581 format disk! Otherwise it might get swallowed up by the voracious Amigas. Now that you know what we' \'e got, we want to know what you'\'ÂŁ' got! The other bit of Transactor news for this issue is the appearance of the first Transactor Reader Survey. This is a Commodore 'consciousness raising' excrcic;e. The results of the survey will help to determine what you' II see in future Transactors. Tell us about your system configuration, the software you use most and your likes and dislikes with regard to magazine content.

people' - or even all programmers. Transactor has responded to these developments by attempting to provide useful information for all of these g roups in every issue. Although there are topics that we haven't covered (or haven ' t covered recently), we feel that Transactor offers more support to prog rammers and serious users than any other magazine. But we want to know what you think. Participate in o ur Reader Survey. Don' t be shy. Let's hear from you.

* * *

This issue pushes the limits with Paul Bosacki 's article on the 1764 REU. You may have seen REU expansion articles from other sources but this one includes a new wrinkle: installing an EPROM. Following on the heels of Adrian Pepper's Power C RAMdisk article, Kerry Gray has us Implementing a In recent years the 8-bit market has become increas- RAMdisk for Super-C. Robert Rockefeller makes his ingly fragmented; i.e., some users rarely leave the first appearance in these pages with some tips on Power C environment, some swear by CP/M , others usi ng pseudo-ops and macros with Commodore's are committed to GEOS. Of course, there are yet oth- Devpak. Anton Treuenfels reappears with a nift} ers who disdain these new developments and con- disk monitor, among other things. Jim Burterfield tinue to use the machines in the ir native environ- disc usses linked lists. Bill Coleman presents us with menl. Such users are content to use BASIC and an an overview of GEOS. Francis Kostella compares assembler and thus avoid the 'overhead ' of a di ffer- two GEOS assemblers. Richard Curcio brings robust ent operating environment. variables to the 128, 64 and VIC. All this and so much more. Enjoy! This polarization of the user community makes it difficult for any magazine to be 'all things to all Malcolm D. O'Brien

Volume 9, Issue 5

I


Transactor

Volume 9, Issue 5

The Magazine for Commodore Programmers

Publi.,her Anton} Jacob,on \ice-President OperaIions Jeannie LaY.rence Assistant Ad,erti~ing Manager Mike Grantham • Editors Malcolm O'Bncn Nick Sullivan Chri !> Zarnara Contributing Writers Marte Brengle Paul Bosackt Btll Brier Anthon) Br)ant Jo~eph Buckle> Jim Butterfield William Coleman James Cook Richard Curcro Miklo'> Garamveghy Larr) Ga) nier Kerr> Gray Todd Herman:il: Adam llerst Robert Huehn George llug Dennis Jarvi~ Garry Kitiak Francis Kostella Mike Mohilo D.J. Morriss Noel Nyman Adrian Pepper Steve Punter Robert Rockefeller Joel Rubin David Sanner Anton Trcuenfeb 'licholas Vrtb W. Mat Waites

Inner GEOS by William Coleman An oven •e"'- of the GEOS operatmg sy\tem.

1541/1571 DOS M-R Command Error

24

by Anton Treuenfels Mulliple-byte reads can be hazardous to your data. Anton explains why.

C128 Simple Disk Monitor

26

by Anton Treuenfels The C 128 's built-in machine language monuor was designed to be e:~.tens•ble. Here 's how you do it.

HCD65 Assembler Macros

32

by Robert Rockefeller Your assembler's pseudo-ops may be more versatile than }OU think.

Implementing A RAMdisk

34

by Kerry Gray Why should Power C users have all the fun? A C64 RAM d1\l.: dmer for Abacus· Super-C.

SuperNumbers ill

37

by Richard Curcio New developments in the wi ld world of sticky variables for the C 128, C64 and VIC-20.

Inside the 1764 REU

42

by Paul Bosacki Can you really put an EPROM in the 1764 - ami double its memory mto the bargam'? Paul explains.

.. Capitals: A BASIC Quiz Program

46

by Jim Butterfield What do geography and linked lists have in common? This program for all Commodore 8-bu computers.

C Problems, Tips And Observations by Larry Gaynier

Co\-er Artist Wayne Schmidt

21

Some anomalies m the Power C comp1ler. and notes on dnve u'age.

so


r,.,_., Is pubbl>ed bimontnly

by Croltwam PUblishing Inc 8S.1 0 Wesl W~ SII- Rocl>

Programming GEOS Icons

56

by James Cook GEOS has a buih · 10 hmu of 11 1cons .. unlc!>S you know the tricks presented here.

mond Htll. Ontatoo. l~B 1K7. ISSNI 0838-0163 C&nadllln Second Cluo Mal ~egostratoon No 7690 GaleN10.!4Sissayg&. Ont USPS Posl INSI8fl -.1 lldcltess c:tlangK lo T~ PO Bo> 338 Sla!Jon C Bllff* NY. 14209

eron..w ll<Jblilhlng Inc. II In no w1y comeaed

w'CI Commooore 8ulinMe Mac:llll>es Uc!. ot Commooore lnc:otporated and Commodore pniCiuCI- 8AI ~-. mat1<S ol Commodore Inc

eo.nn-e

BASIC 2.0 Array Shell Sort

62

Subeaiptoons

by Anton Treuenfeb

Caneda s19 Cdn

The anatomy of n M>rt rouunc. with u machine language implememauon you can call rrom BASIC.

A glob Function For Power C

USA $15 US AI 0111- $21 US Air Mall (Overseas only) $40 US

68

by Adrian Pepper Other opcrming ~ystem~ offer ncxiblc pancm-mutching for file names ... now the Power C shell c.h>e\ too.

S.m all aub..,rtpttona to : TranN<:~or. SUbIO'Iptlons Oe!>anment 85 West Wilmot Street Untt tO. Aoenmom Hill. Ont•rlo. C.n.Jda, l4B 1K7 (418) 7£>4·5273 Fot best resultS use 11\e po&tage paid card a1111e c.ntre ot t1>e magaz.ne Ouanllty Orde,.: In Canada Ingram Sohware ltd, 141 AdM!IO Dove. Conoord. Ontano. L4K 2W7 (416) ?Ja-1700. In the USA IPO (lnterna bonlll PenodOC81 Otsl'•butora). 11760-B Sominto Valey ~ottd. San Ouogo. Co itoma 92121, (619) 481 5928. al IO< Dave 8ueiCher

Departments and Columns

Edota<oal cont,.bu110nS are weloome Only ongonal. P<tYIOUSiy unpiJC>I!Shed malenaJ wil be consld-

Letters

6

Bits

10 Super-C BIT The Ta\manian Dataficr!

Your other !ile copier When Giant!> Walk ...

The ML Column

12

by Todd Heimarck

Progr., li$11nQS and

All ma!ertaJ atXlelliOCI becomes ttoe property of Croltwatd pulllialllng Inc excep by speoal ert&ng&menl AJ material Ia ccpynghl by Croltward publishing Inc: ~odUCJ>On on any form wllllool '*""'"on Is in vo01ar.on ollllPIIcabielaws. Wille 10 ltoe Rkl1mond lfll address fa< a wnter s gu.de The ~ e>preued •n contnbuted 8l1lGtec

11e not necesaanlt those of Crollward llUbltshing

How to handle 4!!-bit number'- up to 281.474.976.710,655... including square root~.

The Edge Connection

a.-a

O>c:luding BITS sut>rNssoons. ol mora tllMl a few lonel ~ be po-ovided on dlsl< Pnof81Ted fotmal II 1541 format wilh ASCII le>l liiK MlWlU"""'U ano.Ad be lyponortl:on. double-spacecl wlll elM chit ..::lira 01 -dearly marll.ed , _ ano.Ad be glosa)' biKII and ........ pnr.!S. lllusuallons shCIJid be on wtllle IMii* wilh blac;k ink only H>res graphicS hies on ..,. po-ef.,..., 10 ,.,.,dcopy illlwatoona ~ W.U. 10 Tranuc:tor a Rlchmot!d Hil olllte 10 oiJiain a wrc .. I guide .,..,

18

Inc. AllflOIIgll acc:Utacy Is a matO< OO,ectJve Cro"· ward llUbi•lhiiiQ Inc canno1 8$SUme habol•ty lot trn>ra ., art c:ln ot programs. Programs listed 111 Tm!WIICfor. aM/or appeanng on TtiOMaCIOI dtskl. are oopyriglll by Croftwilld ll<Jbtlshlng Inc and may no1 be dupltc&ted or dl&trbuted wlthooJ1 pet

m!Sa.on.

by Joel Rubin Pro<lueUon ln·houae wolh Am•oa 2000 and Protaao.,rvol Page

GEOS 128 2.0, ZOOM, macros. r.tdio. etc.

F'"'a' outwt by \leGum Pnnt &

Product Review: Two Assemblers for GEOS

Grapl1c Se<vces. Inc Tororoo

74

A comparison of Berkeley\ Geo,rogrammtr and B1ll Sharp's GenCOP£

Printing Prinlod ., Canada by

Bowne ol Caneda Inc

About the cover: Firthird by Wa) ne Schmidt: "Jn,pired afte r hearing a tr.m~cription of Stravinsky's 'The Firebird' for solo guitar (by Yama~hita). ihc!lf in,pired by legendary Russian folio.. tales, th1~ is my Firebird I am fond of the foil.. a.. "ell a' the pnmitive art traditions. and the rich imagery of Russtan icon' and laquer painting ~crvcd as models for this. Thts was created with Artist 64, modified for the 1351 mouse."- Wayne Schmidt


Using ''VERIFIZER'' Transactor's foo lproof program entry 1nethod •

VLRIFIZER should be run before typing in any long program from the pages of Trcm.\ucwr. It will let )-OU ched. your \\ort... line b) line as you enter the program and catch fru~trating typmg erro~. The VERLflZLR concept works by di~playing a twoletter code for each program line; you can then check this code against the corresponding one in the printed program listing. There are three ver;1on' of VERmZER here: one each for the PET/CBM, VIC/C64. and Cl28 computer'>. Enter the applicable program and RU 11. If you get a data or checksum error. re check the progran1 and t...eep trying until all goes "ell. You ~hould SAVE the program since you·u want to usc it every time you enter a program from Transactor. Once you've RUN the loader, remember to enter NEW to purge BASIC text space. Then turn VFRIFIZrR on with: SYS 634toenable the PET/CBI\1 ver;1on (oil: SYS 637) SYS 828 to enable the C64/VIC ver-.ion (off: SYS 831) SYS 3072, I to enable the C 128 ver~1on (off: SYS 3072,0)

"weighted checksum technique" that can be fooled if you try hard enough: tran~pm.ing I"-O ~etl> of four characters "'ill produce the same report code. but this will mrely happen. (VERI1·1/ER could have been de~igncd to be more complex, but the report codes would need to be longer, and using it would be more trouble than checking the program manually). VERlFIZER ignores spaces so you may add or omit spaces from the listed program at will (providmg you don't '>plit up keywords!) Stan· dard keyword abbreviation' (like nE instead of next) will not atlect the vERIAZER report code. Technical info : VIC/C64 VERJFLZER resides in the cassette buffer. so if you're using a dataseue be aware that tape operations can be dangerous to its health. As far as compatibility with other utilities goes. VERIFIZER shouldn't C~IU'>e any problems since it works through the BASIC wann stan link and Jumps to the origmal destination of the hnk after it's finished. When di~abled, it re~tore'> the link to its origmal contents. PETICBM VERIFI ZER (BASIC 2.0 or 4.0)

Once VERIFIZER is on. every time you prc~s RETURN on a program line a two-letter report code wtll appear on the top left of the screen in rever;e field. Note that these leners are in uppercase and w1ll appear a!. graph1cs character; unless you are tn upper/lowerca.,e mode (press '>hift/Commodore on C64/VIC).

Cl I0 rem* data loader for "verifizer 4.0" Ll 20cs=O HC 30 for i=634 to 754: read a: poke i.a DH 40 cs=cs+a: next i GK 50: OG 60 if cs<> 15580 then print"***** data error **,...*": end Note: If a report code is missing (or "--.. ) it means we've JO 70 rem sys 634 edited that line at the last minute. changing the report code. AF 80 end However, this will only happen occasionall} and usually only lN 100: 0 1000 data 76. 138. 2. 120, 173. 163. 2. 133. 144 on REM statements. 18 IOIOdata 173. 164. 2. 133, 145, 88. 96. 120, 165 With VERIFIZER on. ju'>t enter the program from the maga?ine CK I020 data 145. 20 I. 2. 240, 16, 141, 164. 2, 165 nonnally, checking e<tCh report code after you press RETURN EB 1030 data 144. 141. 163, 2, 169, 165, 133, 144. 169 on a line. If the code docsn 't match up with the letters printed HE I040 data 2. 133. 145, 88, 96, RS, 228. 165, 217 in the box beside the li~ti ng. you can re-chect.. and correct the OJ 1050 data 201. 13.208. 62, 165. 167.208. 58, 173 line. then try again. Lf you wish. you can LIST a range of lines. JB 1060data 254. I, 133,251.162. 0. 134.253. 189 then type RETURN over each in success1on while chect...ing PA 1070data 0. 2,168.201, 32,240. 15.230.253 the report codes as they appear. Once the program has been HE 1080 data 165.253, 41, 3, 133.254, 32.236. 2 proper!} entered. be sure to tum VERIFIZFR off with the SYS EL 1090data 198.254, 16,249,232, 152,208,229, 165 LA 1100 data 251, 4 1. 15. 24, 105, 193, 141, 0. 128 indicated above before you do anything else. KI I ll 0 data 165. 25 1, 74, 74, 74. 74, 24, I05, 193 Vl:RIHZER will catch transposition error~> like POKE 5238 1,0 EB 1120data 141. 1.128.108.163, 2. 152. 24,10 1 mstead of POKE 53281.0. However, VERIFIZER uses a DM 1130 data 251. 133. 251. 96

4

Transac tor

I


VJC/C64 VERrFIZER KE 10 remt- data loader for "veriftzer" * JF 15 rem \ ic/64 version Ll 20 c~=O BE 30 for 1=828 to 958:read a: poke i.a DH 40 c~-cs+a:next i GK 50: FIJ 60 if C'><> 14755 then print"***** data error*****": end KP 70 rem sys 828 AF 80 end IN 100: EC IOOOdat:J 76, 74. 3.165.251. 141. 2, 3,165 EP 1010 data 252, 141. 3. 3. 96. 173. 3. 3. 201 OC I020 data 3. 240. 17. 133. 252. 173, 2. 3. 133 MN 1030data 251, 169. 99. 141. 2. 3, 169, 3. 141 MG 1040 data 3, 3. 96. 173. 254. I, 133, 89. 162 OM 1050 data 0, 160, 0. 189. 0. 2, 240. 22, 201 CA 1060 data 32,240, 15, 133, 91.200, 152, 41, 3 NG I 070 data 133, 90, 32, 183. 3, 198, 90, 16, 249 OK 1080data232,208,229. 56. 32.240,255,169. 19 A'l I 090 data 12, 210, 255, 169. 18. 12, 210, 255. 165 GH liOOdata 89. 41. 15. 24. 105. 97. 32,210.255 JC Ill 0 data 165. 89. 74. 74. 74. 74. 24. I 05. 97 EP 1120 data 32. 210.255. 169. 146. 32, 210.255, 24 ~ 1130 data 32, 240. 255. 108, 251. 0, 165. 91, 24 BH 1140 data I 0 I, 89, 133. 89, 96

*NEW* C l28 VERIFIZER (40 or 80 column mode) KL I 00 rem save"O:c 128 vfz.ldr" ,8 0 1 110 rem c-128 verifizer MO 120 rem bugl> fixed: I) work!; m 80 column mode. DG 130 rem 2) sys 3072,0 now \\.Ork'>. KK 140 rem GH !50 rem by joel m. rubin HG 160 rem *data loader for "veri liter c 128" IF 170 rem • commodore c 128 ver<,ion DG 180 rem • works in 40 or 80 column mode!!! EB 190 ch=O GC 200 for j=3072 to 3220: read x: poke j,x: ch=ch+x: next NK 210 if ch<> 18602 then print "checksum error": ~top BL 220 pnnt "sys 3072,1 to enable DP 230 print "sys 3072,0 to disable AP 240end BA 250 data 170. 208. 11. 165. 253, 141. 2. 3 MM260data 165.254.141. 3. 3, 96,173. 3 AA 270 data 3. 201. 12.240. 17, 133.254. 173 FM 280 data 2. 3. 133, 253, 169, 39, 141. 2 IF 290 data 3. 169. 12. 141, 3, 3, 96. 169 FA 300 data 0, 14 1. 0, 255, 165, 22, 133, 250 LC 310 data 162, 0. 160, 0, 189, 0. 2, 20 I AJ 120data 48,144. 7.201, 58. 176, 3,232 EC 330 data 208, 242, 189, 0. 2. 240, 22. 20 I PI 340 data 32, 240, 15. 133, 252. 200, 152. 41 FF 350 data 3. 133.251, 32. 141. 12. 198,251 DE 360 data 16. 249. 232. 208. 229. 56. 32. 240 Volume 9, 1ssue 5

CB OK ON 01 OD PA BO

370 data 255. 169, 19. 32.210.255. 169. 18 380 data 32. 210. 255, 165.250. 41. 15. 24 390data 105. 193, 32.210.255. 165.250. 74 400 data 74. 74, 74, 24. 105. 193. 32.210 410 data 255, 169. 146, 32. 210. 255. 24, 32 420 data 240, 255, 108, 253, 0. 165. 252, 24 430 data I 0 I, 250, 133, 250. 96

The Standard Transactor Program Generator If you type in programs from the magazine, you might be able to o;ave yourself ~ome work with the program hsted on this page. Since many programs are printed m the form of 3 BASIC "program generator" which create'> 3 machine language (or BASIC) program on disk, we have created a "standard generator" program that contains code common to all program generators. Just type this in once. and !.ave all that typing for every other program generator you enter! Once the program is typed in (check the Veriliter codes as usual when entenng it), save it on 3 di\k for future u<>e. Whenever you t} pc: in a program generator. the hsung w11l refer to the ~tandard generator. Load the !>tandard generator first. then t) pe the hne' from the listing a!> !>hown. The re\ulung program will include the generator code and be ready to run. When you run the new generator, it will create a program on disk (the one described in the related anicle). The generator program is just tm easy way for you to put a mach me language program on disk. using the standard BASIC ed1tor at your disposal. After the file ha~ been created. the generator 1\ no longer needed. The Mandard generator. hO\\.ever. ~hould be kept handy for future program generator<,. The standard generator hsted here w1ll appear in every issue from now on ('>'hen necessary) as a <;tandard Transactor utility like Verlf11er. MG LOO rem transactor standard program generator EE LLO n$="filename": rem name of program LK 120 nd {)()(): sa=OOOOO: ch=OOOOO KO 130 for 1-1 to nd: read x EC 140 ch=ch-x: next f-B 150 tf ch then print "data error": stop DE 160 print "data ok, now creating file." CM 170 re,tore CH 180 open I.8.1,"0:"+n$ HM 190 hi=int(s:l/256): lo=sa-256*hi NA 200 print# l,chrS(Io)chr$(hi): KD 210 for i= l to nd: read x HE 220 pnnt# I ,chr$(x):: next JL 230 close I MP 240 pnnt"prg file "';n$:'" created ..." MH 250 print"th" generator no longer needed." IH 260: 5


T

e

L •

e

R esponses to the ML Column: I don't know if this will help, but I generate my random number<; through the Kemal R0~1. I do this by loading the accumulator with my seed value either zero, a po~itive integer or a negative integer (turning on bit 7). Then I call E09A. The random number.. "ill now be in regi~ter~ $63-$64. <Both "'ill Ouctuate bet\\een zero and 255 quite by random; and, if not. you can alway'> use the random number ju~t proJuced as your -.eed which will definitely guarantee randomness.) Here's a quid.. loot.. at the code for a single random number between 0 and 7: lela ll

jar $e09a lela $63

and 17

There is one drawback: it won't win any awards as far as speed is concerned. Sean Peck, Pittsburgh. PA Campaigning: I was struck by the idea of Campaign (which you described in Transucwr 9:3) for a couple of reasons. The first was that I thought 11 would be fun to see it work and the second was that it asked for a solution to the problem of the generation of random numbers. I had translated into machine language an 1dea for a pseudo-random number generator that I'd een in B-yte in March 1987 It had seemed a nice exercise for wnung mult1-byte divi-.1on and muluplicauon routines. Though it was better than the random number generator with Commodore BASIC and was written to be accessed with the 6

t

s

R

command. it seemed of limited appeal till your article came along. Having a source of random numbers. I carried out your program idea and thought I would send it to you. USR

The request for help 10 your art1cle 1mphed that an ideal solution would be a single memory addre'>) where random number.. could be grabbed qUicl..ly. The pseudo-random number generator that I U'>ed i'> complicated enough that the program takes a perceptible amount of time to calculate each point but nonetheless it moves along at a pretty good clip. Frank van Deventer, Gros.,e Pointe Farms.

\11

Fra nk's FollO\\¡up: I '>ubsequently ran across an article in Transactor. Volume 7. bsue 6 (page 27) thai described 'linear maximal length shift register sequences' as a way to generate a long series of pseudo-random numbers. The method is to add pairs of numbers in a series, called a register, take the remainder after dividing by a base and replace one of the number.. in the register with this new value which is also used as the random number output. A new pair is taken each time this b repeated. Thb proves 10 be a considerably faster method. If you loot.. the original article up. you'll see that the author gave an example program but I found that the idea could be carried out much fal!ter by Ulling the index registers instead of mo' ing data and could be worked in either base 16 (4 bits) or base 256 (I byte) to output random bytes directly. The article indicates that the length of the -;enes is equal to the base rai,ed to the power of the number of item~ in the regiSier. A ba~e larger than the Site of the regi"er does not give a maximum length series but it seem'> to produce adequate!} random numbers. The real question is whether there is any bias in the series and that i'>n't ~o clear. A little inspection

Transactor


~bows

that the maximum ~ries of odd numbers is equal to the length of the register and the maximum series of even numbers is equal to rhe distance berween the positions of the rwo number'> that are added; the upper and lower taps when two taps are used. The program runs faster the larger the register and for those reasons I picked the largest register that had an optimum tap near the bottom. I rewrote the program that I sent you earlier to use the new random number generator. You'll see that it's much fa\ler and. at least to visual inspection, seems to work in a random fashion. It's also fast enough now to fill the screen with random bytes in an acceptable, length of time. There are rwo vers1on~ on the disk, both of which work from BASIC. Campaign64+ works in base 256 and Campaign+ worh m base 16. This requ1res only aminor change in the program. Although the latter program is marginally faster, it isn "t evident to watch it. 1 also included the pseudo-random generator separately as rangen64+ along with a demO+ that shows access from BASIC using the USR function if you'd like to take a look at it. You 'II find I think that Campaign is even more fun to watch when it's speeded up. Frank van Deventer, Grosse Pointe Farms.

~1J

This routine still has problems, however. A true eight-bit random number generator has a one in 256 chance of producing the same number twice in succession, but the nature of this routine eliminates this chance. Note that thi~ i~ only a problem if you are using all eight bits of the number. For example, in your Campaign routine one of e1ght neighbor~ must be randomly \elected. Three of the eight random b1h can be U'>ed to do th". These three bits can come up the -.arne wh1le the other five VaT), so the errors are reduced. It ~eems like the complete solution to this problem requires an independent signal that indicates a new number is present in the 'mndom' register. It's too bad that Commodore didn't thmk of this when designing the sro chip. It may he po'isible to use <;ome other source, '>uch ac; the \.IC scan lmc regic;ter or a CIA timer, a a source for thl\ .,.gnal. Randomness i5 a fascinating !>ubject. It is Rm:ving to me that such a simple concept can be so complicated in execution. I really enjoy your column and I hope it continues as a regular feature. Good luck and keep up the good work. M1ke Gr.tham, Hopatcong. M

SID Sampling Rate: Thr ML Column in TranJactor 9:3 ended with a request for a way to generate random numbers with the C64. I think the following may help.

ML Wish List: I very much enjoy your The ML Column in Transactor. It was not too much over my head, and cenainJy not too basic either.

I have found that the SID chip's noise generator can generate what appear to be trul)' random numbers, but there's a catch. The rate at v. hich these numbers are produced is determined by vo1ce three's frequency setting stored in SD40E and $D40F. At the highest possible frequency, the chip w111 produce about 7000 random numbers per second. This translates to a new number every 140 clock cycles. Consequently, a fast-running machine language routine can read the same number many times between changes.

In a furure column, I would like to see a discu\sion about 1/0 routmes; for example, reading and writing to d1sk v. ith various file t) pes, oos commands, printing, etc. I look forward ro future columns.

One !>Oiution to this problem is to wall for the number to change before using it, like !.O: random • $d4lb;aid random number getrand lda random; get nnmbe"t" emp prev;~ehanged ? qeq getrand; no , wait ata prev; for next time rta

prev

.byte O;prev I storage

This subroutine compares the current value of random with what v..as there during the previous call and waits for the number to change before accepting it. The new number is then stored for the next call before retuming the number in the accumulator. This will slow down a fast-running caller to match the rate at which the sro can produce new numbers. Note that the routine assumes that the SID has been initilllized to produce random numbers. Volume 9, 15SUe 5

Barry Kutner, Yardley, PA Random bunnies: I love your new column, The ML Column. (Great title too!) I like how you pick interesttng subjects, or at lea'>t make dull subjects sound interesting. I was very impressed w1th your binary diVISIOn column m Volume 9. Issue 2. It amwered a couple of questions l had myself. With regard to the column in Volume 9, Issue 3... are you kidding? You had such a brilliant head long jump into the problem, only to be symied by it not being random enough?! (Actually. I skimmed the anicle briefly, was impressed. saw how shon the BASIC generator program was, was l'ery 1mpressed, typed it in, and was disappointed to see the screen not changing. llarumph! ) Anyway. I have a solution that I figured out by !>imply looking at the not-changing screen. The nature of the SID output is such that it develops those irritating diagonal Lines. But each b) te is different from the last in that it is shifted over shghtl)'. Tv..o tricks to solve this, but first the explanation: 'Random • in its pure definition means an absence of pattern, but it does not mean that local patterns may not develop (like squares. triangles, bunnies. etc.). By modifying the progmm to 7


run infinitely, constantly redrawing the screen, I was able to watch out, but I didn't '>ee any bunmes... In fact, all I saw was what looked like chummg water! Obvtously, the SID does not do a good JOb of producing random di~plays. So I figured, "What kind of dt~play are we looking for here?'" and I immediately thought of a :.tatic screen. About-uniform distributrion of blue and "hl!e doh, like ~now on TV. (No diagonals.) Thts 1sn 't true randomne~ ... by the way, because it doesn't allow for recogm7able shape~. <,uch a~ bunmes and duckies. I call this ·,no"' the r.mdom pattern, a really awful oxymoron! • Anyway, two solutions, and the major problem i!> the pesky diagonal lines. I) Change line 630 m the source code to: 630 lpchoose lda random: adc random: adc random: adc random: adc random

Now, the gradual difference that provided the original diagonal tendency is multiplied five-fold. It's still there, but is now much more jagged, and m the 8-bit wide display, is indiscemable. It also takes a lot longer to dra" the screen, because this is executed for all 8192 bytes of the screen! Not so good. 2) The diagonal tendency 1!. cau\cd b) putting these slightly!>hifted data byte:. next to each other... oh, you guessed it already. Change the chOO\e routine! 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690

chooaa • * bitmap c $2000 ldy 10 lpchooaa ldx 132 lda l<bitmap at a aalfmod+l lda • >bitmap at a aalfmod+2 lp2 lda random salfmod eta $tttt,y inc salfmod+2 dax bna lp2 day bna lpchooaa

J actually conjured up thic; solut10n first. simply from looking at your fill routine. I might use the first solution for the campaign routine though, to add a dash of really-more-vaned numbers to the \imulation. Another method would be to use the Commodore random number generator, though that is really ugl)' !)low in compari,on. Pleru,e send me your existing campaign routine!

Kevin 8

~oorman.

Calgary, AB

Precious pages: I read with interest Jim Butterfield's review of What'~ Really Inside The Commodore 64 [available in North America from Schnedler Systems. 25 Eastwood Rd., P.O. Box 5964, Asheville, 'C. 28813. (704) 274-4646) (Transactor, Volume 9, hsue 4). I use the book often. and I agree with Mr. Butterfield\ a... ~es.,ment of it. I wa!> surpri:.ed, bowever, to find t-wo other possible supplements were left out. One of the most useful books in my Commodore library is Mapping The Commodore 64 by Sheldon Leemon rcompute! Publications). It references memory locations, rather than disassembling the R0\1 code. That gtves a ptcture of the dynamics of the machine mts-.ing from the other texh hsted. While the Dan Heeb books )al'>o from Compute! J give in-depth di~cus­ sions of the RO\t routine!>, they're often too detailed. For 'quick and dirty' usc of the C64 ROM code, l invariably tum to Leemon·~ book. In a few words, he tells me what to do with registers, and what to expect a~ output. I usually tell beginners that if they only buy one book, make it ProgramminR Tlte Commodore 64 by Raeto West )also from Compute!). It\ not as deUliled in ROM code as any of the other references. But, We~t list!> the commonly used routine~ and gives excellent example~.Actually. an a.ssembly language programmer should have all six books available. He or

~he

<;hould abo con\tdcr Mr. Bunerfield\ own Machine

Lan~ua~e

FlJr Tlte Convuodore M And Other Commodore Computers (Brady Book.'>). an excellent. ea.~1ly understood beginning text. Man m DeJong'<; Aswmh/_l Lungual(e Pmgrommin~ With The CommoJ01e 6-J 1s another valuable addJuon. It gives well annotated examples of bitmap gmphics. SID, and 1,0 routines. To round out the library, no programmer should be without 1541 User's Guide by Dr. Gerald Neufeld, and Inside Commodore DOS by Neufeld and Richard lmmers Noel Nyman, Seattle, WA More on household aulomation: After reading my review on the X-10 Powerhouse lnteJfa('e, you may have decided that it's too limited by the lack of real-world inputs for your application.

Jf you prefer not to experiment with X-10\ newer modules, and you have an old vtc-20 or C(H not in active ll'>C, there's an inexpensive solution. Check for the Ma) 1986 issue of RadioElectronics maguine. In the "Computer Digest" section, Chandler Sowden published a simple hardware circuit that sends X-10 signals into the power line. It ll'>CS the user pon as an output, so the VIC-20 will \\Ork as -well as a C64 or Cl28. He also provides a BASIC program to generate the control signals. Just add switches to the joy\lick port., (up to 10). or heat/light sen~ors to the paddle inpuh and you have an easily programmed X- 10 sy:.tem that will respond to the real world. Noel Nyman, Seartle. WA Transactor


Some comments and a question: Volume 9, Issue 2: Joel Rubm wrote a comparison of ~orne commercial a~semblers for the 128, and abo mentioned The Fast Assemhler by Yves Han. "'hich appeared in the January 1986 •~sue of Compme"s Ga:ette. l was intereMed in its mention, since I use this ~ystem e~clusively. A few thoughts on this vel) unique assembler: Joel men11oned that FA can't print out lis ting~. Not ~o! Since BAS IC is still active. an invocation of the famous line open 4,4:cmd 4:1ist will do the job. Smce all opcodes and pseudoop~ are tokenized. however. th1o; can only be done \\hile rhe a~~embler is active. And because of this tokenization, source code isn't easily transferable between FA and other asemblers. Another point: •FA operates as an extension of BASIC. not a replacement for it. It can be used to write BASIC program' that use the added features (Indentation of lines is supported, as is the use of bmary and he~ numbers). Becau<;e you can \\rite both BASIC and \1L programs wuh the ac;sembler. you have to manually enclose the \1L part inside a for/next loop to unplemcnt the multiple pa~ses required by a label-based assembler. Volume 9. Issue 4: Jim Butterfield revie\.\ed What's Reallv Inside the Commodore 64? by Milton Bathurst. Jim mentioned Abacus' The Anatomy of the Commodore 64. My advice is: forget it! The source " sparsely commented and umndcxed. Without a memory map }Ou'll go nuts trying to find the routines you want. The prognunmer's reference section is full of errors. Personally. I recommend Dan Heeb\ Tool Kit books. publi£hed by Compuu 1• Regardless of what )'OU may think about their magazines. Compute!\ programming booh are generall y hard to beat. I'm working on a large-scale filing program and need 'orne help on a sofrware project I want to undertake. The filing progr.tm will be wriuen entirely in BASIC' and will utili7e a string arry which occupies about 30K on itS O\\n Obv10usly. this hn't all going 10 til in 8.\SIC \.\Ork~pace. and I'm 10ymg \\ith the idea of setting up a bank of the 1764 REU (say. bank 0) as a "phantom computer". The idea i'> to copy both ROM~. tero page, vectors. the stack, and the string air.!} 10 their appropriate spots in expansion memory, then switch it all in whenever l need to access the array. Parameters and result~ could be transferred back and forth between the 4K bloch starting at $COOO. Of course. there are seveml consideration'> when doing this. The BASIC pointers in expansion RAM would need to be modified for the 'new' contents of BASIC workspace. I \\Ould have to perform the switch with an ML routine and interrupt'> would have to be disabled, since there will be no 1/0. The question is, will this work? If it's possible to pull this off. how do I make the 6510 recognize a bank of expan,ion RA\1 and ho\.\ do I select \\hich bank it will look at? Any information you or your other readers could give me would be greatly appreciated. My address is: 16925 M orrison Ave.. Southfield. 11.11. 48076.

CONCURR.OS ~

It The CONCURRENT Operating system splits your C64 into two BASIC computers and allows you to switch between them. One of the programs can be full length, (38911 bytes) while the other can be a "Short• BASIC program (1270 bytes). When switching between these programs the associated screen display IS also switched and saved. In a typical configuration the Short program Is a utility to aid in your program development. Loading and running a Short program will not affect the main co-resident BASIC or Machine Language program. CONCURR.OS can be loaded AFTER your main program has been loaded, It loads without disturbing existing hatted programs. It swaps out the current RAM between $0000 and $0CF7 plus the colour RAM, to RAM at $DOOO. CONCURR does not affect the valuable RAM at $COOO. This creates space for Short programs which can provide you powerfull functions and ut11ities such as; • List/Disassemble your Main Program • List/Disassemble named Disk Rles • List/Disassemble a track & Sector • List/Disassemble 1541 Disk RAM/ROM • Disassemble Pseudo Codes • List a named BASIC disk file • List a Disk Directory • Look up , create & print data screen files • Un-NEW a BASIC program There is also a Short Screen Editor for creating and filing your own coloured text screens. CONCURR.OS allows you to switch over to the Short side and list an old version of your program to the screen, view a directory, create and file some comments etc. and return to your program In the same state as you left it in. With the 1541 Disassembler program you can place and run your own programs in the RAM of the disk. The CONCURR DISK Includes CONCURR.OS and the Short utilities described here. Send $18.00 Cdn (or $15.00 US) plus $2.00 for shipping and handling, Money Order or cheque drawn on Canadian Bank. Please allow 6 weeks for delivery. Pre-payment is

PRECISIONWARE 1 Adams Street Brampton, Ont Canada, L6Z 2S3

required.

You put out a great maga.tine! Keep up the good worl...! Howard I. Goldman. Sou1hfield. \1t Volume 9, Issue 5

9


t •

s

Got a11 mteresti11g programmi11g tip, a short roll/me, or an unkiiOII'II btl of Commodore trn'ia? Send it in- if we use it in the bits column, we' II credu you mthe column and send you a free one-year subscnption to Transactor

Super-C BIT Kerry Gray, Salinas, CA A Super-C program is loaded from $080 I like BASIC. Its first two bytes fonn a pointer to the first instruction in the program. You can write stand-alone assembler language programs that can be run from the C environment if you follow this convention. Your program should exit with a Jl\fP $0400 to return control to the C 1>hell: Don't use nn RTS. Your other fil e copier I had a 457-block ARC file that I wanted to move from a 1581 to a 1571. My file copier wouldn't budge this monster! I

came up with another idea. I booted GEOS and. sure enough, managed to cop} the file. Not only will GEOS handle veT) large files, but you also get the added bonus of the GEOS disk turbo. The Tasmanian Datafier! Elaine Foster, Launceston, Tasmania

Lines 50150 and 50160 en!>ure that all data elements are aligned (Transactor style), which makes them much easier to read and to copy. This program cleverly erases itself when it has done its job, while leaving the new DATA statements intact! This means that when the new DATA lines have been made the program may be saved 'as is' or you can begin entering lines of BASIC or append another BASIC program. The Deleter is a form of selective NEW, and the details are given in the source code shown (deleter.src - prol"ided and presellled in Speedy Asumbler f ormat - .110). You can see that it scans BASIC from $0801 onward~. looking at each link address and at each line number in tum. If the hne number is not (in this case) 5()()()() 11 goe<, to the next link and next line number, and so on. When 5()()()() is found. 11 backs up two bytes, adds terminating zeros and adjusts the end address b}tes of locations 45 and 46 to suit. The start address of the Deleter routine (53000 in this instance) can be any one where there is room for 67 bytes; this is possible because lines 590-600 replace a J~P by a BEQ, a relative assignment. Th1s is nice, because it allows you to avoid any conflict with the ML program being examined. If you wish to use the Deletcr routine alone (BASIC Line 500 I 0-50080), it may be adjusted to delete from ru1y desired line number: see REMS in lines 50030 and 50040.

When you want to make a BASIC Loader for your own or other ML program, it is very nice directly to translate the data in RAM into BASIC DATA lines. This program does this very simply, and it is only five blocks long compared to a 29-block commercial equivalent. rt does require that you supply the stan and end addresses of the \1L program to be Listing 1: The Tasmanian Datafier! translated. The end address will be at 45-46 after loading, and the stan address will be the fir~t two bytes in the ftrst II 50000 ru --the tUllllll1U dltlfierl -tn.nnctor 9-5 sector of the program on the disk - all in the usual low JL 50010 ru -- al to de1ttt 11111 50000+ • hb f M T ·d th d n 50020 pokt53280 3·pokt5328l 1·pokt646, 6:c!ia$(9) byte/h ig yte ormat. any Uti Illes cartn ges ese ays IB 50030 print' tc1r)(dm)(doWII)(m)buic 101dtr for ra data ' also automatically give the Mart address and end address of 17 50040 dltalU 001133 25UU,OC8,133, 252,160,000 a loaded program. n 50050 datam 251133 253,200,177,251,133,254, 200 With the \iL program in memory, th1s one is loaded into the BASIC workspace and run. It prompts you for the start address and end addres~ and the taning line number for the DATA statements. By u~ing Dynamic Keyboard methods Oines 50190-50230) it then make;) the DATA lines and ends with the usual FOR/1\'EXT reading and poking loop (lines 50240-50250). The loader program is then ready to save to disk. 10

50060 data177 251 201 080 . 2CB . 029. 200 . 177, 251 , 201 ~ ra ~so • lb for lice 50000 50070 datll95.208 ~22 1l6.136.169,000,145,251,136:rta 195 • hb for liDt 50000 50083 dlta145 251 200,200.152 024 101,251.133,045 50090 datal65 252 133.046.096.166 253,1)4, 251,166 50100 datl254 134 252 169 000 240,197 50110 coomoo forPCtoc+66:rtady:dod!y.ra- c &llywhert wll4rt nx:a for 61 bytu 50120 pokes y · ~~tJt : 1fd<>1C818thtnpr1Dt trror l': t:d !R 50133 pr1Dt' ldoln) l•~t•r 0 to llit) 10. 50140 1Dpot' ldm)(dmJ lieqWilDg lddrtu ';bl : ~t'ldml uchnq addms•; u Ill 50150 1fbi=OoruoOth~

01 SO IG 00 PP 11 IE

Transactor

I


01 11

.. AD lOC JQf

rr 01 11

IX ID

AJ rL

81 Yl

Kl

DO

lnpllt'(dow) fint data hat t· I 50170 lfta·batl·9>50000tbtnprint'(dcrn)hnt ovtrlap w1tb thls proql :9Qto50160 50180 lffthto5~290 50190 forn:batatobat9ta :a$(b)=mld$(str$(ptek(n)),2) 50200 lflen (a$ (b))•lthena$ (b) •' ' +a$ (b) 50210 lflen (a$ (b) )•2thena$ (b) •" ' +a$ (b) 50220 ifn=eathenr.•ha+9+a : ~est f•l :qoto502CO 50230 bab+l:Dtrt:b=b·l SC2CO print (clr)(white)'lid$ (str${1), 2)' data';·forpoCtcb-1 pnnta$[p)', ' ; SC250 ust prillta$[p) 50260 pnnt"ha•'ha'· u= u'~ a•'a aq+lO:bzO:l•' l' l•l•IO:fa f :qotoSOISO' 50270 print (dow)(down)(dow)(bloel lil:e t 1 (whltel 50280 poke631, 19:poke632, 13:poie633,13:pokt63C, 3l :poiel98,C:tnd 50290 print'(clr)' ;l; ' fon• mid$(str$(ba),2) to"lid$(atr$(ul , 21":nady:'; 50300 print"pokex,y:next•:print'aya53000' 50310 pnnt'(lllue)oi: data entered. (down)(down)(down)(down)ldown)(wbitel' 50320 qoto50280 501~

Li ling 2: tleleter.src

10 ;block delete: lines >= 50000 20 ; line forut : 30 ,• [linkJ(linef)[line data)O co •. end of proq: 0 0 0 [end addrtu) so ,• (link points to • I 60 equ 50000 :to dalete 70 lint 80 90 org 53000 st&rt addreu 100 ;note· relocatablt anywhere ;sys llO ent 120 ; 130 ;·· IC&II basic: •link lb lCO 1tart Ida 101 ata $fb 150 ; link hb 160 lda 1$08 170 ata $fc ; iM.&ddr. 180 . 190 ; aC&II llftk address: ; init.loop 200 IC&II ldy to 210 lda {$fbi , y ; ld lnk lb 220 sta $fd ;ston it. 230 iny 2CO Ida ($fbi, y ·ld lnlt hb 250 sta $fe store it. 260 270 ac&ll hne DUIIbtr: 280 lint.llO iny next byte 290 lda {$fbl , y . ld lne lb 300 Clip f<line ; lb 50000? bnt link ;n:nxt Ink 310 320 iny ·y:nxt byt lda ($fb) ,y 330 3CO Clip l>liDe hb 50000? 350 bne link n nxt Ink 360 . 370 ·ttDilDatinq reros: ; .y-2 380 ttmnett day 390 dey ;store 0 coo Ida to ClO sta ($fb) , y • thert. C20 dey ·1 byt C30 sta ($fb) , y aqun.

ceo ;

C50 :1091 e.a. ptrs to byte after 000 C60 IOVI .II lilY C70 illy +2 byb cao tya C90 ole ; lhfiii 251 500 adc $fb 510 sta C5 lb of u

Volume 9, Issue 5

520 530 SCO 550 ; 560 link 570 580 590 600

lda $fc

sta C6 rts ld.l st:l ld.l stz lda

$fd $fb $fe $fc 10

; hbfm m ;hb of ea

; nxt lnklb ; stort 1t hb ;ditto

\~hen GiatM W?uk...:•JIIP 10111 Lar r) Rutledge, Sacra mento, CA Imagine how the Lilliputians felt. Let's face it, Gulliver was a big guy. Brobdingnagian, you might say. No, we're not going to tell you. You'll have to type this in for ) ourself. NP PI JN MA FN ML ~

NG OK

0 rem screen display - larry rutledge 1 rem tra nsactor ~-5 2 rem a ll riqhts reserved 3 pr~nt chr$(1 47) J print tab(11) , chr$(15 4 );chr$(17); chr$(17) ;"vatch what happens" 5 for 1=1 to 1000:next 6 for j=O to 3l : poke 53270,j : next 7 qat a$:if a$•"" than 6 8 poke 53270,200

~-

.~

VIDEO BYTE the first FULL COLOR! video digitizer for the C-64, C-128

lntroducmo the world's f1rst FULL COLOR! VIdeo d1grt1zer tor the Commodore C-64, C·128 & 128-0 computer. VIDEO BYTE can grve you digitized video from your V.C.R.• BIW or COLOR CAMERA or LIVE VIDEO (thanks to a fast! 2 2 sec. scan time). • FUU COLOfiiZINGI 1$ possoble due to a unoque SELECT and INSERT COlO< process .,here '~~~" can seltcl one ol 15 COlDRS end .nsert that color lnro one ot 4 GRAY SCAlES This process 1011 01'11! you oYer 32.000 O.tletent c:olol comboniiJOriS to use 111 .,.,.. •Ideo pclln$. • WlS • ICOAlASI 'Meo 8jle abs 10" to SM all your pc!U<U 10 Cllslt as FUll COlOR ~ S AlUr •hoc!I IIISIIIO ~ 01 S!Ma!V ptagnml you can 00 • anG rt(lrJw 0< rea11or .,.,.. VleleO Byte pc·s • LMO 1M RE·OISI'lAYI VIdeo Bylt allows )l)u to loaclltld 11!~ tl VIdeo 8y1t piCIUrH trom •nso<le VIdeo Bytes menu • MENU DRIVEN! VIdeo 8)1t comes v.1th an easy to use menu dtl'ltn UTiliTY DISI< and diQIII!II PIOQillm'

COMPACT~ VIdeo Byle's hardware is compae11In fact no bigger lhan your Mraoe canndgel VIdeo 8)1e comes w.lh lis own cable. • INTtGRATtot Video 8jte os designed 10 be used ..,,th 0< W11h0Ul EXPl.00£1V4 1 C<JIOr cartnOgt Explode' V4 .I Is tht perfect companoon • FIIE£1 VIdeo Bjle users 111 automat.caby sent FREE SOFTWARE ~liS aiCX1II ""lh new !IOc:utniii!IIIOn. Whtn It becGIT'a Mlllbit • PIIINn VIdeo Byte ..,. pmiOUI pc~..m to most pnnters ~r used v.olh EJClllode• V4 1 )'CUI pMOUI s can be doni in FUlL COlOR on lht 1WNIOW Nx.-. 1WNIOW Nl·1101 C. JX. . 1M tilt OODAJA It 121. Wty DRAW a car. llfl)Qne, person or for ttw mzu.r

""*'

:'!':yl~=~~n BYTE

4

VIDEO BYTE $79.95

SUPER EXPLODE! V4.1 w/COLOR DUMP

U your looking lor a CARTRIDGE which can CAPTURE ANY SCREEN, PRINTS All HI·RES and TEXT SCREENS In fULL COLOR to the RAINBOW NX·1000. RAINBaN NX·1000 C. EPSON JX~ and the OKIOATA 10 or 20. Pnnts 111 16 gray scale ID aU O!her pnnters. Comes ..,itll lilt world s FASTEST SNE and LOAO 101111nes In a car· tndge or a dual SEO PRG Ale reader ~ a built-in 8 SI:CONO formal and MUCH . MUCH MQREI Tl\an Exp!Odel V4 1 IS lor )OU PRIC£? $44..15 + Sill tr S4U5 wtvpllonll dls*e awl~-. ' IN 64 MODE ONLY TO ORDER CALl 1-31H51-6M7 Ptrsonal Checks 10 Oays to Clear

VIDEO BYTE only $79.95 SUPER EXPL00£1 V4.1 $405 PlUS $1.50 SIH COD'S ADO S400 IL RESIDENTS AOO 6~ SAlES TAX

THE SOn GROUP, P.O. BOX 111, MONTGOMERY, IL 60538

11


The ML Column Big numbers •

by Todd Heimarck This inMalment of The ML Column started with one large idea that gradually developed into a !>Cries of smaller ideas. If a high-level language is like a pile of bricks from which you build a house, then machine language is like a pile of clay from which you make the bricks to build a house. It turned out that I needed some bricks. TI1e idea behind the original program. which remains in the planning stage. was to build an enormous lool..-up table witl1in the 1750 RA\1 expansion unit. That's 512 kilobytes (or. in the program I had in mind. 4 megabit\). With two bytes. you can coum up to 65,535. which 1s not nearly high enough. The program needs several byte~ to count up to four million. Handhng multi-byte numbers i'>n 't ~o difficult, but there are two problems: input and output. The program needs a routine that accep~ big numbers and turns them into binary values in memory. Plus, ~hen the program is finished doing ~hat it does, it needs a routine to conven the ones and Leros into printable ASCII numbers. That topic is enough for a column. We'll have to discuss the RA\1 expander in some future column.

-

If you examine the beginning of Program I, you'II see the essential structure of the program. 1t does live things: I . Get

a string from the user.

2. Conven it to a big (six-byte) binary value. 3. Do -;omething with the number. 4. Conven it bad. to decimal. 5. Print the re~ult'>.

At various

spo~

along the way, the program prints appropriate prompt~. It also chcch for a 1cro value (the signal to exit the program) and for a number that\ too big.

Tearing apart an ASC II number I decided. for 'ariou~ reasons, to use a six-byte value and to store the low byte liN. The binary number ill stored in a section of memory I've named BIGS IX. 1t can hold numbers in the range 0-281,474.976,710,655 (hexadecimal Sr+FIFHFFFFF). 12

The user types on the keyboard, which means the incoming characters are ASCII values. lf he or she types 910. we'll receive 57, 49, and 48. because those are the ASCn codes for the characters '9', 'I'. and '0'. The program accepts commas because it filters out any characters outside the range of ASCII number~ (48-57). If the user types l3turtle56, the program ~tore~ rhe characters '1356' in memory. The memory buffer for the filtered characters is caUed MEMBLI'. We must deal with two special characters that might come along. An ASCII 13 1S a carnage return character, which means the u er pre<>sed Return and is done. The loop ends 'n hen it sees a 13. In addJuon. a penod can aho mark the end of input. For example. if the user t) pe 156.27. ~e take that to mean 156 and not 15.267. The first big brick, then. is the GSTRI'\G ~ubroutine. It repeatedly calls the Kemal routine CIIRtN (which is preferable in this case to GET"). It filters out all the \SCII numbers and stores them in MEMBLF. Next, we call MAK£:.Btl'.. which converts the ASCII numbers into a six-byte integer. The process is relatively simple: I. Start with a 0 in BIGS IX. 2. Multiply BIGSJX by 10 (bccau~c we're in base ten). 3. Get an ASCII number and \ ubtract 48, to make the character '2' into the value 02 (or whatever). 4. Add that number to BIGSIX. 5. If there are more characten. in \1l::.\1BLF-. go back to step 2.

Say the user t) pes 5993. Start at the left. Zero times ten is 0. Add the first number (5). Five time~ ten is 50 and add 9, which is 59. 1imes I0 (590). plus 9 (599), time~ ten (5990), and add 3 (5993). It seems kmd of \lily to start ~ ith 5993 and end with it, but that's because the example math •., in decimal. Inside the computer. it\ all ones and .teros: 101 (5) becomes 110010 (50). Ill 0 II (59). and '>0 on. A general routine for multiplymg isn't necessary. becau!>e the only multiplication in the program mvolves the number ten. If Transactor


}OU ~>hift a binary number to the left, it's the l!ame a.., multiplying by t\\0. Shifting three times i.., equivalent to multiplying by eight. If 1 is the number, we want IO*X. That's the same as (2* 1) + (8*X). To multiply by ten, shift left and temporarily \ave it (times two). Shift left twice more (times eight) and add the temporary value. The BIGXIO routine multiplie' BIGSIX b) ten as pan of the MAKEBI' routine. The ROTStX \Ubroutine rotate\ all '>IX b) tes one bit to the left, and the DUPSIX subroutine copic~ the B!GSIX number to BIG:!. These routines abo have to check for an overflow condition. which happens when the user types in a number bigger thai} 281 tri Ilion.

number 101 ~hifted left 1s 1010. In b~e ten. ~hitting left is the sante as multiplying b) I0. In base two. sh1f11ng left 1s the ~amc us multiplying by 2. To find out that the rightmost digit of 914 is 4, we must actually divide by 10 (and get the remainder of 4). We cannot shift right. hecuuse the number is c;Jored as a binaJ) quantity. Shiftmg a blllaf) right is equivalent to dividing b) 2. not di\iding b} 10. Calculating big square roots

Do omething interesting

Program 2 is a code fragmen t that contains a new PROCESS routine. ltc; lines replace the lines from Program I; the first pan i., Identical.

The fir..,t version of thi~ program convened the ASC 11 numbers to b1nary and then back to ASCil, which is a rather pointlesl> exerci\e. You type in a number and then it telb you the number you just typed. So what?

Thi'> new PROCESS routine find., the binary square root of a big six-byte number. rounded down to the neare~t integer. It will say that the square root of 25 is 5, but it also says that the square root of 30 is 5.

Stnce we've gone to all thi.., trouble, we should do something. Program one take the binaJ) number and pnnl\ 11 a'> a series of ones and zeros. It happen' in the PROCESS rout me. "hich l>hould be e~y to follow.

Sounds complicated. docsn 't it? It's not. If you' rc curious about hO\.\ 11 works. read on.

A second version of PROCESS calculates the square root of the BIGSIX number. More about that in a moment.

Let'., begm with a higiHchool math refresher and take a square root entirely in base ten. The square root of 65.536 is 256. 11te process is described below and corresponds to the representation included as Figure I.

Con\erti ng back to ASCII After processing the btnary value in PROCESS, we need the routine that convertl> bad. to printable base-ten numbers. Since we multiplied b) ten in the other routine. it\ a good bet that we need to divide by ten in the MAKEDEC routine. Since we 'tuned at the left before, we probably need to start at the right. Take a short number. like dec1mal 57 (binary 111001 ). Let's 'ee, 111001 dhided by 1010 1s about 101 \\ith a remainder of Ill. In decimal, that meum. 57 divided by I0 i' 5 with a remainder of 7. The value 7 can be added to 48 to get 55, which is the ASCII character '7'. The \IAKEDEC routine buildc; up a decimal (ASCII) number by folio\\ ing these steps: I D1vide b) I0. 2. Add 48 to the remainder to get an ASC'II number. 3. Repeat until the re~ult b 0 (with a remainder of 0-9). A previous column dil>cu~sed binary division; I won't repeat m}self here. See The ML Column in Volume 9, l~sue 2 of Transactor tf you're intere.,ted 10 the details of bmary dl\ is ion. An Important thing to remember is that ~htltmg is radixdependent (if that's a word). whereas both division and multiplication are radi>.-indepcndent. The decimal (base-ten) numb<!r 578 shifted to the left b 5780. The binary (base-two) Volume 9, Issue 5

2 )6

-4 2 2

5 55 55 25 30 30

6 36 (0+2)*2 (40+5)*5 36 36 0

(500+6)A6

Figure 1: Finding tile square root of 65.536

First. murk off evef) two digits ~tarting at the decimal point: 6/55/36. Start \\ith a pan1al an~wcr of 0 because \\C haven't begun. Multiply by 20 to get 0 (call this the weird number). Look at the first number from the left. 1t 's a 6 (the first c lump from 6/55/36). Write down 2 as a partial answer, because (2 plus wei rd) times 2 is 4, which fits 11110 6. Subtract 4 from 6 (2) and append the next two numbers (55). ow we've got 255. The new \\eird number IS the partial answer (2) times 20. which IS 40. We need a number x, where (40H)*.I tits into 255. F1ve will do, because 45•5 ts 225 and 46 · 6 1<. 276 (too big). The new partial answer is 25, the new weird number is 500. and the new target i<> 3036. The final d1git in the an.,wer 1~ 6, because 506•6 is 3036. which exactly equals 1036. 13


We need to translate that to base two. As it turns out. the formula for figuring out the weird number i'> not "times twenty," it's "times two, then shift left". Remember the dtfference? In ba\e two. we need ro multipl) by 4 10\tead of 20. No problem. Ju.,t ~hiflleft twice. What about gue1.sing which number is next? Well, there's only two choices: zero or one. So let's say the weird number is I 10100. If the answer is one, then we subtract 110101 (because of the rule to add the digit to the weird number). It works o~t very nicely in binary. Shift the panial answer twice ro the left and add one. If that fm, 1010 the number below. the next digit in the partial answer i'> I. Othern ise, it's a zero.

That's the end of this column about big six-byte numbers, but it's a good stan on another program that will do more with big numbers. We've got a few bricks now.

Listing 1: BIG I.SRC Dl 100 t11 uve"big1 .src•,a

P:> 110 ays100 IL 120 *~91S2 KO 130 opt oo fret uro-page loeit10!1 DO 140 u = $fb lit ISO tap • $fd ra 160 temp2 =$fe CG 170 counter =$ff LI 180 trrfleg • $02 Cit 190 cbrin = $ffcf PO 200 cbrout • $ffd2 LC 210 ; tbis b tbt uin loop GJ 220 uiD ld& ~~ DO 230 at• trrfhg ; llO errors (yet) GL 240 jar pug! ; pnnt . .aege 1 Ja 2SO jsr gatri.ng ; get • atri.aq frca cstt Bl 260 jar 11tkeb111 ; ukt it 1 binary nl:lllber rr 270 bes error ; tbt n1lllbtr vu too b19 CO 280 jar pug2 ; print •mgt 2 Ol 290 jsr process do something to the nUibtr Ill 300 jsr lll&ktdec uke tbe binary value into an ucii string !A 310 jsr pug3 print •ssagt 3 LD 320 j1p main loop forever NG 330 error bne realerr if not equal, 1 real error occurred BG 340 rts else, it wu a ztto entry JL 3SO realm jii pt1159 print ttror Mlltgl •too big" PI 360 jlp uin ; and go back OB 370 , generic loop for print1119 1 MUIIJ' . OP 310 &agout =• II. )90 at& II P1 400 atx u+l ; store tbt address 1(.\ 410 ldy 13 ; btq111 at tht btq11111ing II 120 asglp Ida (ra),y ; get the cbaucttr 00 130 beq msgu ent if zero eht print it Ill UO jar cbrout Cit ISO iny CK 160 bne msglp continue loop Bl 110 IUQIX Its end of ugout cc 480 puq1 • • 1L 490 ld& l<msql n soo ld& l>ugl ; tbt addrua L1 SlO )lip UljOUt ; 11plltd rts at tbt e::d OA S20 &agl uc entu 1 Clbu (c•" ~k) . ri S30 .byte 13,0 ; IDd of p~~gl

14

AG S40 pug2 • • FF S30 Ida l<:&sg2 !!!' S60 ldl l>ag2 BP S70 jlp ugout 10 sao asg2 .byte 13 ro 390 uc "calculat111g .•. CJI 600 byte 13,0 ; end of pug2 II 610 pasgl = • ND 620 ld& l<msgl PJ 630 ldx l~ql GM 64 0 jsr II!gout print, but then 0!' 6SO 1d& l<mu.buf BO 660 ldx l>llllllbuf ; print the buffer, too PG 670 jsr aqoat oc 680 ld& 113 Jl 690 )SI cbroct DJ 700 JSI cbroct a. 710 rts ra 120 asgl byte 13 BL 730 .ase "the answer is PF 140 byte 32,0 • end of puql ll 7SO peasg Ida f<ercasg JF 760 ldl l>erDRSg JL 170 :FIP msgout PO 780 trr11sg .byte!) Pr 790 .ase ••• n~r is too big ** 00 800 .byte 13 ~ 810 .asc "llill•U! is 281, 474 , 976,710,6SS. Ul 820 .byte 13,0 ; end of peug Bit 830 ; the gstrinq rootire gets a string and puts it in IIUbuf CD 810 ; ebrin sands a 13 to i.ndie~te the end, but we uke 1t a zero 1B 8SO gstring = • l!!t 860 1dy ~~ l:l 870 gatlp jsr chrin ; if 13, vt' re done PI 880 aap Ill GC 890 btq qst11 ; special case of period (Sl.IS, for example) IB 900 aap 146 KB 910 btq gstex PH 920 jsr cbknua ; better .ake sure it ' • a n~r carry aet meana not-a-number DB 930 bes gstlp KB 940 ata lllellbut,y if it is a numbtr, atore it GJ 950 iny GN 960 bne gstlp ; branch always Bit 970 gstex Ida 10 liP 980 ata ICbuf, y ; store 1 zero Cll 990 rts , store tl:e langth and 111t All 1000 cbkn\111 Clip 158 ; 51 u ucu 9 OC 1010 bet cbkex if carry set, it' t >'9", 10 uit w/carry set GI 1020 aap 148 ; 48 is aacii 0 IC 1030 bee cbkerr ; if Clrry clr, it' a euller tba.n •o• GI 1010 cle PB IOSO rta ; clear eury • ok BM 1060 chhrr see set = nok PH 1070 chkex rts ; end of gstring ~ 1080 ; makebin uku tbe ueii nWiben in rabuf ~ 1090 ; into a 6-byte (18-bit) nucber by repa&ttdly IIUltiplying by 10. LL 1100 ukebin • • FA 1110 jsr elrbig ; clear out tbe big nambtr liZ 1120 ldy 10 ; surt at the htqllllllll9 PI 1130 a&klp Ida Delbof, y get an mil clwaettr (18-57) AI 1140 beq wend if zero, end of buffer II: 1150 su tesp2 else atuh it JG 1160 )II biqzlO ; and llaltiply biga11 by 10 BJ 1110 ld& errflag OK 1180 bne abort ; if triOr, tban q'Jit ; eltt get tbe digit back sa mo ld& t • Bll 1200 sec JUke it 0-9 LB 1210 abc 148 KD 1220 ele G8 1230 ade bigsix MG 1240 eta bigsix ~ l2SO bee uk2 skip ahtad if DO Clrry EC 1260 1ne bigsix+l Jl 1210 bne uk2 else handle the bigber bytes liiC blgsix+2 Ill 1280 11 1290 bnt uk2

Transactor


£F 1300 IB 1310

...

II: El A! III II GC

J1

rr JG KC BB ID

£G IG

I8

DL DD

oc 01 101 liB IA

EB OB JB

01

RA GL PI LA B!

PB D l.O

II Gil IP

DB .;(

JK: LD Jl IF II

GK rL

DH All

FA DN IC MB LC Clt

PI IlL Jll Gil

iC CP

FA Pll Jl Jl

u 08

BL LS

u Bll II

ro

FF 8J

inc b1gsix+3 bntuk2 1320 inc bigsixt4 1330 bntuk2 1340 inc bigsix+5 1350 bne uk2 l360 1bort iny 1370 sec • 1380 rta • c:lur r flaq wl c fllq to u.rk 111 uror mo..u iny . 1400 bnt uklp • buncb dnya 1410 uteod JSI bigor •• Itt if 1t 1 zeros 1420 bne ukex 1430 ltC 1440 rts •• c:.rry set = error/exit USOukex clc 1460 rta •• clur c:ury •1111 tll i.s well 1470 cbbiq ld!t 15 1480 ldl IO 1490 clrlp sta bigsix, x •• clt1r 1ll six bytes .• count beck 1500 dtx 1510 bpl clrlp 1520 rts . rotate bigsix to tbt left (tiles 2) 1530 biqxlO jsr rotsix '. copy it to biq2 1540 jsr dupsix • 1550 jar rotsix 1560 jsr rotsix 1570 1dll6 • do all six bytes 1580 sta tup ' 1590 ldx 10 1tartinq with byte 0 1600 clc • 1610 biqxlp lda biq2, x • add 2x 1620 Ide bigaix, x •• to 8x 1630 sta bigsix, x •• which equals lOx 1640 llll •• 1650 dtetlllp 1660 bne biqxlp add &11 au bytes 1670 bee ooflow if cc. DO overflow 1680 inc urflaq tlst set error flag 1690 noflow rts return froa b1qxlO 1700 rotsix ul bigsix 1710 rot2m rol b1gsix+l rotate bi9111 Oftt bit ltft 1720 rol biqai.x+2 1730 rol biqsix+3 1740 rol b1qaixH 1750 rol bigsix+S 1760 bee ok ••• if CC, DO Oftrflow 1770 inc trrflaq nt error flaq I 1780 ok rts .• copy biqaix to biq2 1790 dupsix ldx 15 1800 dup1p lda bigsix, x 1810 ata biq2,x 1820 dtx 1830 bpi duplp 1840 rts 1850 biqor Ida bigsix+O 1860 ora biqaix+l 1870 ora bigsix+2 1880 ora biqsil+3 1890 ora biqail+4 1900 ora biqaix+5 • end of uktbin 1910 rts 1920 ; ukedec turns the binary valat into 1930 ; 1 aeries of ascii aUibtra ia lllbuf 1940 uktdtc =• 19SO lda IO 1960 • atart ntb 0, vbicb M111S •w • phi 1970 .Up1 ldx 148 1HO rtx COWlttr 48 bita mo ldl 10 2DDO rta llllf 2010 .Up2 jar rotaix ••• qet I bit 2020 rol tll!f • wl 10ft 1t into tap 2030 ldl t.., 2040 cap 110 if t.., < 10 2050 bee .clcool it' a enol. doc' t worry 2060 abc 110 tlst aubtnct 10 (wry is alrudy set)

Volume 9, Issue 5

DP 2070 stl temp LI 2080 .:!cool php B.P 2090 IP

JA BJ pp Jll

KE EJ

FP

PB

on Jl EJ lA !A

JL DC LP £F

IB DH I! FD

OP

IF PM AB

OP M3

PC Ul

Pl II IP Ja)

DE

cc II LB GA

Ol Jl BI

. atort 1t (c1rry i1 still Itt)

'

lsr biqsix plp rol biqsu dec cOWlttr bnt lldlp2 ldl tap Oil 148 pill JSI biqor bee .Up! ldy 10 ph sh MZ!buf,y btqax

2100 2110 put tbt bit beck into biqs1x 2120 2130 2140 • 2150 • ukt it neil . 2160 • wl push it 2170 u it zero yet . 2180 • oo, 1t isn ' t . go beck. 2190 . 2200 lldlp3 • qat 1 cblr1ctez 2210 2220 if 0, vt' n doct 2230 else incre.ent y lilY 2240 bnt .Up) •. .nd br.ncb dv1y1 2250 dx rts • end of ukedtc 2260 ; process prints tht la llld Oa of tbt bin~ry oUIIbtr 2270 process ldl l<binmaq 2280 ldx l>biiW9 2290 jar uqout 2300 ldy 15 six bytes 2310 proclpl ldx IB tight bill 2320 stx counter 2330 1dl biqsix, y 2340 atl tu;p 2350 proclp2 lda 148 ascii uro 2360 rol tup . 2370 bee send.it • if zero, print •o• 2380 ade 10 eln add 0 (p1as nt c:ury) 2390 stndit jsr throat 2400 dec counter 2410 hnt proc1p2 2420 lda 113 . 2430 )II cbrout • out lint 2440 dey . eoat1n~ octtr loop 2450 bpl proclp1 ' 2460 rta 2470 bilasg asc "binary (hiq!l byte to low): 2483 byte 13 0 •• end of proceu 2490 biqsix = $c400 : tb• biq 48-bit (6-bytt) nUiber 2500 biq2 : .notbtr big 11111btr = $c406 2S10 ..abcf = $c40c : _,ry buffer

Listing 2: B!G2.SRC - To create this program. use lines 1002250 of BIGJ .SRC and add the following lines for the new PROCESS rowine. JD 2260 ; process fiodl the square root . B.P 2270 biq4 .byte 0, 0,0, 0,0,0 IP 2280 big3 .byte 0, 0,0, 0, 0, 0

AO 2290 process : • AE 2300

ldx 15 CL 2310 proc1p1 lda bigsix, x LA 2320 sta big4,x FA 2330 1dl IO LB 2340 sta biq3,x FO 2350 dtx II 2360 bpl proc1p1 DO 2370 jsr clrbig Ill 2380 ldl 124 I8 2390 sta COWlttr oc 2400 puiD = • IE 2410 )II dupsu Ja) 2420 clc AP 2430 Jar rot2 J1 2440 sec DD 2450 )II rot2 liB 2460 jsr rot43 II 2470 )It c:o;p32 liP 2480 pbp JG 2490 rol biqsix BC 2500 31r rot2aix CJ 2510 plp

•• first copy bigsix to big4 and cle1r blg3

•• cltu oat biqsu for tb.

IDSvtr

. • repeat tbt loop 24 tt.s (for 48 b1ts) •• uin loop for process

•• copy bigsix to blq2 •• rotate b1q2

. • rotate aga111 plus 1

rotate big4 111to big3 tv1ce tollplrt big3 to biq2 • lift tbt proceuor statu '

. •

. • pat the bit into b1qaix 15


• 110~

CB 2520

bee

JC 2530

lclx IO ldy" ldl big3, x she b1g2, x ata blg3,x

AJ

Gl. 111 SA AP JJ IL

SJ Nli

CD II BL

Ll Q

u I)

!0

c:

Ill

OP IB B! N!

01 BJ LD Ill BJ

IG EC CB

u

li],

llO Ill

PL

u

DC

08

2540

mo Jalp

if ca.rcy u clur, cootintt

0 0

tlse sUbtract 3°2

2560 2570 2580 iAl 2590 dey 2600 hnt palp 2610 noaub dec coUJlter 2620 bnt puin 2630 rta 2640 ; rot2 rotates big2 to tbe left 2650 rot2 ldx 10 2660 ldy 16 2670 r21p rol b1q2,x 2680 iAl 2690 l!ey 2100 !me r2lp 2110 rta 2;20 ; rot43 rotates two bits fr01 blg4 into b1ql 2730 roW Jsr tnce ; do 1t twice 2140 twict lc!x IO mo ldy 112 2160rlllp rol bigC,x 2110 inx 2780 dey 2790 hnt r43lp rta 2800 2810 ; ca.p32 ca~p&Ies big3 to big2 2820 ca.p32 ldx 15 caapa.rt ub' a fuat 2130 c32lp ldl b1g3,x 2840 Clip b1q2,x 2850 bee c32ex • if cc. big2>1llg3 2860 bctt c32tx • if cot tcpal, b1gl>b192 2810 du else they rt equal, so go back 2810 bpl c321p 2890 c32tx rtl 2900 b1gaix =$c400 tb* big 48obit (6obytt) number ' . 2910 big2 = $c406 • another b19 number 2920 11mbuf • $c40c • met:10ry bufftr

Li~ting

0

0

0

3: BIG I.GEN ° BASIC generator for "hi!( I .ohj"

100 r• gtnerator for ' bigl obj' D 110 n$='b1ql.ob)' . rta caa of proqru BC 120 Ddz568 : sa=491S2: cb=60233 JP

LA 1210 d&tl 53, 46, 13 0, 160 0, 32, 201 JF 1280 d&ta 255, 201, 13 240, lS 201, 46, 240 Il 1290 d&ta 11, 32, 250 192, 176, 240, 153. 12 Gt 1300 dlta 196, 200, 208 234, 169 o, m 12 JF 1310 dltl 196, 96, 201, 58, 116, 1, 201, 41 KI 1320 dltl 144, 2, 24, 96, 56, 96, 32, 79 L! 1330 data 193, 160, 0, 185, 12, 196, 240, 54 BF 1340 data 133. 254, 32, 90, 193, 165, 2, 208 NJ 1350 data 39, 165, 254, 56, 233, 48, 24, 109 CG 1360 data 0, 196, lU, 0, 196, 144, 28, 238 GG 1370 data 1, 196, 208, 23, 238, 2, 196, 208 CL 1380 data 18, 238, 3, 196, 208, 13, 238, 4 IL 1390 data 196, 208, 8, 238, 5, 196, 208, 3 CP 1400 dlta 200, 56, 96, 200, 208, 197, 32, 163 Gil 1410 data 193, 208, 2 56, 96, 24, 96, 162 SA 1420 dltl 5, 169, 0, 151, 0, 196, 202, u PB 1430 dlta 250 96, 32 12s, m, 12, m, 193 PO 1CCOdlta 32 128, 193, 32, 128, 193, 169 6 0, 24 189, 6, 196 It!. 1C50 dlta 133, 253, 162 PO 1460 data m, 0, 196 157, 0 196, 232, 198 Jl 1470 dlta 253, 208, 2C2, 1C4, 2 230, 2, 96 AL 1480 dlta 14, 0, 196, 46, 1, 196, 46, 2 3, 196, OJ 1490 dlta 196, ' · 196, ME 1500 data 5, 196, 144 2, 230, 2, 96, 162 JC 1510 data 5, 189, 0, 196, 157, 6, 196, 202 0, 196, 13, 1 LL 1520 data 16, 2C7, 96, 113, JI 1530 data 196, 13, 2, 196, 13, 3, 196, 13 llG 1540 data 4, 196, 13, s, 196, 96, 169, 0 FE 1550 dlta 72, 162, 48, 134, 255, 169, 0, 133 NG 1560 dlta 253 32, 128 193, 38, 253, 165, 253 4, 233, 10, 133, 253 EC 1510 dlta 201, 10, 144 PI mo dlta 8, 78, 0 196, 40, 46, 0, 196 LP 1590 dlta 198, 255, 208 229, 165 253, 9, 41 LC 1600 d&ta 12, 32, 163 193, 2C8, 211, 160, 0 3, 200, 208 Dli 1610 data 104, 153, 12 196, 240 Cli 1620 data 241 96 AJ 1630 rea following data 1s for proceas1 °1640 rea o• prieta input nUiber in binary -IG 1650 data 169, 28, 162, 194, 32, 39 CM 1660 data 192, 160, 5, 162, 8, 134, 255, 185 PJ 1670 data 0, 196, 133, 253, 169, 48, 38, 253 OJ 1680 data 144, 2, 105, 0, 32, 210, 255, 198 Ott 1690 data 255, 208, 241, 169, 13 32, 210, m Ill) 1100 data 136. 16, 224 96, 66, 13, 78 65 Jl 1110 data 82, 89, 32 40, 12 13, 11, 72 Sl) mo data 32, 66, 89 84, 69 32, 84 ' 19 g mo data 32 16 79 87, u 51, 13, 0

"·

"·

"

00

*

(for lillts 130°260 see tU standard qe:~erator oo page 5)

Listing 4: 8/G:Z.Gl: IV BASIC rJ,eneratnrfnr "h1g2.nhj"

17 1000 data 169, 0 133, 2, 32, AO 1010 data 220, 192 32, 6, 193, Ill 1020 data 92, 192 32, 242, 193, rr 1030 data 32, 116, 192, 16, o, PB 1040 d&ta 96, 32, 155, 192, 76, cc 1050 data 251, 134, 252, 160, 0, NC 1060 data 6, 32, 210, 255, 200, Cl 1070 data 169, 63, 162, 192, 76, IL 1C80 data 78, 84 69, 82, 32, 8L 1090 data 85, 11 66, 69 82, 00 1!00 data 79, 11 11, 65, 83, Cl mo dlta n, 46, 11, o. 169, Bl 1120 data 76, 39, 192, 13, 61, 00 1130 data 85, 76, 65, U o 73, &X 1140 data 46, 46 13, 0, 169, JJ mo data 12, 39 192, 169. 12, II 1160 data 39, 192, 169, 13, 32, DA 1110 d&ta 210, 255, 96, 13, 84, IIC 1180 data 65, 78, 83, 87, 69, 10 1190 data 83, 32, 0, 169, 162, GB 1200 data 39, 192, 13, 42, 42, rc 1210 data 11, 66, 69, 82, 32, CD 1220 data 84, 79, 79, 32, 66, G) 1230 data 42, 42 13, 77, 65, SD 1240 data IS, 11, 32, 73, 83, KD 1250 data 49 44, 52, 55 52, ~ 1260 data 54 44 55, 49 41,

MP 100 r11 gtcerator for big2.abj' II 110 n$='b1g2 .ab)' rea na:~~~ of proqru £C 120 nd=625: saz491S2: cb=68145

16

56, 116, 32, 192, 0, 177, 208, 39, 65, 32, 32, 99, 65, 78, 139, 162 210, 72, 82, 162, 32, 73, 73, 88, 32, 44 44

192, 15, 182, 208, 192, 251, 246, 192, 32, 40, 79, 162, 76, 11, 162, 196, 255, 69, 32, 192, 78, 83, 11, 13, SO, 57, 54,

32 32 193 1 133 240 96 69 78 67 75 192 67 46 192 12 32 32 73 76 85 32 32 11 56 55 53

0

(for lints 130·260, sat the standard generator on pagt 5) (use lines 1000ol620 of 'big1.qen', change tht 242 1n line 1020 to 254 and add the following lines) OK Ill IB OG Jl £1 I()

IK PG II BA

IO OJ CC DO FP kB Jl lJ

1630 res -- following data for prccess2 1640 r• o• hncls squa.re root of ou.btr 1650 data 0, 0, 0 0, 0, 0 1660 data 0, 0, 0 0, 0, 0 1670 data 119, o. 196, 157, 242, 193, 1680 data 157. 241, 193 202, 16, 242, 1690 d&ta 193, 169, 24 133, m. 32, 1700 data 24 , 32, 70, 194, 56, 32, 1710 data 32, 82, 194, 32, 97, 194, 1720 data 0, 196, 32, 131, 193, 40, 1730 data 162, 0, 160, 6, 189, 248, 1740 data 6, 196, 157, 248, 193, 232, 1750 data 243, 198, 255, 208, 208, 96, 1160 data 160, 6, 62, 6, 196, 232, 1770 data 249, 96, 32, 85, 194, 162, 1780 data 12 62, 242, 193, 232, 136, 1790 data 96, 162, 5, 189, 248, 193, 1800 d&ta 196, 144, 5, 208, 3 202, 1810 data "

--162, 169 32, 151, 70, 8, 144, 193, 136, 162, 136, 0, 208, 221 16,

5 0 79 193 194 46 17 253 208 0 208 160 249 6 243

f

Transactor


Transactor Reader Survey Here 11 i~! Tr.m.,actor\ fi~t reader ~urve). We want to know what you like and don't like about Transactor. We want to know what !>oftware and hardware you're u ing. And y.e'd tile to l..now what you want to see in the maguine tn the future. No~ey. aren't we? Please take the time tO do the <,urvey and 1oend ~the results. Make a photocopy. (We wouldn't want you to tear up the magazine). Please send your completed survey page to: Reader Survey, Transaclor, 85 West Wilmot t., Unit 10, Richmond Hill, Ontario, Canada, L48 1K7. System conljguration and <;ofh,are used:

Columns

Features

Love it!

Like it.

The ML Column The Edge Connection

0 0

0

u

....)

0

Bits Leuers News Reviews

0 0

0

0 0 Love it!

Don' t like. Hate it!

0 0

a _J

...J

Like it.

0 Don't like. Hate it!

Article Topics C64 Native Mode C 128 Native Mode Power C CP/M GEOS Re fe rence Material Hardware Projects Software Reviews Hardware Rev iews Theoretical Material

0

w

a

a

0

0

0

0

a 0

a 0 0 CJ 0

u

a a a

a

a

0

..J 0

Cl 0

0

..J 0

a 0 0 0

0 0

Comments or suggestions:

Volume 9,1ssue 5

17


The Edge Connection GEOS 128 2.0, ZOOM, macros, radio, etc . • by J oel Rubin The mo<.t important recent 8-bit Commodore software news is the release of GEOS 2.0 for the C 128. Like GEOS 2.0 for the C64. it include~ a new version of geoWrite Workshop (including Text Grabher. geoMerge. and geoLaser), geoSpe/1 (but not the font editor which came with the separately packaged geoSpe/1 and i~ now pan of Fontpack Plus). a new deskTop (with a built-in clock for midnight had,er~. and. more important, the ability to select more than one file for copying or erasing). ct alia. The new versions of geoWme and geoSpe/1 only work in 80-column mode. In a\\ I\1P (Wmdows Icons Mouse Pointer) o;y<;tem such as GEOS, as you become an e). pen, you may Man wi~hing for cryptic control code~ or a command line interface. TheM! may be 'user unfriendly' but at le~t they get the job done without going through menu ufler menu. Both the OEOS deskTop and OEOS applications arc gradually moving towards control code alternatives, with each version of OEOS having more and more of them. I st1ll thinJ... I would generally prefer to use Paperclip or a similar character-based po t-formatted word processor to enter text and then u'>e Te.\t Grabber to conven to geo~'t-rite. if I'm not ..ati'>fied with an ASCU/control-code printout. But (especially with the 2 Mllz clock) geoWrite i~ becoming less of a pain in the neck as a text editor. Still, there are times when 1 want to move a margin and get a tab marker instead, or when I want to enter texr and accidentally move the mouse and find things scrolling ever so slowly the other v. ay. At those times. r think that the best game to pia> with a mouse is that canine favouritt:. ''Shake It To Death". There are quite a few new printer drive~. including some that work v. ith a user pon to Centronics cable (~uch as the one de'-Cribed in Transactor Volume 9, l%ue 3), some double and quadruple stnke drivers. a few dri\'ers that reduce the size of the page and offer greater dot density, and even a very few driver~ that will work with RS-232 interfaces and a PAL clock ~peed. (Question: How do the Commodore computers work in Fmnce, where they have neither the 1\ ISC nor PAL colour standartb but SLCA."l?) Unfortunately. this neY. version of GEOS does not take advan-

18

all 80-column work ~ going to be in mono. Al!.o, a1. usual, geoWrtte only 1.uppons an 8" (20 em) wide page, so if you want 10 u~e something wider, you are out of luck. The other immediately obvious deficiency is the manual (which doesn't really exist - you get a copy of the 64 version manual and a booklet that goes through the 128 differences, chapter by chuptcr). I always thought that one of the advantages of using a computer for word proce~sing was that it would be easier to edit one·~ document and come out with a neY. edition.

l.O

By the way, although Geoprogrammer 2.0 IS listed as an application one might own, I was told by customer service that this product has been cancelled. Since the current version of Geo programmer and. in parucular, G('oDehugger only work under C64 G!::OS, this leaves quite a gap. Readers might want to express their opinions. Leave them on Q-Link, or write them to Berkeley Softworks, 2150 ShattucJ... Avenue, Berkeley, CA 94704. Germa n viruses invade Michigan! Now that we've gonen through '' ith the supermarJ...et tabloidtype headline, I can tell you that th1s 1\ about a Data Becker book newly translated into Engli~h and releru.ed by Abacus Computer I iruses. A High Tech Di.\ease. On a scale of I to 10, I would give this book an 8 or 9. My major complaint would be that it could use a good bibliography. It deals calmly and rationally with the subject, unlike so much of the popular press. Technical points are illustrated with programs in various languages. including OW-BASIC, Turbo Pa. cal. IB\1 VMJCMS command language (the infarnou' "Chri'>tma-. virus"). and MS-DOS and IBM mainframe assembly language. The Arpanet virus happened too late to be covered. (Just in case you think that Commodore 8-bit machines are immune from viruses, there is a short listing of CP/M+ BOOS calls; although ca•.os. which creates swap files, is far more vulnerable. Always keep a write-protect on original GEOS and GEOS application di~ks, unless you need to write on them - for example, to in\tall the default printer driver. Some verl>ions of GEOS will. 111 an anti-piracy trap, erase boot files if they 'think' you are using a cop), and the test might be ~n~itive to drive alignment.) Transactor


Thi IS not JUSt a teehnical hackmg book. lbere are mten iews with :.ecurity professionall>, ~uch as a Bavarian police detective and the head of an imurance company. (By tJ1e way. tJ1ose who are fighting for the good name of "hacker" will be glad to note that the word is used in this book as a synonym for "technicallyoriented computer user, whether law-abiding or not".) Of cour;e, the legal references m this bool.. are largely irrelevant to most reader~ of thl'> magazine - not only are the specific law~ different, but German law derives largely from Roman law and the Code Napoleon, whereas most of you live under some version of English Common Law. (Frankly. I think that it is a mistake "> make too many specific law~ when the old laws, such as "Malicious Mischief", still have teeth. When the legislators pass a lot of situation-specific law~. the codes get cluttered wnh laws, many of them technologically obsolete, and it become~ difficult for the average citizen to determine his or her rights and responsibilities.) A commercial disk-loaded monitor for the C64 and C128

Loo 11 is a machine language monitor for the Cf>.t. C 128. and the BBC computer. (Has anyone outside Britain ever <oeen a BBC computer? I've seen booh about programming them but that's it. It was a 6502-based computer put out by Acom.fAcorn computers ha1•e been Ql•ailable here in Toronto. - Ed.] It had a very nice structured BASIC that included a built-in assembler, but that's about all l know about it.) Like most monito~ available for Commodore compute~. it b based on tlle monitor built into all but the earliest PET/CB!'-1 computers and the e>.tensions written for it, such as Superman, £.nramon and M1cromon. The mol>! important feature which this monitor has which is not in me built-in C 128 monitor is the ability to walk (single step) code at tllree different t>peeds and to quick trace code (run code until you've pal.scd a certain point n times and after that wall.. the code). One can abo set up non-standard banks, such as S3E (BA.'lK o wim 1/0), check memory for illegal opcodes, and enter values 1nto memory as PETSCn values instead of hex. There is a built-in hex calculator and a wedge; I can't figure out how to make ZOOM's wedge work for device 9. Let's say you are looking through memory for text, but you are not certain whether it's PETSCII, ASCU. or screen code!.. ZOOM allow!. you defme a seriel> of mask byte!. 1.0 that you are looking for an area of memory where byte-1 and mask- 1 = huntpauem-1, byte-2 and mask 2 hunt-pattem-2, et alia. ZOOM, like Enramon, has a relocation facility so that you can change absolute addresses and/or tables of words to a different location. Of course, this doesn't always work. Relocation routines generally will not work if you have the folJowing sort of code:

=

ld& 1 <$8000

ata $61 ld& 1>$8000

sta $61+1 ldy t o 1da ($6l),y

Volume 9, Issue 5

since the relocation routine will not find me actual absolute address $8000 anywhere. Ho-wever, zoo~·s relocauon routines do worl.. on ZOOM itself. The C64 version loads at $COOOO. but you should be able to set it up to work at the top or bottom of BASIC. (I didn't get tile C64 version. C64 users should note that there are several cheap or free alternative~. including Micromon, from public domain sources. and HESMON, avrulable on cartridge from software liquidato~.) The Cl28 version loads at $8000 and takes 6K of memory. It can be relocated to anywhere up to or below $A800-$BFFF. (It works either in memory configuration SOE or $4E- BA~K 0 or BANK 1 RAM, BASIC switched out, KERNAL ROMS switched in. and 1/0 switched in. The very Ill in ( 16 pages for all three versions!) manual states that ZOOM can be relocated but it does not state where; or mat it will work in either RAM bank. It uses a bit of interface code in common RAM around S0290.) So far, 7.00\.1 is the only single-step and/or quick trace routine I have been able to find for Cl28 mode. Abacus' BASIC 7.0 lntemals book mentions that a certain author has wriuen another one, and I have sent him two SASE's but have received no response in at least a year. One other advantage mat Z00.\1 has over the buill-in Ct28 monitor IS that it uses four hex digit addresses and displays the configuration register rather than five hex digit addresses. If you hit a BRK in a machine language program and get into tlle standard Cl28 monitor. the bank given as part of the register dil>pla) may or may not have anything to do with reality e!.pecially if you are playing -with BASIC ROM routmes and get dumped into one of those non-standard bartks wim which BASIC 7.0 is so enamoured. ZOOM i~

marketed by Supersoft in the U.K. and the Commodore versions are imported by Skyles Electric Works (231-E S. Whisman Rd., Mountain Viev., CA. 94041. telephone (800) 227-9998/(415) 965-1735) in the U.S. Assembly language macros

Xytec 's Macro Set I ( 1924 Divisidero St., San Francisco, CA, 94 115, (415) 563-0660) is a disk of assembly language macros for u~e with Commodore's C64 Assembler (available cheap from software liquidators) or Merlin. While the Merlin macro~. at least. work with the C 128 version of Merlm, the object code generated may not work in C 128 mode. For example, in C 128 mode, before you open a file, you have to call SETBNK to tell the Kemal whether the name of the file is in BANKo or BANK t. Generally, BASIC uses BANK t, but most machine language programs use BANK o. so you can't just assume the de· fault IS correct. The macros are generally onented to bu!.mess. rather than graphics or games software. Among other things, there IS a code for a sort of 16-bit virtual machine. somewhat similar to the machine defined by Steve Wozniak's Sweet-16. almough Sweer-16 is an interpreted language. There is BCD multibytc arimmetic, and output numeric formaning, professional-lool..lllg ke}board 19


input and Kemnl culls. There is ~ome useful &tuff in here if you have no trouble u~ing di~k file~ from BASIC but have trouble with the machine language calb for opening the fLies and checking the error channel, or if you want to read delimited variablelength records, similar to Il\Pun in BASIC. One other useful bit of code allows you to create a self-debugging version of your program that "'ill, at specified point'>. dump the registers or an area of memOT). await a l.ey pre~s. and then restore rhe text screen and register<, and continue. Thi~ disk costs $29.95 (U.S.). Xytec, \eT) much a 'gamge-type' operation. also sells a few other program~. including a tree-oriented data base (intended. in pan, for generating a disk-based user manual). a roommate accounting program, and a lotto number choosing program, which is, essentially, just a somewhat entertaining random number generator. (Xytec's louo program does not "help you win the lotto by analy1ing previou~ lotto drawings". but then. no statistician believes that this b mathematically possible. The socalled ''law of averages" docs not apply to independent events, such as the tossing of a coin or the drawing of lotto numbers. It does apply to Blackjack, since if the drown card is not put back in the deck, lhe odds of getting cards with the same value is decreased.) Xytec\ catalog IS free; their demo disk is S2, applicable to an order. Currently, Xytec b willing to send you a disk now and ask you for the money, or the returned disk, later. The dish are not copy-protected. Is this trust justified? We shall see. Mail order IegaJ problems in the U-S. The mail order industry m the U.S. 1s screaming about a bill in Congress. Some states have "use tax" laws that require you to pay sales tax when makmg purcha<;es tn another state to use in the taxing tate. If you buy a car in another state, your state's vehicle licensing authority may have no trouble collecting the difference, if any, between the tax you patd and the tax in your home district when you go to register the car. In most cases. mail order firms do not collect taxe~ on out-of-state purchases. leaving the customer, who may not even know of the requirement, to obtain an obscure form and pay the tax. The state tax collectors have asked Congress to force mail order firms to collect all customers' sales tax. This will raise mail order firm's expen~es. What the mail order firms can't say is that it will also discourage intcn.tate cu.stomers who have been trying to evade their ta.\. If a one-pen.on garage operation has to keep track of all the state taxes which frequently differ in different localines in the same state (I pay a 1/2 per-cent transit district surcharge on my '>tate sales ta:>..) - it may just drive that operation out of busines-.. If you hve m the U.S. and buy or sell mail order and have any opmion. pro or con. you might wish to contact your repre!>entative and senaton.. Computers and radio If you're interested m usmg a computer for shonwave listening or amateur rad10, you might be interested in the free pamphlet, INFODIJTCH, ava1lable from Radio "lctherland's hobbyist show, Media Netwnrk. The address IS Postbus 222, 1200 JG Hilversum,

20

The Netherlands. Among the reference!> given in the guide is one for the Commodore Radio Users Group, 22 Whiteford Avenue, BeUsmyre, Dumbanon G82 2JT. U.K .• telephone 44 389 61250. In the U.K. their magcuine co~L'> £8 per year. If you write for information from overseas, send them return postage - say two International Reply Coupon<,, or British mmt stamps. Fmally. here are a couple of qu1ck tip!>. Let's say you want to pol-e to the C64 text screen m mterpreted BASIC. You can a' oid the extra o,tcp of poking to colour memory if you clear the screen using: poke 53281,1 :print chr (5)cbr$(147);:poke 53281,~ where ' i-. either 0 or 2-15. Text will be in v.hite. Exactly how this works depend!> on which model C64 you have. On the oldest (Kemal I) machines, printing chr$( 147) ("clr") always clears colour memory to white. On middle-aged (Kernal 2) machines. chr$( 147) clears colour memory to the background colour (pcek(53281 )). Thus, by poking I into the background before we clear the screen, we will get white colour memory. Many old public domain programs and even a few commercial programs cause invisible (background-coloured) pokes on Kemal 2 machines. Kernal 3 machines, which includes newer 64s, all 64Cs, and the 64 mode of 128<;. clear colour memory to the current text colour, which 1 set to wh1te by chr$(5). The SX-64 uses a version of the Kemal 3 ROM. although it has certain differences - for example. the default colours are blue on white instead of light blue on blue. and trying to access the cassette unit gives an illegal device error. There is one more ofhc•al orth American Kemal - the Educator model. Th1s computer looks hke a PET. with a metal case and built-in green-screen monitor. and it was sold by some liquidator~. I haven't the foggiest idea what differences it has from other models except that Commodore(rcrrapin LOGO looks for an identifier byte and gives you a special sign-on message if it is found. I don't have access to the European models but, since the Nonh American Kcmals contain PAL RS-232 code, and the European disassembly books seem to have the same code, I assume that this will work on overseas C64s also. The second hint comes from Joe Dawson. President of Xytec Software. One easy method of setting up a text screen which appears to have different bacl.ground colours in different areas is simply to usc reverse characters throughout. For example, you could have a black background, a blue border, and two boxes filled \\ith text. Everywhere outs1de the boxes is filled with reverse blue spaces. v.hich appean. to make the border extend around the boxes. The first box b filled w1th white reversed space~ and text wh1ch appears to be black text on a white background. The other bo>. is filled with red te\'ersed spaces and text which appe~ to be black text on a red background. No raster interrupt'> or multi-colour text or high resolution screens arc required. Moreover, this method will work just as eas1ly on the 80-column screen of a C 128 without BASIC 8 or (HK of video RAM. 1:. Transactor


Inner GEOS A look at how GEOS operates by William Coleman •

Although GEOS allows you to quiciJy write programs that would takes weeks or months to write on a normal CM/128. few people actually program with it. Part of the problem is that most people don't understruJd how GF.OS works. While the inner workings of GEOS are not hard to understillld, they do function quite differently from what most 64/128 programmers are used to.

In this anicle, you will learn how GEOS functions and how its various levels interact with M application. Once you understand this interaction creating and debugging GEOS applications becomes much, much easier. A ¡normal' 64 or 128 program does most of the work itself and uses Kemal subroutme~ for things like disk 110. printing characters, etc. GEOS is vel) different. Basically, it is compo ed of three leveb: Interrupt Level The Main Loop Application Rourines The first two levels are the GEOS Kemal itself and they must be allowed to execute periodically or GEOS will seem to freeze. In fact, if you are testing an application and everythtng seems to stop (mouse won't move. keyboard won't respond, etc.) you CM be 90 per cent certain that your application went into an endless loop and is not lcrting GEOS do it's job. Interrupt Level reads the keyboard and checks for numerous other conditions that require frequent. periodic inspection. It won't act on what it finds; there isn't enough time. So flags are set to indicate when the various conditions are met. The Main Loop then checks these flags and acts on them accordingly. GEOS is an example of Event Driven code. The Main Loop is

simply a <;eries of subroutine calls that operate in an endless loop. These subrouunes ched. 1f certain events have occurred and if so execute Service Routmes that the application has set up to handle tho e situation<,.

icons. For example: when the user presses the mouse bunon, GEOS will ched. to sec if the mouse is over a menu option or M icon. If one of these conditions ('events') is met, the Main Loop will call the service routine associated with that option/icon (defined in a menu or icon table). The next type of service routine is called through the System Vectors. These are word length memory locations that contain the address of a service routine to execute when the condition associated with that vector occurs. If a vector contains $0000 then it will be ignored completely. ln the above example, if the mouse is not over a menu or an icon, the Main Loop will check orherPress\'ector. If it is non-7ero, the routine whose addre s is m the vector will be executed. The third way to act on an event 1s through timers. These come in t\\-0 flavon.: Sleep and Processes. Sleep Sleep is a method of stopping the execution of a subroutine for a predetermined amount of lime while continuing to execute the rest of the application. Remember, the Mam Loop must have control periodically or GEOS w1ll stop. Sleep provides a way to pause while still performing routine tasks. The most noticable example is one that you see every time you use GEOS: icon and menu flashes. When a user clicks on a menu option, the Menu Handler will invert the option. put it~elf to sleep, and when it awakens, simply invert the option a second time. Sleep works through a table of timers, one for each sleeping subroutine. lnterrupt Level will decrement each timer every interrupt. The Main Loop checks these timers; and, if any have reached zero, the associated routine will be executed. When Sleep is called, the rerum address is pulled off the stack. This address is "'here execution w11l continue from.

Proces es Senice routines There are basicall) three type'> of service routines. First, there are the routines that the application attaches to menus and Volume 9, Issue 5

GEOS has a form of multitast...ing called processes. A process is a subroutine that an application can set up that will be execut-

ed at regular intervals. The application passes the amount of 21


time that should elap&e between calls to the process. GEOS maintnins timers for each process. just as it does for Sleep. One point you must keep in mind: while the timers are updated during Interrupt Level. the execution of a process is done during "!am Loop. This mean'> that the time the Main Loop takes to go through one complete iteration can vary signifigantJy depending on how many sleep and process routines need to execute and how long each one takes. l;imer values less then about ten ( 1/6 of a second) will not be very accurate. GEOS has no way to stack a process. If a process comes due before the QreVIOUS Call IS done (i.e. a process times Out rwice before being executed), it w1ll only be executed a single time. OK, now that we ~now what events are and bow they are used, let's take a look at the processing levels themselves. Interrupt Level Normally, a timer in one of the CtA chips generates interrupts that are used to read the keyboard, etc. GEOS is a bit different: sixty times per second a raster IRQ is generated by the VIC chip. This tRQ is set up to hit during vertical blanking so drawing to the screen will not produce flicker.

The Figures that are included with this article are not byte by byte disassemblies (which change with time). They are presented only to give you an idea of what's going on ...

on it). One of the biggest mistakes beginning GEOS programmers ma~e is that they don't let the Main Loop have control. An application is really little more then a group of service routines. They arc called by the Main Loop and when they are finished they must RTS back to it. Since the Main Loop controls the positioning of the mouse and managing keyboard input. the quickest way to kill an application is to prevent the Main Loop from executing (you may have noticed that I have been stressing this).

GEOS does considerably more during an interrupt then a regular 64 or 128; therefore, it doesn't have time to act on things hke mouse presses and processes. That is the job of the Main Loop. The advantage of u ing mterrupts to set flags and manage the timer.. i~ that the Main Loop is not constant. Interrupts provide a mean~ to constantly monitor the system regardless of what ebe is going on.

It is e>.tremely rare indeed that )OU will need to add code to the Main Loop (use a process); but, if you must. a vector has thoughtfully been provided. called appltcationMain. This vector is normally 0000 so it ~on 't do anythmg. If you wedge a routine into it be sure to end 11 ~ith an RT!>.

Normally an application will not need to modify the interrupts but if the need arises there are two vectors provided for adding your own interrupt code. One, imtopVector, occurs before the bulk of the intem1pt has occurred. The other. intBotVector. occurs at the end of the cycle.

Writing most GEOS applications can be done in a series of simple steps:

Several things should be code:

~ept

Putting it all together

• Build the menu tables. Don't worry about al l the service routines at rirst. You can point all unimplemented entries at a JMP GotoFir.ltMenu.

in mind when writing interrupt

• Don't try to do too much during interrupts. The GEOS interrupt is already quite long and you will bog down the application. • Don't clear interrupts. i.e. CLI. • Don't use GEOS routines if you can help it. Some will work during interrupts and some won't. Col/Routine and DolnlineReturn will work OK.

• Design icons and icon can point to a RTS.

table~.

Unimplmcnted icon routines

• Code the proces<> routines if any are needed. • Decide which vectors the application will need to use and code the routine~ nece<,sary. • Write a ColdStan routine which will initialiL.e the screen, draw an> iconl>, start any proces!>es. etc. This routine should end with a RTS. From that pomt on the Main Loop will control the application.

The '\llain Loop This b where mo~t of the nitty gritty part~ of GEOS occur. Menus, processes, and the mouse are all managed from here (remember: interrupb read the status. the Main Loop acts

22

Figures I and 2 list the p.,eudo-code for the Interrupt and the Main Loop respectively. Studymg the~e ~hould provide you with an excellent foundauon for writing your own GEOS applicatioM. ~ Transactor


Figure 1 -lmerrupt Lel'el Pseudo-code ; interrupt ' s work and must be called or ; things will freeze up .

.

Interrupt Level

'

InterruptMain ; Firat the state ot the machine is saved. This ; includes A, X, Y, and S plus r0- rl5 and the

; meaory confiquration

. i t Geos6• ; Gaos 64 services the mouse here jar

.

jar

SavaStata

. andi.t

• ; Now the I/O area is switched ; in . Geos 128 will also ensure that • ; bank 1 is the active bank .

'

jar

MousaSarvica

•• jar

OpdateProcassas

; update process ; timers

IOin

jar

OpdateSlaaps

; update sleep timers

jar

OpdatePrompt

j ar

ServicaRandom

; flash text prompt ; get a new random ; number

'

; Now dblClickCount is decremented . This

rta

; variable is used to tall if the user clicks , the mouse twice in rapid succession

;

Figure 2 - Main Loop Pseudo-code jar

DblCli c k

•• it Gaosl28

HainLoop:

, Gaoa 128 services the mouse hera jar

MouseSarvica

;

tirst we check the keyboard and load

; kayData . Also check i t

. andif

, inputVactor, mouaeVactor, keyvector , or

'

, mousaFaultVactor should be called . Indirectly

, Now scan the keyboard and if a key is

; manu, icon, or otherPressVactor

; tound place it in the keyboard qua .

; will be called .

, Geos 128 w~l handle soft (80-col) , sprites here .

.

jar

~yboard

jar

Alarm

.

.

' ; service alarm tone timer

.

jar

KeyboardSarvica

, Normally intTopVac tor points

' ; now we check if any processes or

; to interruptMain . It you wedge

; sleeping routines should be

, a routine in hera the routine ; must end with jmp IntarruptMain .

.

. ' . '

'

l<intTopVector

.

l>intTopVactor CallRoutina

executed. j ar

ProcassSarvice

jar

SleepService

• ;execute interruptMain

; next update the time and alarm

; variables . If it is time for the

; Normally intBotVector is empty , i a . $0000 .

; alarm to sound call alarmTmtVector

; A routine wedged in hare should and with rts

'

.

••

.

jar lda

l<intBotVactor

ldx

l>intBotVactor

jar

CallRoutina

; normally unused .

• ; applicationMain ia normally $0000. You can • wedge your own Main Loop routines in hera

'

'

jar

RestoraStata

; back the way it was .

rti ;

TimaSarvica

InterruptMain is called during

; each interrupt via intTopVector . ; This routine partorma the bulk ot the

Volume 9, Issue 5

.

lda

l<applicationHain

ldx

t>applicationHain

)Sr

CsllRoutina

jmp

HainLoop

; toraver

23


1541/1571 DOS M-R Command Error A caveat f or multiple byte reads

by Anton Theuenfels

One of the facilities provided by the DOS oftbe 1541 and 1571 drives is the memory read (M-R) command, which allows the user to examine any memory location in the drive. The same purpose is served in the computer's memory space by BASIC's PEEK function: memory read can be thought of as a PEEK function for the drive. A difference between the two i1. that, while BASIC's PEEK is limited to examining one memory location at a time. a single M-R command can return the contents of up to 255 memory locations. There are two forms of the M-R command: a single-byte version and a multiple-byte version. Commodore's documentation of the M-R command in the 1541 User's Guide mention) only the ~ingle-byte version. but ays that if more than one byte ill read then l.ucces~ive bytes come from successive memory location~. In the 1571 User's Guide, however, Commodore l.ays that. in the multiple-byte version of the M-R command, returned bytes come from successive memory locations. The documentation appear<> to be incomplete. The single-byte version of the M-R command never returns values from more than one memory location, and the multiple-byte version becomes confu!>ed ncar page boundaries. If the starting address of the memory read plus the number of bytes to read are such that a page boundary must be crossed to complete the request, the bytes returned after reaching the boundary come from somewhere else altogether. The accompanying progmm demonstmtes the error in the multiple-byte version of the M-R command by requesting reads of the same locations in drive memory using both the multipleand single-byte versions, then comparing the results. If the sum of the starting address and the number of bytes does not cross a page boundary, then the results match (at least when reading ROM location<;). If a page boundary is crossed, the results do not match. The error manifests it elf differently depending on whether or not the Marting address was the laM byte of a page (of the form SxxFF). If so, then the second and succeeding bytes come from $xx00, SxxO I, and 1.0 on (in other words. a page wrap). For any other startmg address DOS stops returning memory 24

bytes at the page boundary and Marts returning the bytes of the OO,OK,OO,OO status message over and over until the number of bytes reque!.ted is reached. A slight variation of the multiple-byte M-R subroutine demonStrates what happens when multiple bytes are requested after a ~ingle-byte M-R command i~ sent. Elimination of the third pammeter byte (NB$) from the PRII'-T# statement sends a singlebyte command. then enterl. a loop requeMing multiple return bytes. The first byte is correct and all l>Uccessive bytes come from the OO,OK,OO,OO status message. The error demon-;rrauon program ha~ been used to test a 1541 and a new R0\1 1571 with tdenucal results. It is interesting to note that two dtffcrcnt edition1. of the 15-11 User's Guide do not mention the multiple-byte version of the memory read command. although both allude to an ability to read multiple bytes. (Both editions also have an example program showing how to read multtple bytes with the single-byte version, but only one ~ill worl. correctly.) The 1571 User's Guide acknowledges the existence of the multiple-byte version but not its limitations. Possibly this was a response to third party discussions of the multtple-byte version in several books about the 154 I.

Unfortunately, none of the books seem to be aware of the problems either. One can speculate that perhaps the original decision not to document the multiple-byte version was made by the persons responsible for implementing it in the first place. The ability rna) have been used in the early development of the DOS by persons who were a~ are of it'> limitations but found it adequate for their needs. References Anonymous, Commodore 1541 D1sk Dnn! User's Guide, Commodore Bu<>iness Machines Electronics. Ltd., September 1982 Anonymou1., ~ IC-1541 Single Dril路e Floppy Disk User's Manual, Second Edition, Commodore Busines!. Machines. Inc., December 1982 Transactor


Anon} mous, Commodore 1571 Dill.. Dri1•e Uler·~ Guide. Second Edition, Commodore Electronics Limited, August 1985

AaT• l A toaplete Interlace tystea tor ttnd and teuhe on cv. lTTl'

(lludot • ASCI t ) an4 A)ff()l, for

uu v ltlil \h C~..odore 6C/UI (~tar. OptratlaJ proaTaa oa

Englisch, L. and Stc7epanowski. N., The Anatomy of rhe 1541. Abacus Software, Inc., 191!4 Jmmers. R.• and mo~t. Inc .• 1984

eufeld. G.• lnsule Commodore DOS. Data-

diaL lnclu4t4.

All• l l A co.,lata

ln tarf•~•

for saad aa4 recti•• oa

cw.

S19f.OO

syat. .

ITTY

(budot fl ASCII) aN AMTOI, :for

uta

" m-r.error.bas" - rhe limitation demom.trmed Cl 100 ptUit"(dow:!} 1541/1571 dos 'a-t ' ow•nd' ll' !C5 prUit error damstntio:l' CO llO : 11G ISO Dl$= ; zr~ cht$ (0} GJ ISS def fchb (1}= int(l/256}: def fnlb (l )• l·iat (l / 256}*256 !B 160 JG 200 print • (down} atart lddrtu of -.ory rud' BL 205 1nput • htxl or <q> to qu1t'; a$ OF 210 if a$="q' then end LC 215 gosub 505: sa= 1 . if aa>65535 then 200 JI 220 input '(down} bed of bytu to rud';a$ Fl 225 gosub 505: nb= a: if nb<! or nb>2SS then 220 BF 230 if fchb(11}= fchb(ll+nb-1} then print' (down} utch expected>';: qoto 240 W 235 pnnt'(down}lllisutch expected>'; IJ 240 qoaub 305 AI 245 qosub 405 MI. 250 if llb$=ab$ then print ' utch foWld': qoto 260 II 255 pnnt • liautch found" !B 260 for i=1 to nb PB 265 print fDUI(sa+H ), uc(lid$(ab$, i 1}} ,uc (llld$(11b$, i, 1}} CB 270 nut Ll 275 qoto 200 111 m . B 300 na ._lti·byte read llO 305 lib$= Dl$ 1P 310 opeu 15,8 IS PP 315 lb$= cht$(fnlb(sa)) : hb$= cht$(fDUI{u)) : Db$= cht$[Db) BL 320 p=tl 1S,'a·r';lb$ hb$ Db$ rr 325 for 1=1 to Db I'll m qetl 1S,a$ if a$--:U$ theo a$= zr$ Jl m lib$= llb$+a$ If 340 CHt Al 345 close 15 Q 350 return II 355 . 11!1 400 res ' sinqlt·byte read OF 405 ab$= n1$ rr 410 open 15, 8,15 Pl 415 for i=l to nb Pl 420 lb$= chr $(fnlb(sa+i·1)} : hb$= cbr${fnhb(sa+l·l}) ax 425 printt 15,"m·r';lb$;hb$ JC 430 qet 115, a$: if a$=nl$ tben 1$• zr$ FP m ab$= ab$ta$ ML H Onest

EG 445 clost15 01 450 return

LD4SS 500 rea •bu·>dec P• 505 a=O: for i=l to len(&$): b= asc(atd$(a$ ,i ,1))·48: a= a•16tb+7 *(b>9): next IB 510 ret11rD li U.

Top-Tech International, Inc.

wit~

0p•ratlaa

C..-odore YIC 10.

•r•ara.

in auM

$ft.tS

s- ~·

cw.

A racaiYa oalr cartrl4aa for ATTT (lludot &ASCII) for usa

•lt• Co..odora •t/IZI . proaraa ln IOH,

Operat lna

$61 ,80

AIRDISl : AQ All•l type

operatlll proaraa Cor u~• vtth your l•terfa.e hardvare. loth VlC ·ZO

••4 c••Jtll ona dis\,

proat••• on

Ut .IS

AJR ·-0. • Cartrtda• Vtttion of AIIOIS~ for C64/ IZI only, 151.11

MORSE

COACH G

AND

G OF

Ml11.56 COAC'JI .

A Coaphta c. . chtna

111nd ttttlna prof" . .

tl1t Houe code

lor C•4 or Clll.

VIC SrECIAL

ror harnina

n • canrtdae.

S4t .ts H9.9S

ELECTRONICS MA~YLANO

8524 DAKOTA DRIVE, GAITHERSBURG, MD 20877 (301) 258-7373

Ulh-F11t Dl•k O(wltlng Sy•t«n for tiN C-64, SX~ & C-128 • SpMdt up Ill diu opellllorw. Lold, SaYe, FOIIMI, Scttth, Valdlle, aca~SS PRG, SEQ, REL, & USA ljes 141 to 15 llm•lalltll • U... no poM, memory, or tX1ra c.bllng. Tl'e JillyOOS ROMs 'Wide yw ~~and ~(1) lnlamally lor mulm~~n apeed and ~tblity. • Gueranlted 1~ compallblt whh ahoftnrtand hardwa,., JifrOOS liP u rls 141 tl'eloldngand irlemai,...ICCeu operation Ill W1uaJy Ill commerciiiiOI!wate. • Bull-In DOS Wtdgt !U 14 adcftlonal command~ llld coi1Yinlance IMlUI8I ilcld~ ant-by lol~ ch:1oty mtl'll llld KIMI1 ~• &ly ~·yvlrltlf lrwtan.lol\ No 11ec:tton1cs tllpllltnce or specitiiDCis,. ~ llusuared ~ inslnJclloiWIUidld. Available b c.4,..C, SX-t4, C.12U C.1280 (Jlfy000112S J1Pttdl 141bofl64 llld 128 modtl) and 1541, 1541C, 1541 ... 1S71, 1511, FS0-1&.2, 11SD S0-1&.2, &ttl 2001, ErNnctr 2000, Am ted\, s.n, lndut & BIUICHpdilltdnYes. Sys~tm rlc:ludet ROt.b lot~ and 1 ditlt dtM. ltldi/Jiy()OS ~ tpttm, ibiJI!Id i1llaltiJon hltud.rJnt. uw. Mar&al tnd Money-kll Guararae.

INDUSTRY FIRST - LIFETIME COMPUTER

Volume 9, Issue 5

25


C128 Simple Disk Monitor Extending the built-in monitor •

b} Anton Treuenfcl<;

There arc time' (often 'hortl:r after scratching a file 1 really didn't mean to) when I find it very useful to have a disk monitor program handy. Using one of these widely available programs I can examine and, if I wi~h. modify the contents of any disk sector. On the other hand. I found that many of these programs were b1g, c lum~y. rigid. and inconvenient to use. The program presented here wa~ designed to overcome these perce•ved problem~. Although it pe1 hap' doe~ not do everything that could possibl:r be "•shed for. it b relatively small. nimble. flexible, and cas) to usc. A disk monitor program mu\1 at lca'>t be able to read, display, ed1t and "nrc dis!.. sectors. The problems of display and editing are shared b) moni10r program'> m general. and DisJ.num12li deals '' llh them b) "edging itself into the main command loop of the CI:!H\ built-in machine language monitor. Tili'> reduce' displa) and editmg to problems that have alread) been 'ohed (al\\a)s a useful progr.tmming technique). As bonuses Oi~J.mnn/28 gams U'>e of the @ d1sk wedge command and the ability to examine and mod•l.> <;ectors by disassembly and assembl:y a~ ''ell as by s1mple memory dump. After empiO)ing '>0 much of the power of the built-in monitor, about all that is left for Di$J.mon/28 to concern itself with ill the proper reading and writing of disk sectors to and from the Cl28's memory. Using the program

DisJ.mon/28 may be loaded and in'>lalled from either BASIC 7.0 or the bu11t-1n monitor. From BASIC: bload " diskmon 128". '>H dec(" 1300" ). monitor. From the monj• tor: I " diskmon l28" . j l300. Once mstalled. the progmm functions as an extension of the C I 28's built-in mom tor There are four ne" commands (in additiOn to all the nonmal ones):

26

/R [<track> <aector>)

- read aector

/W [<track> <aector>)

- write aector

/1 <device> [<drive>)

- aet device and drive numbers

/Q

- diaable diak monitor wedge

All parameter!> are numeric and (:.incc a built-in monitor ROM routine is used to collect them) may be :.pccified in any convenient base (hexadecimal, decimal, octal, or binary). Square brackers indicate opt ion aI pammcters. The read command (/R) copie~ a di'>k sector into a buffer in the C 128 's memory. Once in the C 12!!'~ memory. the contents of the sector may be displayco in hexadecimal and ASCit fonm by using the built-in monitor's memory dump command (m). TI1e buffer b located at SBOO in RA \1 bank 0. so the command to djspla> rhe entire sector is m bOO biT ($BOO is the autoboot dis!.. sector buffer. ote that this page of memor:r is also used for the casseue buffer, and -.o •., incompatible "ith any routines which might want to reside there). If de-.•red. the memory display ma}. of course. be edited 111 the nom1al manner. Alterations made 111 this wa) affect only the cop} of the sector in the Cl28's memory ho"e\er. and no change:. are made to an) actual djsk ~ector until the contcnh of the obk sector buffer are delibemtel) copied bacl.. to di'>l.. using the ~rile command (/W). Borh the read and write command<> may optionally be fol lowed by dis!.. tracl.. and \ector numbers. If a track and sector are ~pecified they are checl..ed only to see if they are each in the range 0-99. wh1ch allows the program to create a syntactically legal direct acce~s command. It is left up to a drive':. DOS to complain if the command cannot be complied with (usually becau!.e the DOS docs not recognit.e the exi~tence of the requested !rack and )>CCtor). This approach is designed to avoid having to hardcodc into the program the internal arrangement of any pa<tt. present or future di~k fonmat by taking ad~antage of the user\ !..no~ ledge and the oos· intelligence. If a tracl.. and sector arc not .. pccified, both the read and write commands usc default tracl.. and sector value~. ln the case of the read command the content\ of the fli'St t\\O bytes of the dis!.. sector buffer arc taken to be the track and sector to read. This is based on t\\0 a-.... umption-.: that the contents of the buffer repre.,ent one sector in a -;enes of \ectors log•cally linked together in a single file, and that the first two b> tes m the buffer represent the lin!.. to the trJcl.. and ~ctor of the next ~ctor of the file. The~ tLssumptions arc often true. making it possible to easil) tmce fo~ard through the s:ystem of linl...s tying file~ together under Commodore DOS. Particular condition.., under "hich the Transactor


a~umption!>

arc untrue include reaching the la~t sector of a flle and before the program htt'> read it~ lif!>t ~ctor. The write command default<. to usmg the values found in the current track and current 'ector variable~ maintained by the progran1. Since these vanables w1ll U\uall) ha'c la.'it been set b) the mo,t recent read command, the default acuon normally amount'> to punmg the (PO''>Ibl) modified) M:ctor current!) 111 the dbl.. -.ector buffer bacl.. where it came from. The /# command is used to ~ct the de' icc and dri\e to \\ hich the program will read and '-'rite. The program defaults to device 8, driv.,e 0. The /Q command rc\ets the built-in monitor\ command 1nd1rect "ector to the value it had \\.hen the disk monitor \\.a~ firM in'>talled, which effective() disables the disk monitor. About the program The main command loop of the built-in monitor is designed to accept a line of mput, find the lir-;t non-space character on the Iinc, and then jump through an indirect vector. Normally this vector points to a routine which tries to mmch that first character to the commands the mon1tor l..m>w'>. Di~~mon 128 re-point~ the indirect vector to lis own match routine. which checks if the character found i!> the disl.. monitor wedge character (/). lf not. control passe.., to the onginul command match routine. If it is the wedge character. the program attempts to match the second non-'>pace character of the mput line to a kno" n dbk monuor command. and report., an error if it cannot do so ( t\.\.0-<:haracter rather than one-~:haracter command!> are required mainly bccau ..e the letter R i'> alread) employed by the built-in monitor for its Reg1-.ter command and no alternative one-character command seemed to make as much intuitive sense as / Read). Dis~mon 128

open!. and close<; a direct access channel to a drive for every read or write attempt rather than opening and closing once for each ~ession with a dbl... The lime CO!>t of dotng thi~ b vimmlly unnoticeable. and it actually ::.aves code ~pace since sel>sion management commands (eg., changing disks) are not needed. High-level Kernel tile routines are u&ed exclusively rmher than going ro the low-level Kernel serial bus routines. There are a number of mas ...-..,torage dev1ces which patch themselves mto the indirect vectors of the h1gh-level routines. and the program 'hould worl.. with an) of them wh1ch recognite the normal Commodore DOS direct acces., commands (eg.. an SFD-1 00 I drhe with a parallel cable '>hould. but an REL '' ith a Commodore RA\1DOS progmm won't). [R l\IDOS does 1wt imp/eme/11 a track and .fector mNhod of data storar:e. - Ed.] Getting in and getting out It is unfonunate that after hav mg prov1ded a documented

method of intercepting the built-in monitor. Commodore did Volume 9, Issue 5

not prO\ ide a documented method of returning to it. The point of interception i!. the command di~patch routine. ln the built-in monitor this routine i'> at the ~ame level as the main loop, so calls from and returns to the mam loop are handled a.\ direct jumps (as opposed to BASIC 7.0\ command dispatch routine, which is a subroutme of the main loop. After bemg intercepted, control can he returned to the mum loop '>Imply by executmg an RT'i mstrucuon). ThiJ> b a '"orkable. if not exactly academically sanctioned. method of doing things. l lowever it would be handier if Commodore had provided another entry in the jump table at the stan of the built-in monitor\ R0\>1; one that pointed to the start of the main command loop. This would mal..e returning after interception less of a risl..y bu'>ines\. A~ it is, Dis~nwn/28 is vulnerable to a ROM revi1>ion (In for a penny, in for a pound - the decbion to usc a R0\>1 routine to collect numeric parameters must be blamed solely on a desire to ~>:1ve about 80 bytel> of code. It is just as vulnerable to ROM rcvisionJ>, and there is really no excuse for it. r simply yielded to tcmpltltion on this one ··as long as I have to use an undocumented reiLirn call anyway... "). Obser vations and possibilities A couple of final observations. The firM i'> that Dis~mon/28 is less than 700 byte' long. and the bui It-in monitor'!> 4K R0~1 contains over II 00 unused byte!>. A possible U!>C of thi!> empty space immediately suggests itself (at least to me): although this might be of more interest to hobbyists than to Commodore itself.... The possibiltt} IS left open b) making sure that. aside from the program code and di'>l.. \ector buffer, all RA \1 uc;age is confined to area\ alread) utilited b} the bu1h-in monitor (mostly variable'> at 60-$68 and AXO-SABr, but ah.o the input buffer at $200 and the "acl.. potnter regiMer ..ave at $09). The other observation ill that the Cl28'~ Kernel contains a limited direct tracl.. and sector read ability in the BOOT CALL routine at $FF53. Thi-. routine can read track I. sector 0 off a disk in any drive into the autohoot sector buffer at $800. It '-'Ouldn' t take many of the over 600 unu~ed bytes in the Kernel ROM patch area to add a routine capable of reading and writing any track and ~ector on a disl.. in any drive. along with a jump table entry to the routine. Although the utility of ~uch a routine to anything other than a di!>k monitor program might be questionable. it would offer a -.lightly higher-level approach to direct rrack and sector read\ and writes than requiring such a monitor to be aware of the mes<,y deta1ls itself. Listing 1: Merlin .wurce for

Dis~mon/2/i

• cl28 silple disk 10nitor • lut re-rinon 09/23/88 • writttD by anton trelltllfela

• 5248 horiton dr1vt • fr1dley, 11nnesota usa 55421 • 612/572-8229 • proqru constants

27


uudr = $1300 cr cu spc que

;assembly address

• inatall 1nstal lda aucr pha lda fbnkl5

=$0d = $ld : $20 =$3f

StliDCI

; direct acctu chwlel filtl •ccurvt chwlel flltl

dacl! =13 c:.dlf • 15

]bbl

bnl:lS • \00000000 ;bank 15

• proqra _,ry use

ldx 13-l lda l$00 sta cm!rv x CUITtnt drttt, tuck, MCtor sta dskbllf x for /r or /• without paraas dtx bpl ]bbl lda 18 stacr~

d'CII $60 lddr ds 2

,

clc JSI setvet · nt wtdqe vector jar prU. dfb cr,cr txt ' disblonl28 v092388' dfb CI txt ' by anton treuenftla' dfb cr,OO pla sta IIIIUCI rts

; (11001tor 11e110ry) ;pointer

dtnd reawri = $0a98

; re~d/write

dull $0aba oldi!Kln ds 2 crrdvc da 1 crrdrv ds 1 crrtrk ds 1 eruct da 1

; (IIDDitOI IIIIOty) ;old comaand vector ; current devtce ; current drive •current tuck ; current sector

flaq

dtnd dstbuf = $0b00

d.uk buffer (boot block buffer)

Wl!litor _,ry ast

t

stkptr = $09 accl = $60 .onptr • $7a but

• $0200

1.:111

=$032e

asgbuf

=$0180

· stack pointer uve DUittlC aCCUIDlator inpllt boffu pointtr : lllpOt bofftr

disk coa•nd buffer

* kernel

;110nitor 1111n loop ;get nu.ric parueter

dskiiOn Clip t I / 1 beq 10ntok j.., (oldiOll)

·ndqe token? ;b:yes ·to norul handler

10ntok JSI qetspc ; look for IOllltor beq reterr ldx fliDnadr-IIDOc:.d-1 )bbl Clip IIDDc:.d, X beq have:.! ;b: found ec-and

CCIII'& ad

du

bpl rtttrr ldx tu jsr dfb

]bbl sttpt r

; restore stack

pna

; report probla ~n

loop

* found cc.and bavclld tu

vectors

clsall • $ffh setbnk = $ff68 prU. • $ff1d setlfa =$ffba sttnaa =$f fbd ope.11 = $ffc0 cllin =$ffc6 chioat = $ffc9 clrcl:ll " $ffcc chrout : $ffcl2 getin = $ffe4

asl ;close all files on dev1ct ;set i/o bank ·print imldiate

tax lda monadr+l,x

pba lela monadr,x pba

; nt filet, deV1ce, cOIIIWid ; nt hltllBI ope.~~ file :set 1nput file · nt output h le ·set dtfanlt i/o files output byte •input byte

rts • 110nitor COIDIM.s IIODc:.d txt 1 qtWf'

• bardnre nquttu

110nadr da da da da

~cr

• execute qutt

= $ff00

;leiOry confiquration

•••••••••••••••••••••••••••••••• ore; aSIIIdr

28

for disk mon1tor coa•nd

csr,que,$00 retiiDn j.., llnloop ;back to

* 10n1tor It1l IIDloop = $b08b n~~q~m = $b7ce

* look

exqnit-1 exread-1 exwrit-1 exdtvc-1

exquttsec jsr ntvct lap retiiDn

Transactor


• set indirect vector (a) • read/write sector set'VCt ldx 12-1 ]bbl lda oldloo,x bcs .1 ·b:replaet old vector 1da illoa,x ·sa?t old ?eCtor sta o1\tlon, x 1da rpbct, x set new ftctor :1

ltl ,._, X

rwsect lda reawri Clip 1' 2' beq2 JSr sndbaf bcs 1 )Sf fddbaf :1 rts

·write' b:yes ·oeand read

b.error read bofftr

du

bpl ]bbl rts

:2 :3

rpl'9Ct da cisbon

sta reawri

;1

jn trksct jsr mkdae jsr elafil jsr opndir bca :1 jsr rwsect JSr clafil jllp rttul

; ' ul ' ;'u2 ' ; read/write flaq ;qet traek/atctor ; WI C<lllll&lld

;close filta on dtvict ;open direct access file ;b.can' t open ;read/wr1tt sector

opadu lda l$00 JSI JttJwl opnfil bcs ·1 ldx l<daCDIII ldy l>daCDIII

; oeaacl hlt

)II

:1

oerM write

rddbuf lda jsr bcs ldy Ibbl JSr ata 1ny bne J&r clc :1 rts

ldacl f chkin .' talk' :1 10 qetin ; input byte dakbnf, y ]bbl elrehn

; ' untalk '

* copy ca~pQter to diak buffer

• open direct aeeeu diak hle

lda ICIIdlf

write buffer

* copy disk buffer to ea~puttr

• execute read/wntt exread lda 1' 1' dfb $2c exwrit lda 1' 2'

JU wrdbaf bcs ·3 jsr sndbaf rts

b:trror

mlbof lda l<dcptrO ldy l>clcptrO JSr clskCIId · bofftr polllttt to start bcs . 1 lda ldaclf JSr chkoat ' listen' ldy 10 1bbl lda dskbot y JU chr<IOt •ootpot byte

iny

ldall

bne )bbl

jsr setnu lda ldaclf JSr opafil rta

JSr clrehn clc rts

;direct aCCtll fllt :1

; 1 unlutea'

• we direct aceesa cOIIIIIIIlld dacnu txt ' I ' • open disk file

opafil tay ldx crrdvc

; secondary addresa

jsr ntlfl lda 1$00

tu jsr setbak jsr open bcs ·1 )st diskst bee 1 JSr clrhl

;check atatUJ DISJtge bok ·close fllts

sec

:1

ttl

• close disk files clsf1l lda crrdvc )st clsall rts

Volume 9, Issue 5

wdac ldx 1-1 ]bbl inx lda dcread, x sta uqbof,x bne ]bbl lda reawri sta asqbof+l lda crrdrv on 1$30 sta asqbof+6 lda crrtrk JSI htxdec atx asgbaf+8 sta asgbaf+9 lda cruet )Sf hexdec stx asgbaf+ll sta asgbaftl2 rts

; copy cOGIII&nd template

;set coaaand ; nt drive

sat track

sat

sector

• send ccwn•acl 1n tht •uaqe buffer · clort t?trythlaq on dt•ice

sllllbuf lda l<asqbuf ldy l>ssqbof

29


* aencl cluk o:.and with error check ,,.., Jar

)bbl

abc 110 ~ )libl Ide f' O +10 rtl

d.skcm

bel 1

•1

w

Jar cluut rtl

* 91t

• send clisk caaand dskCIIId atx addr aty addr+l lclx tc.dlf ; ' hsten' ) lr chkout ·b:error bcs l 1c1y to lela (tddr) y · hrst char )bbl ) lr chrout

track and sector

trksct jar getbyt bca tkll sta crrtrk jar getbyt bee th2 nUIIrr jlp reterr thl

lDJ

:1

tkl2 tks3

* dlsk

cOIIInd messaqes

* qet byte

• check duk status

cliskst lclx lc.dlf Jar chkin bcs :2 )lr qetin cap I' 2' bee :1 jar pri.dfb er, $00 )llbl Jarchrout ) It qetln C11f fer bnt )libl :1 pbp Jar clrchn plp :2 rts

. ' till' ;b:error ;first byte of status measage ;is this an error message' ;b:no

Clip ..

bee

n~~aerr

Clip

130+1

:1

sec

; ' untalk'

;qet number ; b:no nll:lller ;b:too biq

v1lue

qetnu:n jar DUIIplll bcs n~~~~~trr bnt :1

;sets carry llhen true

php jar qotdla bnt DUIItr plp rts

;qet numeric par&meter ;b:too big ;b: found nu.btr ; flaq not found ;save flaq ; check last char ;b:not legal temnator

* character fttchea

;qet devicet ;b:not found ; check serial bus cltvi.ctl 31 is bad nUIIber

beiDUIItr

Ita errdve )It getbyt bel 1 Clip 11+1 bel D\lllert atl crrdrv Jill> retDOn

* get numeric

:1

* trecute dtvicel exclevc jar qetbyt bcs nUIItrr

value

qethyt jar qetnua bcs ·1 lela accl+2 bnt DUIIrt lcll accl+l bnt n-rr lcll ICCl :1 rtl

;display error aeuage

;qet sectod ;b:found

lela rtawn ;wnte? Cllfl2 btq tuJ ;b:yes - usa current values lcll dskbuf ;follow link to next sector atl crrtrk lela dskbuf+1 sta eruct rts

lela (aclclx), y bnt )bbl ;'unhsten' jar elrchn clc rts

clcread txt ' ul· l3,0,01,00' ,00 clcptrO txt ' 1>-p:lJ.O' , 00

;get trackl ;b:not found

·qet drivel ;b:not found ;0 or 1

• convert byte to uc11 deciaal

gotcllll dec 110nptr getdlll jar getchr beq :1 C~plspc

; b:end of input ;check for field separator•

beq :1 Clip , ...

•1

rtl

qetspc jar qetcbr beq 1 Cllflspc beq getspc rtl :1 getchr lclx DOnptr leis buf,x beq :1 Clip

1':'

'

·b:end of iDpat ;b:eat spaces

;b:end of line ; check for other terminators

beq :1

bexdtc

199+1 bel DUIIttt lclx t ' O -1

Clip

sec 30

;wrks for 0-99 ;b:too hiq

lque beq :1 i.DC 1011pt r rts Clip

:1

; next char

Transactor


Listing 2: BASIC generatnrfor "di.tAmon/28.o"

£B 1540 data 24, 96. 85, JD

JP 100 ra qenentor for ' dialt.on128 .o' n 110 n$='disboll128 .o': na - of progtu

01 120 Dd:648· aas4864 · chs6SS74 (for l1nes 130-260, see the standard generator on paqe S) II' 1000 data 113,

0. 255, 72, 169, 0, 141, 0 EP 1010 data 255, 162 2, 169 0, 157, 189, 10 IB 1020 data 157, 0 11, 202 16, 247, 169, 8 00 1030 data 141, 188 10, 24 32, 146 19, 32 JG 1040 data 125, 255 13, 13. 68, 73 83, 75 IJ 1050 data 77: 19 78, 49. SO, 56, 32, 86 PI 1060 data 48, 57, 50, 51, 56, 56, 13, 66 OL 1070 data 89, 32, 65, 78, 84, 79, 78, 32 FH 1080 data 84, 82, 69, 85, 69, 78, 70, 69 IN 1090 data 76, 83, 13, 0, 104, 141, 0, 255 00 1100 data 96, 201, 47, 240, 3, 108, 186, 10 PB 1110 data 32, 108, 21, 240, 10, 162, 3, 221 PN 1120 data 127, 19, 240, 15, 202, 16, 248, 166 PO 1130 data 9, 154, 32, m, 255, 29, 63, 0 10 1140 data 76, 139, 176, 138, 10, 170, 189, 132 1P 1150 data 19, 12, 189, 131, 19, 12, 96, 81 IL 1160 data 82, 87, 35, 138, 19, 170, 19, 113 LP 1170 data 19, 235, 20, 56, 32, 146, 19, 76 DH 1180 data 112, 19, 162, 1, 119, 186, 10, 116 !C 1190 data 9, 189, 46, 3, 157, 186, 10, 189 PO 1200 data 169, 19 157, 46, 3, 202, 16 236 l! 1210 data 96, 81 19, 169, 49 44, 169 so so 1220 data 141, 152 10, 32, 26. 21, 32 87 AC 1230 data 20, 32 2, 20, 32, 202, 19 176 FF 1240 data 6, 32 9, 20, 32, 2, 20 76 :r 1250 data 112, 19, 169 . 0, 32, 189, 255 169 EP 1260 data 1s, 12, 230, 19, 116. 14, 162 229 a1 1210 data 160, 19, 169, 1, 32 189, m 169 oc 1280 data 13, 32, 230, 19, 96 35, 168 174 LD 1290 data 188, 10, 32, 186, 255, 169, 0, 170 Cl 1300 data 32, 104, 255, 32, 192, 255, 176, 9 RB 1310 data 32, 201, 20, 144, 4, 32, 2, 20 JF 1320 data 56, 96, 173, 188, 10 32, 74, 255 PC 1330 data 96, 173, 152, 10, 201, SO, 240, 9 OK 1340 data 32, 137, 20, 116, 3, 32, 34, 20 !0 1350 data 96, 32, 57, 20, 116, 3, 32, 137 OJ 1360 data 20, 96, 162, 13, 32, 198, 255, 176 II 1310 data 15, 160, 0, 32, 228, 255, 153, 0 10 1380 data 11, 200, 208, 247, 32, 204, 255, 24 AI 1390 data 96, 162, 192, 160, 20. 32, 150, 20 01 1400 data 176, 20, 162, 13, 32, 201, 255, 160 1P 1410 data 0, 185, 0 11, 32, 210, 255, 200 1C 1420 data 208, 247, 32, 204, 255, 24, 96, 162 Dl 1430 data 255, 232, 189 171, 20, 157, 128, 10 01 1440 data 208, 247, 173. 152, 10, 141 129, 10 II 1450 data 173 189, 10, 9, 48 141, 134, 10 Ill 1460 data 113 190, 10. 32, 11 21, 142. 136 Bl 1470 data 10 141, 137 10, 173, 191 10, 32 K! 1480 data 11 21, 142 139, 10, 141, 140, 10 Pl 1490 data 96 162, 128. 160, 10, 32 , 150, 20 LC 1500 data 176 3, 32, 201, 20, 96, 134, 96 NB 1510 data 132 97, 162 15 32, 201, 255, 176 Bl 1520 data 16 160, 0, 177 96, 32, 210, 255 ll' 1530 data 200, 177, 96, 208, 248, 32, 204, 255

Volume 9, Issue 5

1!11

8C IF BB LI EF II!

III OK IN 00 IN BN BA OJ liB

AE &D

BA NA PK MP MP Pl CB

49, 58, 49, 51, 44 1550 data 48, 44, 48, 49, 44, 48, 48, 0 1560 data 66, 45. 80, 58, 49, 51, 44, 48 1570 data 0, 162 15, 32, 198 255, 176 27 1580 data 32, 228, 255, 201, 50, 144, 15 32 1590 data 125, 255 13, 0, 32, 210, 255, 32 1600 data 228, 255 201, 13. 2C8 246, 8 32 1610 data 204, 255 40, 96. 32 62, 21, 176 1620 data 54, 201 4 144, SO, 201, 31 116 1630 data 46, 141, 188, 10, 32 62, 21 , 116 1640 data 7, 201, 2, 176, 34 141, 189, 10 1650 data 16, 112, 19, 201, 100, 116, 24, 162 1660 data 47, 56, 232, 233, 10, 176, 251 lOS 1670 data 58, 96, 32, 62, 21 176, 11, 141 1680 data 190, 10, 32, 62, 21, 144, 19, 76 1690 data 103, 19, 173, 152, 10 201, 50, 240 1700 data 12, 113, 0, 11, 141, 190, 10, 113 1710 data 1, 11, 141, 191, 10, 96, 32, 78 1720 data 21, 176, 10, 165, 98, 208, 224, 165 1730 data 97, 208, 220, 165, 96, 96, 32, 206 1740 data 183, 176, 212, 208, 1, 56, 8, 32 1750 data 94, 21, 208, 203, 40, 96, 198, 122 1760 data 32, 118, 21, 240, 6, 201, 32, 240 1770 data 2, 201, 44, 96, 32, 118, 21, 240 1180 data 4, 201, 32 240, 247 96, 166, 122 1790 data 189, 0, 2, 240, 10 201, 58, 240 1800 data 6, 201, 63 240, 2 230, 122, 96

Diamond Text Editor

The Fir<;t Professional Quality Editor For the Cl28 Look. at these features!!!! Over 140 command' m a lt.K huller. 8 file buflc"' .tnd 32 rc,ituble. rclucatabl.: wrndow.,, lnsen and delete c h:lmCtCr\, wnnk hoc\. and hlocl.s. Perfom18 diffcocm upcr;uooo" on text blOt: h. Powerful search/replace with t. operating modes. - Powerfulmac ou r~wrd und playb;~cl. 1',1coluy include' condouonal IF{fHF.N/FI 'lF macrn,, - Edot. debug .•md c~ewtc BASIC' prognun\ or edit text. - Tc~t mode fe;uure' word-11 rap or programmer's line-oriented mode. Compaublc woth m.ln) :1\\Cillhlcf\ and cumpolco\. BASIC mnde alln11' you In u-c the po~~ocr o f a tc~t edotor to create. edit. .md debug. BASIC 7.0 prof!ranl\. Specoal feature allo"' editor to remam co-re,ident m RA \1 11ith Commodore·, IICD65 mJno a\\Cmhlcr anJ luackr. ,\."cmbk. C\IXUIC the loader. and ~ave pmgr.om obJC" lllc\ tmm 111thin the editor, Compauble woth RA \1 d"l.. 'uti ware. \uto·ondentauon. ~t. t>ookmarl' Rrtlctonahle ~C}' ~luch. mu~h more! (!10 <'Oiumn mode onI))

A' ailable now: Onl\'• $42.95 US or $49.95 Can. Send ched. or mone) order 1Foreagn add S5.00) Pcr;onal check\ rec.Juire a three 11ccf.. \\;utmr penod.

Robert Rockefeller. P.O. Ho' IIJ. Langton. Ont. NOE IGO (5 19) 875-2580

31


HCD65 Assembler Macros Making use of assembler pseudo-ops b) Rober) Rockefeller Commodore recently publi,hed thetr new Cl28 HCD65 macro assembler. Since the IICt>M manual explains the ba:,ic function of HC065 pseudo-ops but does not demonstrate how to u:,e them, it seenb pos1.ible that some potential users of thi:, assembler may not be able to muk.c full usc of the macro capability. Thi' article illuwate~ a few macros that the author has found useful. Macros are created with the . \1 \CRO pseudo-op and terminated with the .MIJM pseudo-op. Nothmg new there. The MoveW macro ts an example of a simple macro which transfers 16 bits from one 'ariable to another. The LoadW macro is more complicated in that it has t\\O bcha' iours. LoadW \arl,,ar2 ts equtvalent to the simple MoveW macro. \\luh LoadW \arl,CO'\Sf\'IT,# the presence of the # character "' the thtrd pammeter cau'e' \Url to be loaded "Hh an immediate \alue. IICDM'' ability to test for a blank. lield "ith the .ifnh (if not blanl..) pseudo-op makes it po:,sible to create a macro "'hich has dtffercnt actions depending on the presence or absence of a par..unctcr.

left until the mO'>tl>tgmftgunt bit i'> a I. The DefCtrls macro cre<IIC'> S) mbols corresponding to lhe values of the CO'Il ROL f...cys. " macros.src" - for Cummodore·s IICD65 assembler

·=.nclist $1300 .blut

n.rl .110[ 1 n.r2 .wor 2 OOISIAif =$123. 81!15 =tlOOOOOOOOOOOOOOO POSITIV! " 0 liEGMM =$80

; .ave 16

b1ts

Novel aacro \vla,\vlb

The LineAdrs macro uses the .rept (repeat) p<,eudo-op to create a table of start addres1.es for a text -;creen, color matrix, or for a btrmap. For example. assummg a graphtc~ bitmap screen srans at addre1.s $6000, LineAdrs $6000,320 would create a table of row Mart addresses. The Mark macro stores up to six :,trings with the last character having the sign bit set. Upper case characters and some punctuatton character1. whtch nonnally have values ranging from SCO to SDF arc uutomallcall) converted to equivalent value., rangmg from 560 to $7F. An error mc.,sage i~ printed if graphic-. character' (\aluc' AO to ~Sf) are encountered. The Count macro can store up w 'i' 'trin)!' \\.ith the length of each ~tring "ored ·'' the fiN b) tc:. Both the'>e macrus make u!><! of the .i1p p-,eudo-op to procc:-,., each of the '>ix po!>!>ible l>tring~ in tum. The .irp< p'>cudo-op is used to proce!>!> each character of each \Iring one char.tcter at a time. The Float macro '>lOre' stgned "alue' mnging from -32768 to 32767 a' floating point numhers compatible with BASIC 2.0 and BASIC 7.11. It U\Cs a .rept loop to nommhte the manussa and adjw,t the exponent. ro nonnalite mean'> to shift the mantbsa

32

lda hlb sta hla lda blb+l sta hla+l .endll

HoveW varl,var2 ;sample usage.

·this aacro transfers 16 bita. Accumulator 11 ustd.

Loadl aacro l•la,\vlb,lvlc <\vlc> ;1f 3rd uquaent 11 pruent .lie hlc' - •I ' if 3rd af91Dilt equals •I ' .ilnb

lda l<hlb ,

then load

~tt

value

sta nla lda l>hlb

sta nla+l .tlse , else pnnt error •ssage . .assq ..... bad ~nt 1n Loldll uc:o ..... .endlf

.else lda hlb ;tht

110ft

16 bltl .

sta hla

Transactor


irpc h3,<h2> ·count each charactu w1th an .irpc loop. Lll = Llltl .tndr

ld.a hlb+l IU \flatl

11141f . end~

.byte LEN,'\v2' ;assemble string, length byte first . . enclif

LoadN varl,CONSTANT,I ;sa.plt usage.

.endr

.enca , t~s uero erutes a table of row atart lddresses ·for tbl serttn or color 1110ry or a bitlap. l.ineAdn .ucro l-fla, hlb ADR z hla

;assemble a floating point number coepatible with ;BASIC 2. 0 or BASIC 7. 0 floating point routinu . ;Float accept a up to 6 arv-nta

.rtpt 25 wor ADR

.&Dl•ADathlb

Float .aacro \vla,hlb,hlc,\vld.\vle,\vlf .irp tv2, \vla, \vlb, hlc,lwld, \vle, hlf .ifnb <h2> ;if a~t u not blank KIP • $90 ; !XP = correct binary uponet for 16 bit inteqer lOJi • \v2 ; MAN = 1st 2 bytu of untiua.

llldr

Lint.l.dra $0400, 40 ;create a auph

COQ.Ilt <Tut>, <lore! II> ; suplt unge.

t~lt .

.ift MAN ; if untissa =0 .byt 0,0,0,0,0 · then asselblt a 1ero. ; l'hu aacro stores a string with the lut character ·having the 1bit set. !be angle brackets eclosiog the aaero local vari~les s- to be DtCtuary to hAndle spaces lluk can handle ap to 6 a~tl .

Nark uero \vla,lvlb, hlc,\vld, \vle, \vlf .irp \v2, <\vla>,<hlb>,<\vlc>,<\vld>, <\vle>, <\vlf> .Unb

<~v2>

SIGII "' POSITM

.rept 15 ,

' hl' ·$80 ;if character walue > 128 ' \v3' ·$c0 ; if character ia upper case range $c0 .. $d! ' \v3' 1x$a0 ; then convert to range $60 .. $7£.

now noruli1e untiln lf!Lilt adjustillq KIP He arn5' MAN MAN =MAN•2 KIP •IXP-1

.endif .endr

CHAR

1119

.1flt MAN ; elae deteraine correct 11gu and SIQI • nGAfM , take ~solute value of lWI . MAN = -!WI .the .endif

;don' t usable null atriogs

irpc hl, <\v2> ifge .ifge CHAR • .byte elae

.ellt

; elae pr1nt error eesaage. '**** illeqal qraphlca character in Mari

arquMJ~t uu;

.tndif

MAN • MAN' .!nBIT15 ; clear siqn b1t of a&Dtissa and aslelblt number. .byt IXP, >MA~ '+SIQI, ~, O, O

.ellt CBAR • ' h3'

else assMble character ruue < 128.

endlf

byte ' hl' .tndif

.andlf .endr

.endr ;an entire atrinq las been auabltd, •••-1 , now beck up PC to laat claracter of atrinq. byte OIAR'+128 ;now set 1bit of lut character.

.enda Float 1,-1, -30145

; a&~plt a~aqe .

tndif

tnda Kart <A b>,< c D> ;sample usage .

; !bU ucro atores a strioq with tN COQ.Ilt io the first byte

; It acctpta ap to 6 operands.

;create apbola with ruuea corrupood.lnq to the COiftROL itya. ;workt with all alphabetic CONtROL ch.lractera. DtfCtrla .macro \vl .irpc <'v2>, <\v1> C!RL$\v2 " I \v2' I ' $1f .tlldr tnck

Count .11cro \vla,\vlb, \vlc, \vld,\vle, \vlf

lllilt DefCtrh abel ;tuple usaqe.

.irp \v2,<lvla>,<\vlb>, <\vlc>,<\vld>, <\vlt>,<\vlf> .ifnb <\v2> ;don't uaublt null atringa. LIN • 0 ;initialile string count to 0.

.end

Volume 9, Issue 5

33


Implementing A RAMdisk For Abacus' Super C On Th e C64 • by Kerf) Gra)

Super-C. the 'other' C compiler. is sold in two version~: one for the 64 and another for the 12!!. The syMem include:- suppon for a 'KAMdisk ', an area of memory that appears to the syMem a~ a disk drive.:, thu~ allowing faster access to ftles. The introduction of the 1764 RAM Expan~ion Unit has made RAMdisks possible on the 64, but since the authors of Super-C have not yet seen fit to create such a capability, it h~L<; devolved upon hacker-. to crowbar it in. Installation problems The 1764 REU IS sold wtth KA \1005 !>Oftware that emulate~ a Commodore di'>k drive. In order to make a RA.\1disk simple enough for anyone to in'>tall, tt is highly desirable to make use of thi' softw:are rather than expand the C-<>hell. Simply serring up the RAMDOS before loading the C-'>ystem won't work. since rhe autoboot pan of the C-shell program overwrite:- the vecton. in~talled by RA \1DOS. Therefore, to avoid excel>l>i"e modification of the C-~hell, KA \tdi~k mu!>l be in~ tailed from within the C em ironment. Once the RAMDOS i~ enabled, the memoryre~ident interface page and the altered '>)Stem vector:- mLLst be protected from the C shell and C program~. Using install.c The

program (Listing I) will execute Commodore's RA~IOOS in~tallmion program from within the C environment and optionally copy the C development program!., cc, cl and ce to the RAMdisk. h also change~ the top-of-memory pointer to protect the R\MDOS interface page ($CFOO-$CFFF). This program can be run at any time, but be <,ure the 1764 is installed! Type the program tn, compile it and ltnk it with the library file lihc.l. use \60 for the top memOr) page. Have your 1764 R\\1DOS tnstallatton progmm hand) (the late-'! one b ramclolM.bm-1.2). Run the progmm and msert the RA.\IDOS iru.tallation dbk when prompted. If )OU want to copy the C development files. have )OUr original Supcr-C d~t.. handy too. These tile!. arc coptcd with an a\'>emblcr language subroutine because the in,tall progmm is destroyed when the C programs are loaded. (The :t-.-.embl) -.ource ts tn Lt~ting 2 - it's included only for the cunou,. You needn't type 11 in because it'~ included in l "ling I ) Once the transter " complete. the program restan, the C shell ,md )<lll're ready to go.

34

11Wull c

a no-fnlh program: error checking is minimal. If )OU Iit..e pretty colour~. fancy menu~ or hone~t-to-goodness error checking. feel free to add them yourselr. Thi~ i~

The astute reader may have noticed that the program moves the top memory page down two pages to $CE rather than $CF as one might expect. This is made necessary by a bug in the C compiler: i1 makes a wild POKF in high memory when i1 ~1ans up. onmtlly it land~ hann lessly in an unu~ed addrel.'> tn t/0 space. With 1he memory top moved down. though. the progr.tm clobber-. the KA~mos re!>ident program. If you don't mtend 10 U!>e the compiler when the RA\1dbk i!> enabled. you may change the top page to SCF. ln fact, all but the largest C program'> will leave this area alone. Just to be safe, though. you '>hould re-link your C programs (includmg the C program<> found on your Super-C di-.k) \\-ith the new lower memory top. R AMdisk entomolog) The RAMdi!.k is. ala'>. not a perfect lit. The RAMDOS program differ~ in some subtle ways from 1541 DOS, and there are a few outright bugs to boot. The dtfference that concerns us here is the u~>e of di~k channel one, the SAVF channel. Thts channel is treated specially by the 154 1 oos. It a:.sumes that any file opened on this channel is a tile to be ~taved and creates a write tile. The 1764 treat\ thi~ !.ave channel like any other channel: it know~ whether the file il> a save file because it knows when your program called SA\t.. r<tther than OPCN (they are different entry point~ in RAM DOS). The C Editor and C Linker both ereare output files by mean~ of thi., sa' e channel. Why? Simply because it saves them the trouble of appending ¡" 10 the tile name. When the editor .,aves your -.ource file it open~ the ~ave channel u~ing a ftle name such a-, source.c,u. The 1541 lnow!. thi'> is a write file and treat.\ it accordingly. RMtDOS. however, treah all ftle ... not explicitly opened for writing (i.e., not opened through S.\\ r and not suffixed with ,w or ,a) as read ftles. If the tile e\1\1'>, RAMOOS wtll open it for readtog and then ObJeCt when the edtlor trie' to write to it. If the ftle doe,n't e>.t\1, the KA\1DOS wtll return. "62.file not found". Fortunately, we can a\oid Lhb dba-.ter without Transactor


Ox9lbd, Ox20c0, Oxffd2, Oxdc9, Oxf5d0, Ox5d4c, OxllcO, Ox2049, Ox4143, Ox274e, Ox2054, Ox4f43, Ox5950, Ox4320, Oxd43

surger) on the C file~ by appending the missing letters to rhe file name ourselve!.. );

To ~a'e a -.ourcc file to the RA'I.1di~l.. you need to append·'' to the lite name. Thi~ 1-.ccp~ both the editor and RA.\IDOS happy. The C linker engages in the ~me 'icc: it tric!> to SAVE your object program through OP£·'11. Therefore, to create an object file on the RA \1dt <,k you should append •P•" to it<> name. The RA \100S program -.rore' all file' conuguou~l ) in m memo!) rather than tmitaung a random acce~~ tract.. and ~ector configumtion. Thi~ mal..c!-> for unprc~~·' ely f;c,t loading but can make tr<~uble in program~ that ~rite to more than one file at a time. Every time )OU append to a file. all the files stored in higher memory mu~t be mo,cd up to accomodate the new data. If your program is ~n11ng to 'everal fil es. it may take longer to run than if the file~ were on a tloppy disk!

IWJI()

I f=S!DIO: w!ule (f==S!DIO) (

puts ( \nliiSut disk v1tb RAIC)()S '); puts (' boot proqru in dnve 8 \n'); puts ('Thtn press a iey\n"); getchul) f=fopen (" rudos64 .b1n••, •r, p'); 11 11

You can avoid all thc~e problems if you u~e the RAMdisl.. a:. you would u~c your original Super C di:.l..: it :.hould be set up as drive ·a· (device 8). contain all the :.ystcm file~ (compiler. libraries, etc.), and in general be treated as a read-only device. This setup will make program development much less aggravatmg. since you may now eschew disl..-swapping and the grindingly -.low proces\ of compiling and linking. ~ithout the heartbreal.. of reah7ing ) ou forgot to sa\ e your day\ work to a real dt~l.. before you -.hut the computer oft.

= (int)

fgetc (f); I= ((int) fgetc (f)) « 8;

if (a!=Ox6300)

I puts('\nRAMDOS intallation progru not found.\n'); fclose (f);f.STDIO;

I else I l

lf (1 = 0)

The usual di ~claimcr~ ...

(

I have tested thts program on my o~ n cop) of Super-C V"!. (the startup screen show' #2.02) and ~llh my cop) of Commodore's RA\1DOS \er-.ion 4.2. Earher versions of RA\1005 have ~ome ~eriou\ bugs that can cm:.h ) our computer at any time. If ) ou don't have the late:-.t ver:.ion you can get 11 from Commodore. or it can be downloaded from :.orne online service:. including Compuserve (CBMCmt LIB xx) and QuantumLink. I have no reason 10 belie\ c this program \\ill work with any other verst on of Super Cor RAM DOS.

linclude •stdio.b'

l ,

progtul82)

Ox43d, Ox2a9, Oxffd5 Ox6e0, OdbS, OxlaO, Oxffbd Oxlh4 Ox43c9, Oxa908, Ox384c,

I I fclose (fl; do

I

puts("\n!nter dtsirtd device I (8·14):'); scanf(' \d",&l) ;

/* set-regs progru at $6200 •!

z

Ou084, Ox9f&2, Ox62b0, Oxf8d,, Oxdlb. Oxb&20 Oxla9 Ox2ba9, Ox5d0 Ox8d4c, Ox4cc0,

Ox6200) =0&~9; Ox6201) z (char) i · Ox6202) =Ou2· Ox6203) • Oxcf (' (char' ) Ox6204) =Ox4c (' (char•) Ox620S) • Ox06 (' (char' ) Ox6206) = Ox63

(*(char*) (*(char*) (*(char*) (*(char*)

cbu c, •a·

I

)

putchar(CR);

file f ·

lilt

pats( \nl can ·t read the lWIDOS proqru. \n') : fclose (f) f:STDIO:

I vh1le (1<8 II 1>15) ;

Listing 1: insw/l.c

lilt

fqetf (1, 4x2000 f)'

z

Ou9c0, OxcCaO, Ou211, Ou6c9, Ox6cf7, Ou9ff, Ox2b85, Oxd820, Ox4Sa9, OxcOaO, Oxc07e,

Volume 9, Issue 5

Oxu08, Oxbd20, Ox8a00, Ox52d0, Od OI Ou202, Oda9 OxbOff, Ox6f4c, Ox54c, Oxcc20,

Ox20a8, Oxffba Ou9ff, Cx2000, Oxb67d, Oxt808, Ox77bd, Cx9dc0, Ox»d Oxutf, Oua9f, Ox20c0, Ox2c8S, Ox13a6, Oud21, OxcOaO. Oxc9c0, Oxd045. Ox4cc0, Ox400, Oxa2ff, Oxe8ff,

t• ldt I

•/

/* deVlCI !• ldx I

•/

, . ptqe

•/ .,

, . jlp

.,

, . <$6306 , . >$6306

., .,

t• execute IWClOS 1n1t proqru •I all((char*) 016200).

I* restore C ayst•'• IIIli nctor */ Dillon();

35


I• set

new moory top

*I

••

*(cbar* )Ox04 = (char) Oxce;

;

. •

~tcb

fast loader

puts('\flinsert C·syst• disk in drivt 8 and press a by. \n\n'); CIIOVt ( (char•) 01cO OO, 170, proqru) ·

clc ldx IO tu loop adc ~tch 1 ill1 cp1 16 bee loop Clip l$t6 bee error loop2 lela n~tch·l, 1 sta ~tch·l 1 de.t baa loop2 JIP (prstrt)

gUchar ();

; when it finishu, fast

puts('\n!WilOS 1nstalltd.\n'). puts ('\n\nDo you wub to 10stall C Syst• hles' 'I: do c

=qetchar ()

whll t (c

Ia

y' ' ' c

Ia

' n');

putchar (c) put char (Cl);

1f (c = ' y') (

call( (char*) 01cOOO);

I* 1ubroutine does

not return */

I puts(' Press a key ... ');

return rudev lda dsvnua tu ldy 11 jsr tttlfs

I

ldx ldy jsr lda

f<nllll f>nllll

Listing 2: source code for ML ill insrall.c

sta

lela

· loader for Iudden ; 11sta h l u

st• ldlt

.

ldy lela

'

clrcl:n = $ffcc chroat = $ffd2 l oad = $ff4S nut

,c shell ·in fut lolder ,c prq atart eddr ;save paru ;in11dt 1nterf pq

tryl

• • $c000

:uecute loadtt

ntna l<pntrt txttab l>prstrt txttab+l $13 $14 l<txttab

; rudisk dvc

·prq btqinl . at pntrt

Cut loader luves ;and addren ~re

0

.•

start lela I ' c'

sta nut+l

;file n&M ;it ' cc'

;editor ; linker ;continue

••

~tcb

jlp cboot

; reboot c shell

jlp return jlp error

; new code for ; fast loader

; pr10t error .ess•qe

. '

restrt lela 18 tu

tay

error

clrcl:n lela l$ff

loop)

ll1.l

)lr

lela uq,1 )lr chrout · hlt to copy

Clip l$d

l>ciM

)lr Mtna

lda 10 ]II load bca error

: COipil&r

I

; read in fast loader

jsr aetlh lela 12 ldlt 1<11111

lela IWII+l Clip I' c' baetryl lela I' e' jlpn Clip , . e' bne done ldal' l ' sta n~~~e+l jlp restrt

don•

; call entry pt

36

·send control ·blcl: to •

jsr "" bcs error

ldy

new code to

.

12

.•

chbua

lds

'

chedsua to tlllu.re your 'ftrllOC utchts IWit

; loader will jump here

qetchar():

"" • $ffd8 sttlfs = $flbl setJwt = $f fbd c:boot • $0400 ~tch =$08b6 prstrt " $0801 txttab. $2b dsvnUII c $cf05

CC~~p~~te

uq Dill

bee loopl J11P next .byte 11, ' 1 can', 39,' t copy ' .byte ' cc' ,$d

.end

Transactor


Super Numbers III Sticky variables for C128, C64 & VIC-20 •

by Richard Curcio

Havmg successfully modified Superlllumbers to run on my \IIC-20, I decided to attempt a CJ28 conversion. lf you're unfamiliar with SuperNumbers, it is a neat utility by John R. Bcnnerr which appeared in Transactor, Volume 6. Issue I back in July 1985. It provides the C64 with a new class of numeric vanable. These new variables, which are single letters preceded by the Briti~h pound symbol ( £ ). have fixed locations in memory and are mvulnerable to program failure. CLR, and re~et. They are abo faster variables -;ince BASIC doesn't have to search through its other variables to find a particular supernumber.

Twenty-six new variables is plent). Be~ides. there i<> another way to get more than 26 supemumbers. This is one reason why the new CLRRAM subroutine is seemingly more complex than necessary. Stay tuned.

The "rn'' in the title of this art1cle reflects the inclusion of three versions of a new SuperNumbers program. for the C 128. C64. and VIC-20.

For these new conve~ions. I had to get around the fact that the assembler I was using. LADS64, doesn't have a WORD pseudoop. The original routine contained a table of 26 two-byte values representing the addresses of the 26 five-byte supernumbers. I couldn't use BYf since LADS only acceph decimal and ASC. not e>.pressions for that pseudo-op. and I d1dn 't know what the table entnes would be until the whole thmg was assembled.

C~fVIC-20

On re-examining the original source program. I noticed two nearly identical sections of code. These 1 combmed into one \ubroutine in the new source listings labelled, not un· expectedly. SUBRT'l. This gave me room to add some simple vector management to the initialization. When Superlllumbers 1\ mnialized. the contents of !ERROR is stored at REAl ERR, then II:.RROR is changed to point to 'IEWERR. If !ERROR is already pointing to NEWERR, the initialization exits. This allows SuperNumbers to co-exist with another error-intercepting wedge. The contents of the vector IEVAL, however, are !>imply replaced by ''EWEVAL. In the original article, the Editor noted that there are apparently more than 26 supemumbers (SNs). The routine will accept £1. £@ and even £<shift-a> . Unfortunately, these extra S\s are located outside the area of memory that the machine language set aside for the 26 alphabetic s~s. If the area is unu~ed. no problem. If, on the other hand, that area of RAM is being used by another routine. assigning a value 10 £% or £• could cause bad things to happen. Like a crash. The call to the R0\1 routine CKALPH, near the stan of SUBRT'i, return~ with Cafl) -.et if CHRGET found a letter in the BASIC text. The BCS around J\>!P SYNTAX en~ures that SuperNumbers will only accept the 26 unshifted alphabetic characters. Volume 9, Issue 5

My first VIC convef!lion was done the 'hard way'. The original BASIC loader was run with a protected area of VIC memory as the destination. I then POKEd the RO\.i calls and absolute addresses with the proper values. (Incidentally, VIC\ location for MEMTOI really does have the two middle digits transposed from the C64 location. That's not a typo.)

The table was halved 10 26 single-byte values. SUBRTI\ adds the appropriate table entry to 'l-MS to find the location of the supemumber BASIC is looking for. There is a slight loss of speed using this method. However, this kept the ML, with the added vector management, error check. and longer CJ RRAM from growing much longer than the original routine. In fact, the C64 and VIC versions are two bytes shorter - 163 bytes. LiJ...e the original, these routines require an additional 130 bytes immediately after the ML to hold the 26 5-byte floatingpoint £ variables. C l 28 For the C 128, my Intention was to store thP ...:w variables with the ML in BANK 15, RA.\1 0, and gain mo'" ·1eed by avoiding the bank switching the interpreter perfon ·tween program text in RAM 0, and variables in RA'vl I. BA<' 7.0 would meet me onJy half-way on this brilliant idea, w1 hngly returning values from RA'>1 0, but refusing 10 store values there. With much grumbling. I made the necessary changes <tnd placed the new variables high in RAM I at $FF45. This art>a i' immediately after the IRQ, M11 and reset preliminanes lhe sysrem

37


copies to all hank~. i'>olated from normal variablel. and unused by the sy~tem. Knowing the storage location should have eliminated the table entry question. The lookup-and-ADC method wa~ retained for reasons that \.\ill be explained :.hortJ).

value~

corres[X>nding to the lov. h) te and high byte of the '>tart of the new ~toragc area. !Ob' 10u~ly. £ vanables can't be used for thc~e POii.LS.) If enough memory has been set a...ide for the purpo~e. B \SIC subroutines could have their ov..n set!> of supernumbers • local 'ariable~ like higher le' el laneuaee!.. Local supemumbers could be pas<,ed to the main program (the global variables) b) A = £.\.Two POii.Fs JU'>t before the '>Ubroutine returns will restore the tiN storage area or <In) other set of <>upernumber.,. ~

The ~ource hstang for C 128 SuperVumhers is very similar to the C64/vtc veNon. The Ct RRA\1 ~ubroutine is longer because of the need to use the Kernalt\oDS lA routine to get at the other bank. A'> noted. though ASCFLT ,., located at $8022. en!T) at S78E3 perfornl'> a needed e\tr.l Mep. Tlm e:Hra Mep is v. h). if the variable i'> not a supernumber. "ODIGJr jumps 10 OLDE\ AL + 14 in the 128. and OLDLVAL + 12 in the 6-l/VIC source • listing. • Even with the unavoidable bank '>Witching, C 128 supernumber; are con'>iderably faster than normal variables. especially so in FAS r mode. One thmg the 128 really needs is faster

~

SupcrNumhas· 'cold' ~tart clears the '>torage area pointed to by sn +108 and <,n +110. If SupcrVwnhas i-. the only error wedge in place. or the liN in a chain (the last one enabled), COLD can be called again to clear the alternate Morage area. The CLRRA\1 routine can be called separately with sys sn +11 9 on al l three versiOns.

variable~.

Finally

The Loaders

Thanks must go to John R. Bennett for making his program available to Transactor reader:.. Converting hi!> original work from the C6-l to the C 128, making changes as I encountered ob <>tacles along the wa), provided me v. ith an mteresting project.

All three loaders will relocate the \1L to an address of your choice b) changing the variable •m in line 120. The VTC version POKFs the ML into R\M in Block 5, the slot for auto-start cartndges. For other VK -20 locations, the u~ualtop of memof) lowering POKE\ should be performed before running the loader. C64/VIC SuperNumber:. requires 293 bytes for the \1L and variable Morage. The loader for SuperNumhers 128 puts 173 bytes of ML at address 4864/S 1300. in the ·application'>· area. The £ variable area defaults to 654 W~FF45 1n RAM I. However. all three versions can have their variable'> elsewhere. which brings us to the next topic. More Than XXVI The lookup-and·ADC method of finding the address of a £ variable had the happy side benefit of allowing the storage area to be moved with just two POKEs. By performing these POKE:-. on the fly. SuperNumher.\ can be made to have more than one ~et of variables. If sn equals the start address of the routine, the low byte of the storage area i~ contained in sn +108, and the high hyte m 1111 +110. PEEK these locations and put the value~ into normal variables if you intend to restore the default storage area. For the 128, the \lorage area num be in RA \1 I. Setting aside memory in RA~t I i' \lmple enough. Locauons 47/48 contain the pointer for the '>tart of variable~; and 57/58, the pointer for the end of '>trings. In direct mode. or at the stan of a BASIC program. before an) \ ariable~ .tre .c.signed. poke .t7, 0: poke 48, 5 rai~e~ the nonnal '>tart of variable!> by 256 bytes and poke 57, 0: poke 58, 254 lowers the end of strings by 256 bytes. These POKE.\ hould be followed by CLR. When }'OU want to '>\.\itch to a d1fferent set of supernumbers. your program would fir'>t POii.t:. sn +J08 and so +110 v..ith the 38

~

Listing L: Soune./28 - I \DS format 1000 •: $1300 ; cl28 .oliJ 1010 . 1020 .d anl28 ob) 1030 .s lOCO 1050 npetlllllbers renuted 1060 1070 adapted by r curt10 1080 · fr<~a a proqn:a by )OhD bennett (tOl. 6. 1u. 01) 1090 1100 ·lads for.at 1110 1120 . 1130 chrqet • $0380 1140 ; 1150 valtyp • $Of 1160 intflq =$10 1170 ; 1180 ierror =$0300 1190 ieval =$030a 1200 ; 1210 o1deYal • $78da 1220 ; 1230 •routine which sttl carry if aCCUIIUlator holds a l«tter 1240 culpb = $7blc 1250 • 1260 · routille to 1o.d facl 111th nullbtr in na1 pointed to by a, y 1270 .estol =$7a85 1280 . 1290 routine to ch&Dge ucii to flo.tlnq po1Dt 13GO ascf1t =$7!t3 1310 rout1ne ia rully at $8d22 entry litre hut perfoms ldx l$00 1320 . 1330 1340 syotu =$796c 1350 1Ddsta a $ff77 1360 . 1370 nuas : $ffC5 ;storage for \ vu1ables 1380

Transactor


1390 cold 1400 1410 wara 1420 1430 1440 1450 1460 1470 ~ 1480 1490 1500 1510 1S20 1530 1540 1550 1560 1570 leave 1580 1590 . 1600 newerr 1610 1620 1630 1640 • 1650 realerr 1660 . 1670 found 1680 1690 1700

mo

li20 1130 eeweval 1740 1750 1160

jar clrraa ld& ierror ldy mror+1 ap l<newerr bnt chngyec cpy l>newerr beq leave at& rulerr+l sty re&lerrt2 ld& l<newerr ldy l>newerr at& 1error sty urror+1 ld& t<n-al ldy l>ntwtVal sta' itval sty ievalH rta

cpx Ill

; zero atorage ar11

; teat itrror alrudy ;po1nts to newtrr

2260

:syntu ?

bne realerr beq fOWld

; not aupernWDber

jsr sobrtn ldx 10 atx valtyp stz intflg rts ld& 10 sta valtyp )It chr9tt bcs nodlg1t Jill ucflt

1170 1180 ; 119D : 1800 nodiqit Clp 1"\" 1810 btq founOl 1820 Jill oldf'Tal+U 1830 ; 1840 • 1850 fOWidl JSr subrtn 1860 jmp umtol 1870 ; 1880 ; 1890 subrtn jsr ehrget 1900 jar ckllph bes okay 1910 jrp syntu 1920 sbe t •a• 1930 okay 1940 tu 1950 JSr chrget 1960 nUildx ld& l<nuu 1970 ldy l>nlaS :980 clc !99D ade ad4tab,z 2000 bee elldJ1lb 2010 10y 2020 w!sub rts 2030 • 2C40 2050 clrraa 1dl tO 2060 jn nlaldr 2070 sta $e3 20!0 sty $c4 2090 ld& l$c3 2100 sta $02b9 2110 ldy 1$00

Volume 9, Issue 5

2270 2280 2290

zero

ld& 1dl jar illy cpy bnt rts

1$00 l$01 ind&ta

; byte to atore ;bank 1

1130 zero

. ·table of values astd to calculate address of lllplrnUibtr addtlb .byt .byt .byt .byt .byt .byt ;

0 5 10 25 30 35 50 55 60 75 80 85 100 105 110 125

15 40 65 90 115

20 45 70 95 120

Listing 2: Source.M1·- LAOS format

Clip ,., .

jmp $ffff

2120 2130 2140 2150 2160 2110 2180 2190 2200 2210 2220 2230 2240 2250

; DOt auperntllllbu

;get character ; aake sure its a letter

; po1nt to next ;calculate address ;ot supern=ber

; set supernlllbers ;to 11ro ;set up pointer ;counter

•c

1000 $c800 ; c64 .org 1010 ; 1020 .d sn64 .obj 1030 . s 1040 ; 1050 ; supernWIIbers revinted 1060 ; 1070 ; adapted by r. carcio 1080 ; fro. a progr&a by John bennett (vol. 6, iaa 01) 1090 ; 1100 ;lads foraat 1110 ; 1120 ; 1130 chrget a $0073 1140 ; 1150 valtyp =$0d 1160 intflg a $0. 1110 ; 1180 ierror • $0300 1190 if'Tal = $030a 1200 . 1210 oldeval s $ae86 ; $ce86 for nc 1220 . 1230 ; routine which sets carry if aCC1liiUlator holds a letter 1240 cb1ph = $bl13 ; $dll3 for v1c 1250 ; 1260 ; routine to load flc1 Wlth nuaber pointed to by a, y 1270 . .tol c $bba2 ; $dab2 for nc 1280 ; 1290 ; routine to change ascii to floating point 1300 ascflt =$bcf3 ;$dcf3 tor vic 1310 ; 1320 ; 1330 ; 1340 syntax =$af08 ;$ef08 for vic 1350 ; 1360 ; 1370 ; 1380 ; 1390 cold jar elrraa ;set ra. to zero 1(00 ; 1410 wara 1d& ierror 1420 ldy ierrortl 1430 Clip l<oo~trr ;tttt 11rror already 1UO bnt chnqvee , point a to ntwerr 14SO cpy l>aewrr 1460 beq leave 1470 chngvec sta realerr+l 1480 sty realerr+2 1490 lda l<newrr 1500 ldy l>newtrr 1510 st& ierror 1520 sty ierror+1 1530 ld& l<newval 1540 ldy l>ntwtval

39


1550 1560 1570 1580 1590 1600 1610 1620 1630 lUO 1~50

Listing 3: C 128./dr

ata itYal aty ieval+1 rta

lent ; ; newen: epxl11 bot realerr

;ayntu"?

Dl

asp ,., •

ID JB

• btq found

;

re&lerr JIP $ffff

. 1670 fOCDd )Sf aubrtll 1680 lda 10 ttlt 1'altyp 1690 1700 atx 10tflg 1110 'rta 1120 ; mo newva1 ld& to 1740 sta nltyp 1750 )It chrqtt 1760 bet nodigit 1110 JIIP mflt 1780 ; 1790 ; 1800 nodigit aap t "\" 1810 btq foundl 1820 ~ oldeval+12 1830 ; 1840 • 1850 foandl )tr auhrtn 1860 JliP .Col 1870 . 1880 ; 1190 suhrtn )II chrgtt 1900 )It c:b1pb 1910 bc:a oby 1920 JIP ayntu 1930oby abc: t•a• 1940 tu 1950 )It chrgtt 1960 nuudr 1da l<nuu 1970 1dy f >lllal 1980 clc adc: adiltah ,x 1990 2000 bcctndauh 2010 lDY 2020 todsub rta 2030 ; 2040 ; 2050 clrru lda IO 2060 jar nuudr sta $c3 2070 2080 aty $e4 2090 txa tay 2100 2110 zero sta ($c3),y 2120 iny 2130 cpy 1130 2140 bnt nro 2150 rtt 2160 . 2110 ; 2180 . 2190 2200 · tlble of ,.&lues astd to 2210 ·addreaa of aaparo~r 2220 2230 adiltlb .byt 0 5 10 2240 .byt 25 30 35 .byt 50 55 60 2250 2260 .byt 75 80 85 2270 .byt 100 lOS 110 2280 .byt 125 2290 ; 2300 nuaa .byt 0

; not supemlllber

16~0

40

MI OL DO 80

01 !II

JI

GB CB

n

CJ

DB MK &L

KJ

; not auptrnUIIIbtr

EN AI

n PJ

LO ; not auptrnUIIIbtr

JO E!' AI BP BP 80

00 ·gtt chancter · Ht carry 1f letter

LJ

OB 00

GD Ill EG

; po10t to next ; c:alculatt address ;of aaparoUiber

PI l!ll

EJ ICl

00

BN DP NJ !J

; get start of ttoraqt

00 liB

II

r•

100 t t t superoullbtra !Older t t t 110 rll ttt c128 'fttllOU '** 120 snz4864 baok1S:r. nll relocate 130 ck=O 140 rtadd:ck&Ck+d ifda999tbtnl60 150 goto140 160 ifck<>15872thtnpr10t"trror 10 data":end 170 restore 180 Dl•Sll 190 readchfd=999tbtn240 200 ifd=>Othttpekena, d:qoto230 210 ad=sn+aha(d) :qoauh3SO 220 pokena, lb:oaona+l.poktoa,hb 230 na=na+1·qoto190 240 ad=sn+44:qosuh3SO 250 poktan+10, lb:pokesn+24, lb 260 pokean+14,hb:poktan+26,hb 270 ad=an+6S:goauh350 280 poktsn+34, lb:poktsn+36, hb 290 r111 300 rill 310 print"aupernUIIIbtn installed":pnntan"to'na-1 320 print•eo1datart • aya •an 330 print•wuutart • ays"an+3 340 end 350 bb=ld/256:lb=ad·1Dt(ad/256)*256:rtturn 1000 data 32, -119, 173, 0, 3, 112, 1, 3 1010 data 201, 44, 208, 4, 192, 19, 240, 26 1020 data 141, -53, 140, ·54, 169, 44, 160, 19 1030 data 141, o. 3, 140, 1, 3, 169, 65 1040 data 160, 19, 141, 10, 3, 140, 11, 3 1050 data 96, 224, 11, 208, 4, 201, 92, 240 1060 d&ta 3, 76, m, 255 32, -90, 162, 0 1070 data 134, 15, 134, 1~. 96, 1~9. 0 1080 d&ta 133, 15. 32, 128, 3, 116, 3, 16 1090 data 227, 120, 201, 92 240, 3, 1~, 232 1100 data 120, 32, ·90, 1~, 133, 122, 32, 128 1110 data 3, 32, ~o. 123, 11~, 3, 76, 108 1120 data 121, 233, ~s. 170, 32, 128 3, 1~9 1130 data 69, 160, 255, 24, 125, -148, 144, 1 1140 data 200, 96, 162, 0, 32,·107, 133, 195 llSO data 132, 196, 169, 195, 141, 185, 2, 160 1160 data 0, 169, 0, 162, 1, 32, 119, 255 1170 data 200, 192, 130, 208, 244, 96, 0, 5 1180 data 10, 15, 20, 25, 30, 35, 40, 45 1190 d&ta SO, 55, 60, 65, 70, 75, 80, 85 1200 d&ta 90, 95, 100, 105, 110, 115, 120, 125 1210 data 999

1

I

Listing 4: C64.1dr MI 100 rea ••• aupernumbera loader ••• NO 110 r.. ••• e64 veraion ••• FA 120 sn=S1200:rem will relocate

BO OK LD BC 01

ealcabtt 15 20 40 45 65 70 90 95 115 120

Ill JI GB 08

n CJ

DB lilt

lL IJ

;storage ttarta bert

EN

130 c:k.O 140 readd :c:k=ck+d:lfd=999thtol60 150 qotol40 160 lfck<>l5585thenprint"trror 10 data" :tnd 110 restore 180 oa=sa 190 readd:lfdo999tb&D240 200 lfd=>Othtnpokeoa,d:qoto230 210 adata+aha(d) :qotuh350 220 pokeoa lb:oaaoa+l pokena hb 230 oaona+1 .qotol9n 240 ad=sa+44 goauh3SO 250 poktsa+lO, lb.poue+24, lb 260 poktsn+14,bb poktsn+26,bb 270 ad-aa+65:qoauh350 280 pokesa+34,lb:poktan+36, bb

I

'

Transactor


~

80 PJ U>

JD 17

AI BP lP 05

00 OP 08 00 LB ~

IJ

J:

ra

JJ

J

IG PO Jl

IlL

OL &!'

00

290 ld=sn+l64 :gosub350 300 pokesn+l08, lb:pokesn+llO,hb 310 pnnt' sqltrnu.bets l.llStllltd 'Ptllltsn•to' lll-1 320 prlllt 'eoldstut =sys sn 330 prlllt'wuutart =sys Sllt3 340 end 350 hbold/ 256 lboad-int(ad/256)*256.return 1000 dsta 32, -119, 173, 0, 3, 172, 1, 3 1010 dsta 201, 44 , 208, 4, 192, 200, 240, 26 1020 dsta 141, -53, 140, -54, 169, 44, 160, 200 1030 dsta 141, 0, 3, 140, 1, 3, 169, 65 1040 dsta 160, 200, 141, 10, 3, 140, 11, 3 1050 dsta 96, 224, 11, 208, 4, 201, 92, 240 1060 dstl 3, 76, 255, 255, 32, -90, 162, 0 1070 dsta 134 13, 134 14, 96, 169, 0, 133 1080 dstl 13, 32, 115, 0, 116, 3, 76, 243 1093 dati 188, 201, 92 240, 3. 76, 146, 174 1100 data '32 -93, 76 162, 187 32, liS, 0 1110 dat1 32 19, m m, 3. 76, 8, 11s 1120 dsta 233, 65, 170 32, 115. o. 169 164 1130 dsta 160, 200, 24, 125, -138. IU, 1 200 1140 dsta 96, 162, 0 32, -107, 133, 195, 132 1150 dsta 196, 138, 168, 145, 195, 200, 192, 130 1160 data 208, 249, 96, 0, 5, 10, 15, 20 1170 data 25, 30, 35, 40, 45, SO, 55, 60 1180 data 65, 70, 75, 80, 85, 90, 95, 100 1190 dati 105, 110, 115, 120, 125, 999

Listing 5: •·ic.ldr III 100

II PC BO 01 LD Dl 01 Jill JI

G8 CB

u

CJ D3 Ill ll IJ

II GJ

BO PJ U)

JD

t l

EF A! BP MP 00 00 Oi 01 OD tl ~

J;

8D CB JJ II! PO

rr

1L OL 17 00

ra *** rapernUiben loader ***

110 til ••• vic 91rsion *** 120 st:o40960:ra will relocate 130 cPO 140 rudd.ck:c.i+d.ifd=999thenl60 150 goto140 160 ifck015600thenpnnt'error iD dsta•:end 110 restore 180 na•an 190 rtadd:ifd=999then240 200 ifd•>Otbenpokena.d:qoto230 210 ad=sn+abs(d) :qosub350 220 poktn~,lb ; n~=n~+l ·pokelli,hb 230 n~•ni+Lqotol90 240 ad=sn+44:qosub350 250 poktsn+lO lb pokesn+24 , lb 260 poktln+l4 ,hb:pokesnt26,hb 270 lliaan+65.golub350 210 pokesnt34, lb:potesn+36,hb 290 adaan+l64 qosub350 300 polltsn+lOI,lb.pokesn+llO,hb 310 print'supern1.111btn instdled' :prllltln'to'n~-1 320 priDt"eoldstut • sys'sn 330 print•waraatart =sys' sn+3 340 end 350 bb=ad/256:lb=ad-int(ad/256)*256:return 1000 data 32,-119, 173, 0, 3, 172, 1, 3 1010 data 201, 44, 208, 4, 192, 160, 240, 26 1020 data 141 -53, 140 -54, 169, 44, 160, 160 1030 dsta 141 0, 3 140, 1, 3, 169, 65 1040 dati 160, 160, 141, 10, 3, 140, 11, 3 1050 data 96, 224, 11 208, 4, 201, 92 240 1060 dati 3, 76, 255, 255, 32, -90, 162, 0 1070 dati 134, 13, 134 14, 96 169, 0. 133 1080 dsta 13, 32, liS, 0, 176, 3, 76, 243 1090 dsta 220, 201, 92, 240, 3, 76, 146, 206 1100 dsta 32, -90, 76, 178, 218, 32, 115, 0 1110 dsta 32, 19, 209, 176, 3, 76, 8, 207 1120 dsta 233, 65, 170, 32, liS, 0, 169, 164 1130 dsta 160, 160, 24, 125,-138, 144, 1, 200 1140 data 96, 162, 0, 32, -107, 133, 195, 132 1150 data 196, 138, 168, 145, 195, 200, 192, 130 1160 dat1 208 249, 96, 0, S, 10, 15, 20 1170 dati 25, 30, 35, 40, 45, 50, 55, 60 1180 dsta 65 10, 15 80, 85, 90. 95, 100 1190 dst1 105 110, liS 120, 125, 999

Volume 9, Issue 5

CHIP CHECKER

• Over 650 D•g•tal lCs

• 8000 National + S•g

• 75154 TTL (Ats.as.f.h,l.ls.s)

• 9000 TIL • 14-24 Pin Chips • .3" + .6" IC Widths

• 74/54 CMOS • 14/4 CMOS

(C.hc. hct , sc)

Pressing a single key 1denttf1es/tests chips with ANY type of output in seconds. The CHIP CHECKER now also tests popular RAM chips. The CHIP CHECKER is available for the C64 or C128 for $159. The PC compatible version is $259.

DUNE SYSTEMS 2603 W1lla Dnve St. Joseph. Ml 49085 (616) 983-2352

NOTHING LOADS YOUR PROGRAMS FASTER THE QUICK BROWN BOX A NEW CONCEPT IN COMMODORE CARTRIDGES Store up to 30 of your favorite programs Bas•c & M L, Games & Utilities, Word Processors & Terminals - in a single battery-backed cartridge. READY TO RUN AT THE TOUCH OF A KEY. HUNDREDS OF TIMES FASTER THAN DISK. Change contents as often as you wish. The QBB accepts most unprotected programs including "The Write Stufr• the only word processor that stores your text as you type. Use as a permanent RAM-DISK, a protected work area, an autoboot utility. Includes utilities for C64 and C-128 mode. Packages available with "The Write Stuff." "Uhraterm Ill," "QDisk" (CP/ M RAM Disk), or QBB Utilities Dillk. Price 32K S99; 64K Sl29. (+ S3 S H; S5 overseas air; Mass residents add 5%) I Year Warranty. Brown Boxes, Inc, 26 Concord Rd, Bedford, MA 01730: (617) 2750090; 862-3675

41


Inside The 1764 REU Halfway to a one n1eg 64 I

by Paul Bosacki Thi'> article was wrinen in t\\0 parts. The lir;t hit wa~ written in early Januar) . JU'>t after the mall started to come 1n on Care and feeding of the C256. The re'>t of it was written four months later when some additional info11m11ion led me to quel>tion one of my early ~peculations. But I've left the ftrl>t part mostly as it was because I thought you might appreciate reading about the mental stretching that owning a computer bas required. Ever since Transactor published Care and Feeding of the C256. I've been receiving a little mail. Mo~t of it has had to do with my I meg 64, and how thi~; was achieved. The an~wer ltes in the marriage of two di-.unct memory expansion strategle\. The f1rst 1s <I commer(.tal 511K RAM ExpanMon Unit that use~ high \pt:ed, direct memory access techniques: the second, 5 12k of u~er installed, slower, bank-switched RAM along the line~ of the 256K project from Transactor, Volume 9, Issue 2. I won't be di-.cussing the bank switched R \M project here. That's for later. Rather. it\ the 512K Rf.li that I want to talk about. It'~ a 1764 REL. You l..now. the 256K type. There can be liule doubt that the 1764 REU is one of the mo\t significant peripherals that Commodore ever offered for the 64. In lieu of a faster processor. it is tl1e best thing going for l>peeding up an otherwise ~low program. As long. that is. a~ the program tal..es advantage of the RH. GEOS is one of those programs. And no one, I imagtne, would be foolish enough to suggest that an RF.U of some ~ort isn't necessary when running GF.OS - and the bigger the beuer. Put a 256K REl on GEOS. and you路 re soon WIShing you had 512K. The improvement an REU offers are ju~t ~hort of amaiing. This is the l>tory of curiosity and the cat, including the satisfaction part. What follows is a look inside the RF.L and. best of all. the informallon neces~ary to expand the 1764 REI- to 512K. I have heard that \Orne of th1s infonnation is ava1lable elsewhere: howe\er, it'll important enough to bear repeating. REU lnlernal s Anyone '"ho\ ever been brave enough to open a 1764 ha~ been greeted '~ ith a few vcf) intriguing word\ on the printed circuit board: C 128 RA~t F.xpan'>ion. It seem-. that Commodore uses one RF.C' (RAM Expan~ion Controller) but populates each

42

Rf.L with 'ary:ing quanti tie' or types of RA \1 Sun ply put. the 1764 i~ a 1750 RF.L ""ith only one bank of 41256-15 DRA \1 and a different name Menciled on the case. ln fact, the 1700 REI- ts different from tt~ beefier ~ibling~ only in that it u~e\ the 4164 DRAM rather than the 41256. But all that 路~ intriguing doesn't \top there. At the lower right of the PC board ts an empt} lay out for a 28-pln chip: either an 8. 16 or 32K FPR0\1. Close 1m.pection of the board reveab that the data bu~ and the low 13 uddrc~s line~ arc broughi out to the layout. A\ well, Al-l can be \elected by re~etting a jumper on the board. Of the two EPR0\1 ~elect line~. one is directly con nected to the RFC: the other I\ connected to ground. Yet. how the ROM is accessed by the 64 1s a partial myMery to me. Let me outline some of my ob~crvations. Fir..,t. the REC itself select<; the EPR0\1 in re~ponse to a low on either the /R0\1H or R0\1L line of the cartridge pon. There'll a fly m that ointment though. A cartridge signals the presence of an rPRO\t to the C64 by pulling low tbe /LXR0\1 or /GAMT line {or both) of the expansion port. These lines arc directly connected to the PLA and default high. But, the /FXROM and /GA!\.11 lines are not manjpulated by the REU. Put another way. the fPROM won't be selected becau\e the REL ha'>n 't indicated to the 64 that there\ an EPR0\1 pre\ent! Now th" confounds me. Why the layout for an EPROM, but no way to access it? There are two possibilitiel> here. One. I'm rnl\\ing o;omething ob\ious. Or two, an early des1gn aspect didn't make it all the way to the production stage~. You sec. it IS po-;..,ible to ~elect the EPROM. but we have to cheat. On the IU路t board. connect the JEXROM line to ground. An SK EPROM is then selected in the $8000 range. Or connect the /GA 'v!E line to ground along with /EXROM to allow a 16K II'RO'vl. Now an !.PROM would be selected from $8000 to SBl H. llowever. '"e're alway!. going to be out 8K of syMem RAM. And in the ~econd c:be. we muo,t supply BASIC, however modified (otherwi-.c, why bother \\ith a 16K EPROM'?). peculat ions ow, here路~ a p1ecc of spcculatton for you. The EPR0\1 ..., obvioul>ly selected by the REC' based on the ~tutus of /RO'v!L

Transactor


and /R0'-111. But if the EPR0\1 were always to be ...elected. wh) not connect the lines directly to the EPR0\1? Two po~~ible rea\On'>. eglecting for a moment that At-1 can be routed to the layout. the FPR0\.1 can be either an 8 or 16K chip. This way the RFC handle~ the decoding. Or perhaps there is the option to map in the I'PR0\1 A lool.. at the RFC regt'>ter-. reveals thm three btl\ tn the command regi,ter are marl..ed resened. Perhap' thc'>e btl'> 'er\e that functton. lhi~ mean' that an output from the REC mtght wnncct direct!} to the JE.XRO.\t line. another to 1GA\tl. B> ~cuing or clearing a bit. a IO\\ on the correspond mg. line "ould '>ignal to the 64 \\ hether an EPRO.\t were present. However. I couldn't get any combination of those blts ;o act in that la\h1on. '\gain, ma)be I'm mi<;sing 'omething.

'

Then there\ the fact that h) changing J2, A 14 can be brought out to the lPRO~t. Thi., allow' a 32K EPROM to occupy the layout. But how is the upper 16K selected? Do we again look to the su<;pect bits in the command regiMer'! h. that function somehow hidden there as well? So, what was the rPR0\1 to contain? Your guess is as good as mine. Speculation: maybe custom RFl routine~. Perhaps Commodore intended a CU'>llllll R\'1.1DOS to t"le placed there. It' on1) conjecture. And ,1\ I 'atd, 11 '>CCm'> impo"ible for the REC to ~elect the li'R0\1 without '>Omc form of intervention on our pan: i.e.. conncc.:ting either /EXRO~. or both 'LXRO.\t or GA.\1E. to ground. Then. whatC\ cr code an EPR0\1 contained would be up to the indtvtdual. unfonunately. it seems that the layout made 11 to the board but 'upporung C64 select functions didn't. Any bod} l..now for cenam? ~e 're

here to pump REUs up

Intriguing point number 3: on the solder side of the circuit board IS a jumper with the promising words: 512K-cut. When this line i~ cut, it signal\ to the Rrc that 256K bit DRA\1s are present. What this suggest\ i' that all those people out there \\-hO bought the 1700 RH I tmd now crave 512K of expansion RAM need only un.,older the two bani..~ of 416-h and install 41256~ - and cut the jumper, of course. One bank of 4125615's would yield 256K. another would take the REt.. toiL~ maximum 5121-.. However, it\ on ly fair to wam you that I have not done this, and cannot, therefore. assure you of the results. And it would be a finicky JOb de~oldering 256 pins! If anyone does succeed at this, let me know! For those who own 1764s the proees\ b s1mpler. Becau-,e the 512K jumper .., already cut. all that needs to be done is in~tall another bani.. of 41256- 15~. Fir~t. carefully di'as~mble )Out 1764 (needle!>~ to sa). such action Y.ill void )OUr \\arrant)). The case is held together b) four pla\lic posts set in !.ockets. It's best to <.tan at the e~pan~1on pon connector and pr) up '' ith a \mall o;crey, driver. Work your way around the REU as the Ca\e gives. ln\1de " the Rt- shteld whtch JUSt pnes off. then you're at the board il\elf. Compare the hoard against the drawing. If the} 're not signiticantlv the ~ame. proceed at your own ri\1... Volume 9, Issue 5

llo\\-evcr, if that j., the ca.,e. all is not lost. Checl.. a couple of thing~ out. Lool.. for the jumpe1 on the solder ~ide of the board. It'~ beneath the RfC. If 11\ there. chance., arc that simp!) adding the extra RM.,1 will worl.. even if )OUr board is different. And check for the C 128 R.\ \1 F.xpan\lon title. I can't help but feelthm'' a dead gt\CU\\3). If e'er) thing checl.. s out. look below the b<mk of 41256~ labeled Bani.. I. You w1ll 'ee the la)OUh for eight .,i~teen-pin chip': ju\t to the right of the layout\ \\ill be the words .. Bank 2 .. (another dead gi' ea\\a) ). Cle<tr e<tch of the solder pads U!>ing either a Vttcuum desolder or solder braid and install eight 41256-15s there. You 'II ''<mt to ob..ervc the usual anti-static precautions. Ground )Oursell tiN! With DR•\ \.I co-.tmg $12.00 a chip, mi..tal..es are cxpcn,ive. You rna) want to install the DR ..\ "'s 1n '>OCI..et., to mtninwe the possibility of damage. Use lo\\ profile socl..eh. With the Rl ~hield bacl.. in place. there\ just enough room. But chccJ.. tir~t. JUSt to be certain. Once the chips arc installed. you're done. Put the unit bacl.. together and pull out your copy of GIOS 1.3/2.0 or the utility disk that came \\ith }Our Rn. The RAMdisk utility from that disk will conftgure all 512K (minuo; \Orne room for code) as a R \ ~di .. l... It \ wonh nottng however. that the RI'L test program test!> onl)' the fir...t 256K. Lnder GI.OS, your option' arc somewhat \aried. Under 1.3, you can configure a RA \1 1541 and a Shado" 1541. or if) ou ha'c two 154 I \. two ShadO\\ 1541 \. L ndcr 2.0. configure a RA \1 1571 or\\ hatever. II you want to test the add1t10nal RA\1, load up a RA'I.1 1571 and clicl.. on \Uiidate. If your RA\.1disl.. validate\ then your new R.\ \1 pa,,e,. It\ not a complete te\1: only tracl.. and sector linl..' arc bcin!! fetched. '0 )ou're reall) onl:r tC!>ttng the hr.. I tv.o b)tCs of each RA \I page. However, m mo~t ca\e~. thatte~t ~tlone will tell you tf there·~ a problem. And that. ladies and gentlemen. is t~ll there i... to it. And. a~ a nice ltttle bonuo;, }OUr Rf'll i' (and alway\ has been) compatible with the C 128. As for the I-PROM. it\ one of the more curious <tl>pect., of the REU. It seem~ that much wus intended, but it was ultimately abandoned. All we're left with is the layout and the opponunity to ground /EXR0\4 or both /GAME and /EXROM. At leasL that would allow 8K or 16K of CI'R0\1. But that seems prett) poor fare when 32K is an option, and that there might be lurking there. somewhere, a more elegant '>elect mechani'>m. Following up Funn>. the \\.t} thing' change. n,e abo' e ponion of thi' article was written 111 early Januar). just \\hen it \\;c, becoming clear that a lot of people were mterested in a one meg 64. It seemed obv1ous at the ume th<lt an anicle concerning the 176-1 wa\ again due. I knew no one had e\er attacked the EPR0\1 question, and I wanted to open a fontm of 'on... Then in the Febntary bsue of Commodore Mal(crllle. Bnan Doughen} (of Berl..eley Softworl..\) stated that an LPR0\1 could ju't be

-

43


1764 Board la4out

n

C3

<>

<>

U2 .I>.

<>

<>

<>

<>

U3

U6

.I>. rv

-

VI

CT> I

-..,. CT> I

-

..,.

-

-

U7 .I>. ,...., ..,.

us .I>. ,...., ..,. CT> ..,.I

U9

.I>.

us.I>.

-..,.

-

U4

-

-..,.

<>

<>

<>

<>

<>

<>

<>

<>

-..,. ,....,

·R<I; .......

,...., ..,.

CT> I

-----

CT> I

-..,.

-..,.

.I>.

,....,

CT> I

,....,

CT> I

VI

-..,.

VI

lm~outs

E!JD 94VO

0

-..,."' .I>.

.;:,t

c: c co

CT> I

--- --- --- ----- --- --- ---- -- -- --

-- -- -- -- -- -- -- -- -- -- -pin for odditionol bonk --- ---- ---- 8*16 of 41256-15 DRAMS. Lobeled U16-U17. -- -- -- -- - -- - -- -- -- -1298A 15-87

C9

<>

.. . ...

111111111

1 • 1 I I I I I I I 1 1 • 1

"' .;:,t c: c co

I

<> C18 <> C17

I I

I

I I

RP4

RP1 fP/ CG/ Tf

Vocont 28 pin lm~out for 32k*8 bit ROM. See text.

•I J2

n2

•••••••••

RP2

C2El

C8

<>

.

RP3

C128 RAM EXPANSION FAB NO #312535 C7 C4 C5 C6

I

I

I

I

I •

I

ASSY NO. 312533

111111111

111111111

RP8

RP9

Hotes:

i) R4, present on some eorh1 1758 ond 1788's, is obsent. ii) FB2 hos become o 438 ohm resistor. 18k

Both chonqes point to the speculation thot the REU boord hos not been siqnificontly redesiqned (if ot oil) since its introduction. Question· if so, why did it toke Commodore so lonq to couqh up the 1764?

438S?.

C64 fPRDM ~elect Solutions (for the 17xx REU's)

Holtes: i) REU is shown comp onent side up.

ii) / GAME 6 /EXROM nre lends 8 6 9 respectivel11. iii) SWl

n s sh own IS n DPST nnd when c losed, mnps n 16k EPROM into the S8000 to Sbffr rnnqe. For nn 8K EPROM use n SPST SWitch on the /EXROM line . The EPROM then mnps in nt S8000.

44

F1 I I I I F1 I I I I

Yy

y

Yy

y

00000000

SWl

--0

0

CRD

Transactor


dropped into a 1764. Well. that got me going and the above is the result.

• •

Now four months later, I stil l stand by the above conclusions. But, like I said, things have this funny habit of changmg. And. 'WC learn 1n the process. I mis~ed a valuable point in the above notel>. that l>omething obvious I complained about: the 1764 is, down deep in!>ide, still a product that was developed for the C 128. And as such, the EPROM question needs to be re-examined~ Unkown to me at that time was the select mechanism by \\ hich the Cl28 'log!> in' external (and lor that matter. internal) expan ion RO\t. For the umnitiated, and those who own 64's. I'll brieny sketch it out. Ignoring the Z80 and its pan in a 128's startup routine. we are left \~ 1th only two rouunes 10 the !28's native mode: POLL and PHOL'\IX. Both routines are accessable through the much expanded KfR~ o\L jump table. On !>tan up or reset, POL! does just what its name suggests. First, the routine checks the state of the !GAMF and IEXROM lines. If either is pulled low. a go64 1s executed and we end up m 64 mode. Failing that. the internal and external cartridge \lOt'> are polled for the R0~1 signature CB\1 (at ROMbru,e+7. where ROM base equab either $8000 or SCOOO). If a cartridge is detected, its lD (ROMbase+6) is then logged in the Physical Address Table (PAT). If the ro i'> I. then an auto-start canndge is recogniLed. and its cold ~tan entr) (at R0\1 bru,e) is called immediately. Otherwi e. th1s task is left to PHOEJ\IX \.\. hich checks the PAT and then calls the cold start routine of each cartridge logged there. That's pretty much it. The /GA.\<1E and JEXROM lines are considered onl)' insofar as they indicate the presence of a C64 style cartridge. Interesting. So what does aU this mean? Bal.ically this: the EPROM slot in the 17xx REU's was probably meant for the C 128 only. Commodore's way of using the expansion port but leaving it free for further R0~1 expan~ion - clever! ln a brief experiment, I dropped a 16K EPR0\1 into my REU and plugged it into a C 128. Result: mapped in at $88000 and $98000 (the tirst hex digit is the bank address) was my EPROM. None of the fancy select mechanisms suggested Volume 9, Issue 5

above. nothing. Jlbt the 128\ \.\.ay of ched..ing who\ out there. That\ \\hy the /GA \IE and /EXR0~1line!> are left unconnected. If the) were. \.\.c'd end up with a go6-J and an Rfl.. that only worked on a C64 or in 64 mode. l\taybe those unu~cd bil'> do function just as I speculated four months ago. The format of a cartridge 'ROM signature· on the C 128 and C64 differ significantly, making them incompatible. Perhaps some incompatibility issue is resolved through those bll\. A cartridge designed for the 64 affect\ the 128 in way'> not always desired. and a 128 cartridge wouldn't be recogni.,ed b) the 64 at all! Those unused bit~· funcuon, though still h1dden, ma) someho\\ be tied up in all thi,.And where does that leave us - the 0\\ner... ol these REt:s? lf you're a C64 owner then check out the following diagram~. A s\~itch could easil)' be added to an REU that would allow an EPROM to be mapped in or out on power up or reset. Tf you're a C128 owner, just install a properly formatted EPROM.

;::;.;o-...:Systems invites you to .............. SIEUSAT warld o f

cornrnodore

s ooTH 4 09

LOS A ~GELES CONVENIION CENtEA

MAY 11·21 11119

.. Duy it at the Show .. specials .. PnlcFs IHcL u o eTAx• Ut.e. C.i.ght. tpUl with Amiga Light. Pen Driver HOW GET TOUR FAVORITE LIGHT PEN AND DRIVER BUNDLED WITII GOAPIII CS PKOS WITH

wm~

OR

bOih

ootn ror only

ror only

$I 99.95

$159.95

Big Savings on C - 64 Programs, too!

SPECIAL... PIX PAK GRAPHICS GALLERIA I & II ( 8 Di•k• of Clip Art)

s

32

SPECIAL...SUPER P AK FLEXJFONT, GRAPHICS INTEGRATOR 2 AND GRAPHICS GALLERIA I & II

s 69

=

Inkwell S,I:stems CREATOI?S OF PENWAAF•


Capitals: A Basic Quiz Program Using linked lists

• b} Jim Butterfield

The program included at the end or this article runs on: Commodore 64, Commodore 128, Plus-4, Commodore 16, 8128, PF I, C lli\1 . Do you know the capiwl cities of the fifty ~uue!> and ten provinces? Thi~ program wi II check your knowledge. ll will give you full point;, for a correct an~wer; but if you miss with ) our firM altempt, it will try to help you with multiple choices. And it gives hints. Program C-\P/1 ~1.\ j, \\ritten in B \SI C. and you might like to look at the code for -,ome mteresting programming methods. It u...cs carefull) planned educational techniques: )OU might lile to che~:k these. Since the program i~ in B \SIC. it \\ill be no ~peed demon. Considenng the \\Orl.: it does, howe\ cr. it chps along at an acceptable pace. II )OU happen to have acccs' to a compiler. you may u'e thl\ to 'peed up c \PI I~~\. When you run the program. you'll lind its operation to be fair!) \elf-explanatory. The simple BASIC language docsn 't protect again~t wild l..e) board usage for example. you could ramble around the screen u~ing cuNor movements when you were be· ing asked for an input. But it does sensible things in most cases. Educational considerations The program preM:tm stutes and provinces in 'shuffled' order. Each run \\ill be different. As written. it will go through the entire lbt of 60 prov111ces and states, but the user may respond end at an) time to tem1inate the qutL. A hint "offered to help with a future question. The hint is set to give the ans\\er to the que,tion that is four ttems ahead. An attcnti\ e student\ 'hon-tenn memory will u...uall) retatn this. When thi' leads to a corrc~:t an''"er a ltnle later. the infomlation is rcinlorccd: better learning takes place. If the ,tudent mi ...-.e., the questton. he or !>he i., offered a multiple choi~:e 'upplcmcntal) queMion. There are two kind!> of multiple chou:e . \\ht..:h one the \tudent sees \\Ill depend on the \\a) the que,tton "-U' ltN an,\\ered.

46

If the ~tudent\ reponse is "'rong. but -;Wrt\ with the correct letter of the alphabet, the computer w1ll present a li~t of all cities ~tarting with that letter. Perl1ap-. 11 was a !>pelling mistake; or, the Mudent may have the tight idea but the wrong an~wer. For example: '>Uppose the computer a~k!> for the capital of Kansa~. and the Mudent replie!> Tulsa. Since the correct answer .. tarts with the letter T. the computer \\ill li<;t all cities starting with T. On the other hand. if the ..,tudent".., re\pon'c doe!> not match • not even the fiN letter - the computer prepare\ a different l..ind of multiple choice. In th" c.ase. exactl> .,i, choice!> are presented. The computer ha' quite a ~car~:h to find ·good' choices; there may be a ..,hon pau\c here. The chotec~ will include the correct an~wer. of cour-.e. plu., another cit> m the .. arne '>tate. Whiche\'er multiple cho1ce method ;., u..,ed. the -.tudent i' a-.ked to type in the correct <111\\\er ra1he1 than a number or letter. It\ good e\ercise. <md \\ill help the memor) procc~~. If the ~tudent 't. first rc\pon-.c to <I que.,tion i'> \\ron g. but names a v"lid cit) l..nO\\n to the computer. the computer \\ill say so. For example, tl n \tudent re,pond' \~ith Tul<;a when asked for the capual of Kansas, the computer will advi-.e that Tulsa is a city in Oklnhoma. 'Jhe student irnmedtatel) receives the correct as\ociation for the city name. The DATA List You can ~honen or lengthen the list of DATt\ items, up to a maximum of 99. You can replace it completely with another set of data, for example. European counrrie., and the1r capitals. Data goes from line I(Xl to l111e !<(X): the la\t Ime sa) s DATA E'<D. \\ hich 'ignal' the computer that there arc no more item~. The format of the data '-tatemcnts is easy to foliO\\. but here are the detaib. 1l1e fir-.t item on each line i~ the ~tate or prO\incc; then the capital cit): then another city in that '>tate. The :.ccond Cll> is ohen cho~cn bccau'c 11 1s large or wellknO\\ n. but some. such ::t'> Spnngftcld or Salem. m1ght be p1cked bec•w•e of a name that matche-. a cap11al city of a different state. Transactor


I

Program Details

Linked lists

Ttu~

program carefully hooks together all citie!-. whose name start' with the same letter of the alphabet. Thus, capital cities Phoenix, Providence and Pierre are linked, a... :Jre non-capital Cities Pocatello. Philadelphia. and Portland. u. . ing these 'linked lists·. the program can rapidly search out multiplechoice candidates. More detail on linked li~~ is g" en below.

This is a powerful programnung method to hook simtlar items together. The program u~es it to link cities who>c name:> !>tart with the same letter. That makes searches much faster: for exumplc, to find all capital cmes starting with the letter T. \\-C don't need to <;earch and compare all 50: instead, \\.C follow the "T" chain.

To 'al) the order of que~llon~. a 'shuffie · muM take place a!> the program starts. Moving ~>trings around is a tedious busines~: in~tead. a table of 'quick pointers', array QO. is shuffled. Later. array, Q will tell U!\ the order in which each state or provtnce will be used. You may read the shuffling code in hnes 1100 to 1140. Note that we use random tuncuon rnd(O) once onl}. to scramble the random sequence: after that, "'e use rnd( 1) to generate unpredictable values.

Each cit) ha~. a!> part of Its data. a pointer or •hnk · to the next city that belongs in the group. At the end of the chain. there will be a zero pointer to ~ay, "no more". To tell you where the chain starts, there are a ~et of starting pointer1> for each letter.

The program starts at line 900, where it defines the arrays (tables and lists). Table S$(statc,column) gives us the ~tring value' for each state: column 0 for the state name. column I for the capnal city, and column 2 for the second city. Tables A() and LO are used to keep the linked li t~: more about those in a moment. And list QO. 3.'> "'e have menlloned, '>eh up the order m "'hich we "'ill ask the que~tions. By line 1200, we've completed reading in the data and shuflling. and we can start a~king questions. If the fir<;l an~wer is not correct. we 'II call the subroutine at 3000 to do our multiple cotce work for U<;. Lme I500 covers the ending summary. The .. ubroutine at 2000 offer; the multiple choice menu to the >tudent. The menu ha!> been built in advance. lhi~ subroutine prinh it, asks for the an~wer, and checks to :.cc if the response ts correct. At 3000 is a subrouune that b used whenever the student has gi' en a '' rong initJal an~wer It decides whtch t} pe of multiple ch01ce question will be appropriate. The subroutine at 4000 looks through lists of cities • both capitah and others. If the student·~ first respon~e is not the correct anw.-cr, but is a valid city name, that infommtion is printed. This ~ubroutine also builds a multiple choice table of citie~ whose name'> stan with the \arne lener as the input name. This table might be used, or 11 might be replaced b> another multiple choice table; the deci~ion will be made back in ~uhroutine 3000. Lmc 5000 contains a brief subroutine to add a city to the multiple choice list. Its main function is to remove dupl icatc city names. At 6000 we have an elaborate subroutme to 'elect mulople choice candidates. As ;m example: for state Ari7ona. "'here the capital ts Phoenix and the other city is Tuc<,on. the computer ''ill pick three cities that ~tart with P and three that start with T: three will be capitals and three not: and of course the liM \\ill mclude Phoenix and Tucson themselves. Volume 9. Issue 5

To find all the capital cllie-. that stan wuh letter T. tor example. "'e look at the startmg pointer forT (that·, in .1rra) A. row 20 for letter T, column I for capital cities). rhat gl\ es u-. the number of the firM city in this chain. If it .,hould happen that there are no citie1> ~tarting v. ith the selected leucr (as is the case with the letter X, for example), we would get a \aluc of zero. To move on to the ne,.;t cuy startmg with that letter. v.e look at the pomter in array L (for "link''). It gtve., us the number of the next city. or a tero to ..,ignal "no more cille~". If ow do we build such linked lists? It's not hard. Defore we

read our data, we set all the staning pointers to ;cro. That. of couNe, means ··no cities in this hst"- so far When we read in a Cll). ,.,.e ptck out it'> fiN le11er. \\'e \\ill go to the corresponding point in the staning table: in a moment, "'e'll put the idcntit} ol tht~ nev. city there. But ftrst. tuke the contents of that pointer und move it into the link ol the new city. After that we make the entry in the Marting table. llov. does this work? If this '" the fir~t cit) begtnning with a gtven lener. we 'II pop ''" number into the \tanmg table. and put the 1ero (from the ~tartmg table) into the Cll) \ link. Re'ult: th1' city becomes the fir,t 111 the linked l..,t, and '" hnk value of ;.ero say1> that there are no more citie~ in the cham. JuM what we want. If. on the other hand. the new city i~ not the first that begin, "'ith that leuer. our ,.,.ork '' 1th the staning table and link ''ill add thts City to the top of the cham. The \lartmg table v. ill nO\\ p01nt at thi<> new cit}. v. hich in rum "'ill point to the rest of the chain. Linked lists arc flexible. and may be used to hook together many type of data. In a genealogical data lx"e. such a l"t might be used to build a chain of children in a gi,en famil): using thio; kind of data rclallon~hip mean' that there \\.Ould be no tixed limit to the number of membe~ of the latml). In gen· eral data usage, a hst of names linked by the1r liN letter, simi tar to the !>ystem we have used here, C<m be a good way to search for a specific pcr~>on; it would often be fli'tcr and more 11cxible than an alphabetited liM ~earch.

47


Conclu~ion

The program i'> a good "ay to test your ~I.. ill'>. It may be easily modified to te'>t other areas of l..no" ledge. It u.~es valid educational methods to do more than quiz: it hin~. it supplies extra information, and it gtve~ the Mudent more than one try for a correct ans\\ er. And if )Ou're tntere~ted in programming, you'll find a powerful techmque here, linked li,ts, that can make your program!> more flexible and eflicient.

• CAPITALS: An educarimwl of lmked lws.

pro~?rllm

AK 100 data californi•,••crtmtnto,los angeles JJ 110 data new york,albany,new york city LP 120 data texaa,austin,houston JG 130 data pannay1vania,harrilhurg,phi1adtlphia JB 140 data illinois,apringfield,chicago »0 150 data ohlo,co1Uibaa.clevelaod ID 160 data florlda,tallahasatt,milli 1J 170 data aichigan,lan11nq,dttroit IN 180 data C1W Jltlty,trtttOA,Jtrlty Cltf Gl 190 data north c.ro11na,ra1elgb,ehar1otte FO 200 data umehustttl. bostoo,n1• Fl 210 data gtcrqia,atlanta eol;lbua GJ 220 data virqwa,ne~ DOrfolk I'll 230 data Ulduna , illdl~po1u gary DI 243 data aiuouti,jeftusoo city , ~ l011is ID 250 data riseo111iD. •diaoo.111lnutt !D 260 data tcneutt,nalhvillt, ,tis 1J 270 data lOIIiuw batoo roage 11111 orleua Gil 280 data urylcd,awpolu balti8Ctt CL 293 data WllhlngtOD OlJIPla lttttlt !l 300 data 11111111Sota,lliDt paul,aicotapolla II 310 data alahau , IOttqo~ery,billlloqha GL 320 data ke~t:ety , frankfort, l01111VIllt rP 330 data aouth carolina colCib1a charltaton IB 340 data oklahou oklahe~~~ e~ty, tu1u 8G 350 data cotn~ctiC1lt, hartford. bndqeport PK 360 data colorado.danvtr,eolorado springs IB 370 data iowa dta 110in11, c:tdar rap1da WE 380 data arirona,photaix,tucaoo JO 390 data ortqon aalem,portland NA 400 data aississippi,jackson,biloxi &L 410 data kanaas,topaka, kansas city DP 420 data artanaas,little roek,fort llitb OD 430 data west v1rginia,charlaaton,huntington PG 440 data otbraaka.lincoln,CIIlha GC 450 data utah aalt lake city, oqdtn GI 460 data new me.dco. aanta h , alboqutrqut JI 410 data wot,auquata,portll!ld EC 480 data hawaii lwlolulu,lulo PL 493 data ldabo,bolst,poeatello PF SOO data rl:odt ull!ld providence DtVport :s 510 data Oft b~~palun, eocccrd •nehaattr 11 520 data enada.cuaon city,lu nqu IG 530 data IOCtlDl,htlw b1lhoqa BJ m data south dakota pierre liOill falll .:1 550 data north dakota buurt f1r90 n 560 data dtlewm dovtr,w1laloqton Ml 510 data vttiOtt,IODtptliar,bcrliagton D 580 data wycwq ,cbeytntt eupar Nr 590 data llaaka )UOeat,tncbcragt PO 600 data ontar1o.tcronto.ottawa rt 610 data ~Jtbtc,qutbte city,IOCtrttl

48

rhar demonsrrares use

MY 620 data br1t11b colalbia,vietoria,vancoover PE 630 data albtrta,tdlcoton,cal9ary MC 640 data unitoba winniptq brandon PB 650 data saakatehtw&n,regiDl aukatoon !lO 660 data non acotia, balifu , a~y 01 610 data Oft htu~~fWiek , frtdtrietoo awt john FL UO data cewfOU!ldll!ld aunt John 1.qandtr 6? 690 data prua tdward ull!ld,ebarlottttOWD,I._mde ii.i 800 data and GC 900 dia a$(99 21,1(99.21,q(99) ,a(2,,2) u no dia c(20) 11 920 }=0: pr1Dt plttst wut for data load' ll 930 )8)+1 PJ 940 read s$(J,O):If a$(J.0)= l!ld' goto 1C40 KI 950 ttad a$(),1),a$(j.2) JB 960 for k=O to 2 MG 910 a•uc(a$(J,k))·64 KG 980 1f a<1 or a>26 then print s$(j,k);'?':atcp XL 990 l(j,k)aa(a,k) FD 1000 a(a,k)=j I!N 1010 next t JI 1020 q(j)=j PL 1030 qoto 930 10' 1040 d=J-1 ro 1100 j=rnd(OI EF 1110 for j=1 to a9 rc 1120 k•ict(rnd(l)•a9)+1 ill 1130 q--q(k) :q(k)=q(j) q(j)oq CF 1140 next J

PJ 1150 print chr$(147);ehr$(142) OK 1160 print ' cap1tal c1ty qu11 SH 1170 print • Jia butterfield 01 1200 for j•1 to d SP 1210 ql=JH ED 1220 1f q1<a9 tbtD print ' hint: cap1t1l of •;a$(q(q1) 0);' is ';s$(q(q1) 11 .u 1230 putt FP 1240 qO:q(j)

n 1250 pr1Dt •whit u tba capiW of • a$(q0 0); ?' ID 1260 r$& l '·lCpUt r$: pr~tt ehr$(142) ··1f r$; -=4' goto 1500 Fll 1270 ..0: 111=0 1L 1280 if r$:1$(~ 1) the •10 11 1290 r--uc(r$) rO.r-64

10 1300 if ..o tbu gosab mo 8J 1310 if ..:I tban pnot 'co pointa 1 lllllltr 11 '·aHqO,l) LB 1320 •=sis:If 11>0 tbu pnnt riqht '';:if 11<10 tW pr~tt • (for part points)';

GB 1330 print.prict PM 1340 aO=s0+10 tA 1350 print •acore: ';a; out of poaaiblt •·sO GF 1360 if J/lO=int(j/101 then print '(reply and' to quit)' llD 1370 next j OG 1380 qoto 1510 GB 1500 print '(ans"'r: •;a$ (q0,1) ;')" GI 1510 print •your score:' AM 1520 s$• a very poor':if sOaO qoto 1590 cr 1530 if a/a0>.5 then a$=' a ltdiocre' BN 1540 if a/a0>.7 than a$•'' a paaasble' DI 1550 if a/a0>.8 then a$a''' a dectnt' PB 1560 if a/a0>.9 thtn a$•'' ' ' a good NG 1570 if a/a0>.95 tben a$=' •••• 1 f&ntlltlc' to 1580 if s•sO then s$• ••••• a perfect' OP 1590 print a$;1; oat of ;sO AI 1600 tnd EG 1999 rll offtr eh0101 lt:U MC 2000 lll•1:pr~tt;print'tht capiW of ';a$(q0.01; 11.' D 2010 for Jl=l to c to 2C20 k•illt ir:od(l)•c)+l BD 2030 q=e(J1) CiJl)=e(k) :c(kl=q ru 2040 otxt )1 CL 2050 for j1=1 to c IF 2060 e0ac(Jl):c1•1 BC 2010 if cO<O tuD eO.O·eO: c1•2 DO 2C80 print • • a$(e0,cll AS 2090 cext Jl

Transactor


GG 2100 pn.ct I! mo print ' type ill the anmr, eorrtctly spelled.. ' II 2120 1$= I :1npat 1$ print chr$ (1C2)·. lf r$="tnd qoto 1500 1:> 2!30 1f l$=s$(q0.1) than ..0 li 21CO ntcn £! 2m rea: csvtr 11arc:h strateqy IJ lC~ rl:asc{s$ (q0, 1))·6C·r2=&Se i1$(q0.2)) ·6C a 3010 rea: surc:h 111M for any utch PI 3C20 1f r0>0 IIIII r0<26 thaD 901-ab COOO r: 3m na: first 1tttu utctes; ..na I! 3CCO1f F() IIIII rO-·tl thu 110=7:90Jllb 2000 Iii 3C50 na: DO 1t:ei try gwr&l IUO t3 3e60 1f F() &lid al=O tileD gosllb 6000 13 3C70 nbn I) 3999 ra chtc1 for any utch. build table If Cj00 c=O A: mo 1=a(rOr1l 1~1.11•1 ll 4020 if 1=0 goto C070 E3 4030 1f r$=s$(1, 1) then pr1nt r$; 11 tht cap1tll of •;s$ (1,0);'!' 1.1 COCOgosab 5000 10 coso 1•1(1 1) II C060 qoto C020 OL C070 l•a(r0,2) :10=·1:11•2 r? 4080 if r$•1$(1, 2) than print ' . ;r$;" if I Clty 1n ";s$(1,0);'!' Gl 4090 if laO or c>l5 goto C130 lfl 4100 qosab 5000 BC 4110 1•1 (1, 2) <m 1120 goto COSO (I) 1130 nturn l]j 4999 rea: bu1ld table of DOD dup IWitl FS 5000 if c=O goto 5050 Cl 5010 for Jl=1 to c l.'l 5t20 U•l:lf c(J1)<0 then 12•2 st 5030 1f s$(abs (e(jl)) U)•s$ (1, 11) goto 5070 " 5CCOcast )1 o; 5:50 c:-..ct1 U 5C6) c(c)•l•lO tl 5n70 return !.!. 5999 ra· build gettral llllt1p1t c:bolct Cl 6:00 c=2:e(l )=q0 e(2)•-q0 :0 ialO l=a(rl, l): lC•l:l1•1 &: 6020 if laO goto 6C60 u Em gos:b 5000 II ECCl 1•1 (I 1) II 6~50 goto 6020 Cl 6C60 1f c•2 then l•int (rnd(l) •s9) tl gosab 5000:goto6060 II 6070 cl=c(int ((e·2)*rnd (1))+3) lil 6C80 c=3:c(3)ocl II 6~90 l:a (rl ,2) 10.·1 11•2 IX) 6100 if 1=0 or e>l5 goto 61CO !0 6110 gosub 5000 LP 6120 1•1(1,2) IP 6130 goto 6100 PM 6140 if e•3 thtn 1•int(rnd (1)'a9)+l :goaub SOOO:goto 6140 en 6150 el=c(int((e·3)*rnd(l)) +4) OJ 6160 e=C:e(C)=cl Gl 6170 1•a(r2 ,1) 10•1:11•1 Et 6180 1f 1=0 qoto 6220 l!D 6193 gos:b 5000 ll 6200 1•1(1.1) Ci 6210 qoto 6180 IS 6220 1f e=C then l•int (!Dd(l)' s9)+1 gosub 5000:qoto 6220 ii mocl=c(int ((c·4)' rnd (1)) +5) Q 6240 e=5:c(5)=cl :1 6250 !=a(r2 2) 10.·1 ll•2 I! 6260 il 1=0 or c>IS goto 6300 i! 6210 gos:b 5000 !J 6280 1•1 (I 21 II 6290 goto 6260 J:i 6300 il coS then l•1Dt i!Dd(l)•s9)+l .gosub SOOO:goto mo II 6310 cl=c(int ((c· S)•rnd(l)) +6) OB 6320 c=6:c(6)=c1 10 mo .0:5 :qoaub 2000 10 63U nturn

Volume 9, Issue 5

New! Improved! NSBASIC2!

ee 0 0

R.f

" 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 Mrs. 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 clean 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 laster and better with over 140 added statement and funct1on keywords

Disk and Manual $17.95 US, $19.95 Cdn. (see order card at center and News BRK for mOI'e info)

TransBASIC 2 "Cleaner code, load after loadf" 49


C Problems, Tips and Observations Compiler anomalies and drive usage b) Larr) Gaynier I have the C Poll'er compi ler~ for both the CIH and the C 128. Since I first purcha~cd the C Powrr com pi Icr. I have discov-

ered some problems that I will ~hare with you. Overall, I am favourably imprc~),ed by the package. llopefully. 1 can help you avoid future aggn~vatwn and wa\ted effort if you come up against one of these problems. In this article. I a!>sume Power C from Spinnaker i), identical to C Powa from Pro-Line.

• ip and i2 to always he equal. Thh i<; ba-;ed on the consequence that the result of any a"ignment in C ha.\ a value that is available for ... ub~equcnt use. llere is a sample of the output from th b progrmn: *ip • -512

i2 • 0

*ip - -511

i2 - 1 i2 - 2

il = -509

* ip - -510 *1p = -509

i l - - 258

*ip • -258

12 • 254

i l - -257

* ip - -257 *ip • - 256

i2 • 255

i l - - 512 i l • - 511

il

Command line argument ~ (C l28 and C64) Keep these limits in mind when you use command line argument\, e~peciall) on the C 128. The C64 \hell !>upports 22 argumenh: argv{Oithrough ,trgv{2 11. I have found thi:. to be adequate. The C 128 ~hell I'> more re:.trictive. !>upponing only 10 argumenh: argv[O] through arg\[9). l find thi!> to be inadequate and aggrJvatmg "hen u~ing program~ that allow lots of switche!> and argument\. Exceeding the limit can lock up the machine, Y.h1ch ma) not recover after a soft reset (RUNJSTOP RESTORE).

A compiler bug (C I28 and CM ) The C compiler ha~ an elu~ive bug that was very difficult to track doY..n. Originally, I noticed incon!>istent results in a program that u~ed the following II' \tatcment:

= -510

il - -25 6 il .. - 255

*ip • -255

i2 - 3

12•

0

i2 12=

1

il

= -254

*ip - -254

i1

= -3

*1p - -3

11 - - 2

* ip - -2

12 - 253 12 - 254

i1 - - 1 i1 - 0 i1 .. 1

*ip - -1 *i p - 0

12 - 255 12• 0

*ip .

1

i2-

1

i1 =

2

*ip .

2

i2 •

2

3

*ip ..

3

i2 "'

3

i1

=

2

if ((ptr->c • calloc (10,1)) != 0) i2 • 253

il .. 254

*ip - 253 *ip • 254

i l • 255

* ip • 255

12 • 255

= 256 = 257 = 258 = 259

*ip • 256

i2 12 =

11 • 510

* ip • 510

i1 - 511 i1 512

* ip • 511 *ip • 512

i1 .. 253

In thi1> example. ptr point), to a Mructure containing c. a pointer to char. The re~uh of the call to CALLOC i:. as:.igned to the :.tructure variable c. The IF Matcment tests the assignment result to !>ee if a non 1ero pointer addrcs:. Y.U'> returned b) CALLOC. CALLOC return\ zero if there is not enough free memory to sati!tfy the rcquc't. In situation<; "here plenty of free memory Y.a\ ava1lable. m) program would randomly behave as if CAl.I.OC had returned 1ero. After months of haphatard rec;earch mto the problem. I th),CO\ ered 1t had o.,omething to do "ith the indirection operator ( ptr->c i~ !)horthand for (•ptr).c). The bu!l.C program ( L1\ling I at the end of this article) demonstrate., the ba<..ic problem. The key \latemenr in this program is the mulnple a~'ignment The integer i2 and the integer pointed to by ip are to ~ 'et to the 1nteger it One "ould expect i I.

50

i1 i1 il il

=

*ip - 257 *ip .. 258 *1p

= 259

i2 • 254

i2 "' i2 ..

0 1 2

3

12 - 254 i2 • 255 i2 •

0

Thi ~

clearl) '>hOw\ that -;omething 1<; wrong. The only values that <;eem to be correct are 111 the range 0 to 255. All negative value-. and value\ greater 255 produce bad re~ult<;. The cau'>e of thi'> bug can be seen when o.,ample code b disassembled. Transactor


aain()

mteger variables. Character vanable~ do not exh1b1t the problem becau~e the upper byte i'> naturally 1ero. f-loat variable\ arc handled differently through ~pecial~>ubroutine\. \1y earlier examples can be rewritten to avoid the problem:

(

int .ip, i1, i2; i2

= • ip

= i1;

1

i2

This -.imple example produce., the followmg C 128 object code after compilation:

= • iP = i1;

can he rewrinen as: . ip • i1;

-in 85 fb a9 06 a2 oo aO 00 20 20 a6 04 a 4 OS 98 ao 91 Sa

sa 91

i2 • • ip; 00 I 1803 09 I 1805 oo I 1807 00 I 1809 20 I 180b 00 I 180e 00 I 1810

begin 00 00 I 01 oo 1 02 00 I 00 00 I oo oo I 02 00 I

ata lda ldx ldy jar ldx ldy

indirect 1812 tya 1813 ldy 1815 ata 1817 txa 1818 dey 1819 ata

$fb l $06 1$00 1$00 c$105 $04 $05

and, 1f ((ptr->c = calloc (10,1)) != 0) f unction preparation qat low byte of H qat hiqh byte of i 1

• iP $02,$03 haa address

86 84 a9 a2

aO 4c

ptr->c • call oc (10,1); i t (ptr->c != 0)

l $01 ($02),Y

save hiqh byte indirect

PEEK, POKE, SYS (C 128 onl y)

($02),Y

at this point Y is zero save low byte indirect

At the hean of the Cl28 1s a po\\erful bank witching scheme to ~elect between RA \1 banks. BASIC' ROM. Kemal R0\1, and the 1/0 regi~ter~. Additiona I capahilit ies include tero page relocation and sharing common RAM at the top or bottom of the RAM bank,. These feature~ ~lie controlled by the memory management unit (~t.\1U) with configuration regbter' located at SD500SD50B and SFFOO-SFf'O.l. The.,c registers are critical to the correct operation of the Ct28 and require careful manipulation. Otherwise, a program ma) lose control of the machine and appear to he locked up.

end indirect • ip Y incorrectly assumed to contain the 06 00 I 181b atx 07 00 I 181d aty always zero 06 oo I 18lf lda oo oo I 1821 l dx 00 00 I 1823 ldy 4c 4c I 1825 jmp

can be rewritten as:

hiqh byte $06 s ave low byte of i2 $07 s ave hiqh byte of i2 l $06 l $00 l $00 c$106

function wrap-up

The C64 object code is identical except for tero page locatiOn,. For inreger-typc vanables. the complier a<;sumes the resull of an) assignment remains available m the X.Y registers (lo~ byte, high b) te). During the indirect a..signment through a pointer. the Y register IS used for indirect addre~>sing. But nothing is done to rc~ torc the high byte to the Y register. As a rcsull. the high byte i~> ulway~> zero. The compiler should restore the hjgh byte after '>aving the low b} te. A sample fjo( IS:

The C environment mal..es full Ul>e of the C 128 banking features. The ~hell and RA~I dbk reside in RA\1 bank 0. while programs reside and execute from RA.\t bank I. The lo\\eM I K of memof) is shared between both bank:.. During program execution, the memory page (256 b)tes) at St3(10 is used a~ tcro page RAM. The f1N 32 bytes of automatic \ariable~ declared in a function are placed in the 7Cro page. The true tero page i~ switched back as :~ero page R \M for any callc; to routine~ that do not n:,ide within the program, '>uch as the Kemal. BASIC or shell routine~. The tn1c tero page contains man) register~ needed for calling the Kemal or BASIC routine!>.

Thi-. lix would make the compiler behave hke ·.,tandard" Cat the expense of adding four byte~ to all indirect a<;SJgnments.

The l'rt:iK, POKE. and SYS functions supplied with the function library have been appropriately modified for C 128 memory management. However, there is a problem that can be eac;ily demon-, trated by the PFEKTESTC program (Listing 2). Th1~ program peeks a byte from any C 128 bani... When run, I! produces strange result.-.. You can easily see thl\ if )OU attempt to peek locations with known values '>UCh a~ the Kemal jump table. The problem lies in the f'EEK and POKE fum:tion!>.

I advise you not to u~>e the result of an indirect assignment. Typically, the offending line must be broken up into separate Matementl>. The re~triction onl) applie~ to signed and unl>igned

But fi rst, some background. The shell and C progmm~ U'>e two ~pecia l routines in common RAM to c;witch control between CI2H banks.

iny lds ($02), Y tay

It should be inserted after the second sta ( 02), Y in~truction.

Volume 9, Issue 5

51


• The

~ubroutine

at $0124 doe' a JSRJ-AR to <ln) bank.

ad 00 ff I 0124 48 00 00 I 0127 a9 00 00 I 0128 8d oo tt I 012a

1da $ff00 pha save configuration 1da l$00 sta $ff00 set bank 15

20 6e ff I 012d jsr $ff6e JSRFAR 68 00 00 I 0130 p1a 8d 00 ff I 0131 sta $ff00 r . .tore configuration 60 00 00 I 0134 rts

The zero page regi\ten. $02-$08 mu~t be set up according to JSRFAR preparation before the call to S01:!4. The subroutine at ~)I '5 \tore~ a value to a configuration register. a8 00 00 I 0135 ad 00 ff I 0136 48 oo oo I 0139 a9 00 00 I 013a 8d 00 ff I 013c 98 oo oo I 013f 9d oo d5 I 0140 68 oo oo I 0143 8d 00 tt I 0144 60 00 00 I 0147

tay 1da $ft00 pha 1da sta tya sta p1a sta rts

1$00 $ff00

program may be '>Witched out and lo~e control. Since I prefer robu~ t and con~i~tent de~ign~. I modified SYS to elinllnatc all direct manipulation of the configuration rcgi~ter, making it behave like PErK and POKL. The program SYS.A (Listing 4) contains the updated source code for the SYS function. Old and new code is tndtcated. and SYS.A can be a"embled U\tng any a-;sembler that produces compauble C object. Altemativel}. BASIC generator programs (Lt~ting'> 5 and 6) have been supplted to create the object files for PLLK. POKC and SYS u~ing DATA statements. Delete the original object files PECf...OBJ and SYS.OBJ on your function library disk and replace them with the updated object files. Make sure the new object files usc the same tile names as the originals. Otherwise, you will need to use a object library editor to change the lile names in the object libraries. As a precaution. usc a backup copy for this and save the original function library dbk. PcEJ....A

save configuration

A painful experience (Cl 28 only) set bank 15

$d500,X

set confiq raqister

$ff00

restore configuration

a • configuration va1ue to store x = offset from $0500, which detexainas the configuration reqister to be updated. y used interna11y by the $0135 routine.

=

The basic procedure to execute a routine in another bank is:

I never paid much allention to maga7ine descriptions of 1571 disk drive problems. The infonnation always seemed too vague to apply to me. I a~sume the problem that I painfully discovered came a-. a rewlt of one of the 1571 bugs. It !.trongl) reinforced my habit of doing periodic back-ups and organil.ing disks to minimite my reliance on any one disk. When I first obtained the C Pnll"~r compiler for my Cl28, I configured m) C cnvtronment u\ing two 1571 disk drives as follov. s: I) Work dri\ c 0 wa-. set 10 dtsk Untl 9 and held the noppy disk containing program~ under development.

I) S\\-itch Lero page bad. to soooo using the SOI35 routine. 2) Set up regtsters $02· $08 for the Kemal routine JSRFAR. 3) Call $012-1 in common RMI whtch calls JSRrAR.

2) System dri\.e I was 1>et 10 the RA.\1 disk unit 7. As part of my stanup procedure, I copied the compiler. editor and various utilities to the RAM dt~k. as much as would fit. Then I would '>Witch the system drive I between the RAM disk and disk unit 8 depending upon what utility I needed.

4) Capture results from registers $02-$08 as appropriate. 5) Switch the £ero page to $1 JIXl uo;ing the $0135 routine. The problem in the PFFK and POKE functions is that the) fail to set up the X regbtcr before the call to SOI35. The net result is that tero page docs not get properly swapped. If a function mvokes PFEf.. or POKF. the fiN \IX hytes of variables declared within the function v. til be corrupted because the .tero page locations S02-$08 arc ovcrv. riuen during the setup <Uld execution of JSRF\R. The program I'Of..L.A (Listing 3) contains the updated source code for the I'FEK and PO"-L functions. Old and nev. code i-. highlighted. The svs function does not C\htbtt the 1ero page swapping problem like PEFK and I'Of..E. HO\\-e\er, SYS does directly manipulate the configuration rcgt\ler~. One problem of direct manjpulation of the conligumtion regbters i that an executing

With thb approach. editing and compi ling were done LO and from disk. I adopted this configuration becau!.e it was the fastest way to load the compiler. about two seconds. C 128 compile time busically amounted to reading the source program from disk and '"-rttmg hack the object. These delays could be wb~tuntial when )OU consider the v.riting speed of 1571 ts identical to the 1541. But I had been conditioned by the slo'"" loading time ot the CM veNon of the compiler operating from a 1541 dbk dri\ e. I operated comfortably in this mode for <~bout ~•' months before I encountered the problem. The problem occu~ \.. hen the dbk block total crosses the side I to side 2 boundaf). 1l1e compiler can go into an infinite loop. eatmg up dtsk space. and corrupting the source file and po~sihl} orher files. When the problem occurred. I had to reset the computer. lea\ ing the disk corrupt. After validating the di:-k. I found two "\plat. file~ I L\.IP>V<X I and TEMPXXX2. I Transa c tor


....

as~umc

the TJ:MPXXX file!> were written by the compiler. In addition, the source file v. ns completely corrupted. I saw simtlar problem~ when a C program wa<; executing under the following condillom.: I> The di'>l.. blocI.. total boundary.

wa~

T~o

I) Set up the RA'I.1 di""- configur.uion U\ing the commands rdon. ~etu 0 7 0 and setu 2 9 0.

at or near to the side I to side 2

2) The error channel wa\ open. 3)

work drive 0 followed by sy.,tcm drive I. unless the drive number i~ explicitly given in the file name. The basic procedure is:

files were opened by [open.

4) Command line 110 redtrection .,entthe standard output to a dis!.. file. Notice the total is three open files plus the error channel on one disk drive, which i~ the limit according to the 1571 User's Guide. Although I do not have the details. I recall that one of the I 57 1 bugs is related to the side I to side 2 transition.

{Bugs cnrrec1ed by 1/re new 1571 ROM are documemed in 1he

CJ28 Developer's Package from Commodore.- Ed.] After further investigation, I concluded that the problem never occurs with anything les., than three open Iiles. Any program using two open files or less plus the error channel appears to operate correctly across the stde I to side 2 boundary. The C compiler may have produced the \amc .,ituation ~ith the error channel plu'> three open file\: TF\1P'<XX 1. TE.\1PXXX2, and either the source file or the object tile. Working around the bug I considered many alternatives to avoid this problem. One ~olution was 10 l..eep disk space low to prevent crossing the side I to side 2 boundary. However, this defeated the advantage of a double-.. ided di.,k drive. The approach I eventually tool.. was to avoid all djsk drive situations that would have three open files plus the error channel. I did this by mal..ing bellcr usc of the RAM disk. After some experimenting, I finally configured my C environment as follows: I) Work drive 0 i~ set 10 the RAM di.,k unit 7 and holds the progmm., under development.

2) Copy the appropriate file., from drive 2 (floppy) to drive 0 (R.\\1) u\ing the command cp 2:1ile 0. Be sure to cop) any header file~ needed by the '>Ource file!>. 3) Edit the file\ u\ing the commanded fil e. You can even pull files directly into the edttor from drive 2 (floppy) using the commanded 2:file or U\tng the command get 2:file from within the editor. The editor command put lile writes the file bncl.. to drive 0 (RAM). Similarly. the command put 2:1ile writes the file directly back to drive 2 (floppy). 4) Compile the file from drive 0 (RAM) using the command cc tile. The object file will be written to drive 0 (RAM). 5) When finished. delete the old copie~ from drive 2 using the command rm 2:1ile. Then, copy the updated file~ from drive 0 (RAM) bacl.. to drive 2 (floppy) using the command cp O:file 2. Wildcard characters in the file name arc very useful here. Be careful! It i~ very easy to lose hours of work during this step. This configuration " qu1te fast. 1/0 to the RAM d1.,!.. 1s done at blinding '>peeds b) 1541 .,tandard.,. An} delay., come from loading the editor. compiler or other utilit1e~. Howe' er. I consider these delay'> to be minor \incc the programs are loaded in I571 burM mode. For example. the compiler tales about 10 secondo; to load and the tmn.,lator for the compiler takes about 5 seconds. Important: Don't forget to copy Iiles bad. to drive 2 (floppy) when your worl.. i'> complete. All changes made to file'> residing in drive 0 (RAM) Will be lost when the power is turned off. Listing 1: bug.c

I*

..**** ..**

bug.c demonatrate C compiler bug Larry J. Gaynier

.,**

June 25, 1988

u.in ()

2) System drive I b '>et to the disk unit 8 and holds the floppy dis!.. contnining the compiler, editor and various utilities.

(

lDt •ip, 10, i1 , 12; ip • HO;

3) Drive 2 is set to the d1sk unll 9 and holds the floppy disk containing progmm., under development.

for (i1 • -512 · 11 <• 512· 11..) (

i2

With tht'> approach. edllmg and comp1ling are done to and from the RAM di'"-· The procedure b !>imple and quick. Keep in mind that the normal search order for progmms and Iiles i!> Volume 9, Issue 5

= •ip .. 11;

print! ("il • •d

*ip. d

I )

53


sta $06

Listing 2: peektest.c

,.

1da $0400,X sta $07 1da l$00 sta $08 )St $0124 lda $06

•• peek an addrett fro. a C128 bank

••

•• Larry J . Gaynier •• June 25. 1988

.,

pha ldl l$13

:---- new ----------- old ----

lllill (II9C, ln]'f)

lda l$07

unugud argc; char harqy;

)It

{

pla

unn<Jl*i bank , addrua;

lda sta ldi sta

char byte, peek() ; 1f (arqc

~

3)

{

= \04x

$a0 $0400,1 l$00 $0401,1

rts

aacanf (*++argv, "\x" 'bank) ; ucanf (*++ar<JV, '\x" , hddreu) ; byte • peek (bank, addruaI ; printf ("bank = \02x addreaa ,bank, add.reu , byte);

$0135

byte

= \02x\n"

poke

c$funct init stx $a0 )St

else

txa pha

(

lda l$00

I pruaaqe (); exit() ;

;---- new ----------- old ---ldx 1$07

I )

jsr $0135 pla

prusaqe()

tu

(

ldi $0402,X sta $fc ldl $0403,X sta $fd ldl l$fc sta $02b9 lda l$0f sta $02 lda l$ff sta $03 lda 1$77 sta $04 php pla sta $05 1da $0404 X sta $06 lda $0400, X sta $07 1da #$00 sta $08 jsr $0124 lda 1$13

pr1ntf ("utaqe: peekteat bank addreta\n"); )

Listing 3: peek. a • re' io;ed source for peek.o ;axllf1td to corrt(t zero plqiDIJ :&deled lda 1$07 before jar $0135

"'lY

LuryCaynitr , ___________________ _ :IWch 10,1987 '

.clef paek, poke .ref c$funct init

-

peek jsr c$funct init stx $a0 txa pba lda 1$00 ;---- new ----------- old ---lda l$07 ;---- end ----------- tnd ----

jsr $0135 ph

;---- new ----------- old ---ldx l$07 ;---- end ----------- end ---jl!p $0135

tu ldl $0402,X sta $fc ldl $0403. X

sta $fd ldl l$0f

sta $02 lda l$ff sta $03 lda 1$74 Stl $04 php pla sta $05 lda l$fc

54

Listing 4 : sys.a. re' ised source for sys.o c.odified to use $0135 rout1na hke peek and poh

·eli•1nated resett~DCJ the confiqurat1oo register ; 110 need to enable the hrnal and ~/o · baodled by tbe $0135 rout1ne

.

· Lury GaytUer · March 14, 1987

;-------------------.def aya

.ref c$fUDet_init

Transactor


'

sys Jlr c$funct_init 1tl SaO ldx $0404, X ata Sa2 ldx $0405 X lta$a3 1da $0406 X lta$&4 1da $0407, X lta$15 1da $0408, X ltl $&6 1da $0409,X stl $&7 1dy l$00 1da ($a2) , Y ~ pia 1da ($a4) ,Y pia 1da ($a6) , Y phA ;-- new ------------- old ---txa 1da f$4e pha ata $!!00 1da l$00 1da l$00 ata $d507 1dx l$07 ]It $0135 pll tu ;-- end ------------- end ----

1da Ita lda Ita 1da Ita pla

$0400, X $02 $0403, X $03 $0402, X $04

stl $08

p'a ata $07 p1a sta $06 php p1a sta $05 )It $0124 lda $05 pha lda $06 pha 1da $07 pha lda $08 phA lda l$13 ;-- nev ------------- old---1dx l$07 sta $0507 jar $0135 lda I$7P It& $ff00 •• ; -- end ------------- end ---ldy l$00 pll stl ($&6), y pll stl ($&4), y p1a Ita ($&2), Y p1p 1da l$00 bee snp 1da 1$01

Volume 9, Issue 5

skip 1dx ata 1da It& rta

$a0 $0400, X l$00 $0401 X

Listing 5: peek.gen ·a BASIC generator for peek.o 100 r• qenerator for "pttk.o• 110 ns=·peek .o": r• - o f progru DC 120 Gd=209: sa=1S1: ch=1S837

Bll Jll

(For llnes 130·260, ' " tbe standard qtnerator on page S.) l'D BP BD Ill': BB FD CP EN JD KL JJ FF

w JL

I! I GJ Cit

HL 01 IQI

GO PM 011 !II Q(

J!l

Cl

1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200 1210 1220 1230 1240 1250 1260

Li~ti ng

data data data data data data data data data data data data data data data data data data data data data data data data data data data

32, 0, 189 133, 133, 133, 4, 36, 7, 0, 32, 0, 189, 133, 15, 119, 4, 7, 169 0, 1, 1,

0, 0, 134, 162, 7, 32, 2, 4, 133, 253, 169, 15, 3, 169, 116, s. 169, 252, 133, 7, 169, 1, 165, 6, 32, 53, 1. 4, 169, 0, 0, 0, 134, 162, 7, 32, 2, 4, 133, 253, 169, 252, 133, 2, 169, 133, 4, 8, 4, 133, 6, 169, 0, 133, 19, 162, 7, 2, 0, 80, o. 0, 80, 80, 0, 2, as. 78, 67, 84, 84, 0, 0, 0, 70, as, 78, 67, 73 , 84 , 0, 0, 0

160, 53, 252, 133, 133, 133, 0, 72, 104, 157, 160, 53, 252, 141, 255, 104, 189, 8, 76, 69, 79, 0, lU, 0, 84 ,

o.

138, 1, 189, 2, 4, 6, 133, 169, 166, 1, 138, 1, 189, 185, 133, 133, 0, 32, 53 69 75, 67,

72 104, 3, 169, 8, 189, 8, 19, 160, 4,

12. 104, 3, 2, 3,

s,

4, 36. 1 75 69, 36, 73, 78 0. 67 164 73 80 0

169 170 4 2SS 104 0 32 162 157 96 169 170 4 169 169 189 133 1 0 0 0 70 73 36 78 0

6: sys.gen ·a BASIC generator for sys.o

J!l 100 rea generator for •ays.o Gil 110 n$="aya.o : rea nue of program PA 120 nd=168: sa=136: ch•13130

(for lines 130·260, see the standard generator on paqt S.) lA

CE 10

08 JP DA

IC KF

BF GC !!'

FI CG

AB Ell

oa Al

IB !IF Fit

ltC

1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 1100 1110 1120 1130 1140 1150 1160 1170 1180 1190 1200

data data data data data data data data data data data data data data data data data data data data data

32, 133, 6, 165, 4, 177, 169, 170 4 104 6 165 72, 32 104 0 0, 0 1 85,

u

0, 162, 4, 189, 133, 164, 0, 189, 133, 133, 8,

s. 165, 53,

us.

144 4, 0 0, 78, 0,

0, 134, 160, 189, 4, 4 189, s, 4, 133, 163, 189 133, 164, 189, 7, 4, 133 8, 4, 133, 166, 189, 9 167 ' 160, 0, 177, 162, 72 72, 177, 166, 72, 138, 72 162, 7, 32, 53, 1, 104 0, 4, 133, 2, 189, 3 3, 189, 2, 4, 133, 4 8, 104, 133, 7 104 133 104, 133, 5, 32 36, 1 72, 165, 6, 72 165, 7 8, 72, 169, 19, 162, 7 1 160, o. 104 us. 166 1U, 104, US, 162, 40. 169 2, 169, 1, 166 160 157 169, 0, 157, 1 4, 96 1, 0, 83, 89, 83 0 0, 1, 0, 67, 36 70 67, 84, 164, 73, 78 73 0, o. 0, 0, 0, 0

55


Programming GEOS Icons Some tricks for using more than 31 icons b) James \ook

One of the 11101-.t fundamental user mterface tools in the GEOS operating ~ystem is the icon. An icon b a graphic image on the monitor that cause~ a program routine to be called when the u~er chd.. , the mouse pomter over 11. Icons. along with the mouse and pulldown menus. allow the user to operate the computer 1n a comfortable, easy to gra~p way. Loading and running a program i~ a' '>imple a\ movmg the pointer over the tile icon on the DeskTop and double-chcking. The user doe' not need to remember and type comphcared. often confu~ing commands. GEOS·specilic application program!> make extensive u\e of the GF.OS Kemal, which i' loaded from the boot di~k and consbt~ of a large number of service routines. These service routines take care of most of the common need' of an application such a\ di k and tile handhng. graphic manipulation, the uc;er interface. etc. The memor)'-re'>ident routines wait patiently for a U\cr event to occur. ~uch a-, clicking on an icon. before swinging into action. The GEOS programmer can freely usc these routines in any GEOS application. Suprismgly, a' imponant as icons are to GEOS, there is only one icon-specific routine, Do/cons. 1l11S single routine, however. packs a lot of punch. All of the tile and disk icons on the De~kTop u'e it. All of the tool routine\ in '.lenPailll are called by it. So tmponall! is this routine that Berkeley Soflworks• Official Gl:.OS Progrwwm•n Referena Guide warns that GEOS ao;sumes an application will always have at lea~t one icon. Since mo'>t applications depend heavil> on the usc of icons. it i'> wonh an in-depth look at how to uo;e them in your own programs. The Do!Clms routine i' almost always a part of an application·~ initialit.ation ..cquence. This ~equence call\ a number of GEOS gmphic~ and menu routinell to create the u...er interface ~creen. Theile routines. a' ~ eU as mo'>t of the other available ~ervice routines, are accessed by a JSR to an entry in a jump table. The jump table contains the actual addrcs~ 1n memory of the routine the programmer wishe~ to access. While different vero;ion~ of GFOS may locate the service routines at different addre~se~. the jump table remains the ~ame between versions. Since GEOS ha~ been frequently updated. the jump table provide~ a ~table path to the routine. TI1e GLOS jump table addre\\ for Dnlcom is SCI SA. 56

When Do/cons is called. the GEOS Kemal expects the two-byte .word fo llo~ing the J'iR m memory to contain the pointer to the icon table. The icon table tells GI:OS how many icons are required. thctr location on the screen. their si1.e, the location of the compacted bit-map image for each icon, the service routine to call after the icon i~ ~elected, and the po~ition to place the mouse pomter after the icons are drawn. Here i'> an example of Dnlcnnf and the icon table: ;Icon table example JSR Doicons ;Call the ~con rout~ne. . word IconTable ;Pointer to the icon table. IconTable: ;Here is the icon table. . byte . word .byte . word .byte .byte .byte . byte . word . word .byte .byte . byte . byte . word

8 160 100

;8 ~cons on the screen. ;The mouse to be in the center of ;screen after icons are drawn. IconP~cl ;Pointer to bit-map for icon fl . 10 ; X Pos~tion of the ~con in bytes. 10 ;Y Position of the icon in pixe~s. 2 ; Width of icon in bytes. 10 ;He~ght of ~con in pixels . Doiconl ; Pointer to service routine for fl . IconPic2 ; Pointer to bit-map for icon t2 . 12 ; X Position of the second icon. 10 ;Y Pos1tion of the second icon. 2 ;Width of icon in bytes . 10 ;Height of icon in pixels . Doicon2 ;Pointer to service routine for 12 . ;6 more icon entries.

Let's take a closer look at the icon table. As noted, every application must have at least one icon '>O there will alway!. be at lea~t one call to Dolcon.f and an icon table in every application. The mintmum number in the liro;t enrry of the icon t.able, therefore. i~ I . The maximum numhcr of active icons possible on the screen i11 3 l. You may call Do/cons ..cver.tl times in an application. but only the most recently called group of icon~ will be active. GEOS will not erase the previously dmwn icon graphics from the screen. You may re-call a Do/cons and reactivate its group of icon!. if you wish. If the icons ha'e not been ~nnen over or era\ed. the u~er will not detect that they have actually been redrawn. Transactor


The next two entries allow you to place the mouse pointer anywhere on the !:.Creen after the icons are drawn. Following these three pieces of infonnation, Do/cons expects six data items for each icon. Icon image and position data The first .word contains the pointer for the bit-map data of the icon image tt'>elf. At the memory location indicated by the pointer, you must have the bit-map image coded using GEOS' compaction rules. If you are using GeoProgrammer you need only paste the photo scrap image of the icon into your source file. This makes it easy to use the graphic tools in GeoPaim to create just about any image you like v. ithout having to worry about the rather complicated compaction techniques. Be sure you carefully follow the instructions in the GeoPro~o~rammer manual. Otherw1<,e, you'll have to break the image down manually according tO the compacuon formats described on page 89-90 of the Official GÂŁ0S Prowammers Reference Guide. The next two .bytes are used to locate the icon on the screen. Note that the horizontal position of the icon is restricted to every even byte. This means that you 'II only be able to locate your icons to 40 different position<; hori:wntally. This may be an imponant constraint in some applications. The vertical po~ition of the icon can be on any of the 200 <,can lines nvai lable. The fifth and sixth bytes de:.cribe the siLe of icon. The fifth b) te tells GEOS the width of the icon and byte six is the height in scanlines. As with the position of the icon, the 1>i1.e of the tcon hori7ontally is a minimum of eight pixels. The minimum icon height " one scan line. The maximum icon site is eight b}tes wide and 32 scanhne!. high. Tht~ means that you can almost completely cover the screen with adjacent icons. Calling service routines The final icon entry in the icon table is the .word pointer to the service routine to call when the icon is activated. The service routine can do almo~t anything but it should usually end -..uh a JSR !>O that control is returned to the Do/cons routine. Of course. if you needed to, you could activate an icon which called a new Do/cons: thereby modifying, or completely redoing, the icon table.

leon tricks Here is one ea~y way to accomplish this that I have used in my own program . Remember that after chcl.ing on the tool to change the pattern or after selecting the change brush menu item, the mouse is constrained to an area in the lower edge of the screen that i1> completely filled with adjacent icons. This is the l.ey! Because the mou!>e is restricted to the !.election area. you are forced to make a decision before the mouse can move out of the area. This mean-; that one of the pattern or brush icons doesn't really have to be an icon. Whenever the mouse button is clicked and the pointer is not over an icon or menu item, GEOS automatically calls a routine poimed to by orherPress\tecror. The routine called by otherPress\'ector is deftned by the application'> programmer. Upon '>ystem initialiLation, oms loads a 0 tnto this address and if <;uch an event is needed it is up to the programmer to load the address of the location of the routine. It would be a relatively simple matter to write a routine pointed to by otherPress\lector that would detect and react accordingly to the mouse button being pressed over the one pattern or bru<>h 1con that 1sn 't really in the Do/cons table. Although most applications will seldom need more than 31 icons active at one time, GEOS provides yet another way to include a fev. more. The routine ls.'vfselnRegion tests if the pointer is ino,ide a rectangular area of any size that you define. With this routine you're not restricted to even byte horizontal position or width. You load the vertical si1e and posiuon of the region in r2 and the horiL.Ontal size and position in r3 and r4 prior to calling the routine. If the pointer is inside the region when this routine is called, the accumulator will signal TRUE(1) otherwise the accumulator will be FALSE (0). Calltht!. routine in your otherPress routine, branch on the accumulator being TRUF and you have your own, custom, •Do Icons' rout me! Remember the warning to always include an icon in your program? lf you decide that an icon is simp!) not needed m your application. be sure to place an 'invisible' icon in 11 anyway. Simply usc the following icon table:

Thio, is probably what happens, for instance, when you click on the pattern change box in the lower left comer of the GeoPainr screen. A new Do/cons is called that uo,es a different icon table for the pattern icons. After a pattern is -;elected the original Do/cons is called to reactivate the toolbox. Remember, all pre\ iously drawn icon image:. wiU remain intact when a new Do/cons is called unless the icon table used rewrites them.

;Here is the mandatory 'invisible' icon routine JSR Ooicons ; Always at least one Ooicons . word OUmmyicon ;Pointer to the dummy icon table. Oummylcon: ;Start of the dummy icon table . .byte 1 ; Here ' s the single icon. ; wherever you want the mouse to . word 160 ; be after this routine is finished . .byte 100 . word IconPic ;Pointer to an empty address . . byte 0 ;Place the blank icon in the upper .byte 0 ;left corner of the screen . vord NextAddress ;Pointer to the next section . NextAddress : ; The rest of your code follows.

"Whoa, wait a second! If only 31 icon~ are allowed how come there are 32 pauem icon\ in GeoPaim?"

What are some other way~ icon~ are u~ed'? How about the icon used to position the GeoWrite window on a particular 'ccrion

Volume 9, Issue 5

57


of a page'? When the user clicks on this icon the service routine called probably creates n \prite with the cursor-box as its graphic data and force<, it to follow the venical po~ition of the mou~e. The mou'>e is con'>trained to moving up and down only "- ithin the limi~ of the bo>. that repre!>ents the page. When the mouse is clicked again, the l>prite is disabled and the new position of the window on the page is calculated and the screen moved to the proper location. There are all kmd~ of mteresting "-ays to u..e GEOS routines and thi'> one 1n panicular. Even 1f you've never given assembly language a try before. GLOS makes the !>truggle to learn it a lot easier. With the many. many !>Crvice routine~ GEOS pro• vides, you don't need to worry about the messy, difficult aspects of developing the user mtcrface. You need only worry about exactly what the called service routine is going to do when its icon is clicked on. Even if you already have a good 6502 assembler, I recommend buying Berkeley Soft work'>' GeoProgrammer. Its strong points are the sample application~ they have included. the ease with which you can include graphic images without having to break them down into their compacted hexadecimal equivalents and the nbility to directly create the special GEOS file header. CeoProgrammer produce~ relocmable code so it also includes a linker. And, since programs seldom run right the first time, Berkeley Solrwork~ prov1deo; a memof) resident debugger. While my experiences wtth GeoPro~?rammer·s A!.sembler and Linker have been vel) pol>ttive. I'm afraid I can't say the same about the Debugger. Since memory on the 64 b limited. a mini-debugger ts pro\ ided that can be loaded into the directly accessed system memo!) or there i'> a super-debugger that can be loaded into a RA\t expan'>ion unit. The super-debugger is much more powerful but, if you don't have access to an RElJ you can't use 11. My e>.perience with the mllli-dcbuggcr ha.<, been very frustrating. Even when following the documentation examplel! wordfor-word, the min i-debugger would frequently lock the system up. I recommend avoiding the mini-debugger and buying or borrowing an REU if you can.

assemblers. Only Berkeley's is designed specifically for GEOS applications. however. The other C64 assembler systems will require a lot more work in developing application software. No matter what a'sembler you use you'll need a copy of the Official GEOS ProgrammerJ Guide published by Bantam. Since Berkeley Soft"- orks i'> completely revising this guide. if you don't already have a copy. ll) to borrow one. Even if you have GeoProgrammer and it~ sample applications, try creating your own. Ideas for progrnmo; u<,tng icons are literally every\\ here. Look how they are u<,ed to call GeoPaillf tools, patterns, brush panem'>. color... etc. Application~

can u~e icon~ in very unusual ways. The assembler source lbting that follows. for instance, uses icons as piano keys. When the mouse pointer is positioned over a key icon and the buuon pressed, the corresponding note will play. If you're interested, this keyboard could easily be expanded to include changing the waveform, volume. envelope, etc. Develop your own mouse-driven synthcsit.er! I've abo included the GeoProgrammer linker and header listings. ote that the icon I u!.ed in the geoKeyboard.hdr ftle can be substituted by the sample sequential program icon included with GeoProgrammer. You can then use an icon editor to edit the icon anywny you wish. If you're not going to be using GeoProgrammer, the listmgs may have to be edited to suit your own as,embler. [DeskTop icons are three bytes wide and 21 canlines h1gh. If )Ou're us1ng a different ~sembler you can create the icon With a sprite editor and inscn the data into your l.ource as .byte statement!..- '-'101 I hope you'll now have a better understanding of how to use GEOS icons and will enJOY GeoKeyhoard. If you've never tried assembly programming before get staned! Even if you have worked With in a"embly language but are unsure of how to use the routines provided 1n the ui::OS kernal, give it a try. Don't be afraid to e>.pe1imem with your own ideas. Patience and imagination arc important in developing any application. Getting started is alway!. the hardest pan!

;**************•••··················································· If you are going to be u~ing GeoProgrammer. be aware that it does not include an editor with which to actually create your source file. I recommend u~ing one of the more powerful versions of GeoWrite all your editor. While GeoProgrammer wiU not work with GLOS 128 [See "l11.1itle GEOS 12tf' 111 this issue. - .'JO]. you can still create GCOS 128 programs. I u'iC Writer's ~"-orkshop 128 for editing. Bes1des the 'iCarch and replace functions which are \Cry useful in long listing,. the 80-column \Creen and faster speed are great time saver... When you are finished editing. simply copy }our source file to the R'>..embler di~k and re-boot your 128 in 64 mode v. ith GEOS 64.

GeoPror:rammcr is not the only way to go however. I (and man} other programmers) have succe!>'>full) used Commodore ·s own Macro A~.wnhler Ot'\'elopment System, amoung other 58

gt o!l:tybrdl!dr •

Copyright 1989 By J18 Cook

. •

· ittttttt ttttttt ttttttttttttt ttttttttttttttttttttttttt ttttttttttttttt

Pa.ss1 include <JtOJSya .el!dif .header IIOrd 0

. if

.byte 3 .byte 21

; Iae1ude qeosSya durLDg assembler' s ·1st pus throogh tbt header file llld tht ' IF' elaust . ·Flag the start of beadet secticm • Tht hnt t110 bytes are always 0 W1dtll in bytes . . and bt1ght LD sCIIIlLDts of:

; the Desktop icoa.

Transactor


.byte .byte byte word word word .byte bytt .elldh

$80 I OSR APPLICA'liOII

;CBH file type, with b1t 7 set. ;Geoa proqru type. SEQO!II!UL ;Geoa file structure type. $400 ; Load proqru at this address. $3ff ;IDd addresa for desk accessories. $400 :Start proqraa uecution here . geo«eyboard Yl .0',0, 0,0, $00 ; 20 character• for filename . ;20 characten for author' • CUlt . ' Juet I Cook, Jr ', 0 ;bd of header block

- -

0

By Jia Cook

0

• ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• • 0

. include geosSya include geoJII.ac

vlfreq1o vlfreqhi vlpwlo vlpwhi vlcotrl vlattdec vhusrtl IOdevnl Clllpra culprb

= $0400 = $0401 • $0402 • $D403 : $D404 = $0405 = $0406 = $0418 = $DCOO = $DCOl

;Theae files need to be 1ncluded when ass~­ ; bling, prarided w1th GeoProqraa.er packlge.

;!beat qlobll v1ri&blea were left out of the ;qeoSya file . If you' re planning on expanding ;on thia proqru you ahould include all of the ;SID and CIA registers in an .include file ;called geoaiO.

ldl

; Cltlr the screen and Itt up the b&ciqrOWid.

0

JSr SetPattern )Sf l_Rtct&nqle •byte 0 byte 199 wordO word 319

0

l.oldl rO , KeyboArd

; Addrtu of 1con data table.

Jsr

;Display the icons and actlVlte tha.

Ida IO Lo1dl rO, GeosMenu JSr DoMenu rta

0

0

- - -

-- -- --

0

;Put IIOUII on qeos unu it111. ;Put the address of the menu table in rO . ;Display aenu to quit and return to DeskTop.

0

-

0

=0 = 15 =0 llliJ-Rr = 29 T POS TOP leoti = 24

MlU 'lOP MUJ BOT llliUF!

-

1-POS-TOP-Icotl" 5

; Soee constants for the 1enu structure.

;SOle constants for the 1con atructure

-- -

byboud: .byte 25 word 160 .byte 100 C4 01tural • word lltural byte X POS TOP ICOII .byte Y-POS-!OP-ICOMt32 .byte 2- 32- word DoCll4 C4 shlrp • word Sharp 0

;qr1pbic dlta for the n~tur1l or whlte keys . ;X pontion of the upper left cornu ;Y position of the upper left corner. ;width 1n byttl and ht1qbt in ICanlleeS. ; rout!M to pl1y C natural, fourth octave.

0

Volume 9, Issue 5

- - ---

- -

0

;Gr1phic data for tbt aharp or black keys .

-

--

- - - -

0

;!bit ia the start of the icon data table. :lulber of 1co111 . ; 1 position of IIOUII after 1co111 are duwn. ;y poution of IIOUst after 1co01 ~re drawn

-

- - - - -

G4&barp

.word Shlrp .bytt X_POS_TOP_IC009 .byte YPOS TOP ICOII .byte f 3f .word DoGS4; 14 n~tonl • .word Natural .byte X_POS_TOP_IOON+lO .byte Y POS TOP ICON+32 .byte 2~ 32- .word OoAN4 U sharp • .word Sharp .byte X_POS_TOP_ICOH+ll .byte r POS TOP ICON .byte f 32- .word DoAS4 B4 n~tunl • .word Natural .byte X POS TOP ICOIIt12 .byte YPOS TOP ICOII+32 bytt 2, 32 .word DoBN4 C5 n~toral .word htural byte X_POS_TOP_ICON+ U .byte Y POS TOP ICOli+32 byte 2, 32 .word DoCIIS cs sharp ' .word Sharp

--

- -

0

Doicons

-

0

;SiqDil the start of the proqru. ;Jtw01ak ia Dlldtd for e~rly versions of GBOS. ;Actinte and dlsplay the .ouse po10ter. ;Cltlr any left OYer data 10 SID req1rters . ; Load SID reqirttrt for woioe one only.

102

0

I

psect Jsr llnDuk )Sf lloastOp JSr CltlrSIDRegirtert Jlr LoadSIDRtqlrters

byte X POS TOP ICONtlS byte Y POS !OP ICON .byte 2, 32 .word DoCSS 05 01turll word W.tural byte X POS !OP ICOli+16 byte Y POS !OP ICOIIt32 bytt 2, 32 .word DoDIIS OS ahlrp word Sharp byte X_POS_TOP_IOONH7 .bytt Y POS TOP ICOII byte 2, 32 word DoDSS 15 natural .word Illturd .bytt X POS TOP ICON+l8 .byte Y_POS_TOP_ICONt32 .byte 2, 32 .word DoENS FS natural .word Natural .byte XPOS TOP ICOMt20 .byte YPOS TOP ICON+32 .byte 2, 32 .word Dof115 iS aherp .word Sharp byte X_POS_TOP_ICON+21 bytt r POS TOP ICON byte 2, 32 .word DoFSS GS n~tural .word lltural byte X_POS_TOP_ICOIIt22 byte Y_POS_TOP_ICCII-32 bytt 2 32 word DoGNS GSshlrp word Shlrp .byte X POS TOP ICON+23 .byte YPOS TOP ICX»i .byte 2, 32 .word DoGSS AS n1tural .word Natural .byte X_POS_TOP_ICONt24 .byte Y POS TOP ICOII+32 .byte 2, 32 .word DeANS ASahlrp .word Sharp .byte XPOS TOP ICOII+2S .byte YPOS !OP ICOII .byte 2, 32 .word DoASS B5 natural word llatural byte X_POS_TOP_Icalt26 byte YPOS TOP Icalt32 .byte 2 32 .word Do8.'15 C6 Dltoral .word llltaral .byte X POS TOP Icalt28 .bytt Y_POS_TOP_ICOI+l2 .byte 2, 32

- - - - -

0

0

; Copyright 1989

0

0

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• • •

-- -- --

-

.byte X POS TOP ICO!Itl .byte Y POS TOP ICOli .byte 2~ 32- .word DoCS4 D4 n~tunl • .word llatural . byte X_POS_!'OP_lcotlt2 .byte YPOS TOP lcalt32 .byte 2~ 32- .word DoDll4 D4 shlrp • .word Sharp byte X_POS_!OP_ltnl+3 .byte Y_POS_!OP_leal .byte 2, 32 .word OoDS4 U Dltunl .word llatural .byte XPOS TOP IOONt4 .byte Y-POS-TOP-ICONt32 .byte f 32- .word Do£114 F4 n~tural • . word Natural .byte X_POS_TOP_ICON+6 .byte Y POS TOP ICON+ 32 .byte f 32- .word DoFN4 F4 sharp .word Shlrp .byte X POS TOP ICON+7 .byte ( POS=TO(ICON byte 2, 32 .word DoFS4 G4 Dltoral .word latural byte X_POS_TOP_ICORt8 .byte Y POS TOP 1001+32 .byte f 32- .word DoGII4

---

••

-

-

59


;The end of

word Do016

.

CeosMcu: •byte WI_!01' .byte WI_BOf word WI !IT word WI Rf .byte BORIZOIITALil

t~

icon data tihle.;

tahlt to qu1t ~ proqru. ;Put llellU box in upper left COI'IItt •

; lleml

-

-

.

.word GeosTut .byte SUB_MEllO .word Quitllenu

•• Ceolfut. byte •qeos• ,0 ••

;Only one menu box displayed bor1zontally. ; Location of text for 1111nu box . ;Clickinq on box will display a sub •au . ; Location of sub •nu routine . ; Bere is

t~

tut for the box

..

QluUII:ro~

byte WI_BOf byte lllDI_80!+15 word KADI liT .word lllDI Rf .byte VIRTICALil

-

.word Quitfut byte MENU_ACTION .word Qu1t •• QlutTut· .byte "qutt•, o

; The tub -.nu rout1n1 to qu1t . ;open the -.nu cbnctly below tbt

IIlli lltllU.

;Location of tut for sub itlll. ;Clickinq on tbia calla lllttr!)ut'l'op . . . ; . . . routine tbat 11 located ~re . t~

tut for

~

tub it• box . . •

Sharp ;These an qnpluc data for the icons. .byte 224,32, 1, $7P,1, $F! ;!hey are silplt enough to eanly Natural· ; cc.p~ct and do not need the nice Geo.bytt 224, 31,1,$80,1, $00,2, $FF ;Proqra;aer graphic 11ltlbly feature . •

DoCR4 : lda tta lda sta JIP

1195 aOL

116 aOI Play

at& lda ttl

J11P DoO•t:

1195 aOL 117

aOB Play

1209 aOL lda 118 sta aOI JliP Play

lda tta

OoOS4 : lda sta lda

tta jlp DoEll4: lda ttl

1239 aOL

119 aOB Play; Ill

aOL

lda 121 sta aOB jlp Play

60

lela stA jlp DoFS4: lela sta lela sta

iiiiP

;!bis is the start of the routines called by ;clickinq the tppropriate 1cona. The values ;to play the aote desired are lOAded into a ;pselldo-reqi.ater. !be tubroutlDt 'Play• ; u called to actually aOWid t~ note. ;!his is repeated for uch of ~ 25 keys.

196 tOL

122 tOB PlAy 1181 tOL

123 aOB PlAy

DoGII4:

lela stA lela

J1P DoGS4: lela stA lela sta jrap

130 aOL 125 aOB PlAy 1156 aOL 126 aOR PlAy

DoAII4:

lela stA lela stA J1P DoAS4: lela

su lela stA jlp DoB!!4: lela sta lela sta jllp Do015:

lela

au

lela

au

Dc(S4 ·

lda

au

su

;Only one tub itl:a, opened vertically .

; Btle it

OoFI4: lela

JIP DoCS5:

149 aOL 128 aOR PlAy 1223 aOL 129 aOB Play 1165 aOL

131 aOR Play

1135 aOL 133 aOB PlAy

lda

1134

sta lela sta

aOL 135 a08 Play

j.a:p Do0115: lela sb

lela sta JIP

1162 aOL

131

aoa

PlAy

DoDS5:

lela sta lda

sta

iiiiP

DoEIIS: lela

sta lela sb

J1P

1223 aOL 139 aOR Play 162 aOL

U2 aOB PlAy

Transactor


Dol'liS: lda sta lda sta Jill Doi'SS. lda sta lda sta jlp OOGIS· lda Ita lda sta JIIIP OOGSS: lda sta lda sta JIIIP DolN5: lda sta lda sta Jill OOAS5: lda sta lda sta Jill OOBII5: lda sta lda sta JIIIP

30$ LoadB lda eor and

1193 aOL

eia1pra,\11111111 ;Disable keyboard utril eo11Dillls so only tbe eialprb ;~se button u eu•l ned. Use uclusive or I$PF ; to coapl-t data. !o usk out the l \00010000 ; other 1DpUtl, AND a Oct OD tbt data bnt Clp l \00010000 ; for tbt buttoa 111put and COIIplrt btq 30$ ; . branch if buttoa is still bt1nq held lda 1$40 :llouse button released. . atop p1aytng' sta 'rlcntrl )Sf Oocel1tbiO .Restore standard GEOS eoufiquntioa. rts ; Rtt;rn to loolillq at tbt 1cons. ClearSIDReg1rters· )Sf llutloriO ;This routtne is used to flusb out any old lda 1$0 , data stored in all the SID registers . 1dx 1$18 ; loop to uro ucb reguter and executes a 10$ ;'DocelitbiO jtr when done looping. sta vlfrtqlo,X

tu aOB Play 1107 aOL

U7 aOB Play 160 aOL I SO • aOB Play

t57

del

aOL 153 aOB Play

bne jar rta •

'

199

LoadSIDRegisters: jsr IllltloriO 1da 1$40 sta 'rlcntrl 1da l$0f sta ~vo1 1da l $09 sta 'rlattdec lda t$01 sta •lmre1 lda sta 'rlpw!li 1da 136 sta Ylpwlo jsr OocelitbiO rts

aOL 156 aOB Play

1190 aOL

159 aOS Play

)Sf

1da sta lda sta lda sta lda Ita ldy 2C$

ldx

aOL 163 aOB Play

;Make certain vo1ce u off. ;Stt vol._ full ; Stt attack and decay to p1ano enYilope. ; Stt aust1111 and reltut to pWIO envelope.

Stt ptlln v1dtb rtqlsttrs to pWIO vnefom.

,fin11btd with I/0 operations retli!D to GEOS.

115 aOL 167 aOB Play

Quit: jmp

InitForiO l$40 'r1cntrl aOL 'rlfreqlo aOR 'rlfreqbi

;Must be called to accesa SID or CIA.

I$U

;Play tbt DOte'

l $ff

oop oop 10$ 20$

Volume 9, Issue 5

!nterDeakTop

;Leave gtoKeyboard and return to tbe DeskTop.

•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••

;Make aure voice one ia off.

qeoKeyboard . lnk

;Put tbe frtq"Jency data values in tbe SID.

Copyright 1989 By

J~

Cook

• tttt tttttttttttttttt ttt ttttttttt tttttttttt ttttt t lt t tt ttt tttt ttt ttttttt t

• •

'r1cntrl 1$40

10$

diu bne city bne

;MUst be called 1n to access SID and CIA' s.

us

175

00016· lda sta lda sta jllp Play:

10$ DoneWithiO

' ;A loop to gl'rt tbt DOte I I!D!Imt dnratlOD . ; llott tbt use of local labth 10$ and 20$. ; Rud .,rt ahovt U. 1D tbt qeoProgtumer ; ll&tlllAl.

.output geoleyboard ,lilM for sequential output file . beader geoKeybrd&dr. n1 111M of hle COlltaining beader block .nq Flaq Linker, tb.u 11 a aequenhal proqru. psect $0400 Proqru code starts at acldrtu $C400.

geo!!eyboud. rel

Tile DIM of tbe relocatable hle whlcb contains code and data created by Geo-

Asltllbler. Note that GeoAss.-bler autoutlc· ;ally appenda a .rtl to your 10urce flle IIUI. U

61


BASIC 2.0 Array Shell Sort Putting arrays together and taking sorts apart • b'• Anton Treuenfels There

no ingle · be\t · \Ort for all imaginable \Orting problem~. ~o different sort routines designed for different problems will \trike different b<tlancc!> among such competing requirements a~ size, speed. versatility, and robusUlC!>s. The l.Ort routine described here is an example of one such balance. It is less than 5 12 bytes long, can sort 1000 randomly ordered strings in less than seven seconds, can sort any BASIC 2.0 '>ingly-<hmensioned array 10 either ascending or descending order, and tries to behave reasonably in the face of what it con~idef\ to be errors. IS

Using the program The program is assembled to run in the popular free RAM block starting at SCOOO, although it can ol course be rea,,embled ro run somewhere else (it might even be modified to become a TransBa.\lc module). It can be LOADed using the ,8,1 syntax in either immediate or program mode. Sorts are invoked with a SYS call:

the number of element\ in the array until it is greater than the spec1fied final number of elements. When a pa~s is complete another begins, until the ~pecified number of passes is completed. Averaged resu lts for all passes arc then displayed. There is also an option to display the array elements during the fir•il pa~s. This is handy in verifying that the sort behaves as e"<pecred (which it did not always do during development). Elements are diSplayed in groups of twenty, four aero~!. and five down (a minor deception - strings are displayed to a maximum length of nine ra ther than their rrue maximum length of ten for a c leaner display). About sixty array clements can be comfortably disp layed at once. so values up to 60 for 'number of elements to sort' \\-Ork well. I f more elements are used, the display can be !.larted and stopped by pressing any key. The test program reported these average results (in seconds): lli:l ementa

Str i nq

Real

I nteger

---------------------------------------------

sys 49152, arynam(e I ), ary nam(e2) where 49152 is the start address. ary nam i~ the name of the array 10 sort. and el and e2 are elements of arynam. Arynam can be any legal array name (string, real, or integer). El and e2 indicate the e lements that bound the sort: it is not necessary to sort the entire array if that il> not desired. If el is less than e2, the array will be sorted in ascending order: if el is greater than e2. the array will be sorted in descending order. and if e l equals e2 the sort routine exit~ without affecting anything. Program performance The program Shellsort Test loads the !.Ort program and put!. it through irs paces. The parameters of a test arc: type of array to sort, initial number of clements in the arra), final number of element,, sort direction, and number of passes to a\'erage. Each 'pass' is a series of sorts starting wi th an array containing the 'pecified initial number of random e lements. After the array has been sorted once. the sort is executed a second rime on the now-ordered arra}. T he series continue~ by doubling

62

125 250 500 1000

0. 47/0.26 1. 1 5/0 60 2. 77/1 37 6 .53/3.13

0.55/0. 28 1.36 /0.65 3. 23/1.50 7.67/3. 40

0.34/0. 1 8 0 . 82/0 43 1 . 99/0. 97 4 .64/2.1 9

10-pass averages (random/ordered)

--------------------------------------------About the program The calling syntax of name(element one), name(element two) is designed to solve two problems. First, it helps to guarantee that rhe sort routine has rwo valid pointers into the same array. A common alternative syntax is name(element), #elements, which makes it possible that #elements might accidentally be larger than the actual number of clements in the arra). Without expensive error-checking. the sort routine might happily go on to sort memo!) that wasn't actually part of the array, leading to all kinds of nasty side effects. The syntax chosen makes it fairly cheap in terms of time and code to verify that the pointers arc ·reasonable', although it does not go ~o far as ro guarantee that the array is singly-<ilmensioned. Transactor


The other problem is how to nag which way to order the array. It is certamly easy to require a third parameter, but it is also easy to JU'>t let the sort routine compare the two pointers and dec1de for itself. The heart of a !>Ort routine can be regarded a~ a group of four basic task!> repeatedly executed in a loop ~tructure: decide which two object.<. to compare. find them. compare them and, if necessary, exchange them (or the things used to find them). The main difference between variou~ son algorithms is the method of deciding which two objects to compare. On the other hand. the main differences in sorting different objects are how- the) a"i found. compared and exchanged. The program pre ented here divrdes the four basic tasks into a single Decide routine for all object~ and a ~eparate Find, Compare and Exchange routine for each different object. Although in the interest of saving space there are several places in the code where sharing or overlap occurs, in principle there are ten separate routines (I Decide, 3 Find. 3 Compare, 3 Exchange) and there is nothing to prevent any one of them from being replaced independentl)' of any other (to gain speed at the expense of siLe, for example). The possibility of adding routines to sort other objects or implementing other sort algonrhrns altogether is also open. The Decide routine (the actual sort algorithm) is a Shell sort. It IS a reasonably compact, fast. and understandable algorithm that performs well on random and e'en better on ordered collections of objects. Alternative algorithms that might be U!>Cd here arc the Insertion sort (about the ~ame code size; performs best on nearly ordered collections) and the Quid ~ort (larger code siLe; as usually implemented performs best on random collections).

~arne

code can sort in either direction by :.etting a fe\\ nags at the start of the Decide routine. rather than ha" ing to \\rite a separate routine for each direction. For example, the Decide routine of She/lsort calls the Compare routines looking for e1ther ·greater or equal' or ·tess or equal' (dependmg on which du-ection the !>Ort runs), and exchange~ element'> if the desired relation is '\OT TRuE. The Exchange routines are straightforward. It i'> interesting to note that, even though the process of locating '>lrings requires a level of indirection, exchange is similar to that of reals and integers. Of course, it is the string descriptor. rather than the string'> them-.elves that are being eltchanged. The idea of sortmg de. criptors of objeCt'> tnstead of the objects themsclvc~ can be taken more genera! I). For example. integers in one array can be treated as representing clement numbers of a second array. A J...eysort arranges the integers in the first array according to the values in the ~econd, so that the first array becomes an 'index' to the second. It would require only a slight modification of the Find and Compare routines of Shellsort to implement a keysort of any array type. It would even be handy: there are often occasions v. here it is more useful to have a sorted index to an arra) than a '>Orted array.

In effect, an) of the various modifications that might be made to extend or change Shellsort amount to striking another of the many different possible balances among ~ort requirements. Readers are welcome to use any of the material presented here in their own efforts to strike useful balances.

Listing 1: shel/sort.s- Merlin format

* buit 2 0 array

IMll IOrt

• 1aat rtV1110ft' 09/28/88

The Find routines locate the objects to be compared, taking mto account object sizes and the fact that, while the contents of real and 1nteger arrays are reals and integer'>. the contents of ~tring arrays are not strings but instead string de~criptors. The separateness of the Find step is an often overlooked part of a sort routine. In B ASIC 2.0, for example, a variable is automatically located whenever it occurs in the program text, so that in a BASIC 2.0 sort routine what looks like a Compare operation ts really a combined Find and Compare operation. The Compare routines assume that. gtven an) two objects of the same type. the )tatement can ah•ays be made that in orne :.ense the first is less than. equal to or greater than the second object. The Compare routines determine which is the case and return a nag byte in which set bit!> reprc!>ent logical relationships that arc TRUE. For example, if the fir&t object is less than the second, then all of the logical relations 'less'. ·tess or equal' and 'not equal' are true. Thi~

system of return value from the Compare routines is a little more complex than that used b) compare routines in man)' other sons (often simply a negative value for less than. zero for equal, positive for greater). The ad•antage is that the

Volume 9, Issue 5

• wr1ttan by anton treutnfa1s • 5248 bor110n dr1ve • fr1dley, atcneaota usa 55421 * 612/572-8229

* progr11 eonatants asudr • $c000

;assembly address

tstne " \100000 tatgt • \010000 tstge =,001000 tsteq • \000100 title =\000010 tstls • \000001

;not equal qreater ·greater or equal equal .less or eq-.al

;le.ss

11grt =tatne tatgt.tstge isequ • tstge.tsteq.tstle 1sles • tatne.tatle.tatla

* prograa ltro-paqe usage elptr

=$22

e2ptr • $24 elal = $26 ela2 a $28

;pointer -> lst el•nt pointer - > 2nd tl..nt · 1st ele.nt i..cdu 2nd t leii!Jlt indu

63


Went" $58 produc = $Sa ellen e1adr e2len e2adr

= $60 = $61 = $63

;lst atring descriptor ; 2nd string descnptor

:$U

tatflq "' $69 delta = $61 lstela = $6c errtla = $6e

• report e.rror ;teat-type flag , COIIpllliOD chatanoe . laat el-t thu pau ;current dement this pass

• basic 2.0 raro·paqe vsaqe a.rysta " $2f • YliiWI = HS 1'Uadr" U7

;atart·of-arrays ;current •ar1able nut ;current variable address

* basic 2.0 indirect vectors baserr

=$300

;verify array element arysta l<U varadr+1 Jta be91J...+l, x sbc aryata+l bee typerr ;b not array element rts Clip

;leltMnta ;IUltiplication product

; error report

typerr ldx 122 ; type IUSUtch' jlp (baserr) • sort

~ter

tables

uort <U ell da da

2 fnchnt e11p1nt ucint

fsort da da da da

5 fndflp

ssort da da da da

3

lbytu/ elaent ·find rovtine ;cCIIIplrt rout1ne ;excblnqe routlllt

Cllpflp

excflp

* basic 2.0 r011 chkc011 = $aefd fndvar • $b08b aeafac = $bba2 aapfac • $be5b

; check and skip co-.

;locate variable ; transfer ~e~ery to fac ;c01p1tt ..-cry to fac

• array sort parueter fot111t :

•••••••••••••••••••••••••••••••• orq uudr • basic 2.0 1nterfaoe

parl

par2

jsr chkcoa jst fndn.r ldx 10 jsr sa~ lda niiiD+l pha lda Vl%1lU pha jar cbkcea jsr fndfar ldx 12 jsr uvptr ldx 18*3 pla bpl parl ldx 18*1 tor varnu bee typerr ph lai par2 ldx 18*2 tor vamu+1 bee typerr ldy

)libl

;qet lst pariMttr ;aavt •ar1able address ;aavt •ar1able

fndstr aapstr u cstr

0111

;qtt 2nd parutttr

; au\IM at ring ;1st char of lst name ;b:real or atring ;i nteger ; n11111s utch? ;b:no ; 2nd chlr of lat nut ;b:string or integer ;real

18*1

• • • • • •

word beqea word andea word elasu word fndadr word Clp'dr word npadr

-

location of flrst tl-.nt locat1on of laat element lbytes 1n an element location of find rootint locahon of COIIpllliOII root1111 locatlon of uc:Wigt routint

• arny sort aryart ldx beqea ldy beqe J...+1 cpy endeJ...+1 bee aya2 bee aysl cpx endelll bee ays2 btq ays3 aysl lda endelm sta btgelm lda endelll+1 sta btgelm+l stx endelll sty endtlm+l ays2 php jsr fndcnt plp JSr shlsrt ayt3 rta

b:flrst<lut

;b·f1rat•laat (ont ele=ent) ;exchange pointers

;aave dirtct1on flag :get element count ;execute aort

ldl iaort-1 1 •att r. .ininq parutttra sta elasu·l,y dex

dey bct )llb1 jsr arysrt rts

nl'ptr ldl nradr at a beqela, x

64

fndcnt

;execute sort

save location

sec ldl sbc ata ldl sbc sta ldy ldl

endea ·lbytu 1n array beqela elacnt endeJ...+1 beqeJ...+1 eJ...cnt+1

116 10

Transactor


Jbbl

fdcl

ul eacnt ;dlv1de by lbytes/element rol eacnt+l rol Clip el.ui& bccfdcl she elan& lllC eacnt renlt in eacnt dey brle Jbbl rts

shl3

* lllddle loop tlld shU

* sbell sort shlsn ld& eacnt sta delta ld& el,lw:nt+1 ata delta+l ld& ttstle bee shll ld& ttstgt shU sta tstflq bne shU

* outer )bbl

t

·desctnlhnq sort ;test-result flag , enter outer loop

sec ld& elacnt ; lste~ ellcnt-dtlta she delta sta lstela lda elacnt +1 she dtlta+l sta lstell+l ld& to sta crrela crrtlP 0 sta crrtll+1

crrtla ; elal• crrela elal delt. eW ; tW• crrtll+delta crrtll+l tlal+l delta+l eW+l

jsr fndela jar COIIpU end tatflg bne shl2 JSr eachng sec ld& tlal st. eW sbc delta sta elal ld& tlal+l staeW+l sbc dtlta+l sta tlal+l bel Jbb3

* llllltr shl2

; find

o•

;b:no - continue

; finhhed

fndlnt ldy dfb fndflp ldy dfb fndstr ldy ldx )bbl ld& sta ld&

fndl

; ca~p~rt

Jbb2

;eW• elal ;elal= elal·delta fnd2

12·1 $2c IS-1 $2c

13-1

12 elal+l, l produc+l tlal ,l cpy Il-l ;lnttgtr? ;b:yts bee fndl asl . •2 rol product1 cpy IS-1 , stri.IICJ' bccfndl ; b:yes asl :•4 rol produe+l adc elal,l . •2 •1, •s sta produc lela product1 adc elal+l,a sta produc+l lela produc adc btqela ; add offset to but address sta elptr,a lda produc+l adc btqtla+l sta elptr+l,x dex dex btq )bbl :b:do second tl. .nt cpyll-1 ;string' bne fnd2 ;b:no ld& (elptr) ,y ;get string descriptors sta ellen,y ld& (e2ptr) , y sta t2len,y dey bpl Jbb2 rts

• CXllfUt two tl-ts

;b:tlal

)c

0

loop end

inc crrtla ; crret. errell+1 bllt shlJ inc crrtla+1

Volume 9, Issue 5

:delta:

fndela jmp (fnd&dc) ;to current handler

ele~~~nts

eleaents ; 1n proper order? ;b:yes ;swap eluents

;deltaz lnt (delta/2)

* f1nd two el111nts

• inner loop )bbl

delu+l delu delu+l delu Jbbl

rts

loop

clc ld& sta Ide sta lela sta adc sta

hr ror ld& ora bllt

• oater loop end

·ucendinq sort

loop

mddlt

Jbb2

; delta= eacnt

ld& htela cqo crrela ld& httll+l she crrell+1 ·b htela >= crrtla bel Jbb2

COipU

jlp (Clpldr) ; to current b&ndltr

* CQ~PUt

l.Otegen

cqoint ldy 10

;101t ngniflcant byte

sec lela (tlptr) ,y

65


abc (eZpU), y beqci!l2 1m =1 ; Slqned CCIIIplrt

bve tlgrt bvs elles e1n1

cUll

dey bp1 )bb1 rts

• aort par&Dtter storage dua •+U$fffe

bve e1les bva tlgrt

;word-align

lllJ lda (elptr), y

beqtla dJ 2 ;polllter -> flnt elaent tlldtla ds 2 ;pointer -> lut t l - t tlath dJ 2 ;fbyt:es/elaent

abc (tZpU). y beq e1eqo bee elles ; unsigned

fodsdr ds 2 ;vector -> find rouhne Clpldr ds 2 ;vector -> COIIpUt routine swpadr ds 2 ; vector -> excb&D9e routine

COIIplrt

• return e1 greater than t2

dend

tlgrt lda llsgrt rts

Listing 2: BASIC generatm f or "shellsort.o"

• CCIIIplrt floatlllg points

811 100 ra gcerator for "abtlhort .o•

GC 110 n$•"abtllsort .o•: r• nut ot progru

empflp jsr lelfact4 jar cmpfacH bid elles bnt tlgrt

;el to fac ;compare t2 to fae ;b:el<e2 ;b:tl>t2

• return t1 equal e2 e1eqa Ida liseqo rta •

ca~p~re

strings

empstr 1da ellen Clip t2len ' COIIpUI lenqths ;b~el<t2 boecstl 1da t21en cstl tu ;use shorter stnnq ;b:aborttr ia null beq cat2 ldy 1-1 )bbl iny lda (eladr),y ;chars different? Clip (e2adr) , y bne cst3 ;b:yes du :all char I CCIIfUid? bnt )bbl ;b;DO est2 1da ellen ;lenqthl dlfttrtnt' Clip t21en ;b:t1..2 beq tltqa ;b:el>t2 eat3 bot t1qrt • return tl less tban e2 tllu 1da lisles rta • exeb•nqe elements

exchnq JIIP (awpadr) ;to current hlnditr excint ldy 12-1 dtb $2e ; skip atxt two bytes excflp ldy 15-1 dtb $2c ucatr ldy 13-1 )bbl ld& (elptr), y tu lila (elptr), y sta (elptr),y tu ata (t2ptr),y

66

Fl 120

nd=~95 : sa~9152 :

ch•61786

(tor lints 130-260, see tbt standard generator on page 5) LB 1000 data 32, 253, 174, 32, 139, 176 162, 0 aa 1010 d&ta 32 ~. 192, 165, 70, 12 165, 69

IG 1020 data 72, 32, Ll 1030 d&ta 2, 32, n 1040 data 2, 162, BM 1050 data 48, 2, IK 1060 data 160, 8, OF 1070 data 202, 136, ON 1080 data 165, 71, PL 1090 data 12, 157, Hi 1100 data 96, 162, OL 1110 data 57, 193, PJ 1120 data 60, 193, EM 1130 d&ta 63, 193, C. 1140 d&ta 193, 172, Gl 1150 data 27, 208, BK 1160 data 240, 26, BO 1170 data 173, 243, u 1180 data 193, 140, OM 1190 data 40, 32, Cl 1200 data 193, 237, ~ 1210 data 193 237, Jl 1220 data 169 0, NO 1230 data 244, 193, 01 1240 data 88, 136, CM 1250 d&ta 106, 165, AC 1260 d&ta 2, 169, IL 1270 data 165, 88, 10 1280 d&ta 229 107, GC 1290 d&ta 133, lll, OC 1300 data 106 133, II 1310 data 107, 133, AI 1320 data 193, 37, GN 1330 data 56, 165, JN 1340 data 38, 165, DA 1350 data 39, 176, JG 1360 data 111, 165, MB 1370 data 111, 176, EM 1380 data 107, 5, RI 1390 data 193, 160, Cl. 1400 data 2 162, 01 1410 data 38, 192, Ol 1420 data 192, 4, !DC 1430 d&ta 38, 133, ID 1440 data 91, 165, 1C 1450 data 165, 91, DC 1460 d&ta 202, 240, PI 1470 data 34, 153,

253, 174, 32, 64, 192, 162, 8, 69, 69 , 162, 16, 69, 189, 85, 192, 208, 246, 32, 157, 240, 193, 241 , 193, 229, 22, 108 0, 136, 193 217, 167, 193, 220, 180, 193, 223, 241, 193, 204, 7, 236, 242, 173, 242, 193, 193, 141, 241, 243, 193, 8, 197, 192, 96, 240. 193, 133, 241, 193, 133, 6, 81, 31, 144, S, 237, 208, 238, 96, 89, 133, 107, 8, 133, lOS, 229, 106, 133, 133, 109, 169, 24. 165, 110, 40, 165, 111, 41 32, 54, 105, 208, 22, 38, 133, 40, 39, 133, 41, 224, 230, 110, 108, 197, 110, 191, 70, 107, 106, 201, 162, 1, 44, 160, 2 181, 39, 2. 144, 10, 144, 3, 10, 90, 165, 91, 90, 109, 240, 109, 241, 193, 208, 192, 2, 96, 0, 177,

139, 24, 208, 70, 153, 110, 197, ~8 .

3, 193, 193, 193, 243, 193, 141, 193, 32, 56, 88, 89, 19, 244, 165, 169, 208, 108, 0, 133, 133, 193, 32, 229, 229, 208, 165, 102, 96, 4, 133, 10, 38, 117, 193, 149, 208, 36,

176, 162 104, 16 42, 104 208, 33 243, 193 192, 96 47, 165 lU, 1 2, 0 S, 0 3, 0 174, 240 193, 144 144, 20 240, 193 142, 242 157, 192 173, 242 173, 243 160, 16 42, 205 193, 230 88, 133 2, 144 84, 56 165, 89 133, 110 38, 101 39, 101 32, 133 214, 193 106, 133 107, 133 2, 230 109, 229 106, 165 108, 246 44, 160 91, 181 38, 91 91, 117 39, 133 149, 34 35, 202 13, 177 153, 99

Tronsoctor


DP 1480 data 0, 136, BM 1490 data 160, 0, n 1soo data 10, 48, BP mo data sa 112, OB 1520 data 240, 15, CP 1530 data 166. ll7, LG 1540 data 243. 169, Ml 1550 data 144 2, IP 1560 data 255. 200, lJ 1570 data 202 208, OG 1580 data 224 176, PI 1590 data 193, 160, 08 1600 data 2, 177, BA 1610 data 138 145,

16, 243, 96, 108, 56, 177, 34, 241, 4, eo, 15, 112. 9 200. 177, 34, IH , 47, 169, 56, 32, 95, 181, 48 14 96, 165, 96 165 99, 170, 240 177 97, 209, 100 246 165 96, 197 209 169 35, 96. 1, H 160, 4 34, 170, 177, 36, 36, 136, 16, 243,

248, 193 36, 240 60, so 241 , 36 96, 32 36, 208 197, 99 12, 160 201, 9 99, 240 108, 250 H , 160 145, 34 96

IE 535 print' {down}lelements ,'randoa','lorted' CO 5CO print cc=ie:ci=l lB 545 printcc.fnrn(up (cl) ), fnrn (sp(ci}) GJ SSOcc=2*cc :cl=ci+1 EJ S5S ifcc<=fetbenS4S Elt 560 : CA 565 p$='(down)anotbu test (no, yes)' · q$='ny'·9o1Ub975: Ha=2tbtxln~oto1SO ( l 570 : E! sao ~

liL 585 :

CJ 600 printcc p$. AI 60S

lfso=1t~=1

b=cc

otl 610 i!so=2thtna=cc:b=l

• Listing 3: Shellsort TeH DB 100 print'(down}* array sbt11 sort tester' DC 10S print•• by anton trtutnfe1s'

IN

Ill IJ

Ll 110 print * last revised - 09/28/88'

ax

80 115 :

BG

rz 120 ifpeek(49152)<>32orpttk(49153)<>253thena=peek(186) :load"shel1sort.o",a,1

PM

BP 125 :

EB

MN ISO ae=1000:sr=20:mp=20 AJ 1SS Ul=32000:irz16000 !N 160 r.=1000000:rr=SOOOOO: rp=l00 .:! 16S : lJ 180 print (down}define test para:Detm:• .: 185 : MG 200 p$=' array type (string, integer, rell}":q$=' sir':gosub97S:at=a Bi 20S : II> 210 p$= (down}initial hlwnts' :p=1:q=-:r=int(R{8) :gosub950:ie=a Ll 215 : LI 220 p$='(down}finll h1wnts':p=it :q:u:r=-:9os1lb950:fe=a Fl' 22S Cl 230 p$= (down}sort order (ucendiDg, clesetnding}':q$='ad':qoscb975.so=a t1 235 !! 240 p$='(down}lpa1Sel to 1Vetl91' p=l:q<200 r=1 :goscb950:np=a Ji 2C5 AI 250 p$= (down}duplly hut pus (no, yu)' :q$='ny• .qostlb975:df=a Cl 255 OD 300 deffnr0 (t )•tnt(rnd(1)'1) Q 305 cltffnrl(t)"lnt(rnd(1)*a)+l IJ 310 cltffnrn(t )•lnt((at.005) •100)/100 PI 315 · B!l 330 ifat=ltbendWr$ (M) 80 335 iflt=2tbtnch.uri ,.., Dl 340 ifat=ltbendiau (11) liM 3CS : JM 350 dialup lap) ,sp(ap) B!l 3SS : Q! COO forpc=1tonp OC COS print'{down}paaat•;pc Oo\ 410 : II C20 cc=ie:ci=l A! m ifat=1tbengosub750 cc C30 : EB 450 gosub800 !D 455 p$=' nndOF' !l! 4£0 gosub600 Jl 465 up (ci):up(Cl)t(et-up(cl))/pc e:; 470 p$•'sorted•' 11 II J'F !J JG !!' Iii

G!(

DA

LA BP BG

615 onatqoto620,625,630 620 c=tl:sys491S2,u$ (t),ar$(b):d=tl:goto63S 625 c=ti·sysC9152,ar\(a),tr\(b):d=tl:qoto63S 630 c=ti·sysC9152,tr(a) ,lr(b):d--tl 63S et=!nrn( (d-c) /60) 640 printet;'seconds' 645 ifdf=2andpc=lthlngosub850 650 return 65S : 750 print'(down)91neratinq aaster string. • 7S5 a=rnd(rnd(-ti) ):~$='' 760 fori=lto2SS:as$-as$tchr$(fnr0 (26)+6S) :next :rlturn

BB 765 •

FI 780 fori=1tocc:ar$ (i)='';next·•=fre(O):return PI

EJ

AB IL

FI DI IC liM PF

78S 800 prtnt'(down)gtDintlnq';cc, ' lliDIDtl. ' 80S t=rad(rnd(-ti)) 810 on~tgoto815, 820, 825 SIS •=8+df:forl=1tocc :u$ (i)=aid$(as$.fnrl (240) fnrl(a)):aext :goto830 120 forl=1tocc u\(i)•fnr1 (ua)-lr Dllt:goto830 825 fori=ltocc u (i)=(fn:O (ra) -rr)/rp cart 830 lfdf=21ndpc=1tl:tllqos1lb850 835 rtti1III

IlL 840 CP

EH AB lli GR

AC ER

OD GJ

DP PN BP Kit

!!A

or

850 fori=Otocc-1sttpsr SSS prlnt:onttgoto860,865,810 860 forj=ltosz:printleft$(u$(itj), 9) ,:nert·qoto875 865 forj=lton printu\ (i+j) , : ntrt:qoto815 870 forj=1tosz :printar(i+j),:ntxt 875 gosub900 880 nut 885 print :print" (down)prm any kly(dovn) ' :gos1lb905 890 return 895 900 qeta$:ift$•''thtn910 905 qeta$:ift$=' 'then90S 910 return 915 950 a$=str$ (p) b$=atr$ (q) :c$=rtr$ (r) 9SS pr1ntp$;' ('. t$ · -';b$;' ) ';c$;1eft$('(7 1eft)',len(c$)+1); 960 LnpQta,l=int (a): lft<pora>qtbtn9S5

m 90sub6oo

KF

cas :

BO 965 retnrn 00 970

480 sp(ci}<tp(ci}+(et-sp(ci))/pc

500 ifat=1theaqo1Ub780 50S cc=2•cc:e~=cH1 510 ifcc<=fetbtnCSO SIS

lA 520 Dlltpc BI S2S I!G 530 print'{down}{down)avenqes ovtr';np·'pauu:•

Volume 9, Issue 5

BB

BC FJ DN IP

915 prlDtp$;' • left$(q$,l); ' (left)(1tftl{1eft)' ; 980 tnpata$:t$=left$(a$,1) 98S fort=1to1en(q$)· ift$~d$(q$, t , l) tbtn995 990 next:qoto975

pp 99S

rtti1III

67


A glob Function For Power C Wildcard pattern matching •

by Ad rian Pepper

The Pov.er C .,hell provtdes a pleastng command-line interface. llowever. I often found my~elf wishing it would provide the useful 'wildcard' file name facilities of systems such as MS-DOS and UNIX.

available file names for pattern matching. The ..,imple dir program illu..,tratcd doc~ thi~. It C!>!>Cntially mimic!> the built-in shell I command which give!> a directory listing of the drive currently designated as the 'work' drive.

'Wildcard' is a term used to refer to the ability to specify many file names at once in a command line by having the command line interpreter treat \Orne argument\ not ju~t as single literal names, but as pattern~ matching sets of file names. Many of us get used to I) ping *.con other sy terns to match all file names ending with .c. llcre the • b not interpreted literally, but is a metacharacter, used to mean "any number of repetitio~ of an> character". From the hM of all currently available ftle names. all matching file names are selected and the command funcuons a'> tf all the names had been ltterally typed in place of the pattern.

I*

For reason'> buried deep in the fifteen-)·ear anuquity of li:-.tx development, progran1s and routtnes for expanding wildcard patterns into li'>l'> of matching file names often go by the name glob. It is an abbreviation of "global". and a reference to the fact that the command wtll be executed ··globally"; that is to say, for all appropriate available file names. A very narrow-minded u~e of the word "global". if you think about it.

* dir.c - basic-1tylt directory lilting

*I

I include <stdio .h> static char buf[lOO) ; uin(uqc, U9"f) WISlCjlled ltqC:

char '*"9"'.

I

chit tp&t ; Wl.Ugued deY; fiLl fld ; unugued c;

1• co-•nd llie p.atttm 1f qnen, pat = (uqc > 11 ' lt9"f[l) ••

tl.. upty ltnng

sprintf (buf ' $h" p.at) ldefille wrkdeY (*(char •)Ox17fc) dev =wrkdel'; I* deVlet Itt by abtll work cc-•nd

*I

*I

fid : 5· if (!open(fid, de•, 0, but) ferror() ) ( -prictf(' Can' t open h on device \d\n", buf, deY) , exit(!] ;

I Although the Power C shell docs not provide this, it proved not too difficult to create a gcncralited means to allow Power C programs to easily support it themselves. This article attempts to not onl) give a solution, but also to trace the <;teps by which a concept can become a practical tool. In addition, 11 attempts to give a httle insight into rhe C language and the Pov.er C package. Strangely enough. though. the algorilluru. and syMem details pre~ented can be easily adapted to a variet) oflanguages. Reading a disk dri\C direciOr) \\ ilh Power C The fir'>t \tep v.a., to verify that Power C programs could quite ea.-.ily process dtrector) ltsttngs from 1541s and similar dbk drives. This directory liMing would be considered our list of

fgetc(fid); fgetc(fid); /* skip 'load address• •/ while ((n = qdirline (buf, fid)) '• WF) printf('\u la\n', n, buf) ; felose(fid) 1• !close for open () allows rt·use */

I The !{dirline rout me is crucial to the dir program: I• • gdlrliDt.c - rtld a lint froa a •

directory load' 111to 91Yet1 but

• retum u fullctioc Yxloe • • tba hne c1Jibtr' part of bu1c • style line (thlt is, nllllbtr of • blocb) • - !OF at end-of-fllt

.,

l111clude <stdlo h>

Transactor


I*

qdirliae(buf, fid) cbu *buf; FILl fid;

* devglob.c - expiJld vildcud filenuet

*

* devglob executu tbt qiven fWictlon * for each flle DUll returned by a * directory litt1D9 of the 91\'tn • filena~e v1ldcud pattern on the * qi\'tll device

I cbu *b• lll!SlqDed C .

D;

fqetc (tid) ; fgetc(!id) ;

1•

n = fqetc (fid)

/• qet hne nlllber', low byte */ 1• and hlgh byte •/ I* and put tbe two toqetber *I

•1

c<<8.

• read rut of Hoe· ended norully by a rero byte for (b =buf (c = fqetc(fld)) '' c '• IOf; +tb) • *b = c·

•b

*

I• . *I

c = fqetc (tid) D •:

skip "link'

='\0'; I*

* returns u fWiction nlue tbe nuabtr * of - • utcbed t

*I

JUSt in e&ll didn't end w1tb rero */

1f (c = EOF) return &01'; return n;

I* return 'line number' *I I* usUM &Of is invalid line mlllber *I

)

* 'lbe ' select funchon U91*nt allows • tbt file selection process to be * custCialnd

*I

I include <stdio. b>

I* * this structure il to create a linl:ed * list of utcbinq flle n-s

*I

typedef struct link ( struct link •l$nest; I* point to next 1n bat char *l$naae; I* point to name of tbit file

'I *I

) I.IIIK;

static LIIIK *n&m~liat; static char buf(lOO) ;

The dir program takes advantage of a feature of the 1541 and sirmlar di~k drive~ by opening a 'directory listing'. signified by a ftle name beginning with a dollaHign character ($), but also specifying zero a... the \econdary address for the drive. This is interpreted specially by these drives. causing them to format and send back what appears to be a BASIC program, complete wnh load address. and meanmgles:. statement links. The number of block~ for each file is l.ent back a... the line number for the 'statement'. while the Matement itself forms the rest of the directory line. Whenever the file name used for an open begins with a dollaNign, the directory is opened. Only if a secondary address of zero is used "'ill the special 'BASIC program' format be tran~mltted. All this b why load "$" ,S 1n BASIC replaces your current program with 1>omcthing that, when listed, g1ves you information about the directory of the disk.

While Power C docs provide library routines for reading the actual disk directory eorries, there were a number of rea~ns for not wanting to usc them. The most important was that they would not work at all with the normal RAMdi\k ~oftware provided by Commodore for their 1764/1750 RA\1 expander, while the opening of a directory lbting on secondary address zero would. Sa' ing a directory listing for later use The Commodore disk drive~ perform limited wildcard matching \\.hen retummg d1rectory listmgs. A question mark ('!) can be u~ed to match any '>mgle arbitrary character, and an astensk ( ) can be u\ed to match any number of any character~.

A preliminary routine for providing the glob facility then can be !>imply written. as foliO\\.\:

Volume 9, Issue 5

devqlob(dev,pat, func,aelect) unsiqned dev I* device to use for dir *I cbu *pat; I* fllenua pattern to up&nd •1 int (*func) (); I* fWiction to call on utcbea */ int (*select)(). I* extra utcber *I

I

utem chu •ulloc (): utem chu *strdap () Lin ttpllnk· / ' keep track of end of list •/ LIIl *nlw · I• po1ntu to nw Lilli cnated •1 chu *unae' I* pointer to new aUld nae •1 Llllt *llw· 1• qtl)tral po1ntu to Lilli •1 chu *b; fiLl fld

int n· sprintf(buf,'$h ', pat);

I* fora directory n• *I

tid = S; if ('open(fid, dl'f, 0, buf) terror() ) return 0; plink ~ 'nameliat; *plink = NULL;

I* utchinq file naaea will *I I* be saved in a linked lilt *I

fgetc(fid) ; fqetc (fid):

I* skip "load addreu • *I I* . . . •I

while (qdirline(buf,fid) '• tOr) I if (*buf ,., • •) ; I' not a filtn&DI liDI; sk1p it else ( for (b = baf+ltrlen(buf); b > buf '' *b '• •••• --b)

*I

*b = '\0'. for (b =buf 'b '• '\0 '' •b++ !• '"'; ) · /* sklp to lOS or after first ''' *I lf ('lllect (*lllect) (b)) (

I* qot a gOOd ooe• •1 I* use ulloc to create a Lilli atruct for lilt *I

nhcl = (I.Illl *)ulloc(l,sheof(LIIIl)); ~ =ttrdDp (b) 1• ane copy of IIDI •I I* note; baq 1n POI!R C causes low byte •I I* only to be tested if amqDMnt clone ins1ele 1f *I 1DIWII) I 1f (! nlink

69


printf(' glob: too aany 01111 1t \s\n', b) ; break; / • finish prtuturely */

l nlillk·>l$1W11 • llllUI' *plink = nlink; plink • 'nl1Dk·>l$ntlt; *plink • troLL·

!• po111t to IWII •/ / • llld link lltW Lin */ / * link next one bere •/ / • lULL (tnd) for now */

l l

To provide a wildcard facility of the sort we would like then, we need to check up on the results of the Commodore disk drive wildcard matching. Because the C language and the Power C Implementation both support recursion, a nice wildcard matchmg routine IS not aJl that difficult to write.

I fclost (fld); / • felon for

,. ., .

ope:~ ()

allows re·uu •/

• now ruo throogh tht lilt of sntd • cues, eucutinq tht functioa for

• uch one

n •

0;

for (llink • cuelilt lhnk; llink=nlink) ( if (fUllC) ( 1 fUllc)(llink·>l$na~~); /• call funct1on */ nlink • llink·>l$next; / * r••btr next */ fr.. (lhnk·>l$nlllll) ; !• before ptr frttd 1 / free (llink) ; Hn; / 1 count utching na~~s •I

l return n;

Recursion refers to the ability of routine!'. in a computer language to invoke themselves. To implement this, the language must create an entire!> new environment (i.e. set of local variables) for each invocation of a routine. This means it does not matter when a routine calls Itself, either directly or indirectly. The recursion is needed as an easy way to check that all possible ways of expanding any occurrences of • are considered before the pattern is rejected. For example, rhe panern a*x?o matches the string axyoxyo, but it is necessary to reject the first matched x?o, and go back and look for another.

I Our wildrnatch routine, to support • and ? , i~: This merely requests a directory, and stores the list of names returned in a linked list, making use of the C language srruct facilities, together with the C libarary dynamic memory allocation routines. When 11 has finished collecting the directory hsring, it execute~ the g1ven function once for each ftle name found. In add111on, a 'selector' facility is provided.

I• • wildlatch • do IOderately priliti,.. • wild card 11tch

• returns non-zero u tht fl:nctioa •aloe • 1f 91,..0 pattern 11tcbes string I

The strdup routine used b> derglob is mere!}: t111cladt <at4.1o b>

I• • strd1:p • alloate a copy of string t

• returns u functioa •alue the • newly alloattd str1ng

• !lOLL if enough 111110ry il not aYailablt

*I

• pattern can cocta111 the following • special chlncters:

• • •

• - 11tch any n,_r of eny characters ? • 11tch exactly one of any character

t

all other characters art 11tchtd littrally. ' •• end '?' C&Mot be

• • •

utchtd literally. Pattern entire string.

.,

~nat

utch

char • strdup(string) char •string;

tdefine NO 0 tdef ine YES 1

{

wilcbutcb (p,a) char *p; I* pattern, as a literal string •/ char •a; I* string to tut aa utclung entire pattern •/

extern char *aalloc() ; char •newstr; newstr =lllloc(strlen(string)+l) ; if (newstr 1• !lOLL) strcpy(newatr, atr1ft9) ; return newatr · )

C hecking up o n Commodore's wildcards

{

char pc; for ( ; ; ) { I* Ulltil we return by fulure or success I* sntch oo next char in pattern •1 switch (pc • *p++I

I can ' ••:

The trouble with a Commodore drive's interpretation of • is that an) suffix following it i~ 1gnored. The •.c example given above, for in~tance, would be interpreted b) a Commodore drive ~ matching all files on the drive, not just those ending in .c.

70

*I

I• 11tch any nllllber of any char *I

do {

I* chtel: all pouible

suffices • I

1f (nldlatch(p, all return TIS 1• at leaxt 1 auffil woru */ I while 1'•++1· ret= 10; 1• all auffic11 lDCoaustent •1 cut , ?':

Transoctor


if (*a - '\0'1 return NO;

I* utch any

1• tbt chtck next chu

l.ll

rt&l chu

p an4 a

*I

•!

bru.k;

char *aaae, (

retum wHdrutch (savepat, oue) ;

I

case '\0': /• pattern eDded •/ rttum •a "" '\0'; 1• YIS oaly 1f 1 ancla too */ t• returnillg ns IUICOII4itlOJW.ly bert woald •/ t• cbeck if lllitial port1oo of a utcbed p •/

!• literal utch of chu ill pattern */

cllfalllt ·

/ * ASSD! · if •s "" '\0' if (•• '•

1ft

rttlll'D (1101 */

pel

ret= 110·

• glob - lltc:Ute giftD function for each • hlt on tbe work de-rice utcluoq • the qiftD pattern

.,

qlob(pat f1111cl / * return quit/coot10ue status •/ chu *pat· t• filto&M pattern to llplDd •/ lilt (*fwlc) (); I* f1111etioo to call oo utcbes */ (

!• else checl: uzt chu I • ++1 ; / • atlt char io 1

lll

p an4 •

lilt select () txtem illt apnntf ()

*I

tlttrn char *Ulloe();

*I

11111iqned iobauc:: /* flag if liolted u buie progna •/ 1111aiqned dev; char *p, *tndp;

l l

• Because each invocation of wi/dmatclr has its own private copies of p and s, and docsn 't disturb the values known to the one calling it, this provides an automatic method of keeping track of the success of each possible suffix to the string thus far matched. With some care, a non-recursive solution to matching this simple definition of pauems could probably be written, but the algorithm given here is easily extendable to more complex wildcard features. These include characters classes, typically represented by enclosing a list of characters in square brackets ([ and ]). For example: *

0

tdefine wrkdev (*(char *10xl7fc) I* device aet by shell work command */ tde!int krndev (*(char *IOxba) I* device last used for ktroal OPEN */ dev = wrkdev; I* ASS!Jlf: sprintf needed by cllvglob *I lDbasic a •sprlntf > Ox880; if (illbalic:) dev • krndlf; if (patiO) ... ':' 1 / *outs won' t contain dnve •/ p = pat+l; else if (pat[l) "" ':'I p = pat+2; else p = pat; I* uke pat aec:euiblt to stltct 11 savepat = ztrdllp(pl;

(eh)

/* r~vt =typ froa tnd of pattern •/ I* llllct it woo' t appur eltbtr */

would match file names ending with either .c or .b extensions. Other exten!>ions to pauern matching include allowing the repetition of any element, not just the 'any number of any character' as implied by • . An excellent discussion of pattern matching techniques is included in the classic programming text Software Tools, by Brian Kernighan and P.J. PI auger [ 1], and a sample implementation of the algorithm is actually included on the Power C distribution disk as the programjind.c. Putting it alllogether... We now combine de~·glob with a call to wi/dmarch, and produce the routine glob

,. ,.

• glob.c - llplDd w1ldcard

filtna~ts

*I

hoclucle <Jtcho.b>

• select - double cbeck outs utcbecl • by lSU (etc I doa

• (Ill~ by

eodpop-4 v!ult (p > andp " p > llvtpatl

if (*--p- ' •' ) ( 'P : I \0'; breU.;

I return devglob(dev, pat, fuoc, Utlec:t) ;

I

And taking it on the road A canonical use of the file name matching glob routine is Lo produce a selective list of matching names. This is similar to the Is command of the UNIX system. Is is already implemented slightly differently in the Power C shell, so we have named our ver:sion If. It's quite simple really. It just calb our glob. u~ing as the function for each file name a routine that simp!) echOC!> it!> argument.

I*

* lf • lilt f1le OlliS

glob func:tiool

•I char •sutpat " !lULL;

atat1c

p=saytp~t+strlen (aavtpat);

aeltct(aa~~l

Volume 9, Issue 5

.,*

stltcted by a lilt of

pattern~

tillclucll <atdio.h>

I* 71


• function to all for tach • utched by glob

.,

chu el;

!I&M

unsiqned length, llneno; el =*utchJtr, length = Jtrlen (utchatr), lllfid =fope.u(filenaae, ' r'); if (infid - IULLJ I fprintf (atdout, •anoot open h .\a', retum

lllt ji(Mna•(II&M)

char

I

*IWIII '

prllltf('! s\11 ', II&M) :

l

ftlt~~&MI ;

I for (linenozl, fqeta (buf, IIAXBill', inhd), ++hoeoo) ( for (p=bof· (p=iadll(p, cl)) '• ~~; ++pi ( /* consider all occurmcta of el •/ 1f (stmCip{p, utchltr, length) = 01 { priDtf('h 'd h', filtllaat, lineno. bufl ; break; /* ltop after fmt utch on lint */

uill (arqe. ~)

Ull519lled arqe; char··~·

I utem iot tchonul () ; onu9lled i · •

I

I

1f (arqe < 2) / * if ootluoq apeeifled *I glob ('*' ,,tcboii&M) ; I* provide a default action */

else

for (i =1; i < arqe; ++i) /* process each pattern •/ glob(argr[i) ,,tchoname) ;

I !close(infidl ;

I

The same modification could be made to the programs which come on the Power C disk, such as print.c,format.c andfind.c.

l

A slightly more interesting thing to do is augment a program that takes a li~t of lile name arguments so that it can use patterns in!>lcad. This can save much guesswork and/or typing. as in the following program which ltearches for and prints occurrences of a string in a list of ftles (patterns).

,.

Improving performance

A noticeable perfonnance improvement can be made by replacing the C Rdirline routine with one written in assembler. This is primarily bccau!>c the C library Jgetc routine does a relatively expensive CHKI!'l Kemal call for each character.

• fllldstr e - atnng search pro<Jn•

• !Ius proqraa wlll print all occurmcts • of the qiftll ltri.Dq iD tbe speeihld files ,

C/ASSH · vtrSlOD 2.0 • 10/ 24/85

.,

qdirline .1: ; qdlrline - C allablt fuoctioo ruda a lint frca directory "l01d fomat lllt qdlrlint (baf. fld) . chu *bllf • FILl hd ••

ldtfine IIUBIJF 250

; retums as function Vllae ' baJie line nUibtr' ('nUibtr of blocks 1n ; directory lint)

• !be filet an be lpKlflld u a hit of

• patterns.

tinclude <stdio .b>

•' char *indu () ; st1tie char •a~tehstr

=NOLL;

uin (arqe, argr) onsiqned argc;

.

chu *arqv() ;

I 1nt findatr() ; ansi9lled i;

rrcc

chili elrehn

033C 004C 001'8 004D 004!

arqstk•$033e I&YIP$4e bufp=$fb lid=$4d aaveM4•

tnt() ·

I

utchatr =~Ill : for(1:2. i<uqe. ++i) qlob(~(l) , ,fllldatr);

l atltie char bllf(lllXBil1) • 101: fiodstr (fileDDt) char •hlenae; (

FIL! lllfld · chu •p

72

.

$ffe6 $!fee

; and $fc ; for ehkin

. ref e$funct_init rtf e$qetchar .clef gdirliDt

1fluqe < 3){ fprintf (stdout, 'h · <latch-string> file (a) \n', ~[OJ)

• •

l'lC6

-

; first, call e$fonct ill1t for quiclt setup ; copy passed puaaetera frca tr1111fer un (euaette bllffer) to rp

0000 0003 0005 0008 OOOA OOOD OOOP 0012 0014 0015

20 00 00 qdirlioe 86 4C Bll 3C 03 85 Fl Bll 3D 03 85 PC Bll 3! 03 85 4D AA 20 C6 n'

]It

e$funct init

au

SI'I'U

lda Ita lda aU

lda ata tu )It

arqstt,x bafp output baf arqstl+l ,x bafp+l arqatt+2,1 low byte fld of fld ug ; set loq1al input denee ehklll

Transactor


0018 20 42 00 oou 20 42 00

)lr

jsr

cgtt · ahp link' cget

~trange

; cow qet 'basic line cuaber' and save u no!'lla1 return value 0011 0021 0023 0026 0029 002B

20 42 16 4C !ID 3C 20 42 A6 4C 90 30

00

)Sf

ldl ata jsr ldl sta

03 00 03

0032 20 42 OOlS A4 41 0037 91 FB 0039 16 41: OOlB cg 00 0030 oo r3 003F 4C cc

oo loop

jsr ldy

sta illc Clip

bne jJp

rr

Very often, but not always. the la~t fe"'" files on the di'>k ""ill be absent from the h~llng created tn the output file.

cget saftlt arqstk,x ; low byte cget

Exer cises for the reader

Sa'ltx

argstk+l,x ; and biqb

• ; rNd rut of hne Ulto buffer, untH 1 ttro byte or •• 0021 10 00 1c1y to 0030 u 4! • aty savey ••

errors. The same phenomenon can be oh~erved when redirecting the output of the Power C built-in I command, as in: 1 >directory. tmp

cget aavey (bufp) ,J savey 10 loop clrcbn

~

atatus tne:OWltued

· nut char : 11'" it

; zero' ; no ; yea return

;

Well. it wouldn't be fair to finish this dbcu~\tOn wtthout lea\ mg the reader "'"ith some food tor thought. \\-Ould it? So I'll end with a fe"'" l>uggestion~ as to how you ma) want to alter !I lob for your own application<;. Very often when specifying a file name to a Commodore di<;k drive. it is necel>sary to uffix 11 with the file type. Under cenain circumstance,, then, this ,s. ,p. or ,u (or even ,r or ,c) suffix gives extra information about the file name. It ts \tmilar to the file name extensions of MS DOS. although u'>ually it is optional. Still, it might be nice to have it on the end of the rue name passed to the function called through glob.

; cgtt - call tht C librlr)' Ultemal routUie e$91tchar to rud a character frca ; the =rent chili UlpUt file. c~tchar 8lllt atill be passed tbe log1w file Perhaps. then. if the pattern pas~d to del'f?lob include\ a ,uffix : ll1llbtr ill the ' a ngister so it Clll check 'llhtther !OF hu been naehed on like ,p. or ,•. or,? attention should be patd to the file t)pe and ; thlt file yet . • it ~hould be put on the end of the file name pas\ed on to the ' : c$getcber returns with carry set if EOF reached, otherwise 1t function. : return• the nut character !rca the file 1.0 the ' a' reguter. c:qet u local : to tlua qdirlillt f1mcti011, ao 1t arrangtJ to return frca qdirlillt nth a Stmilar treatment could be afforded ?:. *:. or 0: or 1: to : fwlct1011 'fllue of £Or wben end-of-file is reached. spectf} a directory. A way could even be \\-Orkcd out to treat : llorully, cget ret11I111 tht the device number as pan of the pattern. , nut cberacter frca tile current file ill tbe ' a' register . •• 0042 1.5 40 C91t lda hd On L'IIX, the li t of file namef> matching a pattern i' al"'"ays 0044 20 00 00 jsr e$91tchar sorted alphabeticall} Thus could be done in derl(loh as well. 0041 110 01 ba eof 0049 60 rts

••

004A 68 00(8 68 004C A6 4C

eof

oou u rr

ooso 90 3C 03

om

!ID 3D 03

.

pla ; return &or from qd1rline pla ; pop return address , store BOF (-1) as return value ldl Sivtlt lda l$ff Ita arqatk.x sta argstk+l, x

• ; and return from gdirline 0056 4C cc rr

jlp

clrcbn

11loh is presented here as a routine. This 11lob routine could be used to create a glob program that could, in a limited fa~hion,

'glob' other programs or commands. qlob <command> (<pattern> . .. )

could expand the patterns into the and cause:

lt\t~

of matching file names.

<comm•nd> [<filename> .. . )

lad of asselblJ, 0 errors

The gdirline.a file can be assembled using the public domain CIA.ssm assembler to produce a !ldirline.o file which can be linked in place of the compiled version of Rdtrline.c to make ~lob run about twtce as fast. A bug (oh no!)

A word of caution: Commodore drives do not work well \\- tth an output file open at the \arne time a~ the directory. Sometimes (but not alwayl.) a program usmg the glob function. and creating an output file on the ~arne device will have its directory reading terminated prematurely with Volume 9, Issue 5

to be executed. This can be done by wntmg the expanded command line to the screen. and stuffing the keyboard mput buffer to caur.e it to be read by the Power C ~hell after the ~loh program exits. Of course. if the line \\-Ould end up bemg greater than eighty characters in length. 11 \\-Ould need to be truncated. As presented here. the glob facility can be u'eful to save typing, and allow searching for files. As hinted at earlier. the pattern-matching principle need not onl> be u\ed for tile name'>. but can be used when matching other l)pe' ol '>tnngs. Ill Kern1ghan. Bnan W. and Plauger, P.J .. So[11mrr loolf. i] Addison-Wesley, 1976.

73


Two Assemblers For GEOS A comparison ofGeoCOPE and Geoprogrammer •

by Francis G. Kostella

GeoCOP£ is m·ai/ablefor $20 (i.JSJ[rom. Bill Sharp Computing PO. Box 7533 Waco, TX 76714 Geoprogrammer i.1 al'ailahle from: Berkeley SoftworJ.s 2150 Shattuck A1·e. Berkeley, CA 94704 I'd like to present you with a brief overview of two assemblers that run under Gt:-.os. and then throw a short argument at you as to why ~·ou should be writing progrnm~ for GEOS. If you've written programs for GI::OS with a non-GEOS assem-

bler, you are probably familiar with the time-consuming hassle that the programmer must endure in order to convert his object file IntO a runnable GF.OS file. Besides the object file needing to be manipulated m order to work with GEOS, one must constantly exit GEOS to make modifications and wait while the assembler creates the new file, usually without the speed that the Turbooos add!>, then re-boot the GEOS sy~tem. What the GEOS programmer needs is a system that operates while in the GEOS environment and outputs GEOS-ready files. There are presently two packages (that I know of!) that do this: geoCOPE from Bill Sharp Computmg and Geoprogrammer from Berkeley Softworks.

source file. A VLIR file can have 127 records. and at 8K per record, you can see that each of your source files can get very large if needed. A few other features of the l::.ditor that I liked and found very useful were the ability to !let a Bookmark. so that you could return to the last line edited. and an Autosave feature that automatically updated change~ when selected. The biggest advantage of the Editor is that it is fast! Unlike geoWrite. you can quickly scroll up or down through a document, and since it doesn't support fonts or font styles you're not left waiting while the \ystem calculates 24-pomt bold outlines. The Editor also support' Text Scrap\, ha\ a Save & Replace function. and allows you to save single page~ of a VLIR source file as single SeQ source file • and SEQ as pages of VLJR files. The COPE Editor aho allow!> you acce:.s to De!>k Accessorie!> (the !>yMem comes with one: llexCalc a hex/dec/bin calculator) and works with an REU. The only thing missing from the Editor is the ability to use tabs to ofTset the opcodes and comments from the left margin. One thmg to be aware of when using con 's Editor. is that it store!> each line of the source file as a null-terminated string. If you use the Text Scrap function to move text to or from geoWrite, you'll run into a few problems. Pasting a Scrap into a COPE file from a geoWrite document is simply taken care of by entering CRs where the line ends should be. But geoWrite will choke on COPE Scraps (the Te\"1 Manager has no trouble with them. though). I've managed to get around this problem by writing a ">imple filter program that strips out aJI the nulls except the final one.

Looking into GeoCOPE GeoCOPE is the less complex of the two and was the first GEOS-specific assembler released. The COPE system has two main programs. Editor and copeAS'd (the assembler). The mcest part of the con system is the Editor. COPE uses its own unique structure for its source files. and each page of a !>Duree file can hold up to 8K of text. A feature that 1 found very U\eful. wa~ the Editor's ability to make the source files either GEOS SEQ or VLIR. Thus. my system equates ftle would be SEQ structure and would be .included in the main VUR 74

COPE supports 21 different pseudo-ops, from the typical .BYTE and .\\ ORO to some GEOS-specific ones like .JCO=" for defining header icon\ and .SEGMENT for mapping out any VUR modules. COPE al\o allows you to define macros with the .MAC and .M'\'D directives. Labels can be up to 32 character; in length and are case sensitive. COPE also allows you to use local branch labels - up to 32 outstanding (unresolved) local labeb are permiued. All the usual arithmetic and logical operators are supported (*, /, +, -. AND, EOR, OR). Transactor


The major advantage that the COPE system has i~ its simple and direct approach. Withm an hour of reading the manual, I had an applicatiOn up and runnmg. The manual itself only detail~ the feature, of the I diwr and cope \S\1 The examples are few. but cover all the specific~. If }ou've u~ed \1AOS. ) ou 'II adapt 'cr) qu1cf..l) a~ the t\\<O are 'ery similar. The manual together "'ith the sample tile~ "'ill have you writing VLIR application~ in no time at all. B> using the .SEG'.fE:".T directi\'e, you simply indicate the end of one VLIR module and the ~tart of another The nice thing about this approach is that labels m all the d1fferent module~ are global and the need for JUmp table · or duphcate label definitions is eliminated.

cation was just about four minute:.! Now I've got to admit that this was on an RCU, but even without it, the assembly took about six or seven minutes. (Besides, \1ADS didn't support the RLL..)

If you're ju'>t gettmg )OUr feet \\et with GEOS. COPE i~ the perfect place to -.tart The '>y\lem ea\1ly handle-. \maller programs and i-. fairl> fa-,t and ea'>y to maimain. But once your applications begin to grO\\ in :.ize. that 5.000 character symbol table begin-. to fill up fairl> quickly. Once you get to this point, you should consider Gcoprogrammcr.

The first thmg that Mrikes you when you open the Geopr ogrammcr pacf..age l!t the 450-page manual. If you COPt Iiles arc easy to mamuun and update. I've f..ept all my have a number of GI.OS program~. you are perhaps used to the COPE 10ource in VLIR ~tructure: the fir~t page holds the header sometimes simplhtic documentation that pre!>ents you with the bloc!.. definition and an index to the entire file. the second page "this is a c.li~f... put the disk in the drive.. :· level of informaholds my constants and equates, the third page holds all of my tion. I was very pleasantly ~urprised to open this manual and macros, and the source code begins on page four. Writing even read through it without ever having my intelligence insulted. the largest of applications, I've never gone over 20 VLIR pages The first two do7cn pages do contain the basic info for first of source. time GEOS users. and there is a chapter devoted to an overview of the Geoprogra mmer system. but the rest of the manual is Once you have your source code fi lied with loads of useful information. together, you load the assembler Granted. the info is not all organized and select the tile. Copl'AS\1 b a as well a~ it might be ("Now, 11here is rwo-pass assembler that will assem- If you're just getting your feet wet that part about bitwbe exclusiveble to disk and print any errors to or?!") but generally you'll be able to with GEOS, GeoCOPE is the the screen. You rna> list the a'isem find what )OU need with a little persispelfect place to start ... bly on its 'iecond pas~ and can rum tence In adduion. the appendices of thb listing on or on·. CopeA.Hf ai\O the manual contam detailed li tinW> of allo""~ you to pause the hsung 1f all the '>Y'>tem constam-. and variable • needed. If the file assembles ""1thout an) errors. you can exit along with a hardcop} h'>ling of the macro and sample source to DeskTop and run the file. If you do ha"e errors. you'll ha'e files included on di-.1... to pause the assembler and scnbble them do\\<n. This is the weakest part of the system - an option to output to an error file The Geoprogra mmcr disk itself b a tlippy that includes, beis sorely needed. Furthermore. attempting to pause the screen sides the sample files and system symbols and macros, the listing will sometimes scroll the errors off the screen. forcing three programs that make up the Geoprogrammer system: you to reassemble just to !tee the error!.. GEOASSH18UR. Cf.OUNKI:R and GI:.ODFBl/CiGER. No. there is no editor here. Unless you have a text editor that handles Presently, COl'!': can only handle up to 5000 characters in its geoWrire files {such as Q&D Edit. writ/en by Kostel/a and label table, so you' II have to keep those labels short and use Buckley and a~·ailable from RUt> - Ed.]. you'll have to edit plenty of local labels if you are assembling a large application. your source files with geoWrire! And Geoprogrammer is a Another limit of copeASM is thtll it can only assemble 8K sec- two-drive system; you can usc it with one drive, but the tions of code at a time. This isn't a~ big a problem as it may amounr of disk swapping involved will quickly convince you seem. though: you can simply divide the file up into VUR that that second drive is worth the money. Better yet, an REt.. modules and load them in a~ part of your initialization routine. is not only a fast second drive that makes usmg geoWnte My fa, orite approach here ~~ to put all of my table~. graphics. tolerable, but it w11l allow you to use GEODEBUGGER 10 it~ and fonts imo one or more VLIR modules and load them in fullest. right after drawing the intro screen. That being said, let me give a brief overview of tbe assembly Although I ha .. en 't done any rigorous compari. ons of assem- process. Once you've edited all of your source. you a:.semble bly times. I've got one good example: the original version of each of the source files into .rei relocatable object files. Then CTRCF was assembled with the \1ADS assembler. then convert- you load a linker file (also a ~eoWrite document) IntO G£ed to GEOS format. The amount of ume taken between loading OUVKER ro link together your .rei file\ mto a runnable GEOS the \1ADS as.,embler and loading the assembled and converted file on dbk. ow )OU can load GEODE.BLGGER to te~t and defile from the DeskTop was slightly under 35 minutes. After bug your program. Sound~ :.1mple. eh? Well. there's a lot more convening the source files to COPE format. the time between going on here than would appear. Geoprogrammer gives )OU loading the COPE assembler and loading the assembled appli- access to some powerful features and abilities that you rna) Volume 9, Issue 5

75


find that you won't want to do \\ ithout once you've gotten used to them. Fir:.~

off. (iWASSF\18L£R is a two-pas~ a..-.cmbler that suppons a number of u~ful features: conditional a~'embl), macros. local labcb. the ability to parse complex algebraic expre~sions. and the ability to p~s symbols to the linker or debugger. GEOASSF.M8L£R will also output an eiTOr tile tO disk (in gMWnte fonnat, of course!), if needed, for each file assembled. When (,1-.n. \.\SHtBI fR stanl> assembling a file. It u~es three counter:. to ~ecp trad. of the code· ./.Sect for 7ero page ram. .psect for program code. and .ramsect for unmitiahzed data. If you're laly like I am. when you need a new variable. you j~t add it somewhere in the current section of code instead of adding it to a separate section of code for variables. By using the .psect and .ramsect directives, you can add variables just about anywhere like this: .r-aect MyVariable:

.block 1

paect\b

When the a\\Cmbler encounter!> th1s construction, it will give the lahcl My\ariahle the address of the current address of .ramsect (\\ hich can be set b} the .ram sect d1rective or in the linker f1le). The .ramsect secuon defaults to the RA \1 followmg the last byte of code, thus we don't end up assembling uninitialiled variables and add to the length of the program. Perhaps not a big deal. but when you have tt few hundred bytes of variables it becomes noticeable. Another useful feature of the assembler is the 16-bit expression evaluator (GFOU,..KFR also uses the \arne evaluator). Beides the U\ual anthmetic. the evaluator handle' a number of logical operator:.: the manuaJ list thin) of them. I usually keep a... ay from creating expres~ions too complex to be understood at one glance. but GEOASSEHBLER w1ll let you create some trul) bi1arre and outlandish expressions if you so desire! But the real power I find here is that you can easily create data table\ with a few easily changed constants at the root of some complc>. expressions. Perhaps this doel>n 't ~cern that unusual. but I've hcen able to create expression., that all the other assembler-. I own have chok.ed on. and I don't miss having to do the math by hand. You run GFO.\SSF.MBL£R from De~lTop and -.elect the file to~­ semble from the typical IS-file dialog bo\. Once you've selected the file to a~~emble, you are g1ven a chmce of drive for the output file, then the file is assembled. The output file is the same name as the source file bul with a rei appended. When tim, i~ done, you can quit to DeskTop. assemble another file, or open the error file (i.e. enter geoWrite) if one wa~ generated. A friend of mine who beta-tested the ver:.ion 2.0 package tell~ me that GLO \SS£\tBLER V2.0 w11l aiiO\\ you to go directly to the hnker. and that it is not limited to selecting only the first 15 '>Ource files on disk. 76

Once you've assembled all the .ref files in your program, it's time to use GFOUI\KFR. GEOUI\KER does more than just connect \eparate object files together. Fir..t of all, GFOUI\KER uses a hnk file to detennine the structure of the output program, be 11 C.EOS SI:.Q, vuR. or CBM. wh1ch is a 'regular' object file. Secondly. the linker will add the header to the file. The linker will also cro~-.-rcsolve all label reference~ between the different .rei tile~; if a label is defined in two different tiles, but is not referenced in a third file GEOUNKER will not flag an error. One thing I would like to mention here i'> that although the assembler and linker accept symbol names up to 20 characters in length. only the first e1ght are ~ignificant. Thl'> IS not really a problem, but you should remember that there are a fe.,. hundred -.y.,tem symbols in the geosSym file u\ually .included during as:.embl).

r once wrote a routine named DeleteRegum that was only called from a routine in another source file. DeleteRegion never seemed to be called, but the disk would go active for a second when it should have been called. The debugger only show~ the e1ght significant character'> of the label when you list the code. -.o I couldn't imagme "'hat \\U'> happening. But the debugger also lets you vie"' the label name by its hex. address. and upon examination. thi!> label appeared some.,.here in the Kemal jump table. The routine that was being called "'as the Kern a! routine DeleteRecord! Luckily I didn 't have any VtiR tiles open .... will abo allow you to ou1put a separate symbol table (again, a geoWrire tile) to the drive of your choice. Like G£0,\SSEMBU.R, if there are any errors. you have the option of directly opening the error file after linking. One thing to note here i<. that when there are more than 99 error-.. the system will ~omellmc'> have a fatal crash. Gl:.OLINI\IR

When GWUVKFR creates the file on di'>k. it al\0 \\rites a special .dbg file to dl'>k for use by the debugger- more on this later. The manual

doe~

not include

~pecitications

for either GEOASSI.'MBLER or GEOUNKER. otherv.i~c I'd be happy to include a list here. If you do run into problem~ a~sembl ing and linking very large files, you can always usc the .noglbl and .noeqin directives to cur down the number of S)mbols passed to the linker One way to quickly cut do\\n on the number of symbol~ 1\ to U'>e .noglbl and .noeqin before .include geoSym (the system labeb and equates) and .glbl and .eqin after. Of cour..c you don't get anything for free, and these symbols don't get pa~sed to the debugger! A sneaky trick I use when doing this, to get the system symbol~ to the debugger when writing a large vt IR application, is to a\semble the RPOsRowines and ~:eosMemoryMap and link them into one of my modules that i.,n 't u~ing very many symbols. Each module has its own set of symbols and is selected in the debugger by the setmod comm.tnd. If )'Ou're debugging a ~tretch of code that uses a lot of l>)'stcm cal b. just reset the module pnonty to the module with the sy\tem ~ymbols. Transactor


Alternately. I find that ju~t defining the p!>eudo-registers 3!> global equates help' a grcm deal when debugging. Another potential problem I've noticed that is not documented, i~ that when linking files from two drives, the hnker seems to o;earch for the file on the current drive fir\t, then checks the other dnve. The problem here ,., that tf you have two different verstons of one particular .ref file. let\ call it hera.ref. and tilt file i~ \Upposed to be linked after a file called alplra.ref that i!> not on the current dbk, when the linker switches drives to fmd afplw.ref, it doe~ not switch back to the original drive, potenriall:y linking the wrong hcw.ref. I don't have any empirical evidence fQr this, but tf your modification' don't seem to be appearing in your new version of a program, try moving all of the ref files tn one VI tR module to the same disk.

autoexec macro removes these from the symbol table. like thh: .macro autoexcc ; name clrsym Pas~ l( crJ; eliminate symbol clrsym picW(crj clrs.} m picHIcr I .endm There are doLens of other commands. but there are problems with l>Ome of the memory command!>. mo!>t notably FILL, which doesn't work at all. My beta test friend tells me that this bug has been eliminated in the 2.0 version. The only other thing that one could desire would be a more detailed description of the macro pnmtllves in the manual.

Once you've a\sembled a GLOS program. it's time to load Overall. the Geoprogrammer package is nicely put together, GEODEBUGGfR here'1. where the fun begins! GEODEBUGGI:.R is and along with an REV will c.lramaticully increal>e your output a sort of 'shell' that u~cs f'.IMt~ to take control of the machine and capabilities. Most especially, the debugger will teach you and allow<> you to debug the program (or examine the Kemal) about programming for GEOS by allowing you to examine any in an almost interactive environment. Load your program from GEOS program and the ar:os Kernal in detail. the debugger. eed to tweak some values or check why that branch isn't being taken? Just bang on the RFSTORE key and If you're new to a~~embl) language. I suggest that you give you're in the GWDfBl GGFR again. w nting GtOS programs a try. A comGf.ODfBUGGIR ts the best thing about mon problem for beginner!> is the this package; :you can ~et breakpoinb. need to develop a '>Ct of routine!> to Geoprogrammer along with an alter stack or regtster values, and perform common functions: i.e., access the disk drive~ almost like a REU will dramatically increase printing text and graphics to the sector editor. screen. moving large chunks of your output and capabilities... memor:r around, dir,k access. and There are actually two ver,ion\ of '>tnng input to name just a fe"'. GEODEBUGGER. When }'OU load the When you ·re just startmg out, you program, it lir!>t checks for a RW. lf there is one connected. basically begin wtth nothtng. and until you ·-.e accumulated the full debugger is loaded mto the REIJ. otherwi e the mini- enough experience to write code to perform some of the above debugger il> loaded into RAM from S3EOO to S5FFF. eedless to functions. your ability to write useful progr.rnl!> i!. hindered. say. the REU <,upcr·debugger ts the preferred option. When you code for GEOS, all of these basic functions are always available. You can concentrate on writing the 'hean' of the proWhat makes the debugger truly useful is the ability for it to gram without getting bogged down in minor details. By getting use the .db~ tiles generated by the linker. These files contain a programs up and running quickly. the beginner will (hopefully) list of symbols and their addresses. This way, while in the de- form positive association-; with as~embly language. inMead of bugger, you can lbt and modify a section of code using labels thinking of it as some arcane art which is painfully learned! from your source fi les. Of course. your changes are not saved, but this allows you to try out different things without con- If you're interested in writing GEOS programs. you must get an stantly reassembling the program. assembler package that run\ in OEOS. If you're not sure how far you want to go I suggest you get the geoCOPE assembler GEOD£Bf..,GGER is bastcally a machine language monitor with from Bill Sharp Computing. The price is good and the system plenty of features. One of the mmt powerful of rhese in the direct and uncomphcated. If you later decide that you need super-debugger is the abihty to define macros. Most of the more power and you have a two-drive system (or REU!) and command!> in the debugger are actually l>ystem macro com- can afford the pnce. go for Geoprogrammer. If you're an expo ed of a number of macro pnmitives. GE.OD£8/,.,'GGLR allows perienced programmer. I suggcl>t that you go ~traight to you to define up to 1.000 b) tC!> of U!>er macros. These user Geoprogrammer or get them both. macro!> can be made up of the macro primitives or system macros. A macro file with the same name as your application Berkeley Softworks should be commended for releasing ~uch wtil be automancall) loaded along with your application. a nice package, espectally con'>tdenng the relati\'ely small Optionally, you can define a default <>et of macros and an au- market for product<; of this nature. Unfortunatel:y. they don't toexec macro to run when the debugger i'> loaded. For <;eem as tf they're gomg to relea'e ver~ion 2.0 an} time soon. example, the linker alway'> pa.-...es a few of the sy~>tem One only hope1. that the:y would at lea-.t con~ider doing a mailvariables to the debugger. but I have no use for them, so my in upgrade for present users. ll Volume 9, Issue 5

77


NewsBRK Format Executhe Version 4.0: Po\\.ersoft has announced the release of Format E'\ecuthe \ ersion 4.0. Format Executive is the firM and only comprehensive d1~lo.. fonnat and file tran.<.fer program for the Commodore 128 and 128D. Format Executive no\\. aiiO\\.l> a Commodore 128 or 128D computer \\.ith 1571 or 1581 drive to read, Mite and format over ISO different 3S' or 5.25" MS-OOS (PC-DOS). CP/M-80. CP/M-86, Commodore CP/M and Commodore DOS (PRG, SEQ, t..:SR, REL) disk formats. Thi~ means the Commodore 128 can now transfer files back and forth from almost any CP/M or MS-DOS microcomputer. The manual abo dcta1b how to use Fom1at Executive Version 4.0 to tran~fc1 filel> from machinel> such as the Commodore Amiga, the Atari STand the Apple Macintosh. Format Executive Version 4.0 features include: high speed burst file transfer technique, file transfers between all formats. Commodore PETASCII to true ASCII conversion. linefeed adjustment, wildcard ~upport ('?. ). single drive. multiple drive~. dual drive~. RA \1di~k. and hard drive l>upport; CP/M ~r area support. 1581 partttion support. and automatic dblo.. login. Baclo..up d1sh arc permitted. All Commodore drive devices arc supported: 154:<>, 157:<>, 158x drives. and 17xx RAMdish. Formm Executive Vers1on 4.0 will permit transfers of any ASCII or OBJECT file of any length at burst speed. Format Executive i'> compat1ble w1th Cl28 sy-.tem enhancement<> such a.s JiiTyDOS. A complete ltst of supported forma(), is available on QuantumLink in the fLie: FE-FMTS. Format E."<ecutive Version 4.0 is available for the Commodore 128 or 128D with 1571 or 1581 drive. Send cheer... (2 v.ks.) or money order for $59.95 plus $3.50 S&ll (COD add $3) to: Po\\.ersoft, Inc.. P.O. Box 7333, Bradenton, FL. 34210. On QuantumLink: POWERSOFr CPfM Productivity Sofl\\.are: The Public Domain Software Copying Company is offering CP/M users an exclusive repackaging of WordStar version 2.26. PDSC say~ that CP/M users arc often left out of current software releases. PDSC says that it b commiued to providing CP/M users with the most productive CP/M software available. WordStar version 2.26 can tum a Commodore 128 imo an effective, powerful word proce,c,or mcluding features such a.~ Matl\1erge. wh1ch allowc, uc,er-. to merge text and/or data files to generate form letters. botlerplate text (text created from file~ of pre-exbting, commonly U\Cd !>t!CLiOn'> of text). mailing li~ts. and large documcnh.

WordS tar version 2.26 1\ IBM data-compatible using readily a' ailable conversion :.oft\\.:lre including Big Blue Reader and Uniform. WordStar ver.,ion 2.26 and manual are available for $39.95 plu., $4.50 for postage and handling. The User's Guide also describe~ how to use other programs available from PDSC: SupcrCalc and MicroSoft BASIC, wh1ch are 20 each when ordered v.ith WordStar version 2.26 ($39.95 each plus $4.50 for postage and handling if ordered separately). Also included in the WordStar version 2.26 package is a set of Key Fronts. More useful than a quick reference guide, these self-adhes ive letters attach to your keyboard and include all the commands you need to w.e the special word processing functions of WordStar. For more infonnation. call or write: PDSC. 33 Gold St., Suite L3. New Yorio.., NY, I0038, (800) 2217372, (212) 732-2258. FORTRAN Compiler for C64: Th1rty yean. ago, FORTRAN was the first high-level language. Today it remains one of the most universally-used programmmg languages. Fortran 64 supports more than 45 ~tatements and functions and is a practical. econom1cal and convement way for users to team Fortran on the C64. Fortr.m 64 io, aimed at the student and nov1ce programmer who wants to use thi-, maLhematicaJiy-based language. Fortran 64 includes a built-tn ed1tor. compiler and linker. and creates a fast standalone program. Once completed, the program module rna) be run without Fortran. Subroutines and functions may be compiled separately from the main program. Input and output may be free-fonn or formatted, and the user has access to the 6502 regi~ters. Kemal and machine language routines. Fortran 64 carries a suggested retail price of $39.95. Other language product:. from Abacus: Ada, Assembler, BASIC compi lers. COBOL, C and PascaJ. Contact: Abacus Software. 5370 52nd St. SE. Grand Rapids. Ml, 49508, (616) 698-0330. SYSLA W: A Legal Guide for SysOps: A new book from LLM Pres<; explains the legal rights and responsibilities of sysopc,, the people who oper.1te computerized bulletin board system., <BBS). Written in clear Englbh by Jonathan Wallace and Recs Mormon. two la'-"YCh v.ho are both veteran sysops, Lhe one-hundred page boot... covers all aspects of the emerging area ofSYSLAW.

PDSC 1s offering th1s as the f1rst of many class1c software pro-

granls formatted for the Commodore 12H. Th1s Commodore 128 - CP/M di\lo.. edition come-. complete v.tth an O:,bome I l.Jser \ Reference Guide that explatn~ hO'-" to usc WordS tar. and also ha~ sectiOn'> on the CP/M operatmg sy~tem.

78

"More than 4,500 computer bulletm board systems are running in this counll). but the legal nght\ and mlo..s of the1r sysops have never been explained". 'aY' Jonathan Wallace. " Hundreds of unknov. ing ~y,op' ~ct up BBS\ on thc1r home computers each Transactor


year," according to co-author Reel> Morrison, "and they don't know what can happen to them legally, or what they can do.··

Sims live. wort.., play. move, drive, and complain about taxes, traffic. taxes, crime and taxes - just like human!..

SYSLA W, or 'ysop law, for those who run bulletin board systems. concerns the legal con,equences for those who run BBS'\. The total number of people who dial the thousands of bulletin board sy~tem., is in the '>everal hundred thousands. and the legal1"ue., arc plentiful. More 1mponant, the law affecting sysopl> b not merely un~ttled. it IS unestablbhed.

SimCity is primarily a constructive game, but those who can't enjoy a game without destruction can wipe out a city through terrorism, financtal mismanagement, or by evoking a natural disaster such ac, an eanhquat..e or mon\ter attack.

Significant legal issues have ansen in connection with BBS ·s. but neither courts nor legislator~ have come to grips with this technology. Scattered state and federal statutes can affect a BBS. and the common Ia\\ development of the area has been sparse and confused. Given the dynamic activity of BBS 's, the time was ripe for a careful treatment of the many potential problems, which include: • What if someone posts copyrighted material on the board? • Does it matter if you charge users or accept ads? • What if you delete a crucial message by accident? • Can you bar someone from using your BBS? Being unsettled. SYSLAW might deter the development of this telecommunication'> explosion. The authors believe that BBS's offer an exciting. progressive and influential medium, even in its infancy, that will be promoted by clarity of law and an understanding of syo;op 's right'> and responsibilities. The '>Oftcover manual com S 19.00 plu<; $2.00 for postage and handling. Orde~ and cheque\ rna} be -.ent to LLM Press, 150 Broadwa}. Suite 610. New Yort... Y. 10038. SimCity, The City Simulator : Maxis Software announces the release of SimCity, The City Simulator. for C64/C 128. When you enter SimCity you take on the role of Mayor and City Planner of a sophisticated o;1mulated city. You zone land, balance budgets, install utilities, manipulate economic markets, control crime, traffic and pollution and overcome natural disal>lers. You control the fate of the city. Design, plan and grow your own utopian dream city from the ground up, or take over any of eight included pre-built cities on the verge of disaster. Scenarios include: San Francisco, CA 1906, just before the great quake; Tokyo, Japan 1957. just before a monster anack; and Boston, MA 20 I0. just before a nuclear meltdown. Watch the disa~ter occur, gather your funds and infonnation and bring the city back to life. The city is alhe: you ~ec traffic on the roads, trains on the rails, planes in the air. even football game~ in the stadium. You see population levels nse and fall, reJ.idential areas develop from single fan1ily homes to condos to slums. Watch commercial and mdustrial area\ grow or decline depending on your skill as a strategic city planner While you do the planning and .tOn mg. 11 i!> the Simulated Citizens, a.t...a. Sims, who move 1n and actually build the city. Volume 9, Issue 5

SimCity come~ with exten\1\e documentation mcluding a User Reference, an explanation of the inner workings of the simulation, and an essay on the History of Cities and City Planning. SimCity is distributed by Brooerbund and carries a retail price of $29.95. Maxis Software speciali1es 111 System Simulations, a new type of entertainment \Oftware, with emphasis on quality graphics and sophisticated \imulation techniques. Maxis Software, 953 Mountain View Drive, Suite # 113, Lafayette, CA, 94549. C l28 CP/M Sofh\Bre from Cranberry Software Tools: Cranberry Software Tools offers a variety of products in~lud­ ing a public domain di!.kette containing what the vendor describes as "an entirely new CP/M environment for the C 128 ". Included on the di\k are: • NEWSYS.COM - generates the 12/6/85 version of CP/M 3.0 • CONF.COM - CP/M 3.0 configuration utiht} • CCP.COM- the famouc; CCPI04 upgraded command environment • HIST.COM -command line edllmg acce\sory The CCPI04 env1ronment allow\ the recall, editing and reexecution of command hncs; cas} use of user areas; and named reference to user areas. A total of 21 files are supplied, including powerful CP/M file management utilities such as ACOPY, CSWEEP and NSWEEP. Limited documentation is also included. The cost of the disk is just $5.00 posrpaid! Want to try your hand at programming? Cranberry Software Tools' PD Programming Series is an inexpensive way to get your feet wet. The following CP/M Language packages cost only $5.00 (!)per disk: 1. 2.

Three BASICs: BASICS, EBASIC. ZBASIC FOCA L - calculator-like stack language (SOil). no documentation) 3. Two FORTH\: UN IFORTH. and H G-rORTH (sorry. no docun1entation) 4. LASM - Z80 As..cmbler 5. SAM76- unusual symbolic processing language 6. Smali-C Interpreter- fun, interactive C environment 7. Smaii-C Compiler fa.\t subset of standard C, assembler requ1red 8. Parasol System - powerful and complete, like COBOL 9. Draco System - powerful and complete. hke C 10. E-Prolog- rule-based art1ficialmtelhgence II. Algoi/M - scientific language lit..e Algol-60

79


12. Concurrent Pascal-S - has coproce~~e~ like Modula-2 13. PLIO- mimature comp1ler. complete with ~ource 14. RATFOR Translator- FORTRAN never looked this good Cranberl) 's Disk Re porter-128 was created with the C 128 owner m mmd. DR 121:! takes advantage of many of the special features found only in the C 121:! \CP/M+. DR-128 wiJI display the content\ of your CP/\1 dJ\I..ettes sorted by filename, exten.,ion, SIIC or data. The contents of all user areas are shown. not just area LCro. Unlike many utilities written for the older CP/M 2.2, DR-128 w iU dtsplay the correct amount of free space remaining on a C 128 diskeue. Best of all. DR-128 will print hand) diskeue labels on your printer. Just $8.95. The Alphal'l.ote Quick Re ference System from Cranberry is a per,onal text dataha~e program for all computers running the CP/M operating -.yMcm (a special version customiLed for the Cl28 is available). AlphaNote has been designed to serve as an "intelligent memo pad" that can assist you in capturing the large number of useful facts that bombard you during the average day. AlphaNote can store an unlimited number of free-format text notes, wnh no length restrictions other than the size of your drive. Each note can be a\sociated with several 'key phrases' that can ass1st you m findmg the note after it is stored, much like the card catalog in a libr.try. Partial keyword matching and case-mdependent keyword matching are available to extend the power of your searches through AlphaNote data tiles. No need to memorize lots of keywords - you can choose to search through the main text of your note\ as well. You can create and use ru. many different ·note-bases· as you \\>ish. Usmg AlphaNote b a snap. with the program·~ ea'>y-to-use. smgle-l..ey menu interface. AJphaNote can di~pla) any note using quick, random-access disk techniques. You can call up a full-screen 'directory' of your stored notes as an alternative to <;earching for a particular entry. Notes may be quickly added and deleted, to better accommodate the short-terrn importance of this type of data. The special introductory price of AlphaNote b just $9.95 postpaid. Also from Cranberry Software Toob. Alpha Text Tools ($39.95) is an intl.!gratcd text processing sy&tem perfect for home or small business usc. The Tools are divided into six maJor sections: I) Alpha Text Formatter, an em bedded command text processor with over 30 commands. giving the user total control over margms. page layout. headers and footers. numbering st) lc, and text justification. AlphaText also features mail merge capability. automatic numbering of paragraphs and li.,ts. table of contents generation, and user c ustomizable printer and vtdeo control, including on-screen preview of the formatted text. 2) AlphaEdit Editor. for effortless editing of both documents and program text. AlphaEdit feature., over 30 -.ingle key commands and 1s optimized for use with AlphaTc:>.t. 1) AlphaSpe ll Spelling C hecker. complete with a 34.000 word dic tionary. 4 ) AlphaFoot Printer

80

E nhancer, which give~ owners of Epson compatible dotmatrix printers the capability to produce ncar letter quality documents in four distinctive fonts. You can design your own fonts or modify the fonts suppplied with the package. Custom symbols may be eas1ly created. Mo .. t Eu ropean languages are 'upported and font'> are bemg created for many M iddle and Far Eastern languages. Alphafont can proce s both nght-flowmg and left-flowmg languages. 5) AlphaMenu Interactive Environment. for e~y execution • of the Toob "'ith just a single ke) press. 6) Alpha Utilities, which perform dictionary update, text file conversion, and font creation and modification. The Alpha Text Tools are furn1shed with an example-filled User'<; Guide, two qu1ck reference pages, and a Tutorial for new users. An 80,000 word AlphaSpell dictionary is also available ($10.95) as is a disk with four additional fon ts ($ 12.95).

AlphaShapc ($9.95) will reformat documents that have already been formatted, such a'l the documentation files that usually accompany shareware. AlphaShape reparses such documents. elimmating control characters and changing pagi.nation, blank line sequence\, and margin!. to the user's taste. lt also :.upports a two-column printing mode for dramatic size reduction of the input text. The Alpha C Tools package ($31.95) is composed of: I) ource Lister Utility, that produce appealing listings of source code on the CRT. the pnnter, o r m a d1 k file. Listings are paginated; page headers contain the input filename, the system data/time. a user-supphed commentary line, and the fLle modification date/time. Each source line is displayed with a logical nesting level to highlight the hierarchical structure of the code. A handy table of contents lists all procedures and functions. Reserved words can be printed in uppercase, boldface, or both. An outlining feature permits interactive viewing of the code by logical nest level. 2) Source Rerormatter Utility, that automatically realigns the mdentation of the source code according to program logic. 3) Cross Reference Utmty, that comple te ly maps all no n-reserved symbols and provides the same elegant reporting format as the Source Lister. Each membe r of the C Toob has a flexible UNtx.style command line interface. AlphaC PP ( 19.95) IS a macro preprocessor that provides po"'erful conditional processing feature for normal text files. and for languages lacl..mg conditional constructs (like Turbo Pascal V3). Support for the #define, #ifdef, #ifndeL #include, #ebe. and #undef keyworcb. AlphaDump is a file dumping uuhty that produces formatted output on euher the CRT or pnnter. The user can select five dump formats: bmary, octal, decimal. hexadecimal and ASCII. Only H.95. All pnce\ in U.S. dollars. Contact: Cranberry Software Tools. P.O. Box 68 1. Princeton Junction, I:J N J. 08550-0681. Transactor


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.