News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Joseman

CPChessNet [developing]

Started by Joseman, 00:36, 03 March 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackdalek

So.... I've recently rediscovered #cpc channel on freenode IRC servers.
If anyone want to try CPChess with me I could be hanging out in there waiting. Or alternatively message me on the forum so we can arrange a time.

@Joseman will there be an english language  version of the interface forthcoming at a later date?

I should also mention, I am terrible at chess and haven't played in at least 20 years ;)

CPC6128 modded with ABBA switch. External 5.25" floppy drive with side switch and Multiface 2. Now also sporting a joystick splitter and M4 WiFi board.

Joseman

#101
ok!

time for 1.6b version!!

*this version has HUGE improvements in the chat code, no more chats lost in favour of a board move, first i do the move, next i see if any message is pending to receive or send. This was really hard to make it work!! I hope there is no problems! Only it can lost a message if a board is send and casually the chat message is lost on any packet on internet, but i suposse is difficult that happens.

*Little sound for the chat receive message, same as board move, you don't have to stay looking at the screen waiting for a move or chat.

*Now you can chat in the end screen, you can laugh at the loser or arrange another game!

KNOW PROBLEM:

*if a chat window is open when the end game ID is sent the end game ID gets lost (same as happenned with the board move on 1.0b version), this is for the same reason, no end game ID confirm is send back... No big problem at all... one side will display the end screen, the other simply will can't do anything because the king is on checkmate, the code will not allow to do anything on this situation, only to chat, and this is almost the same you can do on the end screen!.

*if the program has to check if any message is pending on the other side when it needs to send the board, then it will enter a bucle (that prevents the m4 to hang), it will delay 3-5 seconds...no big deal...


***as there is a lot of internal changes it can be some bug that didn't exist before**

play all you can!!






Joseman

Quote from: blackdalek on 15:20, 26 March 18
@Joseman will there be an english language  version of the interface forthcoming at a later date?

Yes, but i need to know that the program is almost 100% bug free before induce potential bugs on the char arrays changing the language!

anyway: cursor keys to move cursor, space to select/move. T for chat, enter to send chat. that's all

Joseman

Hi!

version 1.7b ready to download!!

*English language added!

of course different languages can play together!

As English is not my mother tongue, please let me know any spelling, grammatical errors or bad translation!



Emu

@Joseman : I stumbled across CPCchessNet via the M4 board documentation. I like it very much. Its complete appearance is highly professional, even beautiful, I think. And of course, it works. Thank you for providing it!

Are you interested in a German translation? I offer to translate the texts if you send the English version of them to me in a file.

Joseman

Quote from: Emu on 20:49, 05 April 21
@Joseman : I stumbled across CPCchessNet via the M4 board documentation. I like it very much. Its complete appearance is highly professional, even beautiful, I think. And of course, it works. Thank you for providing it!

Are you interested in a German translation? I offer to translate the texts if you send the English version of them to me in a file.
Hi
Thanks for the compliments  :)
The appearance is far from professional. The pieces are copied from Colossus Chess, and the texts are a simple font with that simple frames.
And it doesn't work always!! on local LAN it works without problem, but, on internet, if a packet is lost, the program waits forever for it... I never managed to fix that problem... If you chat a lot, you'll see the problem...
send me a mail to sjoseman@hotmail.com and i'll send you the text files
Regards

zhulien

I have created most of a lobby system which I was hoping there would be some interest in it needs a first game... it also supports chat (email like).  Did you create a lobby yet? I also have achievement and leaderboards. At 8bitology.net

Joseman

No, the game has a little chat integrated (that is the source of the problems with the packets lost), i ended tired of trying to fix that and the game is as is on the final version. On local lan never fails but on internet... well, the game can end stuck on a packet lost.

Joseman

Hi @Duke
I want to fix the problem with CPChessNet and the infinite loop when a packet lost happens on internet.
can you help me a little (again)
Thankyou!

Emu

@Joseman : Hi, I've been working on CPCemu in the recent months and stumbled over a strange behaviour of CPChessNet while debugging my M4 emulation network code (and preparing it for IPv6). The user can specify the port number to be used by the chess server. The server binds to this port when started for the first time. If the server is started again it does not use the port number specified by the user, but it increments the previously used port number by the specified value. Is this intended?

There is some strange arithmetic around $8458 (ADD HL, DE with DE containing the user-specified value; this happens also before at $83fe, $841c and $843a). These additions seem to be the origin of the - from my perspective wrong - increasing port number.


Joseman

Quote from: Emu on 22:55, 19 April 22@Joseman : Hi, I've been working on CPCemu in the recent months and stumbled over a strange behaviour of CPChessNet while debugging my M4 emulation network code (and preparing it for IPv6). The user can specify the port number to be used by the chess server. The server binds to this port when started for the first time. If the server is started again it does not use the port number specified by the user, but it increments the previously used port number by the specified value. Is this intended?

