3D Chess 2K18

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
uglifruit
Manic Miner
Posts: 700
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: 3D Chess 2K18

Post by uglifruit »

The epic program I've just compiled:

DI
EXX
EI
RET

causes a hang on return to basic.

If that helps at all.

Edit:
DI
EXX
Ld hl, bc, de, a with some arbitrary numbers
EXX
EI
RET

Gave me a "c nonsense in basic" but did return
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: 3D Chess 2K18

Post by Ast A. Moore »

Yes. You need to save HL’ and restore it before returning to BASIC.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Just HL’ ?
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: 3D Chess 2K18

Post by Ast A. Moore »

Well, IY, too, obviously, since it holds the base address for all the system variables. But as far as prime registers are concerned, yes, just HL’.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

No need to worry about iy. But being able to use one of the alternative register pairs for addressing instead of Ix may give the possibility of saving a few bytes.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: 3D Chess 2K18

Post by Ast A. Moore »

I only learned about it by accident (just like you did) when I was perfecting my QuickPrint routine. I even investigated why HL′ in particular was important. I just looked at my source and found this informative snippet:

Code: Select all

	exx			;\
	ld (saveHL+1),hl	; needed only for the BASIC interpreter (routine at $32d7)
	exx			;/
;)
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Alone Coder
Manic Miner
Posts: 401
Joined: Fri Jan 03, 2020 10:00 am

Re: 3D Chess 2K18

Post by Alone Coder »

You may write ld hl,10072:exx:ret, this number doesn't change.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Christmas cheer to all!

After almost an entire year of faffing around trying desperately to save an odd byte here and there and failing, I woke up yesterday morning and came up with a Solution to save 4 bytes!!

..so now my little chess thing has now broken the 500 byte milestone.


499 bytes!


I’ll post some .asm soon, as although the bytes saved are actually only in the part that sets the board initially, there have been performance improvements elsewhere over the past year.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Oh dear!! I always seem to have a habit of premature posting when I think I’ve done something good!

Well, actually I’ve saved more than I thought!

Now

497 bytes!


Now I really didn’t expect to save a whopping 6 bytes!!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

The board initialise routine is now 26 bytes with 6 bytes of data ;)
User avatar
Pegaz
Dynamite Dan
Posts: 1209
Joined: Mon Nov 13, 2017 1:44 pm

Re: 3D Chess 2K18

Post by Pegaz »

arkannoyed wrote: Mon Dec 21, 2020 7:00 pm Oh dear!! I always seem to have a habit of premature posting when I think I’ve done something good!

Well, actually I’ve saved more than I thought!

Now

497 bytes!


Now I really didn’t expect to save a whopping 6 bytes!!
Like I said, you're a wizard and this is witchcraft. ;)
Is there a chance for some compact chess engine in the near future ?
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Yes! Development has definitely slowed, but it has continued.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

This is the new routine to set the board;

Code: Select all

init_board:
           ld de,data20
           ld hl,0ffc0h
ib1:
           ld bc,0602h
           ld a,(de)
           ld (hl),a
           inc e
ib2:
           inc l
           ld (hl),c
           ld c,00h
           djnz ib2
ib3:
           ld (hl),03h
           inc l
           inc a
           ld (hl),a
           inc l
           jr nz,ib1
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: 3D Chess 2K18

Post by Einar Saukas »

You are now storing the board sideways! That's clever!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Yes, it suddenly occurred to me that it was so much smaller to code, and there is only 8 bytes of date, two of which are an 06, 04 (ld b,04) at the start of a routine, so technically 6 bytes only.
Alone Coder
Manic Miner
Posts: 401
Joined: Fri Jan 03, 2020 10:00 am

Re: 3D Chess 2K18

Post by Alone Coder »

Does anybody know, what is the smallest chess program that thinks deeply for any number of moves?
Post Reply