2024-12-02 09:33 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0006621WHDLoad[All Projects] Generalpublic2024-11-14 09:19
ReporterJOTD 
Assigned ToWeplProject InfoHD-Installer for OS-Killer
http://whdload.de/
 
PrioritynormalSeverityblockReproducibilityrandom
StatusresolvedResolutionfixed 
Product Version19.0 
Target Version19.1Fixed in Version19.0beta 
Summary0006621: ReadJoyPort parasite outputs
DescriptionI think the underlying readjoypad routine implemented in whdload has issues.

I've adapted a lot of games to call this implementation and some games have parasite second button reads when using just first button.
>
I've adapted JST adding the resload_ReadJoyPort routine, but using the old
implementation, no timing cache or other complex stuff, and it works properly,
meaning the changes I have done are okay interface-wise.

 The game I'm talking about is Jim Power, unreleased in v19 form but ready.
 Test it with whdload v19 and "2nd button for jump" you'll notice that the
 character jumps from time to time because you're just shooting.

 Use latest JST on the same slave and it doesn't occur, not once.

Someone reported the same thing on the new Turrican 2 slave
Steps To Reproducerun Jim Power slave or Turrican with joypad mode (2nd button jumps)

Firing sometimes triggers jumps or other extre buttons
TagsNo tags attached.
MachineA1200
CPU68060
CPUSpeed50
ChipSetAGA
GFXCardNone
ChipMem2 MB
FastMem0 MB
WorkbenchOS 3.0
KickROM40 - Kick 3.1
KickSoftNone
WHDLoad19.0
Attached Files

-Relationships
+Relationships

-Notes

note ~0014170

DJ Mike (developer)

Last edited: 2024-10-26 01:28

View 2 revisions

Observation from watching joypad reads in Turrican II (WinUAE only at this stage) - all held button bits are shifting up by 1 in some reads - not just spurious red button presses.

i.e. sometimes Red (bit 22) becomes Blue (bit 23), but likewise yellow (21) will become red, green (20) will become yellow, etc.

Blue will alternate between bit 23 and not triggering at all - if you hold down blue to jump in game your character will keep half jumping because the button appears held then not held. :-)

To me it looks like the first potinp test is happening slightly late sometimes, i.e. actual first button (Blue) isn't read in time, so all remaining buttons are treated as Blue onwards when it is supposed to be Red.

I notice that in ReadJoypad.s, the first potinp test is after 6x tst.b $bfe001 instructions (for waiting), but all subsequent potinp tests have 8x tst.b gap. This approach was not taken in resload_ReadJoyPort (all reads have 8x tst.b wait, including first).

note ~0014171

DJ Mike (developer)

Last edited: 2024-10-26 10:43

View 2 revisions

Confirmed - shortening the first CIA 8x tst wait to 6x was enough to fix the problem in my testing. I also moved the bset/bclr ciapra calls for the trigger pulse to be adjacent.

All other RJP code left alone. I don't think the caching/TOD timing is an issue here.

note ~0014172

Wepl (manager)

Last edited: 2024-10-26 12:33

View 3 revisions

Great investigation!
Yes, I tried to simplfy to code here. Didn't expect that timing is so sensitive at this place.
Can you provide PR/branch?

note ~0014173

DJ Mike (developer)

I will put together a branch.

One thing I'm not sure about - is the final pulse after all buttons have been read necessary? In original ReadJoyPad.s, additional pulses happen at the end of the loop just before dbf, meaning after the last button has been read there is one final pulse (but no potinp read). In WHDLoad RJP I see that there bclr has been moved to the top of the loop but not the bset.

I wonder if instead both bset/bclr could be at the top so we don't do unnecessary work. However that is a change in behaviour so I'm uncertain. Perhaps it is safest to do what ReadJoyPad was already doing.

note ~0014174

DJ Mike (developer)

Doing some more precise testing on this, it seems the change that matters the most is the order of the initial pulse + potgo set. The following is the order in ReadJoyPad.s:

bset d3,ciaddra(a1) ;set bit to out at ciapra
bclr d3,ciapra(a1) ;clr bit to in at ciapra
move.w d5,potgo(a0)

WHDL version has ciapra + potgo the other way around (with some instructions in between):

bset #CIAB_GAMEPORT1,(ciaddra,a1) ;output mode (trigger pulse)
move #$6f00,(_custom+potgo) ;input mode (data)
moveq #RJPB_BLUE,d2 ;first button to read
moveq #7-1,d3 ;amount of bits/buttons to check
bclr #CIAB_GAMEPORT1,(ciapra,a1) ;trigger pulse low

This order matters! Changing potgo write to be immediately after bclr in the above instructions is enough to fix the problem - not even reducing the number of tst.b instructions makes a difference to my tests.

However I think because we know ReadJoyPad.s works, I will still reduce the initial tst.b instructions as well.

I have pushed a branch with proposed changes.

note ~0014202

Wepl (manager)

I have merged your fixes, thanks!
New beta https://whdload.de/whdload/whd191.lha should fix the problems.

note ~0014203

DJ Mike (developer)

Thanks Bert! :-)
+Notes

-Issue History
Date Modified Username Field Change
2024-10-24 22:21 JOTD New Issue
2024-10-24 22:21 JOTD File Added: JimPower_v19_slave.zip
2024-10-24 22:22 JOTD Assigned To => Wepl
2024-10-24 22:22 JOTD Status new => assigned
2024-10-26 01:27 DJ Mike Note Added: 0014170
2024-10-26 01:28 DJ Mike Note Edited: 0014170 View Revisions
2024-10-26 10:41 DJ Mike Note Added: 0014171
2024-10-26 10:43 DJ Mike Note Edited: 0014171 View Revisions
2024-10-26 12:32 Wepl Note Added: 0014172
2024-10-26 12:33 Wepl Note Edited: 0014172 View Revisions
2024-10-26 12:33 Wepl Note Edited: 0014172 View Revisions
2024-10-26 13:29 DJ Mike Note Added: 0014173
2024-10-26 15:27 DJ Mike Note Added: 0014174
2024-11-13 22:42 Wepl Note Added: 0014202
2024-11-13 22:42 Wepl Status assigned => resolved
2024-11-13 22:42 Wepl Resolution open => fixed
2024-11-13 22:44 Wepl Fixed in Version => 19.0beta
2024-11-13 22:44 Wepl Description Updated View Revisions
2024-11-13 22:45 Wepl Target Version 19.0 => 19.1
2024-11-14 09:19 DJ Mike Note Added: 0014203
+Issue History