Repton 3: Emulator/RNG issue

reminisce about classic bbc micro and acorn electron games here
Related forum: adventures


User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Sun Apr 05, 2020 12:55 pm

Yeah, I realised yesterday that -- because I'm a dummy -- I'd been comparing a disc version (Bill Carr v1) to a tape version (bbcmicro.co.uk), which certainly explains some of the wilder differences I found. ("Why is this OSFILE stuff so starkly different? Ohhhh ...") Provided the level editor is intact, an easy way to tell tape/disc versions apart is just to load up the editor and look at the save/load icons ...

So I started again with Bill's full-price v1 and v2 versions. I haven't finished, but the striking change is a switch from running a timer using an OS hook (IRQ2V) to instead programming the User VIA directly and then using a raw interrupt handler to service it. Not sure why this change was made, but it's interesting.

Michael Brown
Posts: 2330
Joined: Sat Apr 03, 2010 1:54 pm
Location: Nottingham
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Michael Brown » Sun Apr 05, 2020 1:13 pm

Here is D045 with the amended REPTON2 file that now matches the code of the other 3 Repton 3 games.
Could someone please play test this game and see if it works Ok.
The fungus test seems Ok, but you never know if by changing the code, something else happens?

regards,
Mick.
Disc045.zip
(195.83 KiB) Downloaded 20 times

User avatar
billcarr2005
Posts: 1605
Joined: Fri Sep 09, 2005 4:01 pm
Location: UK
Contact:

Re: Repton 3: Emulator/RNG issue

Post by billcarr2005 » Sun Apr 05, 2020 2:16 pm

Michael Brown wrote:
Sun Apr 05, 2020 1:13 pm
Here is D045 with the amended REPTON2 file that now matches the code of the other 3 Repton 3 games.
Could someone please play test this game and see if it works Ok.
The fungus test seems Ok, but you never know if by changing the code, something else happens?
Apart from the fact there is a documented change between Repton 3 and the expansion packs regarding spirits, ergo not ALL of the code will match?
If the code from the disc version of Repton 3 is used, then it would be logical that the game will play exactly as Repton 3 was expected to play? :?

Triax
Posts: 66
Joined: Fri Aug 25, 2006 4:21 am
Location: Wiltshire, England
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Triax » Mon Apr 06, 2020 5:43 am

Have you tried using the cassette version? I found that, for example, on one of the ‘Now’ screens of Repton Thru Time, it was only possible to reach the time bomb in time on the cassette version... so in my Repton YouTube videos, that’s the version I always used..?

Michael Brown
Posts: 2330
Joined: Sat Apr 03, 2010 1:54 pm
Location: Nottingham
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Michael Brown » Mon Apr 06, 2020 10:25 am

Hi All,
I may have jumped the gun quite a bit changing RTT as my original copy on D045 may have been OK to start with.
Sure I could not load the FUNGTST file to test it and yes the code is different, but I assumed it was original and had the bug, when now I read RTT was released last, so surely must have been fixed.
Checking the code, although in different places, the &85 and &86 routines seem to match all the other Repton 3 games.

Now, if you take the FUNGTST file and rename it FUTURE then it loads into RTT and yes the test screen appears and no fungus spreads.
I now believe the copy I have was fixed all along.

Just to be 100% certain, could I ask Bill C if he could please post his original copy of RTT here so I can check the code against mine, unless he has the time to do it.

regards,
Mick.
Disc045.zip
(195.89 KiB) Downloaded 22 times
Edit. I meant Repton Thru Time and not Life of Repton, sorry, I have amended this post.
Last edited by Michael Brown on Mon Apr 06, 2020 1:11 pm, edited 1 time in total.

User avatar
leenew
Posts: 4239
Joined: Wed Jul 04, 2012 4:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: Repton 3: Emulator/RNG issue

Post by leenew » Mon Apr 06, 2020 10:42 am

