Track n field algorithms?

virtvic

The Cabaret King
Feedback
21 (96%)
Credits
1,983CR
I have just been speaking to Jon Stoodley about Track & Fiekd for the podcast.

We were interested in how the game code calculates scores on how far/fast etc you do the different events and also on the long jump how you do worse after not qualifying on the first 2 attempts. We reckon it's just because the game is mean
smiley36.gif


I'm sure Jon will jump in if I have the question exact or not - but we think it would be good to find out how the game works a bit...

Any of you lovely boffins up for the task?

Haven't heard from cmonkey for a bit, or maybe Mr Banana could have a look?
 

big10p

Coins detected in pocket!
vacBacker
Feedback
12 (100%)
Credits
5,687CR
If you've ever done any game coding (?), you'll appreciate how easy it is to build in subtle cheats to make it look like everything's above board, when it's not.
smiley17.gif
Mario Kart, anyone?
smiley36.gif
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
I may well decide to look into this Victor, not promising anything but it is the kind of thing that mildly interests me.

In-game player scores are 3 bytes each starting at $2a80 (i.e. P1 is at $2a80, P2 at $2a83, etc). Scores awarded for a successfully completed event are calculated and stored from $2b60 and there's a 20 byte lookup table in rom at $dc70 which is used in that calculation based on time/distance/etc achieved in that event. That's what I've deduced from having a quick 5 minute look into the code.

You should try to have a quick look at 6809 one day Eric, it's a nice arch to work with. I know that time (or rather lack of) is your enemy though.
 

virtvic

The Cabaret King
Feedback
21 (96%)
Credits
1,983CR
I have (just today) spoken to Jon about T & F for the podcast and it was an interesting conversation, as it always is with Jon. He goes into some quite technical areas about T & F.

This will be on aired on the next podcast.
 

tronads

Active member
Feedback
5 (100%)
Credits
448CR
I wasnt aware that the 3rd attempt on long jump was less rewarding.....I guess its like the 1st attempt on the javelin then.
It would be interesting to find out what the theoretical distances achievable are, for example by artificially filling the speed bar on the long jump and jumping 42 degrees precisely on the line, and "running" the jump out at the same full speed.....or similar on the javelin but of course at 43 degrees.
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
I've now identified the 6 routines (1 per event) which calculate the player's score upon successful completion of the respective event. I'm currently analysing the 100m scoring routine, it's not overly complex. The score multiplier is based on the number of seconds BELOW the qualifying time (which itself varies, based on dip settings) that the player finishes the race in, you get a slightly better multiplier if you finish in a time of less than 11.00 seconds. There's no extra bonus for winning the race, you get the same score whether you finish 1st or 2nd.

Should have a full understanding of the 100m routine by tonight or tomorrow. After that you'll know what your score for the 100m race will be BEFORE the game updates it on screen (assuming you can do on-the-fly calculations quickly in your head!)

The long jump score calculating routine is very short, only 19 instructions (39 bytes) and there's certainly nothing within that routine that indicates you get punished, score-wise, for fouling on the first two attempts.
 

bomjac

Active member
Feedback
3 (100%)
Credits
453CR
T & F rewards you also for consistency. For example, 99.99m (or maybe 99.95m - I forget exactly) is I think possible, but only if you get the magical 45 degrees down the line 3 times on the bounce. If you get it only 1 time I think it awards 98.50m.

It is possible that the long jump and the javelin do something similar, but these instances seemed to affect the "bonus" distance etc rather than the scoring.

For example, BITD I can remember seemingly un-inspiring angles and speeds giving 100m+ throws on the javelin and hence no qualifying throw. Also that the magical 42 degrees dead on the line long jump always seemed to give 9.72m no matter the speed (it gave a speed boost iirc)
bomjac2016-07-18 11:24:55
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
[font="Courier New, Courier, mono"]; long jump score calculating routine [/font]

[font="Courier New, Courier, mono"]; score is calculated as follows :-[/font]

[font="Courier New, Courier, mono"]; for distances of 3.00m or above : ((whole metres jumped - 3) * 2000) + (centimetres * 20)[/font]

