"The greatest program ever written"

General games-related topics
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

"The greatest program ever written"

Post by zsolt »

Dear All,

The above sentence sadly was not written about my program, but I think the blogger is right. All praise to the author of this program. It is not so easy to create anything that can be used in 1 kilobyte. Today's programmers are also concerned with this challenge. Of course this is only on the source code level and the final result is unreadable (for me).
A year ago, when I dealt with the "flicker free" programming technique, thought about rewriting of the "1KCHESS" to run on both platform (ZX80/ZX81). A little sketch was made, but I found too small the remaining free space (559 bytes for code and 68 bytes for data, e.g. stack), so It was not continued. Then the "ISR" occupied all my free time.
NewBoard.zip
(3.77 KiB) Downloaded 763 times
In august (it was rainy in Hungary) I took out the program again, and re-created it based on this article
1KCHESS_mod.zip
(1.17 MiB) Downloaded 885 times
While the fully-commented source was completed I realized that (with some optimizing) we can free up a lot of space. In step 2 I got more free space reusing the area of the system variables and setting the SP to the top of the available RAM.

The final results are 142 bytes of free space and some functional addons:

1. the outlook was changed a little bit (and the DFILE also became shorter);
2. the input is not in reverse order;
3. the input line may include a cursor character;
4. the original version did not work on an upgraded ZX80, this newer does.

The latter two functions depend on compiler options - so if you don't like the cursor, and if you don't want the owners of the upgraded ZX80 to have the opportunity to play, then you have 142 bytes of free space for the further development (otherwise 129 bytes only).

If anyone can, please help me to find the author to get his blessings to these modifications.

Zsolt
Last edited by zsolt on Sat Oct 18, 2014 11:40 am, edited 2 times in total.
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
antoniovillena
Posts: 23
Joined: Fri Aug 15, 2014 5:48 pm

Re: "The greatest program ever written"

Post by antoniovillena »

Hello zsolt

I have released recently something similar, source code is here:

http://sourceforge.net/p/emuscriptoria/ ... ree/chess/

An exact disassembly is in chess.asm, and a 148 bytes optimization in nchess.asm. Use it in your code if you see it interesting, probably you can cross the optimization of both versions and squeeze even more bytes.

Also attached the binaries, but you can assemble yourself with SjAsmPlus and this utility.

http://sourceforge.net/p/emuscriptoria/ ... s/make1k.c
Attachments
nchess.zip
(25.05 KiB) Downloaded 250 times
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: "The greatest program ever written"

Post by zsolt »

Hello Antonio,
antoniovillena wrote:I have released recently something similar, ...
I read about it in your "Unkatris" topic, thank you for sharing of your great work.

Using your excellent loader and these optimisations above, there are 164 :!: bytes free space to make it smarter. :D
So we have to find the autor of the original program to get his permission.
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
antoniovillena
Posts: 23
Joined: Fri Aug 15, 2014 5:48 pm

Re: "The greatest program ever written"

Post by antoniovillena »

zsolt wrote:Hello Antonio,
antoniovillena wrote:I have released recently something similar, ...
I read about it in your "Unkatris" topic, thank you for sharing of your great work.
Also thank you for sharing your work.
zsolt wrote:Using your excellent loader and these optimisations above, there are 164 :!: bytes free space to make it smarter. :D
So we have to find the autor of the original program to get his permission.
Zsolt
164 bytes is much, you can do many things with them.

About original autor I think that It's a difficult task, he wrotes 1k chess 30+ years ago. I've found these profiles:

https://www.facebook.com/public/David-Richard-Horne
http://www.192.com/atoz/people/horne/da ... 455054775/

But I doubt we can find him. I think you can distribute your MOD as a homebrew improvement of his work. If you clarify that the original code belongs to David R Horne and you don't earn money with that, there were not legal problems.
RWAP
Posts: 1348
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: "The greatest program ever written"

Post by RWAP »

The listing on 192.com is definitely not the right person - he was in his 30s in 1984 - so that makes him in his 60s now (at least) - he lived in Crowborough in the early 1980s which is in East Sussex. I have attempted to find him, but no luck unfortunately (I have been fairly successful with finding people for the QL!).

That said, reading his commentary on the listing in Your Sinclair - http://archive.org/stream/your-computer ... 9/mode/2up

He does say that although the listing is copyright, you can use it to produce a copy of the program for your own use, but should not copy the listing or parts of it and offer it for sale...

I doubt that he would have any complaints about someone basing a new free chess program on his original code

Could the extra space be used to add the missing features and/or enhance the computer's intelligence?
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: "The greatest program ever written"

Post by zsolt »

So you believe that the focus is on the selling, and not on the usage of the code parts. In this case "nothing is impossible" ;)

Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

1K CHESS plus

Post by zsolt »

This amendment contains 3 :!: add-ons:

1. the program is restartable at any positions of the game.
If you type in "I1" (instead of a real board position "A1...H8"), then the program puts the pieces again into the start position.
2. choosing "I2", you can place them according to your preferences!
In the input line, first you must provide the target position (eg. D3), then the letter (K,Q,R,B,N,P) and finaly the colour of a
piece: 1=black, 2=white. If you don't need more, then type in "I1" as target position and you can start playing.
3. the 1KCHESSplus knows the queening (in chess, of course :mrgreen: )
the 1KCHESSplus is now a little bit more
the 1KCHESSplus is now a little bit more
1KCHESSplus.jpg (61.58 KiB) Viewed 8595 times
See on video

Enjoy,
Zsolt

(Edit: here is a newer version)
Last edited by zsolt on Thu Nov 13, 2014 12:08 pm, edited 1 time in total.
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: "The greatest program ever written"

Post by siggi »

Hi Zsolt
I tried to load that program from USB-stick using my USB-filemanager. The program starts, but crashes when I press any key.
What is the difference between the "K" and the "Q" version of the program?
Do they run only at a 1K Zeddy (my Zeddy has 64K ram and thus the display file is not collapsed).

Could you explain, what those 2 programs do? So mayby I can handle and load them using MEFISDOS without any user-interface needing an expanded display file ...

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: "The greatest program ever written"

Post by zsolt »

Hallo Siggi!
siggi wrote:What is the difference between the "K" and the "Q" version of the program?
The "K" version is the "King's pawn game" and the "Q" is the "Queen's pawn game" (opening ;) ).
siggi wrote:Do they run only at a 1K Zeddy (my Zeddy has 64K ram and thus the display file is not collapsed).
It is a "simple" 1K program with own collapsed (but standard) D-File at a non-standard memory area (see in source) .
The SP points $4400 at the beginning - and the program uses all the bits of the 1K RAM
(except the next system variables: D_FILE, LAST_K, DEBOUN, MARGIN, FRAMES and CDFLAG).
siggi wrote:The program starts, but crashes when I press any key
:o
It reads the LAST_K system variable then calls the DECODE routine to check keypresses.

I tested it in 1K/16K real environment (and now with 8K and 32K RAM too) without any problem.

Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: "The greatest program ever written"

Post by siggi »

The best results were, that I could use the I1 and I2 commands, after I loaded the game using the command level USB driver only (without "graphic" user interface ;-)
But the other chess commands for moving anything were ignored (cursor jumps back to the beginning of the line, nothing has been done on the chess board)

The problem is probably, that the USB-driver as well as MEFISDOS does the LOAD properly, but when they return to BASIC they use

Code: Select all

rst 08
DEFB $FF
to return "without" error to BASIC. But that affects some BASIC system variables, which seem to be used for other purposes by the chess program.

Could those programs be loaded using ZXPAND?

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Post Reply