Repton 2 colours

reminisce about bbc micro & electron games like chuckie egg, repton, elite & exileRelated forum: adventures


Post Reply
caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Repton 2 colours

Post by caspian » Tue Dec 04, 2018 4:54 am

I played BBC Repton 2 from an SSD file on an emulator recently and only one of the screens was red, but I also saw BBC Repton 2 maps online at reptonresources and the colours seemed to match my memory of playing it on a real BBC computer, with screen D (and some others) being red too. I also saw a forum post by AJH talking about how the code for the colours worked, but I'm not sure I understood it right.

I also saw on the repton resources page screen D was blue in newer platforms like Archimedes and RiscPC.

I played all the versions I could find from stairway to hell, and only the Electron version (which otherwise looked quite different) had it. Even the tape version with the missing diamond had a blue screen D.

Does anyone know if there was a different BBC version with a red screen D?

Repton 2 BBC level D map:
http://www.reptonresourcepage.co.uk/Wal ... e=&level=4

Thread with description of its colour algorithm for repton 2:
viewtopic.php?t=830

User avatar
geraldholdsworth
Posts: 544
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Repton 2 colours

Post by geraldholdsworth » Tue Dec 04, 2018 8:10 am

The colours for the maps on BBC and Electron Repton 2 come from lookup tables, along with a bit of calculations:

"The palette is stored in two locations. The first location is four bytes. Each byte is made up of the logical colour (top four bits), and the actual colour (lower four bits). To get the appropriate palette for the level, you will need to AND the level number with 3 (with the level number being 0..15) to produce an offset of 0, 1, 2 or 3.
However, this data is only valid for levels 2..15. For 0 and 1, there is a second location with two bytes. Also, logical colour 0 is always actual colour 0 (black), and logical colour 3 is always actual colour 2 (green). And finally, level P (15) appears to be a combination of offset 2 and 3 of the first location."
(taken from Decoding Repton)

Desktop Repton 2 and Archimedes Repton 2 use just lookup tables.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Repton 2 colours

Post by caspian » Wed Oct 16, 2019 8:31 am

Possibly I was mistaken about the red screen D in the BBC. I did often play it on a monochrome green screen, so maybe that made it easy to mix up colours with the ZX Spectrum version.

There's a bit missing from the calculation description: where does the trousers colour come from when it isn't in the palette entry for the screen?

My understanding now is that the colour is left the same from whichever screen you were on before you entered the level.
Often that's the home screen (number 0), with blue trousers, but on level 15 it's level 14, with cyan trousers, and that's why level 15 has a different colour combination that the others.

I had a search through the code and didn't find anything else to reset the trousers colour between levels apart from what you quoted, and that's consistent with the colours I've seen while playing in the emulator.

This does suggest that if you could enter one of these screens via transporters from screens with two different colour trousers, the screen would be have the different colours the two times you entered it, but there don't seem to be any such transporter combinations in the game as it is.

Also if you make the palette change the diamond colour from yellow it stays changed on the levels that don't set it. I confirmed this by making a copy with a modified palette and it worked.

