Author Topic: CPChessNet [developing]  (Read 13738 times)

0 Members and 1 Guest are viewing this topic.

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #50 on: 20:06, 19 March 18 »
if i setup first the client and put it listening for a server and after of this, setup the server, the conexion doesn't work NEVER

what can i doing bad?

Check the status byte. You cannot connect to a server which does not exist so it should time out and give you an error.

Quote
And other question, this is from the start, but never looked back again until the game is nearly finished...

my client/server cpc's create a socket, but i never close the sockets, the first time they choose 01h, if i reset the cpc, they choose 02h and so on...

what is the correct way of closing a socket, and this way the cpc's always use 01h?
When you no longer need the connection (say user exits), you simply close the socket you were given (ie. 1) and it will be available next time.
Also if an error occurs, you should close the socket and re-create it.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #51 on: 22:29, 19 March 18 »
Thankyou @Duke

to close a socket i understand that this is the code:

Code: [Select]
exit_close:
            ld    hl,cmdclose
            call    sendcmd           
            ret

but i cant see  where the number of socket to be closed is specified... maybe in the a register?

if i do this code alone (without specifying socket) sometimes it appears to close the open socket but other times it just freeze...

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #52 on: 23:03, 19 March 18 »
but i cant see  where the number of socket to be closed is specified... maybe in the a register?

if i do this code alone (without specifying socket) sometimes it appears to close the open socket but other times it just freeze...

Yes, you need to send the socket number you want to close aswell.

Code: [Select]
cmdclose: db &03
dw    C_NETCLOSE
clsocket: db &0                <----------- put socket number here

You can also find parameters for all M4 commands here:
http://www.spinpoint.org/cpc/m4info.txt  under "Developer information".

C_NETCLOSE      0x4333      Implemented v1.0.9.   data[0] = socket. 

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #53 on: 11:09, 20 March 18 »
Hi!

Thankyou for the answers!

You can also find parameters for all M4 commands here:
http://www.spinpoint.org/cpc/m4info.txt  under "Developer information".

C_NETCLOSE      0x4333      Implemented v1.0.9.   data[0] = socket. 


Yes yes, i read the documentation but for someone like me starting with M4 and protocols is a little hard to understand some things!

for example C_NETCLOSE is 2 times repeated with different ports, wich can be fine, but it's a little obscure, i didn't know what to use until i saw in your client code that C_NETCLOSE    equ &4333!

and "C_NETCLOSE Implemented v1.0.9.    data[0] = socket"

it took me a little while to understand that data[0] is
cmdclose:        db    &03  <---- data[0]
            dw    C_NETCLOSE

maybe it's just me, but maybe the instructions are a little advanced to people trying to understand whats goin' on with protocols, m4 and client/server applications!  :laugh:


Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #54 on: 11:42, 20 March 18 »
it took me a little while to understand that data[0] is
cmdclose:        db    &03  <---- data[0]
            dw    C_NETCLOSE
It's not correct, this is how it works:
cmdclose: db &03           <---- Size of command+data to be sent
dw    C_NETCLOSE         <---- command (size 2)
clsocket: db &0               <---- data[0] (size 1)

Quote
maybe it's just me, but maybe the instructions are a little advanced to people trying to understand whats goin' on with protocols, m4 and client/server applications!  :laugh:
Sorry ;) - Maybe that's why so few used it. I did provide examples, so usage should be self explanatory... oh well.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #55 on: 11:54, 20 March 18 »
It's not correct, this is how it works:
cmdclose: db &03           <---- Size of command+data to be sent
dw    C_NETCLOSE         <---- command (size 2)
clsocket: db &0               <---- data[0] (size 1)
Sorry ;) - Maybe that's why so few used it. I did provide examples, so usage should be self explanatory... oh well.
sorry, thats is how i understood it!! the first is the size data, yesterday i saw it, today morning... oh well XD

Enviado desde mi GT-N7100 mediante Tapatalk


Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #56 on: 16:06, 20 March 18 »
Hi @Duke


if i do this piece of code in my program:

Code: [Select]
wait_connect:

                        ;wait for ESC to press, if it's pressed then i do the cmdclose command
       
            ld    a,(ix)    ; get socket status  (0 ==IDLE (OK), 1 == connect in progress,
                                        ; 2 == send in progress)
           

                        cp    1 ; connect in progress?
            jr    z,wait_connect
            cp    0
            jr    z,connect_ok
             jp no_connect


