3D Chess 2K18

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

Re: 3D Chess 2K18

Post by arkannoyed » Thu Apr 18, 2019 11:21 am

And there is the possibly to save another byte by changing the first byte of the data to 96 instead of 9E so it can act as the jump vector for the loop.

Have to watch that though in case I save more bytes. I think I'll leave it for now.

Both routines now weigh in agonisingly at 257 bytes!
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Thu Apr 18, 2019 11:45 am

And another byte saved.

Silly me, never noticed that the first byte of both the Standard line and data line routines was LD L,A. So now that can be placed before we enter either of those.

Now 482 bytes
0 x

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

Re: 3D Chess 2K18

Post by d2010 » Thu Apr 18, 2019 5:59 pm

arkannoyed wrote:
Thu Apr 18, 2019 11:45 am
And another byte saved.
Silly me, never noticed that the first byte of both the Standard line and data line routines was LD L,A. So now that can be placed before we enter either of those.
Now 482 bytes
You make animations with demos.Why the pieces don't- move in table 8x8?

Please subscribe , please you click on like-on-youtube for more-fun.
:arrow:
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Thu Apr 18, 2019 6:38 pm

Substance abuse is a strange pastime!! :lol:
3 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Fri Apr 26, 2019 2:08 pm

Not had a great deal of time to dedicate to this lately, but a couple of quick changes I spotted were possible this afternoon.

The first is 3 bytes saved in the Graphics data, where they can be shared elsewhere with just the addition of an extra jump vector (2 bytes)

The second I've been puzzling over for a very long time, and now I've finally figured out the maths of it. Instead of the traditional next line up routine, I've replaced it and shared the correction part from the squares calculating routine with calculating the next line up on screen.

All bafflingly complicated, however, its saved 3 bytes, and also allowed me to move the (still not completely fixed) board initialising routine to just before the board data matrix. Now there are precisely ZERO free bytes wasted inbetween.

The main routine and data is now an impressive 479 bytes!

Thats actually only 7 bytes away from the ENTIRE project fitting snugly into 512 bytes (if you include the 40 byte initialise routine)

Thankfully there seems to be no drop in speed at all.
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Fri Apr 26, 2019 2:23 pm

Next line up changed from this;

Code: Select all

nxt_line_up:
           ld a,h                         ;fairly standard stuff
           dec h                          ;I'm sure we're all
           and 07h                        ;familiar with!
           jr nz,piece_loop               ;
           ld a,l                         ;
           add a,0e0h                     ;
           ld l,a                         ;
           sbc a,a                        ;
           and 08h                        ;
           add a,h                        ;
           ld h,a                         ;
to this;

Code: Select all

	   ld a,h                         ;adjust to the next line up
           sub 20h                        ;
           ld h,a                         ;
           jr nc,piece_loop               ;if theres no Carry, then skip the next bit
           ld de,0ffe0h                   ;this takes care of adjusting the line
           add hl,de                      ;and SCReen 1/3rd adjustment.
Then the shared correct routine is just;

Code: Select all

scr_crt:
           ld a,h                         ;correct the SCReen address
           rlca                           ;
           rlca                           ;
           rlca                           ;
           ld h,a                         ;HL=correct SCReen position
I realise that out of context it probably remains puzzing!
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Fri Apr 26, 2019 2:56 pm

Oh, and it also means no having to reset the screen address to the centre of the line before calculating next line up.
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Fri Apr 26, 2019 3:24 pm

Blimey, Friday afternoons!!

Because we no longer need to restore the screen address, the B register if freed up allowing the Left hand side bit placing routine to shrink by 1 byte and get a little quicker too;

from this;

Code: Select all

left_ovr:
           ex de,hl                          ;swap data into HL
           add hl,hl                         ;propagate MSB
           ex de,hl                          ;swap back to SCReen in HL, data in DE
           sbc a,a                           ;apply carry
           xor (hl)                          ;XOR screen contents
           and c                             ;mask current bit
           xor (hl)                          ;XOR screen again to write the bit
           ld (hl),a                         ;place byte
           ld a,d                            ;check if data finished
           or e                              ;
           jr nz,left                        ;loop if not
left_end:
           ld a,(hl)                         ;change the last bit to 0
           xor c                             ;
           ld (hl),a                         ;

           ld l,b                            ;restore SCReen address
           ret                               ;
to this;

Code: Select all

left:
           rlc c                             ;next left bit
           jr nc,left_ovr                    ;
           dec l                             ;move left screen address
left_ovr:
           ld a,(hl)                         ;get SCReen byte into A
           or c                              ;set the current bit
           ld b,a                            ;save result in B
           xor c                             ;reset the current bit
           ld (hl),a                         ;write the result back to (HL)
           ex de,hl                          ;
           adc hl,hl                         ;shift bit 7 of H into Carry
           ex de,hl                          ;
           ret z                             ;if the result of ADC HL,HL=0000 then end
           jr nc,left                        ;if no carry, then we've already reset that bit, so loop
           ld (hl),b                         ;otherwise write the bit set result to (HL)
           jr left                           ;loop
Nice! and also saves yet another valuable byte, and in a very intensive routine too! :)

Now at 478 bytes
1 x

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

Re: 3D Chess 2K18

Post by d2010 » Fri Apr 26, 2019 3:40 pm

Please , you do no more reduce size of tap/z80.You insert more animations between
the pieces.If can not insert chess-role-game, then you insert first move.
Other you play the Chess with other game.z80, you save all moves(.Eg. A4-A6.C3-C7..)
The 3DChess-2K18 read all moves.
:P
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
arkannoyed wrote:
Fri Apr 26, 2019 2:56 pm
Oh, and it also means no having to reset the screen address to the centre of the line before calculating next line up.
0 x

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

Re: 3D Chess 2K18

Post by arkannoyed » Fri Apr 26, 2019 4:11 pm

But its size is eventually intended to be below 1k, so all this reducing is still of great importance.
0 x

Post Reply