Hi,
l would say we should go back to basics and create new versions from BillC's originals....

OK,
Having dug through some magazine reviews of these games, the release timeline was as follows:

Repton 3: December 1986.
Reviewed in Micro User Dec '86, Computer Gamer Dec '86, and A&B Computing Jan '87

Around the world in 40 screens: August 1987.
Reviewed in A&B Computing Sept '87, and Micro User 'Aug '87

Life of Repton: January 1988.
Reviewed in A&B Computing Jan '88, Acorn User Feb '88, and Micro User Feb '88

Play it again Sam 2, June 1988.
Reviewed in Micro User June '88.

Repton Thru Time: August 1988.
Reviewed in Electron User August '88, A&B Computing Sept. '88, Acorn User, Sept. 88 and Micro User Sept. '88.

The latest releases were:
Play it again Sam 08 in xx 1989 which contained Around the World in 40 screens...
Play it again Sam 09 in July 1989 which contained The life of Repton.
Play it again Sam 10 in August 1989 which contained Repton thru time.

I hope this helps.

Lee.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Mon Apr 06, 2020 12:07 pm

So, it seems there has been some confusion, most of which is probably my fault.

The only version that we have found so far with the bug is the very first Repton 3 stand-alone full-price disc release (which we've been calling "v1"). This seems to be the version that's on Stairway to Hell (or at least a de-protected hack of it).

Every other disc version we've seen, including the second Repton 3 stand-alone full-price disc release we've been calling "v2" (the one that Bill described as having a black write-protect sticker rather than a golden one) was fixed. This includes every expansion pack. It also includes the version on bbcmicro.co.uk (which is a tape version, anyway).

I am pretty sure that all of Mick's versions were actually 100% bug-free in the first place, before I started muddying the waters and confusing everybody.

We know basically nothing about tape versions yet, apart from the fact that at least one good tape version was released at some point.
Last edited by Diminished on Mon Apr 06, 2020 12:14 pm, edited 1 time in total.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Mon Apr 06, 2020 12:12 pm

leenew wrote:
Mon Apr 06, 2020 10:42 am
Hi,
l would say we should go back to basics and create new versions from BillC's originals....

OK,
Having dug through some magazine reviews of these games, the release timeline was as follows:

Repton 3: December 1986.
Reviewed in Micro User Dec '86, Computer Gamer Dec '86, and A&B Computing Jan '87

Around the world in 40 screens: August 1987.
Reviewed in A&B Computing Sept '87, and Micro User 'Aug '87

Life of Repton: January 1988.
Reviewed in A&B Computing Jan '88, Acorn User Feb '88, and Micro User Feb '88

Play it again Sam 2, June 1988.
Reviewed in Micro User June '88.

Repton Thru Time: August 1988.
Reviewed in Electron User August '88, A&B Computing Sept. '88, Acorn User, Sept. 88 and Micro User Sept. '88.

The latest releases were:
Play it again Sam 08 in xx 1989 which contained Around the World in 40 screens...
Play it again Sam 09 in July 1989 which contained The life of Repton.
Play it again Sam 10 in August 1989 which contained Repton thru time.

I hope this helps.

Lee.
This is great, thank you.

This is interesting because (thanks to the inlay card that Bill found) it means that they were still selling full-price copies of vanilla R3 alongside Around the World and Life Of. Presumably they finally pulled this full-price version sometime in the first half of 1988 before the release of PIAS2.

User avatar
billcarr2005
Posts: 1605
Joined: Fri Sep 09, 2005 4:01 pm
Location: UK
Contact:

Re: Repton 3: Emulator/RNG issue

Post by billcarr2005 » Mon Apr 06, 2020 1:09 pm

Michael Brown wrote:
Mon Apr 06, 2020 10:25 am
Just to be 100% certain, could I ask Bill C if he could please post his original copy of LOR here so I can check the code against mine, unless he has the time to do it.
Find attached the unadulterated 80 track images of Around the World in 40 Screens, Life of Repton and Repton Thru Time :)
Attachments
REPTON 3 EXPANSION PACKS.zip
ATWIFS, LOR, RTT
(168.19 KiB) Downloaded 32 times