I'm waiting for ESC to press to go back to the menu, while the bucle wait_connect is made...

when i hit esc, i go to a sub that performs the cmdclose command and jump to the main menu.

But not always returns to main menu, sometimes it returns, but sometimes is just hangs on the cmdclose command (i know it because i change to red border just after the cmdclose command, and because if i disconnect the M4 from power it goes back to the menu!)

Why is the M4 hanging in the cmdclose (but not always)?

on the no_connect jump i jump back to the cmdconnect command continue to the wait_connect command

can i call the cmdconnect command as many times as i want or there is a limit, or is supossed to call only one time?
« Last Edit: 16:11, 20 March 18 by Joseman »

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #57 on: 16:22, 20 March 18 »

Why is the M4 hanging in the cmdclose (but not always)?

Do you store the socket number when you open it, so you are sure you are closing the right socket?

Quote
on the no_connect jump i jump back to the cmdconnect command continue to the wait_connect command

can i call the cmdconnect command as many times as i want or there is a limit, or is supossed to call only one time?
You are only supposed to call it one time. Of course if it eventually gives an error code, you can jump to it again, but as long as it returns "connect in progress" (1), you should not send a connect command again.
Just read status byte and check when it is connected (or error occurs).

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #58 on: 16:28, 20 March 18 »
Do you store the socket number when you open it, so you are sure you are closing the right socket?

yes, on the server and on the client, just when you save the socket on (csocket) i save it to another variable (using_socket), when i go to close de socket
i do ld a,(using_socket) ld (cLsocket),a --> cmdclose



Quote
You are only supposed to call it one time. Of course if it eventually gives an error code, you can jump to it again, but as long as it returns "connect in progress" (1), you should not send a connect command again.
Just read status byte and check when it is connected (or error occurs).

one question:

if i do

Code: [Select]
; connect to server
           
            ld    hl,cmdconnect
            call    sendcmd
            ld    a,(iy+3)
            cp    255 ;#FF error
            jp    z,error_conectando_server

.error_conectando_server
 call 0

if i put an inexistent ip (192.168.0.50) i suposse that the cpc it's going to reboot

BUT it doesnt reboot, it reach the wait_connect bucle!
« Last Edit: 16:38, 20 March 18 by Joseman »

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #59 on: 16:44, 20 March 18 »
yes, on the server and on the client, just when you save the socket on (csocket) i save it to another variable (using_socket), when i go to close de socket
i do ld a,(using_socket) ld (cLsocket),a --> cmdclose
Also make sure that when you opened the socket, its a valid socket (1 to 4 ).
Quote
if i put an inexistent ip (192.168.0.50) i suposse that the cpc it's going to reboot

BUT it doesnt reboot, it reach the wait_connect bucle!
It will not know at that point, that the IP does not exist.
You will have to check the status byte from the read only address for the corresponding socket.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #60 on: 16:55, 20 March 18 »
Also make sure that when you opened the socket, its a valid socket (1 to 4 ).

added  check port 1 to 4 to my code (server and client code)! [/quote]

Quote
It will not know at that point, that the IP does not exist.
You will have to check the status byte from the read only address for the corresponding socket.

then the cp #ff, jump z,error

when activates? only when on the other side is another cpchessnet server but for some reason didn't accept the connection?

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #61 on: 17:04, 20 March 18 »
then the cp #ff, jump z,error

when activates? only when on the other side is another cpchessnet server but for some reason didn't accept the connection?
The 0xFF error only occurs, if the socket is out of range (less than 1 or bigger than 4).

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #62 on: 18:00, 20 March 18 »
The 0xFF error only occurs, if the socket is out of range (less than 1 or bigger than 4).

almost i have it...

BUT

sometimes the cmdsocket command retuns '0' socket, if i understand is the local M4 not giving any free socket to the local cpc.

i compare that IF it's 0 then try to do another cmdsocket (without close anyting, i understand that at this point there isnt any conexion to close)

