Wednesday 9 January 2013

Word Wrapping and Web Crawling for Code


As I worked on programming projects to create the programs I had wanted as a kid for my MC-10, I realized that there was a large amount of Basic code available on the Net from which to work. I began to search for sites that archived old code which might be suitable for conversion to MC-10 Basic. I discovered that many of the magazines I had drooled over as kid, were available as scanned PDFs.  Sometimes these PDFs had also been converted to text, or could be, by using OCR software. This was not always perfect, but it did help reduce some of the typing involved. It's faster to correct each line (while consulting a printout of the original) than re-typing a whole program (although this is what we did when I was a kid). I also discovered that there was a large number of programs available on the Net already in text format. I found that the best way to find such programs was to do a search using two unique Basic language words like GOTO and GOSUB (which don't appear in properly spelled ordinary English), and some desired program "theme" word such as FIRE or ATTACK or DUNGEON or MAP, or SPACE, etc. Using this method I came across large numbers of "classic" 8-bit game programs.  Most of them were essentially text based programs, but sometimes I could jazz them up using the colourful VDG graphic characters.  New Poker was one of my programs that emerged in this way.  It was taken from a text based David Ahl Basic listing, which used full text descriptions to describe your hand.  I added a routine that printed the cards "graphically."  By using a black background for the card, I could create simple representations of the suit symbols.  However, this necessitated also printing reverse video numbers.  Unlike the poker program I had created as a kid (which I simply called POKER).

David Ahl's original listing didn't format the screen in any way, the cards could end up being being printed on different rows of the screen.  But in Coco basic you must use poke to put the reverse versions of numbers on the screen, so I needed a way to know where the cursor was and to print/poke the appropriate reverse character for the card suit/number wherever the card got printed.  Fellow MC-10ers on the Yahoo group provided the relevant peek locations for finding out the current location of the print cursor.

P1=(PEEK(17024)AND1)*256+PEEK(17025):POKEMC+P1-1,PEEK(MC+P1-1)-64:RETURN


The Coco equivalent uses the peek locations 136 and 137.  Using this location you can simply peek the value the location you want to "reverse" and poke that peek value -64.  It provided a simple way to get full reverse video messages for all the character set, instead of just the alpha characters.

Another problem I had to overcome converting listings like those of David Ahl, is that they often printed long detailed messages.  These messages usually assumed at least a 40 character screen, if not an 80 character screen.  For the oldest classic programs, like Ahl's poker, it was assumed that information would simply scroll up off the top of the screen.  This was OK but I needed a way to deal with long messages so I decided to work out a simple word wrap algorithm that I could use to replace all print commands.  I had tried various forms of doing this in other program conversions I had done, such as GARGOYLE CASTLE,
which read each character until it passed a certain threshold, when it would start looking for a space character, at which point it would split the line.  These character based wrap routines were slow.  They spit out lines like an old three hundred baud terminal program.  Finally I came up with a simple and fast routine that used the MID command:
0 CLS:DIMC1,CC,P,K:GOTO5:REM WORD WRAP ROUTINE. INPUT VARIABLE=M$ THEN GOSUB1
1 C1=1:CC=32
2 IFMID$(M$,CC,1)<>""ANDMID$(M$,CC,1)<>" "THENCC=CC-1:GOTO2
3 PRINTMID$(M$,C1,CC-C1):C1=CC+1:CC=C1+31:IFC1<=LEN(M$)THEN2
4 RETURN
5 REM PROGRAM START
6 INPUT M$:GOSUB1:GOTO6

Once I had this routine, converting some of the basic text based adventures I had wanted to play as kid on my MC-10 were easy, such as ASMOVIAN, which I remember seeing in an old Atari book  and games for the TRS-80 model 3 that my mother used to bring home from school (she was a primary teacher) on weekends, such as Ray Sato's SABOTAGE:
You can also see the use of my reverse video routine being used for the message at the bottom of the screen.  Here are just a few of the sites for archaic code that I've found:
basichome Commodore.ca Gallery Magazines Compute! Magazine - 44 to 90 Gorilla download (Arcade action game) index if-archive-games-source-basic Ira Goldklang's TRS-80 Revived Site Documentation - Books Quite BASIC — Trebuchet Game Steven's ZX81 Computer Tandy 1000 Basic Programs TI-92 BASIC Games - ticalc.org trek iii.4 - Google Search TRS-80 Color Computer Software Repository - -coco-Documents-Books- World Of Dragon WP List Shareware Add-ins Directory JSBasic The Nascom Home Page Index of /if-archive/games/source/basic TRS-80 Model III Emulator Commodore - Magazines - Input General retrogaming websites • Retroaction The *HUMONGOUS* CP/M Software Archives Index of /cpmarchives/trs80/Software/Model 1/S TRS-80 Color Computer Software Repository Brutal Deluxe Software BASIC Gamer - Issue #1 The Game Creators Forum - 20 Liners - [DBPro] Grail Of The Gods ... 18 line Rogue-Like Dungeon Crawler Sync Commands - DarkBASIC Professional Help Wiki Other platforms and computers Software (Dragon, TRS-80, CPC, BBC, PC, Coleco Vision etc..) Index of /pcsig08 Dragon 32 Games by Abacus - Provided by Dragon 32 Universe Dragon 32 Games by Argus Press - Provided by Dragon 32 Universe labs » mclelun Pipe Dream Flash Game » mclelun 


2 comments:

  1. Hi. I too have been keen to get a good word-wrap routine working, but in my case on the BBC Micro, to which I recently ported Nellan Is Thirsty, which was originally written for the Heath and for (one of) the Tandy machine(s). Perhaps you should try porting Nellan to the TRS-80 and/or the MC10 so that the game finally "comes home", as it were..?

    https://stardot.org.uk/forums/viewtopic.php?f=40&t=18536#p257305

    ReplyDelete
    Replies
    1. Thanks for the feedback. Sorry for the delay. I looked into Nellan. I think it is too large and complex for the MC-10. However, it's good to know there are other working versions of it out there. Keep the good work.

      Delete