[font="Courier New, Courier, mono"]; no score for distances < 3.00m[/font]

[font="Courier New, Courier, mono"]; ENTRY: Y is pointing to the longest distance jumped (out of three) by the currently active player (4 bytes from $2b61)[/font]

[font="Courier New, Courier, mono"]; EXIT: the calculated score is stored from $2b74 (3 bytes)[/font]

[font="Courier New, Courier, mono"]
[/font]
[font="Courier New, Courier, mono"]D32E: A6 2C LDA,Y ; get tens of metres[/font]

[font="Courier New, Courier, mono"]D330: C6 28 LDB #$0A ; B = 10[/font]

[font="Courier New, Courier, mono"]D332: 3D MUL ; multiply tens of metres by 10, store result in B[/font]

[font="Courier New, Courier, mono"]D333: EB 03 ADDB $1,Y ; add metres to B[/font]

[font="Courier New, Courier, mono"]D335: C0 81 SUBB #$03 ; subtract 3 from B[/font]

[font="Courier New, Courier, mono"]D337: 25 33 BCS $D354 ; branch if less than 3 metres (no score for a jump of less than 3 metres)[/font]

[font="Courier New, Courier, mono"]D339: D7 DA STB $52 ; store result at $2852 (used as loop counter for routine @ $d514)[/font]

[font="Courier New, Courier, mono"]D33B: 27 2E BEQ $D343 ; branch if jump is > 3.00m and < 4.00m (no multiplier for the metres in this case)[/font]

[font="Courier New, Courier, mono"]D33D: CE 54 F6 LDU #$DC7E ; point U at the score lookup table (2000 points)[/font]

[font="Courier New, Courier, mono"]D340: BD F7 96 JSR $D514 ; calculate score for whole metres over 3, store at $2b74[/font]

[font="Courier New, Courier, mono"]D343: A6 00 LDA $2,Y ; get tens of centimetres[/font]

[font="Courier New, Courier, mono"]D345: C6 88 LDB #$0A ; B = 10[/font]

[font="Courier New, Courier, mono"]D347: 3D MUL ; multiply tens of centimetres by 10, store result in B[/font]

[font="Courier New, Courier, mono"]D348: EB 0B ADDB $3,Y ; add centimetres to B[/font]

[font="Courier New, Courier, mono"]D34A: D7 DA STB $52 ; store result at $2852 (loop counter for $d514)[/font]

[font="Courier New, Courier, mono"]D34C: 27 2E BEQ $D354 ; branch if centimetres are zero[/font]

[font="Courier New, Courier, mono"]D34E: CE 54 50 LDU #$DC72 ; point U at the score lookup table (20 points)[/font]

[font="Courier New, Courier, mono"]D351: BD 57 96 JSR $D514 ; calculate score for centimetres (as long as they are over zero), store at $2b76[/font]

[font="Courier New, Courier, mono"]D354: 39 RTS[/font]

[font="Courier New, Courier, mono"]
[/font]

[font="Courier New, Courier, mono"]; routine at $d514 calls a further routine at $d56f which does all the multiplying and decimally adjusts the result[/font]
 

virtvic

The Cabaret King
Feedback
21 (96%)
Credits
1,983CR
Even though I don't understand much of it, it's fascinating stuff! Hopefully it might help Jon with his world record campaign - but I think it's going to be his machine gun fingers that do that!
smiley36.gif
 

joe34

Active member
Credits
448CR
hey if a free book is useful to anyone, pm me your address
smiley2.gif


-- gone to hurray banana
smiley20.gif
--

1eeee.jpg


2eeee.jpg


joe342016-07-19 15:50:28
 

Battlezone

Active member
Feedback
1 (100%)
Credits
410CR
Good work cmonkey!

One thought I had while disassembling the 6809 for track and
field was that the "Konami custom cpu" looks very fixable with
a small daughter board should one ever break.
Has anyone done this in the past?
 

philmurr

Active member
vacBacker
Feedback
46 (100%)
Credits
2,350CR
Excellent work with that disassembly Adrian. Wish I could work things out that quickly.

And the 6809 book is very good, just been studying the same author's 8080/8085 book and his writing style makes things very clear.
 
Top