Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bank switched reset
03-07-2012, 11:34 AM
Post: #1
Bank switched reset
Inserting some code into a bank-switched section caused a reset, both in pinmame and in the actual machine. Looking at some old code involving Dracula which was intended to eliminate the tilt warning kills bonus scoring bug. (Which is present in Dr Who as well)

The author of the code indicated that it resets the game in testing. This has been my experience as well with a mod in Dracula inside the switched bank that added to the clock cycle of a routine. Am I right in thinking it's a timing thing or completely off base?

This old tournament code also attempted to quash the random awards and just award 5 million each time.
Find all posts by this user
Quote this message in a reply
03-07-2012, 10:02 PM
Post: #2
RE: Bank switched reset
It's probably just a problem with the code. The code shouldn't be that delicate that few extra instructions would cause any sort of timing related problem while running code in a bank. Whenever I've had crashes it was just something dumb like jumping to a wrong address.
Find all posts by this user
Quote this message in a reply
03-08-2012, 05:46 AM
Post: #3
RE: Bank switched reset
(03-07-2012 10:02 PM)mrglee Wrote:  It's probably just a problem with the code. The code shouldn't be that delicate that few extra instructions would cause any sort of timing related problem while running code in a bank. Whenever I've had crashes it was just something dumb like jumping to a wrong address.

Code has a delay loop built into it (although it's using the machine's delay function, not a local one).
Find all posts by this user
Quote this message in a reply
03-08-2012, 05:59 PM
Post: #4
RE: Bank switched reset
Is it jumping to a "sleep" sort of function? If so, does it take a 1-byte or 2-byte parameter bytes following the JSR? If you're inserting a JSR to a delay function then I assume you had to relocate some code? I can't help much without details about what code changes you're making.
Find all posts by this user
Quote this message in a reply
03-08-2012, 06:45 PM
Post: #5
RE: Bank switched reset
; This hook is used prior to calling the bonus effect handler
; to ensure that no high priority effects like Tilt Warning
; are still active. Once high priority effect finish to
; completion, bonus can continue.
;
; This function needs to be placed in blank space at 0xC7F85.

#define DR_TILT_WARNING 0x0D
#define TIME_66MS 4

#define old_bonus_handler 0x7464
#define task_sleep 0x8383
#define dr_get_active 0xCADD
#define audit_inc 0x8912

.area .text (ABS)
.org 0x7F85
new_bonus_handler::
jsr task_sleep
.db TIME_66MS
jsr dr_get_active
cmpa #DR_TILT_WARNING
bhs new_bonus_handler
jmp old_bonus_handler

Above is some code from an attempt at fixing the tilt/bonus bug someone emailed me. In a machine it resets; in pinmame it does not.
Find all posts by this user
Quote this message in a reply
03-08-2012, 08:26 PM
Post: #6
RE: Bank switched reset
Some of that makes sense to me, it is saying to create a new function like this:
BD 83 83 ; JSR to $8383 which I verified is the sleep function
04 ; Sleep time byte
BD CA DD ; JSR to function to fetch "active" which appears to be correct.
81 0D ; CMPA with 0x0D, the ID for tilt warning
2C F5 ; BGE, branch back up to sleep if greater or equal
7E xx xx ; Jump to original bonus handler code.

The above code needs to be placed in same bank as the bonus handler, in unused space. I'm not sure where the original bonus handler is. Your message says 0x7464 but I'm not getting a breakpoint on that address (in any bank) when bonus is awarded. Then there must be a callback table (ie in the sttng video mode thread) that contains a pointer to the old bonus handler which you need to fix up to point to the new code you're adding. I'll play around and update this post if I can find the original bonus handler address.

Might want to preserve the A register, it may be perfectly safe without, but just in case, the following might be a more safer approach since A register will be unchanged when the bonus handler code gets entered:
34 02 ; PUSH A
BD 83 83 ; JSR to $8383 which I verified is the sleep function
04 ; Sleep time byte
BD CA DD ; JSR to function to fetch "active" which appears to be correct.
81 0D ; CMPA with 0x0D, the ID for tilt warning
2C F5 ; BGE, branch back up to sleep if greater or equal (assuming this is only true during tilt warning)
35 02 ; POP A
7E xx xx ; Jump to original bonus handler code in this same 4k bank.
Find all posts by this user
Quote this message in a reply
03-08-2012, 11:19 PM
Post: #7
RE: Bank switched reset
I don't think the problem is going to be fixed with a simple delay. There might be some other condition that has to happen besides just waiting for the tilt warning to finish prior to processing the bonus.

I did a few experiments but wasn't able to fix the problem. First I tried the fix like you described by inserting the hook into bank 0x36, where I think the bonus handler occurs at $44B1,36. No luck.

