The Let's Play Archive

EXAPUNKS

by Carbon dioxide

Part 18: TEC Redshift - Dev kit

Part 18 - TEC Redshift - Dev kit

=== Trash World Inbox ===

Cloudmonkey98 posted:

At no point did the instructions say you lost points for your opponent's movie playing, just for you touching them, or trying to hide them in your Host room, since the enemy can't access that area, the instructions aren't incorrect

This is a really interesting mode that you can do some fun with I imagine, competing into increasingly complex and esoteric counter-solutions seems like a wild trip, and then at some point someone undermines it all with regressing to basic solutions, like a really basic counter to your solution for your friend you mentioned would be to just wait a few cycles, the Exas would KILL themselves and you could walk in freely
Huh. reading back, you're right about the instructions, my bad.

As for the hacker battles, I agree with GuavaMoment here:

GuavaMoment posted:

Hacker battles are a neat idea, buh ehh.....it's seemingly impossible to make a robust solution. It's like trying to optimize rock paper scissors, you're always going to be vulnerable to one tactic when using another.

Nth Doctor posted:

They're here!
Neat! I have the digital copy of Zach-Like. It's free, and it contains all sorts of behind-the-scenes information of Zachtronics game design and even some early games and prototypes.

Since it doesn't really make sense to talk about optimizations for the hacker battles, let's jump straight into the new update.


=== TEC Redshift - Development kit ===

You're off to a good start.
I knew you were good at what you did.
Even after you forgot, you picked it right back up.
That's why I contacted you.




Three votes for the second option.

But what do you really want?

All I've wanted is for you to do a little hacking for me.
That's it. Really.


Well, that doesn't explain anything.



Leafing through the zine I found the letters page.

Some interesting stuff there. First of all, heh, the letter Ember made me edit actually got printed in the zine. The original writer is in for a bit of a shock. Also, the tip about the KGOG tv station is probably where mutex got the number for the modem through which we did our hacker battle.

I also like the reference to "red boxes" and "blue boxes". They were real things. Back in the day phone exchanges were controlled through specific tones (nowadays it's usually a digital signal of some kind). In the USA, red boxes could be used to make an exchange think you put a coin in a pay phone, so it would let you place a call for free. Blue boxes could be used to place long-distance calls and bill them to some other number.



Anyway, I got this developer Redshift kit from Ghast, let's see if I can do anything with it.

Why do you think Ghast gave you this?



Two out of three votes for "I'm not sure".

I'm not sure.

Does he get something out of it?
I suppose he enjoys helping people.
Such a nice guy.
Too bad the dev kit is password protected.
He should have thought of that.
Better not let that stop you...


Yeah, no worries Ember, we'll just jailbreak this thing real quick.

There's a whole section about the Redshift in the zine, but most of it is about how to develop games for it. We're not quite there yet, but here's the frst page just so you have an idea of what we're dealing with.



The small print under the ad says: "Batteries not included; 3D mode not intended for use more than 15 minutes at a time; EXA is a registered trademark of Axiom, Inc. Used with permission."

An early attempt at a 3D handheld where using the 3D mode for too long would cause problems? This thing seems to be some sort of mix of a Nintendo Game Boy and a Virtual Boy.


OST: Code and Registers

No files or anything in this thing. Our assignment simply says:
There is an unknown three-digit code (such as 4-7-3) that, when entered one digit at a time into #PASS, will unlock the link between debug and secret. Find the three-digit code and create a file in your host that contains the code as a sequence of three values, followed by the development kit's RDK ID.

Okay, simple brute-forcing it is.



Entering some numbers into #PASS makes them appear on the little display in the secret host. If the code is wrong nothing will happen, and the fourth digit is simply the start of a new attempt. Any negative numbers or multi-digit values are ignored by #PASS.

Well, we got an instruction to grab specific digits from a number, why not use that?

code:
LINK 800

MARK TOP
SWIZ X 1 #PASS
SWIZ X 2 #PASS
SWIZ X 3 #PASS
ADDI X 1 X
JUMP TOP
The SWIZ function takes a mask as second operand. If the mask is 0002 (or just 2) it says "take 0 for the thousands, hundreds, and tens place, and take the value from the input's tens place (second digit from the right) for the output's ones place." The Language Reference Guide in the second post has some examples.

Since the #PASS expects digits from left to right while this takes the input from right to left, I actually enter the numbers in reverse. It shouldn't matter, it will try all numbers anyway, just in a different order. But since I need to store the password I'll swap the SWIZ calls around so I get the right password in X.

This unlocks the secret host, but this EXA keeps going forever. The #PASS register keeps accepting digits even after entering the right password.

I need to somehow stop this EXA at the right time, save its password, and go get that id from the secret host. Let's first see what we can find in the secret host, now that I unlocked it.





The link id between the debug and secret hosts is simply 800 again. There's four files in there: two core dumps, some game's save file, and a file containing the RDK id.



This is my first working solution. After some trial and error I decided that while a multi-EXA solution might be faster, it's gonna be hard to get the passcode out of the initial EXA at the right time. So I went for a single-EXA solution. Every loop, it tries to send a replica into the secret host. If the link is closed, the replica dies immediately.
Otherwise it gets the ID from the file. Then it needs to explicitly DROP the file (if you LINK an EXA holding a file with a lock icon it dies).

It KILLs twice (because by the time it gets back, the original had just enough time to execute a new REPL instruction), then goes back to the home host to write the file (which contains each digit of the password and then the ID).

This runs quite slow at 5959/22/11.

I tried to output it as a gif, but since it shows all digits being entered on the password display, the result is over 10MB and over 2 minutes. It also crashed my game when I tried to go back to editing afterwards. Don't try this at home.

Anyway, getting the activity down should be a question of minimizing LINK and KILL instructions.

We don't need to LINK back home with an EXA that waits for M signals:
code:
;XB

MAKE
COPY M F
COPY M F
COPY M F
COPY M F
And to get rid of the KILL, the original XA needs to know when to stop. Since I'm using M now, the MRD test works.
code:
;XA

LINK 800

MARK TOP
TEST MRD
TJMP END
SWIZ X 3 #PASS
SWIZ X 2 #PASS
SWIZ X 1 #PASS
REPL TRY
ADDI X 1 X
JUMP TOP

MARK TRY
LINK 800
GRAB 199
SWIZ X 3 M
SWIZ X 2 M
SWIZ X 1 M
COPY F M

MARK END
It's important to have the TEST MRD when the replica is already sending on M, but before XA can do another REPL (since that'll cause a LINK). This solution times it right and runs at 7938/23/2.