There is some strange arithmetic around $8458 (ADD HL, DE with DE containing the user-specified value; this happens also before at $83fe, $841c and $843a). These additions seem to be the origin of the - from my perspective wrong - increasing port number.



Hi, i don't remember much about the code, but i'm pretty sure that is not intended that the server port is incremented with the new value, i'll take a look, thanks!!

One question, how the debugger part of the CPCEmu is going? i found it somewhat "obscure", it can help a lot for a future debugging of my buggy Net code on CPChessnet :)


Emu

Well, the debugger is a quick-and-dirty port from the DOS version. I've only modified it to enable CRTC single-stepping. I was thinking of adding a GDB remote stub, but seeing that there are only very few Z80-compatible GDB implementations, I gave up the idea. It's not worth the effort.

One of my less important projects is to change the UI interface of CPCemu to a more modern system, but this would be little fun only, so I tend to postpone this. However, it's no fun to use the debugger, either, so I could imagine to start with the debugger as it is rather independent of the rest and indeed needs some polishing.

Joseman

Hi @Duke 

Sorry for bringing up an old topic

One question

Sometimes when you do cmdsocket you receive a number upper than number 1.

It happens more and more if you don't reset the M4.

how can i make sure that only will receive the socket number 1?

maybe i have to close the open sockets?

how can i do that? if i receive for example number 3, close sockets 3, 2, 1 and try to get this time socket number 1

Regards

Duke

Quote from: Joseman on 18:05, 23 March 23Hi @Duke

Sorry for bringing up an old topic

One question

Sometimes when you do cmdsocket you receive a number upper than number 1.

It happens more and more if you don't reset the M4.

how can i make sure that only will receive the socket number 1?

maybe i have to close the open sockets?

how can i do that? if i receive for example number 3, close sockets 3, 2, 1 and try to get this time socket number 1

Regards
You should only need to make sure that socket 1 was closed on last use, then the next C_NETSOCKET should pick that socket first.

Joseman

Quote from: Duke on 08:22, 24 March 23
Quote from: Joseman on 18:05, 23 March 23Hi @Duke

Sorry for bringing up an old topic

One question

Sometimes when you do cmdsocket you receive a number upper than number 1.

It happens more and more if you don't reset the M4.

how can i make sure that only will receive the socket number 1?

maybe i have to close the open sockets?

how can i do that? if i receive for example number 3, close sockets 3, 2, 1 and try to get this time socket number 1

Regards
You should only need to make sure that socket 1 was closed on last use, then the next C_NETSOCKET should pick that socket first.

yes, but sometimes if you reset the cpc (only the cpc) or the program hangs (and you need to reset the cpc too), the socket keeps open forever.

how can you close a socket in this case?, where the actual program still didn't make any socket

Duke

Quote from: Joseman on 12:56, 24 March 23
Quote from: Duke on 08:22, 24 March 23You should only need to make sure that socket 1 was closed on last use, then the next C_NETSOCKET should pick that socket first.

yes, but sometimes if you reset the cpc (only the cpc) or the program hangs (and you need to reset the cpc too), the socket keeps open forever.

how can you close a socket in this case?, where the actual program still didn't make any socket

You can try to close the socket before using it, I think it should work ok, even if it isn't open.

Joseman

Hi @Duke 

I'm unabled to get socket1 and only socket1

the first time it's ok, I get socket 1.

Reset the cpc (not the M4), socket1 remains open

Execute the routine get_socket, and I do a "if socket >1 --> close socket"

do a bucle until socket1 free

but it never exist the bucle

it's like that the M4 is not closing sockets and then the bucle never exist

are you sure that the M4 is capable to close sockets that was open on old connections before reset the CPC?

maybe i'm doing something wrong, but i followed your source code as you explain

Duke

Quote from: Joseman on 08:34, 29 March 23Hi @Duke

I'm unabled to get socket1 and only socket1

the first time it's ok, I get socket 1.

Reset the cpc (not the M4), socket1 remains open

Execute the routine get_socket, and I do a "if socket >1 --> close socket"

do a bucle until socket1 free

but it never exist the bucle

it's like that the M4 is not closing sockets and then the bucle never exist

are you sure that the M4 is capable to close sockets that was open on old connections before reset the CPC?

maybe i'm doing something wrong, but i followed your source code as you explain
You should close the socket before opening it, to ensure it is closed after the reset/crash.

Ie.
; close socket 1 first thing
ld hl,cmdclose
call sendcmd

; you can check return value, if -1, then the socket was not open, thus could not be closed.
; ...

; then open a new socket
; ...

ld hl,cmdsocket
call sendcmd
; should return socket 1 (first avaiable socket)
; ...

ret

cmdclose:
db &03
dw C_NETCLOSE
db 1 ; socket 1

cmdsocket:
db 5
dw C_NETSOCKET
db &0,&0,&6 ; domain, type, protocol (TCP/IP)


Joseman

Quote from: Duke on 09:01, 29 March 23
Quote from: Joseman on 08:34, 29 March 23Hi @Duke

