Love Letters (BBC BASIC)

discussion of beeb/electron applications, languages, utils and educational s/w
Post Reply
User avatar
lurkio
Posts: 2091
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Love Letters (BBC BASIC)

Post by lurkio » Sun Apr 21, 2019 4:28 pm

A BBC BASIC version of the Love Letters program written in 1952 by Christopher Strachey. Possibly the first program to generate "art".

Code: Select all

 10 REM Love Letters by Christopher Strachey, 1952
 20 REM BBC BASIC version by lurkio @ Stardot, 2019
 30 REM via nickm.com/memslam
 40 :
 50 MODE7:L%=40:REM line-length
 60 PRINTTAB((L%-12)/2-1,12)"Press a key ";
 70 PROCw(5):IFRND(-TIME)
 80 :
 90 DIM s1$(4),s2$(4),adj$(31),n$(29),adv$(21),v$(25)
100 FORI%=1TO4:READs1$(I%):NEXT
110 FORI%=1TO4:READs2$(I%):NEXT
120 FORI%=1TO31:READadj$(I%):NEXT
130 FORI%=1TO29:READn$(I%):NEXT
140 FORI%=1TO21:READadv$(I%):NEXT
150 FORI%=1TO25:READv$(I%):NEXT
160 :
170 REPEAT
180  CLS:PRINTTAB(0,5)s1$(RND(4));" ";s2$(RND(4))''" ";
190  Y%=FALSE:REM The "You are" flag
200  :
210  FORJ%=1TO5:REM Five lines
220   IF RND(2)=1 PROClong ELSE PROCshort
230  NEXT
240  :
250  IF POS>0 PRINT
260  PRINT'TAB(L%*.075)"YOURS ";adv$(RND(21))''TAB(L%*.075)"M.U.C.";
270  PROCw(20)
280 UNTILFALSE
290 :
300 END
310 :
320 DEFPROClong
330  PROCp("MY "):IF RND(2)=1 PROCp(adj$(RND(31))+" ")
340  PROCp(n$(RND(29))+" "):IF RND(2)=1 PROCp(adv$(RND(21))+" ")
350  PROCp(v$(RND(25))+" YOUR "):IF RND(2)=1 PROCp(adj$(RND(31))+" ")
360  PROCp(n$(RND(29))+". "):Y%=FALSE
370 ENDPROC
380 :
390 DEFPROCshort
400  IF Y% PROCd:PROCp(": MY "):Y%=FALSE ELSE PROCp("YOU ARE MY "):Y%=TRUE
410  PROCp(adj$(RND(31))+" "+n$(RND(29))+". ")
420 ENDPROC
430 :
440 DEFPROCp(s$):REM Word-wrap
450 REPEAT
460  IF INSTR(s$," ")>0 w$=LEFT$(s$,INSTR(s$," ")-1) ELSE w$=s$
470  IF L%-POS>=LEN(w$) PRINTw$; ELSE PRINT'w$;
480  IF INSTR(s$," ")=0 UNTILTRUE:ENDPROC 
490  s$=RIGHT$(s$,LEN(s$)-INSTR(s$," "))
500  IF POS>0 PRINT" ";
510  IF LEN(s$)>0 UNTILFALSE ELSEUNTILTRUE
520 ENDPROC
530 :
540 REM Find the last full stop
550 DEFPROCd:REPEATVDU8:A%=&87:C%=(USR(&FFF4)AND&FF00)DIV256:UNTILC%=ASC"."
560 ENDPROC
570 :
580 DEFPROCw(s%):*FX15
590  TIME=0:REPEATUNTILINKEY0<>-1ORTIME>s%*100
600 ENDPROC
610 :
620 REM salutation 1
630 DATA DARLING,DEAR,HONEY,JEWEL
640 REM salutation 2
650 DATA DUCK,LOVE,MOPPET,SWEETHEART
660 REM adjectives
670 DATA ADORABLE,AFFECTIONATE,AMOROUS,ANXIOUS,ARDENT,AVID,BREATHLESS,BURNING,COVETOUS,CRAVING,CURIOUS,DARLING,DEAR,DEVOTED,EAGER,EROTIC,FERVENT,FOND,IMPATIENT,KEEN,LITTLE,LOVEABLE,LOVESICK,LOVING,PASSIONATE,PRECIOUS,SWEET,SYMPATHETIC
680 DATA TENDER,UNSATISFIED,WISTFUL
690 REM nouns
700 DATA ADORATION,AFFECTION,AMBITION,APPETITE,ARDOUR,CHARM,DESIRE,DEVOTION,EAGERNESS,ENCHANTMENT,ENTHUSIASM,FANCY,FELLOW FEELING,FERVOUR,FONDNESS,HEART,HUNGER,INFATUATION,LIKING,LONGING,LOVE,LUST,PASSION,RAPTURE,SYMPATHY,TENDERNESS
710 DATA THIRST,WISH,YEARNING
720 REM adverbs
730 DATA AFFECTIONATELY,ANXIOUSLY,ARDENTLY,AVIDLY,BEAUTIFULLY,BREATHLESSLY,BURNINGLY,COVETOUSLY,CURIOUSLY,DEVOTEDLY,EAGERLY,FERVENTLY,FONDLY,IMPATIENTLY,KEENLY,LOVINGLY,PASSIONATELY,SEDUCTIVELY,TENDERLY,WINNINGLY,WISTFULLY
740 REM verbs
750 DATA ADORES,ATTRACTS,CARES FOR,CHERISHES,CLINGS TO,DESIRES,HOLDS DEAR,HOPES FOR,HUNGERS FOR,IS WEDDED TO,LIKES,LONGS FOR,LOVES,LUSTS AFTER,PANTS FOR,PINES FOR,PRIZES,SIGHS FOR,TEMPTS,THIRSTS FOR,TREASURES,WANTS,WISHES,WOOS,YEARNS FOR