Next, let's look at cycle count. As I already said, if you swap around the SWIZ instructions, you basically change the order in which you test the passwords. Since I use the same SWIZ to write the data to the file I can easily try all permutations. Turns out 1,3,2 is the fastest at 5821 cycles, as compared to the 5959 solution.

But that's just a minor optimization. I'll need to do much better.

A basic loop unroll gets me to 5020/47/11.

code:
LINK 800

MARK TOP
@REP 6
SWIZ X 1 #PASS
SWIZ X 3 #PASS
SWIZ X 2 #PASS
REPL TRY
ADDI X 1 X
@END
JUMP TOP

MARK TRY
LINK 800
GRAB 199
COPY F T
DROP
LINK -1
KILL
KILL
LINK -1
MAKE
SWIZ X 1 F
SWIZ X 3 F
SWIZ X 2 F
COPY T F
Much better, but still a far cry from the top percentile. I believe the only way to get there is with parallelism.



It took some fiddling but this solution runs at 3405/50/17.

It still uses the ADDI/SWIZ combo so each EXA keeps a full counter. I could have one EXA just store the tens digit and one just store the hundreds digit but I don't think that would matter much since that would speed up those EXAs... for them to be limited by the one having to increment the ones digit every loop.

The EXA that makes it to the secret host immediately sends a REPL back to go KILL its buddies because the TRY REPLs add up fast now.

In fact, I just barely managed to squeeze out a single loop unroll. The loop unroll makes the REPL trigger even faster so I needed an extra KILL, which I managed to fit in by giving XC only one starting NOOP and hoping it would LINK after XB, which it did. I also needed an extra SUBI instruction because for some reason the ones digit is off by one now.

By the way, there's something cathartic about typing "KILL KILL KILL".

To make this even faster, well, as I said at least one EXA needs an increment instruction in its loop so it will act as the bottle neck. The only thing I can still remove from that loop is the REPL TRY:
code:
;XA
LINK 800

MARK TOP
SWIZ X 1 #PASS
ADDI X 1 X
JUMP TOP


;XB
NOOP
LINK 800

MARK TOP
SWIZ X 3 #PASS
ADDI X 1 X
JUMP TOP


;XC
NOOP
NOOP
LINK 800

MARK TOP
SWIZ X 2 #PASS
ADDI X 1 X
JUMP TOP


;XD
NOOP
NOOP
NOOP
LINK 800

MARK TOP
REPL TRY
ADDI X 1 X
JUMP TOP

MARK TRY
LINK 800
GRAB 199
REPL OT
SWIZ X 1 M
SWIZ X 3 M
SWIZ X 2 M
COPY F M
HALT

MARK OT
LINK -1
KILL
KILL
KILL
KILL
KILL
KILL


;XE
MAKE
COPY M F
COPY M F
COPY M F
COPY M F
2918/48/15. Not bad. According to the top percentiles it should be possible to get the cycle count further down to at least 2884, and it should be possible to have a solution with only 20 lines of code, too. I'll leave that to the threads.

So Ghast used to work at a game studio?



I'll skip this vote because all three answers lead to the same follow-up question.

Yeah, he was a programmer. It says so in the zine.

I wonder what that was like.



This one is for the thread.

Next time, we explore the Redshift dev kit. Ember would like to know why.

You're really going to make a game with this?
Why?
I'm not offering a reward for it.