I'm unabled to get socket1 and only socket1

the first time it's ok, I get socket 1.

Reset the cpc (not the M4), socket1 remains open

Execute the routine get_socket, and I do a "if socket >1 --> close socket"

do a bucle until socket1 free

but it never exist the bucle

it's like that the M4 is not closing sockets and then the bucle never exist

are you sure that the M4 is capable to close sockets that was open on old connections before reset the CPC?

maybe i'm doing something wrong, but i followed your source code as you explain
You should close the socket before opening it, to ensure it is closed after the reset/crash.

Ie.
; close socket 1 first thing
ld hl,cmdclose
call sendcmd

; you can check return value, if -1, then the socket was not open, thus could not be closed.
; ...

; then open a new socket
; ...

ld hl,cmdsocket
call sendcmd
; should return socket 1 (first avaiable socket)
; ...

ret

cmdclose:
db &03
dw C_NETCLOSE
db 1 ; socket 1

cmdsocket:
db 5
dw C_NETSOCKET
db &0,&0,&6 ; domain, type, protocol (TCP/IP)


At last!!! it seems to work!! thankyou!!

One question:

if all the sockets are opened in old connections, and only close socket1, the m4 will allways try to get first socket1? or there is some case that it will try first to open socket>1

thankyou!!

Duke

Quote from: Joseman on 10:19, 29 March 23One question:

if all the sockets are opened in old connections, and only close socket1, the m4 will allways try to get first socket1? or there is some case that it will try first to open socket>1

thankyou!!

Yes, sockets are always opened in the order 1,2,3,4 - if a socket is in use it will check the next one.

Joseman

Now the big problem with chessnet

sometimes when the program is doing certain things, there isn't any check if a new message is received (board move or chat).

When this occurs, if a board move is not received, the cpc that sent the move, change turn, but the other (not receiving board move), doesn't change turn, then the 2 cpc are thinking that the other cpc is that move next and keep waiting for a new board move that never will occur.

I was thinking that maybe, if i create an interrupt that checks for new messages, when receive a new notification, priorice this new message (inside the int) do the things (actualice the board table, actualice the chat table), exit the int and continue doing what was doing before the int.

what do you think about this solution, may work?

Duke

Quote from: Joseman on 15:00, 29 March 23Now the big problem with chessnet

sometimes when the program is doing certain things, there isn't any check if a new message is received (board move or chat).

When this occurs, if a board move is not received, the cpc that sent the move, change turn, but the other (not receiving board move), doesn't change turn, then the 2 cpc are thinking that the other cpc is that move next and keep waiting for a new board move that never will occur.

I was thinking that maybe, if i create an interrupt that checks for new messages, when receive a new notification, priorice this new message (inside the int) do the things (actualice the board table, actualice the chat table), exit the int and continue doing what was doing before the int.

what do you think about this solution, may work?
I think it is a good solution to check for incoming messages via an interrupt, probably you should do both send and receive from the interrupt and just prepare the data to be send from your game loop and set a flag that you have a package to be sent.

andycadley

The classic way to solve a problem like this is to number messages and then include an acknowledgement into the protocol. If the sender doesn't receive a matching acknowledgement after a while it just re-sends it. If the client receives a duplicate message, it just re-sends an acknowledgement and ignores the message.

It's not perfect and on a really unreliable connection could theoretically loop forever, but practically speaking it solves the problem most of the time.

Joseman

#123
Quote from: andycadley on 17:23, 30 March 23The classic way to solve a problem like this is to number messages and then include an acknowledgement into the protocol. If the sender doesn't receive a matching acknowledgement after a while it just re-sends it. If the client receives a duplicate message, it just re-sends an acknowledgement and ignores the message.

It's not perfect and on a really unreliable connection could theoretically loop forever, but practically speaking it solves the problem most of the time.
i like this idea (number the messages), the reality is that chat messages doesn't mind me, if a chat line is missing, well, if the message was important, just retype it again. But the board message is crucial to be received.

maybe a mix of the 2 things are a good idea, number the board messages and do the receive message on an int.

Talking about ints, i know how an int code works, but i never used one on any of my programs.

The CPC has 6 ints... an int occurs every 52 scanlines (52 * 64 NOPS). I'm right about this?

we can wait for refresh int, and use it as "our" int 1, in chessnet this int can be where i check for incomming message. The rest of the ints are ignored (please correct me if i'm wrong on something)

If what i'm talking is right... then the next thing: what's the correct timing for checking messages, i suposse that checking the M4 every int1 is too fast for checking a message... if this is right, what will be the correct timing to check for incoming messages?

thakyou for your help!





Joseman

Hi @Duke 

i see this annotation on your source code

" ld bc,250 ; max size, prevent overflow because I am too lazy to re-write the sendcmd... "

what's supposed to mean this annotation?

any problem with the buffer if >250?


Powered by SMFPacks Menu Editor Mod