3D Chess 2K18

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Ahem! (Clears throat!) Emotional moment! 512 bytes.

Image

Yes, ok ,its not playable, but look how pretty it is! :lol:
Last edited by arkannoyed on Wed May 01, 2019 3:46 pm, edited 1 time in total.
User avatar
PROSM
Manic Miner
Posts: 473
Joined: Fri Nov 17, 2017 7:18 pm
Location: Sunderland, England
Contact:

Re: 3D Chess 2K18

Post by PROSM »

Congratulations! It's been quite a journey to get to this point! Do you think you'll go any smaller? ;)
All software to-date
Working on something, as always.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I can (fairly) confidently say that this is as small as it will get. No matter where I look in the code now, there isn't anything obvious that I could squash or improve.

It ended up being almost a cheat to save that last byte, as I examined the graphics data it became apparent that the very last line of the Knight data only produced an empty line, and removing it made no difference really. So after altering a few things and shifting everything up by a byte, here it is.

What now, I wonder?

Should I consider it as an official release? Could it even go on the ZXDB database? Obviously the playable version is going to be a considerably larger size than this when it eventually comes to life.
User avatar
Ersh
Manic Miner
Posts: 480
Joined: Mon Nov 13, 2017 1:06 pm

Re: 3D Chess 2K18

Post by Ersh »

Wow! Grats mate! :D Is everything (sans the logic) inside that 512?

This is going to break the forums when it's done, released and gone viral. ;)
reeagbo
Dizzy
Posts: 61
Joined: Mon Apr 29, 2019 9:11 am

Re: 3D Chess 2K18

Post by reeagbo »

It really looks great. Hopefully the engine won't take you so long. Congrats!
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Ersh wrote: Wed May 01, 2019 3:51 pm Wow! Grats mate! :D Is everything (sans the logic) inside that 512?

This is going to break the forums when it's done, released and gone viral. ;)
It is all in there, the code to build it, display it, the graphics data and the code to set/ reset the board too. No ROM routines borrowed either so compatibility should be universally Speccy. Source anyone?
Last edited by arkannoyed on Wed May 01, 2019 4:13 pm, edited 2 times in total.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

reeagbo wrote: Wed May 01, 2019 3:53 pm It really looks great. Hopefully the engine won't take you so long. Congrats!
Thats a whole other world to me really. The game as you know very well is something that can take a frustratingly long time, especially when you're restricted in size.

I do now have 512 bytes though, and as you and a few others have consistently proven, Chess is possible well within that size.

I don't know how much of your 363 (or 367 now?) bytes is dedicated to displaying the board and how much is actual game logic, but I'm hopeful that 512 bytes is going to be enough to get it to operate at least convincingly.
User avatar
Fahnn
Microbot
Posts: 135
Joined: Sun Jan 27, 2019 7:56 pm
Location: Redcar, UK
Contact:

Re: 3D Chess 2K18

Post by Fahnn »

Congratulations! This is such an impressive achievement. I've found this thread absolutely fascinating, even though when you talk about the nitty-gritty of the programming, I can't pretend to understand more than about one word in ten. Hope we can look forward to more like this!
reeagbo
Dizzy
Posts: 61
Joined: Mon Apr 29, 2019 9:11 am

Re: 3D Chess 2K18

Post by reeagbo »

arkannoyed wrote: Wed May 01, 2019 4:07 pm
reeagbo wrote: Wed May 01, 2019 3:53 pm It really looks great. Hopefully the engine won't take you so long. Congrats!
Thats a whole other world to me really. The game as you know very well is something that can take a frustratingly long time, especially when you're restricted in size.

I do now have 512 bytes though, and as you and a few others have consistently proven, Chess is possible well within that size.