I did some further checking in the code, and found logical colour 0 is only reset to 0 on screens 2 to 15 (it's an alternative code path to setting the palette from the second location, which happens for screens 0 and 1)

So if the main palette for screen 1 is changed so it sets colour 0 to magenta, both the magenta background from the first palette and red trousers from the second palette apply. And the magenta background is kept when re-entering screen zero (home screen). But it can be reset to black when leaving the home screen again for a different screen

There's probably a palette hack I could do to confirm whether non-blue trousers colour could be kept when transporting from other levels apart from 14 and 0, but I haven't tried yet.
Last edited by caspian on Wed Oct 16, 2019 2:23 pm, edited 1 time in total.

User avatar
geraldholdsworth
Posts: 544
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Repton 2 colours

Post by geraldholdsworth » Wed Oct 16, 2019 12:41 pm

Very interesting...not sure about where the trouser colour comes from. I'll need to try this out too.

Cheers,

Gerald.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Repton 2 colours

Post by caspian » Fri Oct 18, 2019 4:22 am

I think the electron version must use different palette code as in that version, jumping from the home screen to level D does change two colours, green pants/head to cyan pants/head, and blue jacket/walls to red jacket/walls. (or changes one and resets one to default)

User avatar
geraldholdsworth
Posts: 544
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Repton 2 colours

Post by geraldholdsworth » Sat Oct 19, 2019 8:31 pm

I've found these notes, sent to me by (IIRC) Jasper Renow-Clarke:
The offsets are for when the game is running.
The colours which you get are a combination from 2 separate bits of pallete data and depend on which level you are on.
Interestingly the table entry at 0EC5 for Level A isn't actually colour 1 = Magenta, because this is only used if the level number is >= 02 - see code below. Same for Level B.
; --------------------------------------------------
; Levels colour palette 1
0EC5 15 21 ; AEIM Logical colour 1 = actual colour 5 (Magenta)
0EC6 14 20 ; BFJN Logical colour 1 = actual colour 4 (Blue)
0EC7 16 22 ; CGKO Logical colour 1 = actual colour 6 (Cyan)
0EC8 36 54 ; DHLP Logical colour 3 = actual colour 6 (Cyan)

; Then in the code ..

1CDF A9 32 LDA #$32 ;
1CE1 20 9F 0F JSR $0F9F ; Logical colour 3 = actual colour 2 (Green)

1CE4 A5 8B LDA $8B ; Current level
1CE6 29 03 AND #$03 ;
1CE8 AA TAX ;
1CE9 BD C5 0E LDA $0EC5,X ;
1CEC 20 9F 0F JSR $0F9F ; Set logical colour to actual colour from level palette

1CEF A9 00 LDA #$00 ; Logical colour 0 = actual colour 0 (Black)
1CF1 20 82 33 JSR $3382 ; Set logical colour from second level palette
---------------------------------------------------
2400 A9 32 LDA #$32 ;
2402 20 9F 0F JSR $0F9F ; Logical colour 3 = actual colour 2 (Green)

2405 A5 8B LDA $8B ;
2407 29 03 AND #$03 ; Current level AND 0x03
2409 AA TAX ;
240A BD C5 0E LDA $0EC5,X ;
240D 20 9F 0F JSR $0F9F ; Set logical colour to actual colour from level palette

2410 A9 00 LDA #$00 ; Logical colour 0 = actual colour 0 (Black)
2412 20 82 33 JSR $3382 ; Set logical colour from second level palette
---------------------------------------------------
; Levels colour palette 2
3380 14 20 ; A Logical colour 1 = actual colour 4 (Blue)
3381 11 17 ; B Logical colour 1 = actual colour 1 (Red)
; Then in the code ..
; --------------------------------------------------
; Set palette from level number AREG always 0
; --------------------------------------------------
3382 8D FC 0B STA $0BFC
3385 A6 8B LDX $8B ; Current level
3387 E0 02 CPX #$02 ; For levels >= 02 set from AREG logical 0 = 0 (Black)
3389 B0 03 BCS $338E ;
338B BD 80 33 LDA $3380,X ; For levels A,B use level palette 2
338E 4C 9F 0F JMP $0F9F ; Set colour palette

So in summary ..
default = Black,Blue,Yellow,Green
with
colour 0 = always Black
then
A,E,I,M have colour 1 = Magenta (from 0EC5)
B,F,J,N have colour 1 = Blue (from 0EC6)
C,G,K,O have colour 1 = Cyan (from 0EC7)
D,H,L,P have colour 3 = Cyan (from 0EC8)
then
A has colour 1 = Blue (from 3380)
B has colour 1 = Red (from 2281)
however
P seems to be a combination of (0EC7 and 0EC8)
and a further override is
code at 2400 sets colour 3 = Green (presumably for instances when it's not Cyan)
Level | 0,1,2,3
------|--------
A Black,Blue,Yellow,Green
B Black,Red,Yellow,Green
C Black,Cyan,Yellow,Green
D Black,Blue,Yellow,Cyan
E Black,Magenta,Yellow,Green
F Black,Blue,Yellow,Green
G Black,Cyan,Yellow,Green
H Black,Blue,Yellow,Cyan
I Black,Magenta,Yellow,Green
J Black,Blue,Yellow,Green
K Black,Cyan,Yellow,Green
L Black,Blue,Yellow,Cyan
M Black,Magenta,Yellow,Green
N Black,Blue,Yellow,Green
O Black,Cyan,Yellow,Green
P Black,Cyan,Yellow,Cyan
Hope this makes sense. So for you to have full control over the palette for each level, you would need to change the data tables aswell as some of the machine code parts.
Obviously, this is based on the BBC version.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

User avatar
Snuggsy187
Posts: 28
Joined: Wed Apr 03, 2019 8:53 pm
Contact:

Re: Repton 2 colours

Post by Snuggsy187 » Sun Oct 20, 2019 4:47 pm

Not sure about the BBC version, but I found this nugget in the Electron version:

Part of the main loop appears to be a palette reset (VDU 20/&14) when redrawing the screen area. So Repton's jumper defaults to red:

1C6D LDA #&00
1C6F JSR &35C2 ; Reset Palette
.....
35C2 STA &0BFC
35C5 LDA #&14: JMP &FFEE ; Reset Palette (1=Red, 2=Yellow, 3=White)

then:
1C72 LDA #&32 ; Colour 3 > Green (head and legs), all levels
1C74 JSR &0F92 ; Do Palette

then:
1C77 LDA &8B ; Screen
1C79 AND #3
1C7B TAX
1C7C LDA &0F43,X ; Lookup table: 15 / 14 / 16 / 36
1C7F JSR &3488
......
3488 JSR &0F92 ; Do Palette

so:
screens 0, 4, 8, 12 and 16 set colour 1 to Magenta (jumper)
screens 1, 5, 9 and 13 set colour 1 to Blue (jumper)
screens 2, 6, 10 and 14 set colour 1 to Cyan (jumper)
screens 3, 7, 11 and 15 set colour 3 to Cyan (head and legs) - colour 1 stays default to Red (jumper)

then:
348B LDX &8B ; Screen
348D CPX #&02
348F BCS &3497 ; RTS if Screen >=2
3491 LDA &35C0,X ; Lookup table: 14 / 11
3494 JSR &0F92 ; Do Palette
3497 RTS

35C0 14,11

so:
screen 0 set colour 1 to Blue (jumper)
screen 1 set colour 1 to Red (jumper)

Colour 2 (eyes and hands) are always yellow (default colour)

This seems to make sense to me, but why not just use a 2 byte lookup for each level for colours 1 and 3.....! :roll:
.... or 1 byte for that matter !
PUSH PARCHMENT > POKE LOCK > PULL PARCHMENT

caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Repton 2 colours

Post by caspian » Sun Oct 27, 2019 11:37 am

Thanks to both of you for that information.

From Jasper's notes it does look like in the BBC version, the trouser colour isn't updated when you enter levels D,H,L,P, so it's left as it was in the level you came from.

The palette reset in the Electron version explains how it's different from the BBC micro version. Apart from that it looks very similar to the BBC version.
I wonder why they used different colour schemes/code.

As to why not use a full sized table, I'm guessing it was either to save memory, and then it wasn't worth rewriting even if there was spare memory available, or it was easier to have code decide the palette while the levels were still in development because there wasn't a basis to judge palettes until the levels were created.

I also found another possible source of my memory of level D not being blue.
There's a Repton 2 screenshot on the cover of the Superior Collection Volume 2, and it looks like there's a magenta level D there (at least for the earth and trousers, I can't see the walls well enough to judge). Maybe the screenshot is from an unreleased version, or not from the game itself:
http://www.computinghistory.org.uk/det/ ... -Volume-2/

I would have seen that screenshot on the cover whenever I used it. It would be good to see a better picture/scan though.

User avatar
geraldholdsworth
Posts: 544
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Repton 2 colours

Post by geraldholdsworth » Sun Oct 27, 2019 12:16 pm

caspian wrote:
Sun Oct 27, 2019 11:37 am
As to why not use a full sized table, I'm guessing it was either to save memory, and then it wasn't worth rewriting even if there was spare memory available, or it was easier to have code decide the palette while the levels were still in development because there wasn't a basis to judge palettes until the levels were created.
I could only guess at that Tim Tyler rushed through the code for Repton 2 - apparently he wrote it in a month.
caspian wrote:
Sun Oct 27, 2019 11:37 am
I also found another possible source of my memory of level D not being blue.
There's a Repton 2 screenshot on the cover of the Superior Collection Volume 2, and it looks like there's a magenta level D there (at least for the earth and trousers, I can't see the walls well enough to judge). Maybe the screenshot is from an unreleased version, or not from the game itself:
http://www.computinghistory.org.uk/det/ ... -Volume-2/

I would have seen that screenshot on the cover whenever I used it. It would be good to see a better picture/scan though.
I've got that - I'll dig it out and scan it in. The game itself, on that disc, is identical to the other released versions (apart from the double height characters actually working on a BBC Master on the loading screen, IIRC).

Over on the Stairway to Hell archive are the two early releases of Repton 2, which had the red screen A and the missing diamond. Not sure what other differences there are - I'll need to fire up the PeeCee, run my application and load the early release images into it to see.

Cheers,

Gerald.
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Repton 2 colours

Post by caspian » Mon Oct 28, 2019 4:53 am

geraldholdsworth wrote: I've got that - I'll dig it out and scan it in. The game itself, on that disc, is identical to the other released versions (apart from the double height characters actually working on a BBC Master on the loading screen, IIRC).
Thanks, that would be very interesting.
geraldholdsworth wrote: Over on the Stairway to Hell archive are the two early releases of Repton 2, which had the red screen A and the missing diamond. Not sure what other differences there are - I'll need to fire up the PeeCee, run my application and load the early release images into it to see.
I think I checked level D on one of those - it has cyan walls, normal green skin. But I haven't checked the other levels.

User avatar
geraldholdsworth
Posts: 544
Joined: Tue Nov 04, 2014 9:42 pm
Location: Inverness, Scotland
Contact:

Re: Repton 2 colours

Post by geraldholdsworth » Sat Nov 02, 2019 11:51 am

Sorry...took me a while - had to go to Edinburgh for work. Anyway, I've found I have two copies of the Superior Collection 2.
Superior Collection Vol 2 (2).jpg
Gerald Holdsworth
Repton Resource Page
www.reptonresourcepage.co.uk

caspian
Posts: 19
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Repton 2 colours

Post by caspian » Thu Nov 07, 2019 11:38 pm

Thanks, very interesting.

The earth and trousers could be magenta. Not red when compared to the other screenshots, though that could be from some different photos processing. Clearly not blue either in my opinion. To me it looks like the wall is a separate colour from the earth, maybe blue (which would mean it's not a normal 4-colour Repton 2 screenshot with any palette).

Post Reply