Run the program in JSBeeb:
Link dump: :idea:
Last edited by lurkio on Mon Apr 22, 2019 11:36 am, edited 4 times in total.

User avatar
BigEd
Posts: 2528
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Love Letters (BBC BASIC)

Post by BigEd » Sun Apr 21, 2019 4:45 pm

Very nice. From within a linked article:
The magnetic drum was located in a room above the actual computer workshop, which led to introduction of the terms “down transfer” and “up transfer” for these two operations that live on in the modern variants “upload” and “download”
- There must be an angel

User avatar
lurkio
Posts: 2091
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: Love Letters (BBC BASIC)

Post by lurkio » Sun Apr 21, 2019 6:03 pm

BigEd wrote:
Sun Apr 21, 2019 4:45 pm
Very nice. From within a linked article: "The magnetic drum was located in a room above the actual computer workshop, which led to introduction of the terms 'down transfer' and 'up transfer' for these two operations that live on in the modern variants 'upload' and 'download'" - There must be an angel
Interesting. I'd missed that. The OED only has citations going back to the 1970s for the computing senses of the specific words "upload" and "download":
:idea:
Last edited by lurkio on Sun Apr 21, 2019 6:04 pm, edited 1 time in total.

User avatar
BigEd
Posts: 2528
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Love Letters (BBC BASIC)

Post by BigEd » Sun Apr 21, 2019 6:49 pm

Hmm, it seems Google's book search is bad for that sort of thing, as the given dates of publications are often very far adrift. I suppose the OED know how to do it!

User avatar
lurkio
Posts: 2091
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: Love Letters (BBC BASIC)

Post by lurkio » Tue Apr 23, 2019 12:28 am

I tried adding speech to the program:
It was a mistake.

:shock:

EDIT: Here's a version with improved pronunciation, thanks to a custom dictionary:
Here are the custom dictionary entries for Love Letters which I added to the Speech program (by editing the file $.SPEECH in a hex editor on macOS). I've cleaned up the formatting:

Code: Select all

ADORABLE /UDAOR/UBL
AFFECTION /UFEHKSH/UN
AFFECTIONATE /UFEHKSH/UN/UT
AMOROUS AEM/UR/US
ANXIOUS AENKSH/US
ARDENT AAAAD/UNT
AVID AEVIXD
BREATH BREHTH
COVET KOHVIXT
DEVOTE DIXVOWT
EROTIC IXROTIXK
FERVENT F/UERV/UNT
PATIENT PAYSH/UNT
LOVEABLE LAH/UV/UBL
LOVE LAH/UV
PASSION PAESHAHN
PASSIONATE PAESHAHN/UT
PRECIOUS PREHSH/US
UNSATISFIED AHNSAETIXSFIYD
ARDOUR AAAADAHR
CHARM CHAAAAM
DESIRE DIXZIYR
DEVO DIXVOW
FANCY FAENSEE
FERVOUR FERRV/UR
HEART /HAAAAT
INFATUATION IXNFAECHYUXWAYSH/UN
LIKING LIYKIXNX
RAPTURE RAEPCH/UR
SYMPATHY SIXMP/UTHEE
YEARN YERRN
COVETOUSLY KOHVIXT/USLEE
DEVOTED DIXVOWTIXD
SEDUCTIVE SIXDAHKTIXV
ADORE /UDAOAOR
FOR FAOR
CHERISHES CHEHRIXSH/UZ
OLD OWLD
PRIZES PRIYZIXZ
TREASURE TREHZH/UR
WANT WONT
WISHES WIXSHIXS
SWEETHEART SWEET/HAAAAT
HONEY /HOHNEE
MOPPET MOPIXT
JEWEL JUXW/UL
OO UXUX
Last edited by lurkio on Fri May 03, 2019 9:36 am, edited 3 times in total.

Post Reply