How to emulate PSG and SCC in Windows applications.

Pagina 5/6
1 | 2 | 3 | 4 | | 6

Van mth

Champion (507)

afbeelding van mth

25-06-2011, 13:59

You can write to registers using the debug command, which you can send over the control connection using the <command> tag.

However, I would not recommend that approach, since the timing would be inaccurate: since openMSX is a separate process, it would receive the command whenever the OS hands control to it. Then it will change the chip register at whatever emulated time the Z80 is currently at, which is only synchronized to the real time once per frame.

Instead, you could upload your MSX replayer and song data to openMSX and make the emulated machine run that. It will give you more accurate timing, both because the communication is done before playing and because the actual replayer will be used.

Van Huey

Prophet (2694)

afbeelding van Huey

25-06-2011, 14:25

@mth: Thanks!

First of all. Sorry for my n00bness.

Ok. I have done some more reading.

- I can set up a connection with OpenMSX using a TCP connection (local IP, random port in a range).
- I can just try ports in the range to find a port (as the file containing the port can be in many many places Crying )
- To start playback I just upload the (preprocessed data) to RAM on the MSX. (debug write_block {Main RAM} <offset from 0xc000> <values> )
- Give the simple replayer the command to process the data.

- I'll try to sync the tracker and openMSX by using a timer in the tracker and by polling the replayer stats (line/pattern) using the socket. The display of the data played is very important.

Van Huey

Prophet (2694)

afbeelding van Huey

25-06-2011, 16:12

I am trying to set up the connection, using blitzplus basic, and reset openMSX:

tcp = OpenTCPStream ("localhost",9954)  <- I did a lookup in the socket.xxx file

;-- this code loops infinite

If tcp
   WriteLine tcp,"<openmsx-control>"	
   WriteLine tcp,"<command>reset</command>"	
   WriteLine tcp,"</openmsx-control>"
endif

Sadly nothing happens. Am I missing something trivial?

Van Manuel

Ascended (19270)

afbeelding van Manuel

25-06-2011, 17:17

The port is different each run, so you can't hardcode it. Just read the file to get the port. Adding some debug prints to see whether you got the connection would be useful Smile

Van Huey

Prophet (2694)

afbeelding van Huey

25-06-2011, 22:16

The port is different each run, so you can't hardcode it. Just read the file to get the port. Adding some debug prints to see whether you got the connection would be useful Smile

Smile I check the port every time I start openMSX. I do get a handle after about 15 seconds (tcp != 0).
But I cannot read/write anything.

I try to write what I posted earlier. But nothing happens. Also reading the handle results in nothing.

I have no debugging information as I have nothing as a result. Cn;t see what I could debug.
Anyway thanks for the help and tips but perhaps this is not the way to go.CryingCryingCryingCrying

I use this command to make the connection:

OpenTCPStream (ip$,port)
Definition
Opens a client TCP stream to the specified server.  

Parameters
ip$=Address of stream 
port=TCP/IP Port Number  

Description
Use this command to open up a TCP/IP stream to the designated server and port. If the open command was successful, the command returns a stream handle.
Otherwise it returns 0. 

You can use this for a multitude of different 'internet' options. Obviously to contact a TCP/IP host outside your own network,
you'll need to be connected to the Internet. 

The IP address can be in the form of 1.2.3.4 or "www.domain.com".  

Van Manuel

Ascended (19270)

afbeelding van Manuel

25-06-2011, 23:12

Well, maybe it's Blitzbasic? As I said, it works fine from C++ code for instance... Maybe there's buffering going on? Do you need to flush something with that connection in Blitz?

Van Huey

Prophet (2694)

afbeelding van Huey

25-06-2011, 23:35

No need to flush. Just need to set up a connection (url+port) and then it returns a handle (0 if not successful) .
Then you can write or read the handle as if it was a file.

I guess it's unsolvable by me.... back to an MSX tracker...

Van mth

Champion (507)

afbeelding van mth

26-06-2011, 02:10

What happens if you use telnet to connect to the control port and send those same commands?

Van Huey

Prophet (2694)

afbeelding van Huey

26-06-2011, 11:01

What happens if you use telnet to connect to the control port and send those same commands?

telnet 127.0.0.1 9966

The console halts at the message:

Connecting To 127.0.0.1...

It stays like that (more than 5 minutes) until I close openMSX. Then it says that the connection is lost.

netstat says:

  TCP    ltcornelisser:9950     localhost:kpop         ESTABLISHED

telnet to my computername:

C:\telnet ltcornelisser 9966
Connecting To ltcornelisser...Could not open connection to the host, on port 9966: Connect failed

Perhaps it is a firewall issue?

Van Huey

Prophet (2694)

afbeelding van Huey

26-06-2011, 12:21

Anyway. Forget it. Thanks for all the help. This is just not meant for me Wink

This is taking too much time. I just waisted 2 days trying without any result (yeah I'm a little frustrated).
It's just not that trivial for me. I was hoping to be able to have something that could be re-used (not reinventing the wheel). But it is just too much effort to make myself comfortable with the material. I was planning to make a quick tool that we could use to create our music. The editor tool is no problem at all. The sound emulation is just out of my league (and interest).
Smile2

Pagina 5/6
1 | 2 | 3 | 4 | | 6