Michael Brown
Posts: 2330
Joined: Sat Apr 03, 2010 1:54 pm
Location: Nottingham
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Michael Brown » Tue Apr 07, 2020 8:07 am

Thanks Bill,
The code to Thru Time matches mine so that clears that up.

regards,
Mick.

User avatar
Kecske Bak
Posts: 719
Joined: Wed Jul 13, 2005 8:03 am
Location: Treddle's Wharf, Chigley
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Kecske Bak » Wed Apr 08, 2020 8:32 am

Just checked. There's an easy way of seeing the change in the spirits' behaviour. Load the original version of Repton 3. Then load the "PREHIST" level set from Repton Thru Time. Two spirits at the start of the level will circle for ever as the behaviour of spirits has been changed.

If you load the PREHIST level set into Around the World. Repton Thru Time or Life of Repton, it'll work fine.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Fri Apr 10, 2020 4:09 am

Righto, here are the v1 -> v2 changes. I think this is comprehensive, but hey, I screw up a lot. Obviously there are a ton of other binary differences between the two executables, but to the best of my observation everything not mentioned here is just reassembled addresses.

The addresses at the start of each line are in the form v1/v2.

Some of these changes are trivial byte-savers (removing redundant code, shortening a few sequences). There is the change from using the MOS timer hook to using IRQ2V I mentioned before (anyone have any theories as to why this was done? ROM problems perhaps?) There are also maybe four other changes which look plausibly like bug fixes and might be interesting to investigate a little further.

&0413/&0413: removed NOP
&04A0/&04A1: inserted sub call, JSR &0CB8 (not sure what this does, further research needed)
&0680/&0682: INC &78 / RTS inline code replaced with BEQ &0618 to similar piece of code higher up, saves one byte
&068D/&068E: CMP &10,X replaced with EOR &10,X
&0693/&0694: similarly, CMP &14,X replaced with EOR &14,X
&0707/&0708: removed SEC, presumably redundant, saves one byte
&1E4F/&1E4F: LDX #&D replaced with INX, saves one byte
&1E6D/&1E6C: removed JSR &296F which was the subroutine that set up the MOS timer hook, replaced with inline code that sets up IRQ2V
&1ED2/&1EC3: brand new IRQ2V interrupt handler inserted; 30 bytes
&2DEF/&2DEF: JSR &296F removed here, again
&2EAC/&2EA4: short routine that called OSWORD &4 (write interval timer) replaced with short routine to set up user VIA timer instead (writes to SHEILA)
&2F01/&2F01: LDA &31A0,X / LDA #&C sequence replaced with CPY #&A0 / AND (&A9),Y / ASL A; purpose unknown
^^ took another look at this, and decided it was probably data and not code; certainly "JSR &A25C" just above it makes very little sense
&2FAB/&2FAB: that famous fungal fix: inserted LDA #&FF / STA &86
&59C6/&59C6: LDA #&00 / STA &6F pair inserted; purpose unknown, but interesting
&5A96/&5A9A: ASL A / ASL A / ORA #&1 replaced with ASL A / SEC / ROL A, saving a byte
&5AC6/&5AC9: and again, ASL/ASL/ORA replaced with ASL/SEC/ROL, saving a byte
Last edited by Diminished on Fri Apr 10, 2020 7:48 pm, edited 3 times in total.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Fri Apr 10, 2020 12:56 pm

