Автор: Jim Waterman
Год: 2020
Издатели: Jim Waterman
Языки:
Английский
Формат:
TZX лента
Требования:
ZX Spectrum 16K
Ссылки:
Страница на ZXArt
Страница на Spectrum Computing
Скриншоты:
Год: 2020
Издатели: Jim Waterman
Языки:
Формат:
Требования:
Ссылки:
Скриншоты:
COMPUTER HAIKU
Originally written by/for(?) Commodore Educational Software
for the Commodore 64 and PET, some time in 1983
Translated for 16K Spectrum by Jim Waterman, September 2020
===========================================================
Inspired by this thread on the Spectrum Computing forums which dug up the original C64 haiku-generating program, once I'd discovered it was written in BASIC I thought I'd examine the listing and convert it for the Spectrum. Obviously, all the colours were going to be different and the layout was probably going to be different seeing as the Commie can handle 40 columns at a time.
Most of the original code was discarded as the Bread Bin has no PRINT AT or colour commands, and uses massive strings of system variables, POKEs and control characters instead - so the title screen, menu and instructions sections were all rewritten to make them look like the original, just in different colours. More system variables and control characters had to be worked round from line 1000 in the original (660 in this version), to make the haiku appear as it should. Generating it in the first place was more complicated on the Commie as - for reasons only known to the original programmer - the random number generator was set by the system timer. I thought it unnecessary to PEEK 23672 (the Spectrum's equivalent) and translate that - it's just using RANDOMIZE at the start of the program and then taking whatever comes from then onwards. The second line had to be generated first, so that the length of the line could be checked and junked if it was over 32 characters - one place the Commie had an advantage. I think my introduction and exit screens are far better than the original, though.
The original was full of error-checking routines which were unnecessary on the C64 but which would stop the program in its tracks if it was run on a PET that couldn't handle it. (There was probably a VIC-20 version as well, but with its horrifically limited text screen, everything would spill over onto two lines.) None of these were needed - all I had to do was condense the program after I found out it couldn't be loaded on a 16K Spectrum (see that as the equivalent of a PET in this case). This involved removing all the REM statements - which I've shown below just in case anyone wants to examine the structure of the program and make it easier - but it also meant wheeling out the old 1K ZX81 trick of using NOT PI, SGN PI, INT PI and a ton of VALs every time a numerical value appeared... and there were a lot of them. Still, that meant plenty of bytes were saved, and the program would run on the smallest Spectrum with ease. It now looks like a complete mess, but at least on a Spectrum the memory-saving tricks don't slow the process down anywhere near as noticeably as they did on a ZX81.
Here are all the removed REMs:
20 REM MENU
180 REM STUDENT INSTRUCTIONS
260 REM TEACHER INSTRUCTIONS
350 REM PRESS SPACE BAR
390 REM PAGE DESIGN ROUTINE
430 REM PLEASE WAIT REMARK
460 REM TITLE SCREEN & ARRAYS
660 REM MAIN PROGRAM STARTS
690 REM a$/g$=SUBJECT
700 REM b$/h$=MODIFIER
710 REM c$/i$=ADVERB
720 REM d$/j$=PREP. PHRASE
730 REM e$/k$=EXPLETIVE
740 REM f$/l$=THOUGHT OR REMARK
750 REM x$/y$=DUMMY VARIABLES
760 REM IN SPACE-STRIP ROUTINE
860 REM STRIP SPACES FROM
870 REM ARRAYS AND CHECK THE
880 REM 2ND LINE FITS ON SCREEN
970 REM PRINT THE HAIKU
1090 REM ARRAY CHOPPER
1140 REM NOUNS
1200 REM VERBS
1260 REM ADVERBS
1320 REM PREPOSITIONAL PHRASE
1380 REM EXPLETIVE
1440 REM REMARK
1500 REM UDG DATA
1550 REM END ROUTINE
Originally written by/for(?) Commodore Educational Software
for the Commodore 64 and PET, some time in 1983
Computer Haiku (1983)(CES) : Free Download, Borrow, and Streaming : Internet Archive
Computer Haiku (1983)(CES)
archive.org
Translated for 16K Spectrum by Jim Waterman, September 2020
===========================================================
Inspired by this thread on the Spectrum Computing forums which dug up the original C64 haiku-generating program, once I'd discovered it was written in BASIC I thought I'd examine the listing and convert it for the Spectrum. Obviously, all the colours were going to be different and the layout was probably going to be different seeing as the Commie can handle 40 columns at a time.
Most of the original code was discarded as the Bread Bin has no PRINT AT or colour commands, and uses massive strings of system variables, POKEs and control characters instead - so the title screen, menu and instructions sections were all rewritten to make them look like the original, just in different colours. More system variables and control characters had to be worked round from line 1000 in the original (660 in this version), to make the haiku appear as it should. Generating it in the first place was more complicated on the Commie as - for reasons only known to the original programmer - the random number generator was set by the system timer. I thought it unnecessary to PEEK 23672 (the Spectrum's equivalent) and translate that - it's just using RANDOMIZE at the start of the program and then taking whatever comes from then onwards. The second line had to be generated first, so that the length of the line could be checked and junked if it was over 32 characters - one place the Commie had an advantage. I think my introduction and exit screens are far better than the original, though.
The original was full of error-checking routines which were unnecessary on the C64 but which would stop the program in its tracks if it was run on a PET that couldn't handle it. (There was probably a VIC-20 version as well, but with its horrifically limited text screen, everything would spill over onto two lines.) None of these were needed - all I had to do was condense the program after I found out it couldn't be loaded on a 16K Spectrum (see that as the equivalent of a PET in this case). This involved removing all the REM statements - which I've shown below just in case anyone wants to examine the structure of the program and make it easier - but it also meant wheeling out the old 1K ZX81 trick of using NOT PI, SGN PI, INT PI and a ton of VALs every time a numerical value appeared... and there were a lot of them. Still, that meant plenty of bytes were saved, and the program would run on the smallest Spectrum with ease. It now looks like a complete mess, but at least on a Spectrum the memory-saving tricks don't slow the process down anywhere near as noticeably as they did on a ZX81.
Here are all the removed REMs:
20 REM MENU
180 REM STUDENT INSTRUCTIONS
260 REM TEACHER INSTRUCTIONS
350 REM PRESS SPACE BAR
390 REM PAGE DESIGN ROUTINE
430 REM PLEASE WAIT REMARK
460 REM TITLE SCREEN & ARRAYS
660 REM MAIN PROGRAM STARTS
690 REM a$/g$=SUBJECT
700 REM b$/h$=MODIFIER
710 REM c$/i$=ADVERB
720 REM d$/j$=PREP. PHRASE
730 REM e$/k$=EXPLETIVE
740 REM f$/l$=THOUGHT OR REMARK
750 REM x$/y$=DUMMY VARIABLES
760 REM IN SPACE-STRIP ROUTINE
860 REM STRIP SPACES FROM
870 REM ARRAYS AND CHECK THE
880 REM 2ND LINE FITS ON SCREEN
970 REM PRINT THE HAIKU
1090 REM ARRAY CHOPPER
1140 REM NOUNS
1200 REM VERBS
1260 REM ADVERBS
1320 REM PREPOSITIONAL PHRASE
1380 REM EXPLETIVE
1440 REM REMARK
1500 REM UDG DATA
1550 REM END ROUTINE