implementing new function plz help

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

neviksti
Lurker
Posts: 122
Joined: Thu Jul 29, 2004 6:15 am

Post by neviksti »

Dolphin wrote:A few questions, what do you mean by "snes port", and "snes program".

I just took some wires and connected my joystick to where the printer usually goes(Parallel port).

If you want to, you may see my source code, many of your questions may be answered there. PM me and I'll send my source code.
snes port - One of the two ports on the front of the SNES console that you can plug a joypad, mouse, multitap, whatever into. It contains seven lines: ground, power, clock, latch, two data lines meant to give data to the SNES, one data line meant to give data to the device on the port (but the device can also send data on it under certain circumstances). In this case, when referring to the snes port, I also mean a connector which a SNES device can be plugged into and the port "emulated" (in this case with the parallel port + some code running on the PC).

snes program - a program that runs on the SNES. In this case, the ROM that is ran on the emulated SNES console + cartridge.

------------------

I need to look at the zsnes asm code closer. I'll comment later when I have time to do this.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

Ah. Well, I was half right.
[u][url=http://bash.org/?577451]#577451[/url][/u]
neviksti
Lurker
Posts: 122
Joined: Thu Jul 29, 2004 6:15 am

Post by neviksti »

Okay, I looked at the code.

If I understand correctly, it looks like you periodically read from the port by doing this:

latch status
clock in 16 bits of data
then interpret this as joypad data an change the zsnes keypress data accordingly

Instead, to provide direct access, you should do something like this:

Code: Select all

if (autojoyread is enabled  and  it is time to read the port)
   read 16bits from the snes ports and store it for zsnes to report to the snes program when it reads ports $4218/$4219/$421a/$421b/$421c/$421d/$421e/$421f

if (program writes to $4016  ... or $4017 I think)
   change latch line on ports accordingly

if (program reads $4016)
  toggle the clock on the first snes port and read the data
  take the data from the two data lines on the first snes port and return them in bits 0,1

if (program reads $4017)
   same thing as above ... but for the second snes port
Now you can connect any SNES accessory to your emulated SNES port. And the SNES program can use the manual read method correctly now.

I realize this is easier said than done.
Your code looks good; I just wouldn't call it "direct access".
Post Reply