3D Chess 2K18

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

Re: 3D Chess 2K18

Post by arkannoyed » Tue May 07, 2019 3:08 pm

Some movement, in realtime;

Image

I like the way it speeds up when there are fewer pieces on the board, like Space Invaders! :D

This isn't speed optimised in terms of the copy routines. Interestingly, because the original builds straight to the screen, and contention plays its part, building to a buffer, then copying to the screen hardly adds any extra time at all!

This is using a combined copy and clear routine thats fairly efficient. It copies a byte of the buffer to the screen and then writes a '00' to the buffer for when the board is build next.

Using the optimised block copy/clear routines is bigger and more complex, and actually not much faster. If space allows, this method could be unrolled to increase the speed a little more. Currently only uses 38 bytes.
6 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Wed May 08, 2019 8:11 am

In case anyones interested, below is the flexible Copy/ Clear routine. By just altering the number of LDD/ LD (BC),A instructions to fill a sensible amount of free space, the routine has the ability to speed up if there are free bytes still available. Nothing complicated. BC trails one byte behind whats being copied from the buffer to the screen, so it can be cleared afterwards.

Code: Select all

copy_clear:
           xor a
           ld de,57ffh
           ld hl,0d7ffh
           ld bc,0d800h
cc_lp:
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           ldd
           ld (bc),a
           bit 6,h
           jr nz,cc_lp
           ret
Could be anywhere from 18 bytes up to a whopping 18447, which there would still be room for if I allowed buffering besides the screen too. I have some code that builds it to whatever length you choose, and thats only 27 bytes.
Last edited by arkannoyed on Wed May 08, 2019 9:15 am, edited 1 time in total.
1 x

User avatar
djnzx48
Manic Miner
Posts: 464
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: 3D Chess 2K18

Post by djnzx48 » Wed May 08, 2019 8:20 am

Oh nice, that's pretty clever. Great way to make use of the normally useless BC register during LDI/LDD copies.
1 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Wed May 08, 2019 9:13 am

I know, the BC register just gets wasted in most cases. Nice to make it work for a change. I actually tried the routine fully unrolled to 18k and its quite fast!
0 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Wed May 08, 2019 10:18 am

Well I guess I must've been inspired by Liverpools epic comeback last night. I have just saved a further...

7 bytes

Making my little beauty just 505 bytes!

Thats a 1.37% saving :lol:

Actually I spotted a stupid repetition and a way of sharing a byte in the graphics data. I can't recall saving a full 7 bytes in one go for a very long time :)

No graphics changes in appearance whatsoever. I guess that now brings it perilously close to another milestone of 500 bytes, though it might as well be 100 bytes away, as I don't know where I can save any more. I do find myself uttering those very words far too often though, and proving myself wrong again and again!

Graphics data is now just 210 bytes!
Last edited by arkannoyed on Wed May 08, 2019 10:57 am, edited 1 time in total.
1 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Wed May 08, 2019 10:57 am

Oh hang on, no, my mistake, can't count what with all the excitement!

504 bytes!
1 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Thu May 09, 2019 10:31 am

Bit cheaty, but by swapping the order of some of the graphics data I can use the first byte of it as the jump vector at the end of the main routine, thus saving another byte.

503 bytes
0 x

d2010
Dizzy
Posts: 72
Joined: Tue Mar 26, 2019 9:19 am

Re: 3D Chess 2K18

Post by d2010 » Thu May 09, 2019 11:59 am

arkannoyed wrote:
Tue May 07, 2019 3:08 pm
Some movement, in realtime;
Image
I need replace the board 2colors from black-white to texture-white.
If i enter poke 53484,255[enter] the board will be colored into white+black.
If i enter poke 53484,170[enter] the board will be colored into white+gray(bin1010101).
Can you give me, address of poke and value?(at means cheats code)
:x :?:
0 x

User avatar
arkannoyed
Manic Miner
Posts: 360
Joined: Mon Feb 05, 2018 9:56 am

Re: 3D Chess 2K18

Post by arkannoyed » Thu May 09, 2019 12:27 pm

I don't exactly understand, however, are you asking if it is possible to have White/ Grey board instead of White/ Black? If so, yes, it could be re-written to do that, as that is part of the functionality of the Graphical User Interface. That will not be as simple as just poking one address to a different value unfortunately. The square plotting routine has to be re-written.

Is it because you want to make some weird video of it? :)
0 x

d2010
Dizzy
Posts: 72
Joined: Tue Mar 26, 2019 9:19 am

Re: 3D Chess 2K18

Post by d2010 » Thu May 09, 2019 1:37 pm

arkannoyed wrote:
Thu May 09, 2019 12:27 pm
Is it because you want to make some weird video of it? :)
Yes, i cannot ~different between board_black_color and black_pieces(turn, queen,king).
Last edited by d2010 on Thu May 09, 2019 2:12 pm, edited 2 times in total.
0 x

Post Reply