Next I backed up to the actual outhole switch handler. I found this is in bank 0x37. The actual jump point to handle the outhole switch is at $4F9A,37. At $4F9A,37 is a JSR $5093. I replaced that with a JMP $7F21 (first byte of unused data in the bank) and then at $7F21,37 I added the following:

7F21: 34 02 PUSH A
7F23: 20 04 BRA $7F25 Jump over the delay first time
7F25: BD 83 83 JSR $8383 Sleep function
7F28: 04 Sleep time byte
7F29: BD CA DD JSR $CADD Fetch "active" code
7F2C: 81 0D CMPA #$0D compare A with 0x0D, the ID for tilt warning
7F2E: 27 F5 BEQ $7F25 BEQ, branch back up to sleep if greater or equal (assuming this is only true during tilt warning)
7F30: 35 02 POP A
7F32: BD 50 93 JSR $5093 call function the outhole handler originally called instead of jumping here
7F35: 7E 4F 9D JMP $4F9A Jump to original outhole handler code in this same 4k bank.

I had even experimented with variations of the above including:
a. instead of calling sleep(), I called sleepLong ($86B6 w/2 byte sleep time) with a very long sleep time, but no luck.
b. instead of looping after the sleep, I just did a JMP $990E which is the "done with callback function" but no luck.
c. instead of looping when A is >= 0x0D, I tried only when A==0x0D, no luck.
d. I noticed normal game mode state is 0x03 so after the call to $CADD I had it compare A to 0x03 and branch if not equal, no luck.

There must be some other problem that's causing bonus not to get collected. Need to trace through the bonus acquisition code and see if we can figure out why it sometimes just skips it. Maybe there's some counter that's getting set which makes the game mistakenly think it was a full TILT and not just a tilt warning.

Note with the above code you can set a breakpoint at the sleep call and you know you hit the problem (since it only does the sleep if the current mode is 0x0D, tilt warning). I was able to hit the breakpoint in pinmame by hitting the tilt warning DEL,Q+F and immediately draining the ball DEL,Q.
Find all posts by this user
Quote this message in a reply
03-09-2012, 06:08 AM
Post: #8
RE: Bank switched reset
Thanks for the confirmation on some of the info I received; I know that Pfutz liked to ignore some of the recommended system ways when he was programming and it wouldn't surprise me if he's ignoring the way scores get added and is using some kind of roll-his-own instead. It seems odd that the only 2 WPC games that have this bug are the 2 he programmed.
Find all posts by this user
Quote this message in a reply
03-09-2012, 09:27 PM
Post: #9
RE: Bank switched reset
Did more investigating on this one. I found the bonus handler is at $7464,31 (which I now see is consistent with your original fix). Inserting the fix prior to the $7464,31 call seems to solve the problem but I didn't test it exhaustively.

First I changed the data that points to $7464,31 so it, instead, points to the first byte of unused bytes in bank 31, $7395,31.
ROM Offset 0x7780E WAS 746431, NOW 7E9531.

Next at $7E95,31, ROM offset 0x47E95 I added the following 20 bytes. and that seems to do the trick (not including checksum fixup):

7E95: 34 02 PUSH A
7E97: 20 04 BRA $7F25 Jump over the delay first time
7E99: BD 83 83 JSR $8383 Sleep function
7E9C: 04 Sleep time byte
7E9D: BD CA DD JSR $CADD Fetch "active" code
7EA0: 81 0D CMPA #$0D compare A with 0x0D, the ID for tilt warning
7EA2: 27 F5 BEQ $7F25 BEQ, branch back up to sleep if 0x0d (tilt warning)
7EA4: 35 02 POP A
7EA6: 7E 74 64 JMP $4F9A Jump to normal bonus code in this same 4k bank.


So now that I look at your original fix, the only missing info was the fact that the original bonus handler resided in bank 0x31, or maybe it's in there but I missed it. If I had that info yesterday it would have saved me a bit of time, but it was fun exploring the drac_l1 rom nonetheless. Let me know if I can help fix the other game that you said has this same problem.
Find all posts by this user
Quote this message in a reply
03-10-2012, 06:35 AM
Post: #10
RE: Bank switched reset
Thanks, added into the rom, will send to the real machine to test.

The other game is Doctor Who - I'd be looking at both the L1 and L2 roms, the L1 rom is preferred for me but I know the others looking for the fix will probably be using L2. Same situation, tilt warning during bonus handling kills scoring the bonus (which can be quite large in this game on the last ball since you get all doctors bonus' as well.)

This actually brings me to something that I feel IS a bug in Doctor Who - whatever playfield multiplier is active at game over (at least on L1) also multiplies the doctor bonus. i.e. if you had 3x playfield scoring active, on last ball drain you get 3 million per doctor instead of 1 million. Minor, to be sure, and it's behavior that everyone familiar with the game knows about, and it's not something you'd take advantage of on purpose (ie. get the pf multiplier to 4x then drain on purpose.....)
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)