I don't know how much of your 363 (or 367 now?) bytes is dedicated to displaying the board and how much is actual game logic, but I'm hopeful that 512 bytes is going to be enough to get it to operate at least convincingly.
I had a quick glance a the code and data for the board display is 73B. That means the rest is around 290 bytes. That leaves a lot of space for a more complete engine. But, but, some 'advanced' stuff like en-passant or fully checked castling, under-promotions needs individual piece control and that makes things more complicated thatn in my program. I took the easy path.

I'm looking at the board creation. If I come up with something useful I´ll let you know.
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: 3D Chess 2K18

Post by R-Tape »

arkannoyed wrote: Wed May 01, 2019 3:44 pm Should I consider it as an official release? Could it even go on the ZXDB database? Obviously the playable version is going to be a considerably larger size than this when it eventually comes to life.
It should definitely get a ZXDB ID, even if you stopped developing it now (please don't!). I'll send you a PM.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Now then! Important decisions to be made. Its looking like this final initial version will be added to ZXDB, however, I've not actually ever decided upon a name for it. I've gone along with Chess 2k19 (or 2k18) for some time, simply as a development name.

Some time ago I thought it might be something like 1K 3D Ultra Chess or something similar. I think it needs the ability to add a suffix like 16k version or Display, or Screen Resident to reflect various branches that might follow.

Any thoughts?
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 came across one of the original development +D Disc image images. Below was an early attempt at some sort of GUI, though that was about 1994, way way before the idea of the small size version was conceived.

Image

See, the graphics have remained very true to the original designs.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

And this is how fast it could be displayed when using conventional masked sprites, though this was hand encoded with no assembler over 25 years ago, when I first learned to program in Z80, so fairly simple concepts with little effort dedicated to speeding it up.

Image
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: 3D Chess 2K18

Post by ZXDunny »

How much RAM does your current 512b version take up at runtime?
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

Do you mean any buffering? If so, none, only the stack for 4 or 5 pushes/pops. Everything calculated and placed directly on screen.

The 512 bytes is unaltered, untouched. Everything done in-registers really.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

How about
3D Chess 512 or 3D Chess 200 (200 hex is 512!)

3D Ultra Chess 512?

Half K Chess 3D

Nothing sounds very catchy!
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 Bugger!

Thats messed the naming up now! Saved another byte, so now its 3D Chess 511!

It was another one of those annoyingly obvious situations where saving a byte was very easy.

The Initialise board routine is just plonked in front of the start of the main routine, therefore getting rid of the need for a RET, as in most cases you'd call the display routine straight after anyway. If no reset needed, just skip the initialise part.
reeagbo
Dizzy
Posts: 61
Joined: Mon Apr 29, 2019 9:11 am

Re: 3D Chess 2K18

Post by reeagbo »

arkannoyed wrote: Mon Apr 29, 2019 3:58 pm ...And another version, a bit faster, but sadly still 41 bytes!

Code: Select all

init2:
          ld de,0ffc0h
          ld hl,data2s
lp1:
          xor a
          ld c,(hl)
          rrd
          ld b,(hl)
          ld (hl),c
lp2:
          ld (de),a
          inc e
          djnz lp2
          inc hl
          jr nz,lp1
          ret
I was trying to write a board starting routine that I could use. It's 38 bytes. Maybe you can use it with minor changes. I use the beloved 128 board, and pieces color goes in bit4 intstead of bit 1. Both yours and mine can discount 1B for the 'ret'. Tell me if it gives you any idea.

Code: Select all

org 30000
; preps, 5B
	ld hl, $8060		; point at black pawns start in board
	push hl			; copy HL to DE for later use in loop
	pop de			;
; fill in white pawns, 7B
loopaw	ld (hl), $11		; set black pawn
	inc l			; next square
	bit 3, l		; loop until L=70
	jr z, loopaw		; 

; copy black pieces to white, 9B
	ld l, $17		; point at white pawn start
loocop	ld a, (de)		; copy black piece
	and $0F			; "blacken" piece
	ld (hl), a		; place it on the white side
	inc e			; next black square
	dec l			; next white square
	jp p, loocop		; loop down to square cero

; switch $8003 <-> $8004 for mirror symmetry, 6B
	ld hl, $0508		; black queen, black king
	ld ($8003), hl		; load in black squares

	; alternative
	;ld l, $03		; H =80 now
	;ld (hl), $05		;
	;inc l			;
	;ld (hl), $08		;
	ret

; white pieces, 8B
org $8070
	piesta  defb $14, $12, $13, $15, $18, $13, $12, $14
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I don't understand entirely what its doing?

I know your 128 byte board layout is different to mine, but I can only see that it sets the Pawns and the black King and Queen?

Mine is 'technically' 38 bytes, as the routine is now 20 as the RET has been dropped from the end, and 2 bytes of the data are shared as code with the routine.

I am still working on some rather abstract ideas to come up with a smaller solution.
User avatar
arkannoyed
Manic Miner
Posts: 435
Joined: Mon Feb 05, 2018 9:56 am
Location: Northamptonshire

Re: 3D Chess 2K18

Post by arkannoyed »

I have now officially begun writing and re-writing some of the key routines that will be incorporated.

The core build/ display routine will unhook from some internal routines such as the calculations for square addresses and screen handling, which it will call external routines for. This will slow it a little, however, those routines are to be shared elsewhere. Instead of clearing the entire 6144 bytes of the buffer after every action takes place, an intelligent routine will just clear the 2 squares and a fixed number of lines upwards in a super quick, but compact block clear. This can be done in about a quarter of the time and doesn't take many more bytes really.

Therefore, the actually build routines will shrink in size as parts move elsewhere.

If I were to have a second buffer, then the board could be created upon initialisation and stored as a large bitmap then just copied. That would make it possible to remove the square routines from the build and reduce it to one, more compact piece of code that just cycles through the board matrix and prints the pieces as and when they are found. This would make the whole thing bigger, but might give better speed for the game play point of view in terms of animation etc. A possibility to be considered perhaps.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: 3D Chess 2K18

Post by Einar Saukas »

arkannoyed wrote: Fri May 03, 2019 8:37 amI don't understand entirely what its doing?
The first loop sets white pawns. The other white pieces were already set using DEFB. The second loop copies pieces white to black, then finally there's an explicit LD to switch King and Queen positions.

The initialization only works once, and it's assuming that any position not explicitly assigned will be zero. But under these assumptions, why not simply use DEFB to set all 32 pieces, thus only requiring 32 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 »

A DEFB is all ok from an assembler point of view for a one off game, but to copy 32 bytes of data and clearing the board would still be bigger. As its going to be replayable, it needs a board reset routine.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: 3D Chess 2K18

Post by Einar Saukas »

arkannoyed wrote: Fri May 03, 2019 12:20 pm A DEFB is all ok from an assembler point of view for a one off game, but to copy 32 bytes of data and clearing the board would still be bigger. As its going to be replayable, it needs a board reset routine.
I know.

I was suggesting DEFB for chesSkelet only, since it doesn't clear the board and it's not replayable.
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 I see, sorry!

We we're just discussing the possibility of making it replayable, perhaps in one of the larger fuller versions, and whether some sort of board setting/ resetting routine could work for both of us.
llewelyn
Manic Miner
Posts: 205
Joined: Thu Feb 22, 2018 3:27 pm
Location: virginias eastern shore
Contact:

Re: 3D Chess 2K18

Post by llewelyn »

[/quote]


It was more a jab at the idiocy of the zack4mac's assessment of the state of PC software.
[/quote]

Hey Dunny? Please excuse my probable idiocy but why did you say zack4mac's comment about the state of PC software was idiotic?

I'm constantly annoyed by bloatware. The difference in functionality versus size came up yesterday when I went looking for an RTF to HTML conversion utility. Some of them were several megs in size, the one I eventually chose was around 700k and works just fine (not sure if I got that size right but there was a huge difference between the various examples)
Post Reply