Just quickly, I took a RAM dump of the PIAS2 version and ran it through my diffing process. The PIAS2 version seems to be identical to v2 (as predicted by Bill's Cheat It Again, Joe research and observation that CIAJ only supported two versions total).

The next targets, then, are the expansion pack versions.

skipchris
Posts: 9
Joined: Mon Mar 30, 2020 9:42 am
Contact:

Re: Repton 3: Emulator/RNG issue

Post by skipchris » Tue Apr 28, 2020 10:43 am

I have been meaning to check back on this thread for a couple of weeks now — can’t believe what I’ve spawned! I, too was a bit troubled by a bug like that lurking 'unnoticed' but just reconciled it as "Repton 3 was pretty hard, and we were less-connected then, so the handful people who did notice it didn’t pass the information on efficiently".

I’ve really enjoyed reading the follow-ons. Amazing archeology, and thanks for being so persistent.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Wed Apr 29, 2020 12:49 am

skipchris wrote:
Tue Apr 28, 2020 10:43 am
I have been meaning to check back on this thread for a couple of weeks now — can’t believe what I’ve spawned! I, too was a bit troubled by a bug like that lurking 'unnoticed' but just reconciled it as "Repton 3 was pretty hard, and we were less-connected then, so the handful people who did notice it didn’t pass the information on efficiently".

I’ve really enjoyed reading the follow-ons. Amazing archeology, and thanks for being so persistent.
You know, we live in a boring age where the globe has been completely explored and there aren't really frontiers left to investigate, and in which the concept of mystery has been almost completely destroyed by instant access to information. But there's a lot of old code out there that still retains its secrets. This kind of research is weirdly compelling; you don't know what buried treasure there might be.

I'd still like to investigate those other v1 -> v2 changes and work out what the v1 bugs were that mandated those fixes. I think these four are the interesting ones:

&04A0/&04A1: inserted sub call, JSR &0CB8 (not sure what this does, further research needed)
&068D/&068E: CMP &10,X replaced with EOR &10,X
&0693/&0694: similarly, CMP &14,X replaced with EOR &14,X
&59C6/&59C6: LDA #&00 / STA &6F pair inserted; purpose unknown, but interesting

joachim
Posts: 181
Joined: Wed Jun 21, 2006 2:20 am
Location: Germany
Contact:

Re: Repton 3: Emulator/RNG issue

Post by joachim » Thu Apr 30, 2020 10:56 am

Diminished wrote:
Fri Apr 10, 2020 4:09 am
&2F01/&2F01: LDA &31A0,X / LDA #&C sequence replaced with CPY #&A0 / AND (&A9),Y / ASL A; purpose unknown
^^ took another look at this, and decided it was probably data and not code; certainly "JSR &A25C" just above it makes very little sense
Looks as if you decompiled with the wrong frame.

JSR &A25C / LDA &31A0,X / LDA #&C
can be read as
EQUW &5C20 / LDX #&BD / LDY #&31 / LDA #&C

JSR &A25C / CPY #&A0 / AND (&A9),Y / ASL A
can be read as
EQUW &5C20 / LDX #&C0 / LDY #&31 / LDA #&A

both of which make much more sense. (I manually disassembled these so there are probably transcription errors, but the point stands.)

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Thu Apr 30, 2020 4:22 pm

joachim wrote:
Thu Apr 30, 2020 10:56 am
Looks as if you decompiled with the wrong frame.

JSR &A25C / LDA &31A0,X / LDA #&C
can be read as
EQUW &5C20 / LDX #&BD / LDY #&31 / LDA #&C

JSR &A25C / CPY #&A0 / AND (&A9),Y / ASL A
can be read as
EQUW &5C20 / LDX #&C0 / LDY #&31 / LDA #&A

both of which make much more sense. (I manually disassembled these so there are probably transcription errors, but the point stands.)
Yes, I looked at this again, and you're correct.

Here's what this piece of code actually looks like when disassembled properly:
Screenshot_20200430_160755.png
I think &2F00 is actually the game's entrypoint, and so this is actually the very first piece of initialisation code that gets run.

In v2, the LDX/LDY pair forms a 16-bit pointer to &31C0, which is then passed to tr_print_string, with a string length of 10. At &31C0, we find this:

17 01 00 00 00 00 00 00 00 00

which is a VDU 23 character redefinition.

However, in v1, the LDX/LDY pair forms a 16-bit pointer to &31BD, which is also passed to tr_print_string, but this time the string length is increased to 12. At &31BD, there is this:

16 05 17 01 00 00 00 00 00 00 00 00

This contains the same VDU 23 sequence, but prior to this there is a VDU 22,5 which changes needlessly to MODE 5. So this is indeed another v1->v2 difference, but it's a trivial one.

Thanks for helping clear that up.

User avatar
scarybeasts
Posts: 577
Joined: Tue Feb 06, 2018 7:44 am
Contact:

Re: Repton 3: Emulator/RNG issue

Post by scarybeasts » Wed Jul 15, 2020 9:48 am

Diminished wrote:
Mon Apr 06, 2020 12:07 pm
So, it seems there has been some confusion, most of which is probably my fault.

The only version that we have found so far with the bug is the very first Repton 3 stand-alone full-price disc release (which we've been calling "v1"). This seems to be the version that's on Stairway to Hell (or at least a de-protected hack of it).
Resurrecting this old thread because I've developed an interest in disc variants.

Can I interest people with original Repton 3 discs to try the DCRC command of discbeast to fingerprint them, to demonstrate how we can use tooling to quickly get the community to check their discs for variants?

Discbeast was released here: viewtopic.php?f=2&t=19953


Cheers
Chris

User avatar
scarybeasts
Posts: 577
Joined: Tue Feb 06, 2018 7:44 am
Contact:

Re: Repton 3: Emulator/RNG issue

Post by scarybeasts » Thu Jul 30, 2020 9:10 pm

scarybeasts wrote:
Wed Jul 15, 2020 9:48 am
Can I interest people with original Repton 3 discs to try the DCRC command of discbeast to fingerprint them, to demonstrate how we can use tooling to quickly get the community to check their discs for variants?
Thanks to SarahWalker and sbadger for lots of discbeast testing and imaging (and further thanks to the Bitshifters in general for testing and patience), here are the three original Repton 3 disc variants we have found so far. The files are HFE format, 40 track side then 80 track side.

Variant 1.
https://drive.google.com/file/d/1O1K4cW ... fbyg7/view
https://drive.google.com/file/d/1h9LNsV ... _Uk9X/view

Variant 2.
https://drive.google.com/file/d/1k9l1eC ... Mq9aZ/view
https://drive.google.com/file/d/1tU9Tel ... W4GOt/view

Variant 3.
https://drive.google.com/file/d/1q_QCuh ... jCA1n/view
https://drive.google.com/file/d/19Fx9K7 ... ebvmO/view


Variant 1 and 3 are very similar -- only differences on a couple of tracks. Variant 2 has many differences (some are clearly visible changes in the BASIC loader files; changes to the binary files would need deeper analysis).


Cheers
Chris

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Thu Jul 30, 2020 9:13 pm

scarybeasts wrote:
Thu Jul 30, 2020 9:10 pm
scarybeasts wrote:
Wed Jul 15, 2020 9:48 am
Can I interest people with original Repton 3 discs to try the DCRC command of discbeast to fingerprint them, to demonstrate how we can use tooling to quickly get the community to check their discs for variants?
Thanks to SarahWalker and sbadger for lots of discbeast testing and imaging (and further thanks to the Bitshifters in general for testing and patience), here are the three original Repton 3 disc variants we have found so far. The files are HFE format, 40 track side then 80 track side.

[snip]

Variant 1 and 3 are very similar -- only differences on a couple of tracks. Variant 2 has many differences (some are clearly visible changes in the BASIC loader files; changes to the binary files would need deeper analysis).


Cheers
Chris
Great work, everyone.

I'm guessing these aren't in any particular order (so v2 might have been released after v1 and v3).

User avatar
scarybeasts
Posts: 577
Joined: Tue Feb 06, 2018 7:44 am
Contact:

Re: Repton 3: Emulator/RNG issue

Post by scarybeasts » Thu Jul 30, 2020 9:24 pm

Diminished wrote:
Thu Jul 30, 2020 9:13 pm
Variant 1 and 3 are very similar -- only differences on a couple of tracks. Variant 2 has many differences (some are clearly visible changes in the BASIC loader files; changes to the binary files would need deeper analysis).
Great work, everyone.

I'm guessing these aren't in any particular order (so v2 might have been released after v1 and v3).
v2 being newer is a reasonable guess. One of BASIC files, D.REPTON1, uses *RUN"REPTON2" to replace */REPTON2. Would *RUN be more compatible? I think Stew was saying his Master didn't like the */ variant.

v2 is the only disc of the three to have a duplicator watermark: YY/MM/DD of 86/10/31.


Cheers
Chris

User avatar
vanekp
Posts: 918
Joined: Thu Nov 30, 2000 7:09 am
Location: The Netherlands
Contact:

Re: Repton 3: Emulator/RNG issue

Post by vanekp » Fri Jul 31, 2020 8:10 am

maters don't like */ filename but if you have */ "filename" it's then happy.
don't ask me why.
Peter.

User avatar
scarybeasts
Posts: 577
Joined: Tue Feb 06, 2018 7:44 am
Contact:

Re: Repton 3: Emulator/RNG issue

Post by scarybeasts » Wed Aug 05, 2020 11:24 am

scarybeasts wrote:
Thu Jul 30, 2020 9:24 pm
v2 being newer is a reasonable guess. One of BASIC files, D.REPTON1, uses *RUN"REPTON2" to replace */REPTON2. Would *RUN be more compatible? I think Stew was saying his Master didn't like the */ variant.

v2 is the only disc of the three to have a duplicator watermark: YY/MM/DD of 86/10/31.


Cheers
Chris
Actually, on a second look, v2 is probably older. It lacks the fungus fix as documented earlier in the thread. v2 has:
(6502db) d 2fab
[ITRP] 2FAB: LDA $82
[ITRP] 2FAD: STA $31DD
[ITRP] 2FB0: JSR $2103

Whereas the other two have:
(6502db) d 2fab
[ITRP] 2FAB: LDA #$FF
[ITRP] 2FAD: STA $86
[ITRP] 2FAF: LDA $82
[ITRP] 2FB1: STA $31DE
[ITRP] 2FB4: JSR $2103


It's good to know we've got original, protected captures of v1 and v2 :)


Cheers
Chris

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Thu Aug 13, 2020 2:08 pm

Did a little more poking around today, now that the temperature has dropped and using my big PC is bearable again. I've been avoiding working on this because disassembling is tedious and painful.
Diminished wrote:
Wed Apr 29, 2020 12:49 am
&04A0/&04A1: inserted sub call, JSR &0CB8 (not sure what this does, further research needed)
This added subroutine call is part of a routine at &465 (in v2) which I've provisionally named some_lvl_init, which appears to be called as part of the level initialisation process. Specifically, it seems to have something to do with clearing a space (possibly for the player, and maybe other actors too, since this is part of a loop that runs a few times), maybe if their spawn point isn't vacant.
Screenshot_20200813_135408.png
tr_set_level_cell bounces off a signature Atkinson trampoline at &1CA9 to the actual routine set_level_cell at &1DCF (in v2), taking X/Y as the X and Y coordinates of the cell to be changed, and A as the new cell value to be written. Thanks to the Decoding Repton document from the Repton Resource Page, we know that &6 means "empty space"; this value is passed to tr_set_level_cell, presumably blanking some cells out in the map.

There is a table of values at &58, currently imaginatively named t_58, which must contain something derived from the current map state. It seems Matthew forgot to call the routine to update it in v1 when the cell was cleared. So there must be a bug related to desychronisation between the map state and the t_58 state when the level is initialised. I don't know what t_58 is used for yet, though.

Here's my current WFDIS file if you want to play along. I'm working with v2 now.
v2-ascii-labelled-4.wfdis.zip
(188.19 KiB) Downloaded 12 times

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Thu Aug 13, 2020 6:48 pm

Very provisional, but t_58 has something to do with what's in the four cells bordering the cell under consideration. It seems it only gets populated with a value (from 0-3, depending on which of the four compass points contains something interesting) if an adjacent cell isn't blank, earth, or fungus. I think.

I'd conjecture it's something to do with the behaviour of boulders, spirits, or fungus. Or maybe the monsters. At first I thought it might be the source of the change in spirit behaviour that was mentioned upthread, but people seemed sure that was only something that changed in the expansion packs, rather than in base Repton 3, so I don't know.

Need to cook dinner now so further investigations will have to wait a little bit.

If anyone fancies trying to confirm that the spirit behaviour really didn't change until the expansion packs, or whether it actually changed in R3 v2, be my guest. It was suggested earlier that you could just test it by loading one particular expansion pack level into base R3.

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Thu Aug 13, 2020 9:11 pm

Diminished wrote:
Fri Apr 10, 2020 4:09 am
hey, I screw up a lot.
It's true. I missed something.
Diminished wrote:
Wed Apr 29, 2020 12:49 am
&04A0/&04A1: inserted sub call, JSR &0CB8 (not sure what this does, further research needed)
I had assumed that this -- the routine at &0CB8 to initialise t_58, which v2 invokes on level init -- was a commonly used routine that was also called elsewhere. It is not. Unless WFDIS has missed something, this is the only place in the code that this routine ever gets called.

Since (as already documented) this call was absent in v1, you might be wondering why the routine exists in v1 if the only place it's ever called is in v2. The answer is that it doesn't. This routine is missing from v1.

Not only that, but it seems that some hackola took place in order to shoehorn this routine into v2.

Code: Select all

                    ; copied here from &6000! it executes up there and duplicates itself here as a side-effect!
SM_0ca0             ldx #$5f
L0ca2               lda $6000,x
                    sta SM_0ca0,x
                    dex
                    bpl L0ca2
                    rts
The tables and code of the &0CB8 routine (currently named update_t58) are directly below the above routine. It confused me at first, because it seems to clobber itself -- but then I realised that this copy loop is actually executed from VRAM at &6000 (a breakpoint confirms this, and also confirms that this never happens in v1). It copies update_t58 to its &0CB8 location from VRAM, once loading is finished. As a side-effect, it copies itself down here in the process, so this is an artefact; this copy loop is never actually executed from this location!

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Fri Aug 14, 2020 11:08 am

Kecske Bak wrote:
Wed Apr 08, 2020 8:32 am
Just checked. There's an easy way of seeing the change in the spirits' behaviour. Load the original version of Repton 3. Then load the "PREHIST" level set from Repton Thru Time. Two spirits at the start of the level will circle for ever as the behaviour of spirits has been changed.

If you load the PREHIST level set into Around the World. Repton Thru Time or Life of Repton, it'll work fine.
Diminished wrote:
Thu Aug 13, 2020 6:48 pm
If anyone fancies trying to confirm that the spirit behaviour really didn't change until the expansion packs, or whether it actually changed in R3 v2, be my guest. It was suggested earlier that you could just test it by loading one particular expansion pack level into base R3.
My suspicions were correct.

t_58, now renamed t_spirits_headings, is an 8-byte table which keeps a record of the current directions of up to eight active spirits. Contrary to received wisdom, their behaviour was actually changed in v2, not in the expansion pack versions.

The routine at &0CB8 which was absent in v1 and which I have now renamed to init_spirits_v2only, is responsible for testing cells adjacent to each spirit, and setting up the spirits' initial directions based on these initial surroundings. In v1, the direction just defaults to &1 for all eight spirits.

Here's my current effort at disassembling init_spirits_v2only:

Code: Select all

                    ; V2: completely absent in V1??
T_ROW_OFFS_WSEN     ff 00 01 00 
T_COL_OFFS_WSEN     00 01 00 ff 
T_CB4               00 03 01 02 
init_spirits_v2only ldx spirit_ix
                    lda t_spirits_x,x
                    sta column_base
                    lda t_spirits_y,x
                    sta row_base
                    ; loop counter
                    ldy #$03
                    ; go through all four values and add each pair of offsets to the base row and column values
P_S0cb8_loop        sty compass_points_ix
                    lda column_base
                    clc
                    adc T_COL_OFFS_WSEN,y
                    tax
                    lda row_base
                    clc
                    adc T_ROW_OFFS_WSEN,y
                    ; check four adjacent cells: NESW
                    jsr tr_get_level_cell
                    ldy compass_points_ix
                    ; CONSTANT: fungus?????
                    cmp #$1f
                    beq L_S0cb8_next
                    ; CONSTANT: empty cell
                    cmp #$06
                    beq L_S0cb8_next
                    ; CONSTANT: Earth 1
                    cmp #$02
                    beq L_S0cb8_next
                    ; CONSTANT: Earth 2
                    cmp #$03
                    beq L_S0cb8_next
                    ldx spirit_ix
                    lda T_CB4,y
                    ; store 0-3 in t_58[spirit_ix] depending on which adjacent cell contains something interesting?
                    sta t_spirits_headings,x
L_S0cb8_next        dey
                    bpl P_S0cb8_loop
                    rts
But wait! You're not convinced? Well, what we need here is a test level!
v1_v2_spirits.ssd
(10.25 KiB) Downloaded 11 times
Load up a candidate version, swap in this disc, hit L, and then type "SPIRITS" as the level name to be loaded.

V1 does this:
v1.gif
v1.gif (97.18 KiB) Viewed 619 times
V2, meanwhile, does this:
v2.gif
v2.gif (91.87 KiB) Viewed 619 times
And finally, Repton Thru Time does the same as v2:
thru_time.gif
thru_time.gif (101.38 KiB) Viewed 619 times
(edit: shrank the GIFs a bit ... the filesizes were a bit antisocial, sorry)
Diminished wrote:
Wed Apr 29, 2020 12:49 am
&04A0/&04A1: inserted sub call, JSR &0CB8 (not sure what this does, further research needed)
So, we can cross that one off.
Last edited by Diminished on Fri Aug 14, 2020 3:39 pm, edited 1 time in total.

User avatar
leenew
Posts: 4239
Joined: Wed Jul 04, 2012 4:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: Repton 3: Emulator/RNG issue

Post by leenew » Fri Aug 14, 2020 11:49 am

Well done =D>

Lee

User avatar
Kecske Bak
Posts: 719
Joined: Wed Jul 13, 2005 8:03 am
Location: Treddle's Wharf, Chigley
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Kecske Bak » Fri Aug 14, 2020 12:03 pm

Wonderful piece of detective work. I remember this change really annoyed me at the time as some of my Repton 3 levels relied on the original behaviour and no longer worked in Life of Repton (the first Repton 3 variant I got on 5.25" disc).

User avatar
Diminished
Posts: 566
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Repton 3: Emulator/RNG issue

Post by Diminished » Fri Aug 14, 2020 12:58 pm

Yeah, it was a brave move by Superior to break compatibility within R3 itself, and I'm surprised they did it; it would have meant that certain home-made levels wouldn't be compatible from one household to the next.

Imagine the Twitter storm if someone did something like this today!

Post Reply

Return to “8-bit acorn software: classic games”