and again the m4 hangs in the cmdsocket :(, why?

sorry for so many questions and thankyou Duke.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #63 on: 18:57, 20 March 18 »
@Duke

AT LAST, AT LAST IT WORKS!!!!

you can believe it? i was disabling the upper rom in one routine!

then the socket readed was 0, or what the screen had  :laugh:






Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #64 on: 20:15, 20 March 18 »
AT LAST, AT LAST IT WORKS!!!!

you can believe it? i was disabling the upper rom in one routine!

Good, 'cause I could not find anywhere the netsocket would return 0 :)

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #65 on: 05:45, 21 March 18 »
CPChessNet 1.0b is reality at last!

*Net code is a lot stable now (connect/listen), not perfect, but very reliable,  there is no code to test if any conection lost occurs (i don't know how the game will perfom on internet)
*screen win/lose added, and the possibility of restart a game (it is tricky to assure that is correct, because of the thousands variables that the game is using, i don't know if there is any variable not initialice between games... time will tell)

very very soon the game on your cpc's to test.

@Duke, i suspect that there is need to open the router port 1234 for cpchessnet server?

Pic:





Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #66 on: 08:04, 21 March 18 »
@Duke, i suspect that there is need to open the router port 1234 for cpchessnet server?
Yes, if you used same port as the example it is port 4660 (0x1234). Also on the server you will need to forward the port to your CPC IP.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #67 on: 19:46, 21 March 18 »
Yes, if you used same port as the example it is port 4660 (0x1234). Also on the server you will need to forward the port to your CPC IP.

Do you think that i should include a port election and not attach the game only to one port?


pic:


Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #68 on: 21:03, 21 March 18 »
Do you think that i should include a port election and not attach the game only to one port?
Yes, that would be a good choice.
Play as server/host, enter port (default to something, so you can just press enter).
Cool loading screen !

Offline remax

  • 6128 Plus
  • ******
  • Posts: 1.137
  • Country: fr
  • Liked: 422
  • Likes Given: 471
Re: CPChessNet [developing]
« Reply #69 on: 14:10, 22 March 18 »
Nice Game Gear screen simulation  :-X

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #70 on: 14:45, 22 March 18 »
Nice Game Gear screen simulation  :-X

game gear?

Offline remax

  • 6128 Plus
  • ******
  • Posts: 1.137
  • Country: fr
  • Liked: 422
  • Likes Given: 471
Re: CPChessNet [developing]
« Reply #71 on: 17:33, 22 March 18 »
game gear?


Having both at home (multiple copies) i can tell you that your last screenshot has far more in common with the screen of a Game Gear than with the screen of a CPC  :D .


To compare, just take a look at the photograph you took a few posts before !


Anyway, i long for playing this game ;)

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #72 on: 20:00, 22 March 18 »

Having both at home (multiple copies) i can tell you that your last screenshot has far more in common with the screen of a Game Gear than with the screen of a CPC  :D .


To compare, just take a look at the photograph you took a few posts before !


Anyway, i long for playing this game ;)


yes, it's the winape screenshot option, nothing like the real hardware

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 806
  • Country: es
  • Liked: 675
  • Likes Given: 488
Re: CPChessNet [developing]
« Reply #73 on: 21:03, 22 March 18 »
Hi

time has come!

Added the port option!

the default port is 6128  ;D

it was complicated for me to add a dec to hex port! i do in the nasty way, if you put 64321 i multiply 6x10000, 4x1000, 3x100,2x10,1x1, add all the result to a variable, then load the variable on a 16bit register (hl) and i do. ld de,#0000 , inc de, dec hl cp #0000, if not repeat bucle. at the end of the bucle, de has the hex por number  :laugh:

You can see the slowness of the routine if you put a high port, for example 60000, it take a while to go to the next screen!

oh, and is not the first time that i'm doing another things and found a bug on things that i thinked that it worked!!

this means that CPChessNET 1.0b has the 100% of possibilites to have bugs... take this on mind .

Here it is!

CPChessNET 1.0b for you.

REMEMBER to open the port 6128 (or whatever you choose) on the server router!!

I think that while CPChessNET is not free of bugs, better not upload it on your webpages or repositories!
« Last Edit: 21:07, 22 March 18 by Joseman »

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
  • Liked: 1473
  • Likes Given: 1206
Re: CPChessNet [developing]
« Reply #74 on: 21:35, 22 March 18 »
Cool, congrats on the release.  Look forward to try it.

Now someone pm with their IP if they want to play a game over the inet :)