Silent Hill 2 looks really great on modern computers with all the modern enhancement mods installed.
there we go.
it turns out if you install it without the full movies install, the nocd-hack in the enhancement pack causes it to lock up instead of loading the video off the CD
it does have a minor problem where when you hit escape, the background is something that's on your screen, like, uh, twitter.
what the heck is this encoding? uppercase is lowercase, uppercase is shifted down.. so "3" is "S"?
gah using other people's tools to hack games is so annoying.
there's a tool that can edit the .MES files, which contain the encoded text! so clearly someone figured out the encoding.
is source available, or did they document it?
No, fuck you.
but hey, someone wrote a tool to extract the files right out of the game.
Neat, right?
but they posted it on sendspace in 2017 and the download has been auto-deleted
THIS IS WHY I HACK MY OWN GAMES
I... what?
I didn't mean to do that. MARY WHAT DO YOU MEAN
there we go. working text injection.
I'm doing |HERE| so I can extract the width back out by measuring how much the | glyphs move.
although there's a question of background here: if the font has any black in it, I won't be able to tell the difference between black and transparent
ugh, it does have black in it.
so text injection here isn't the best solution.
maybe I can inject text elsewhere and it'll be the same font?
hmm, it turns out the font I was looking at was the wrong one.
the enhancement pack I installed gave me this (left), but if I remove it, I get this font (right)
it seems to be pretty much the same font, just rendered at a higher resolution
FINALLY!
I replaced the Mary's Letter background with Magic Pink.
so now I can correctly extract the font
there we go. automated text extraction
ok extraction completed.
next steps:
1. remove the pink background
2. extract the widths from the | glyphs
3. map this strange character set to unicode
but it's too 3am to do any of that now
as silent hill would say...
BTW, if anyone (including future me) needs to replace .TEX files in SH2:
So there's a tool for this called the the SH Texture Explorer, which says it can do it, but I wasn't able to do it for .TEX files. I think it might only work for .MDL files?
so what I did instead was use it to convert the .TEX file to a TGA, and then maintained the size and colordepth when I edited it.
I then used GPUOpen's Compressonator to convert it to a DXT1 file https://gpuopen.com/compressonator/ 
Then I did a header-swap:
I copied all the bytes in the .DDS file from byte 0x80 onward:
and replaced it over the bytes 0x50 onward in the .TEX file.
This seems to have worked just fine.
I wasn't able to find any source for programs that handle .TEX files, or any file format documentation, so there is almost certainly a much better way to do this? but this is what I did, which worked fine.
still purple but I've got the font nicely extracted now
now I gotta figure out where I left my color-math code.
I wrote some shit that takes things like this and turns it back into a shade of white + a level of transparency, by basically brute forcing it:
there's 256 levels of grey and 256 possible opacity levels: which is closest?
the problem is that I wrote that code and I use it very rarely and every time I have to use it I have to figure out where I left it
ahh, I last used it for Squirrel Stapler, another of the 900 generators I finished 90% of and then never did the final 10%
ahh, it's in D:\\avfe, as compare .py.
Just in case you're searching in future, Foone.
ANYWAY it's running.
someday I should clean up the code, put it on github, and make it faster than a snail.
ok I limited it to only the first few characters so I could confirm it works, and it sure does look like it does!
time to run it on the whole thing and go out for a coffee, and a movie, and a nap, and maybe just schedule to come back in a few days.
how's tuesday work for you?
so I ran it on just the first 4 letters and it took 26 seconds.
I tried making it so that the lookup-color stuff is memoized and will cache colors, and that got it down to 18 seconds.
and hopefully that speed increase will be non-linear, since as the image gets bigger more and more colors will be cached?
it's possibly the stupidest way to make this faster but it was like 5 lines of very simple code so I'll take it.
unfortunately it's seeming to be non-linear but in the wrong direction
going from 4 symbols to 8 symbols went from 18s to 48s, which is more than twice as much.
going up to 16 symbols increased it to 64s, so maybe we're finally hitting that non-linear behavior I was dreaming of
32 symbols: 110s.

WHERE IS MY NON-LINEAR BEHAVIOR DAMN YOU
64 is 197s.
we're still under linear behavior but not by much.
@vidthekid pointed out I was doing it wrong: I was assuming a B&W font but this one is clearly blue-shifted. So I fixed that now!
ok had to do a quick test before I re-ran the whole thing
progress has been made
Ugh. this is non-simple. I don't know what the game's native resolution is, but it's definitely not this.
It's clearly composing all the text and then scaling it down, causing it to use non-integer spacing.
this means I get in a fun situation where if I display letters at width N, it's too wide. if I use N-1, it's too thin.
so I gotta either try to figure out the native resolution (which hopefully uses integer pixel widths) or give up and accept that my generator is just gonna be Wrong.
None of them seem to be exact, sadly, but it looks like 1280x720 is the most pixel-accurate I can get out of it.
That's kinda too big for a generator so I think I'll crop it down to 888x500, which is a lot smaller but preserves the 16:9 ratio of the source, which is coincidentally what twitter wants to see to avoid cropping
so now I gotta restart the whole capturing and widthifying and de-backgrounding process! Hurray!
see yah in 2021
btw one weird thing about this game:
the texture I'm editing is the one at data/pic/etc/p_letterm.tex, right?

not the more obvious one at data/pic/item/p_letterm.tex.

Which is identical, but apparently not used.
huh.
ugh. you see the difference between the left and right pipes? They're not the same... that's a telltale sign of it using non-integer scaling.
WHY ARE FONTS SO HARD

I'M GOING BACK TO AN NES GAME
ALL THEIR FONTS ARE 8X8 PIXELS AND MONOSPACED
I COULD GET THE GENERATOR FOR ONE OF THESE GAMES DONE BEFORE I FINISH THIS SANDWICH
Here's Rambo for the NES.
Look at that font.
it's pixels. nice 8x8 pixels.
let's open up the PPU viewer and
oh look, a font
then we paste it into paint .net
next we edit out the duplicates and the hard-to-map japanese, and save the file as games/rambo/rambo.png
open up a command line and run linearize on it. Hey, it defaults to 8x8 pixels, and it'll delete out all those empty tiles.
and now we've got a nice flat image for all the letters.
so now we need to map each glyph to a unicode codepoint.
it's time to get smarter, with makesmarter .py
we just gotta modify the CHARS bit to line up with the characters in the font.
like so!
after fixing the minor typo, makesmarter can be run and it generates a sort of json fragment.
we just need to take that and put it into rambo.json
like so. That's not valid JSON yet, so we gotta fix that up and stick in the required header bits.
like so.
You've got the height (which is difference between lines), then the origin, which tells it where to start drawing characters.
That's the wrong place but we'll fix it later.
so the next step is that we need a background for the generator.
That's easy: screenshot the game that's open!
so now we can just name it rambo-blank.png and fix the name of rambo-linear.png to rambo-font.png and then we need to load up the generator.
Rather than uploading it anywhere, we just need to launch a local webserver.
and there we go, a basic generator!
let's try it out.
ok so there's two problems here:
the text is in the wrong place and we have no space character, so it's defaulting to the first character, which is a !.
let's fix the second problem first.
so our font has no space.
we could edit one in, then modify and re-run makesmarter... but why do that? a space is just a blank character. So...
let's just set it up as being off-screen. We use the 8-by-8 non-existent pixels left of the left side of the screen.
(32 is the ASCII/unicode value for space)
and now we have spaces!

But we still need to move the characters over.
So here's how it works. You type in the first couple characters of the first line, and then open this up in the image editor
so in the image editor we can see in the lower-left that the difference between the existing one and the correct one is 80x30 pixels.

(We have to remember to resize this image to 50% first, because the generator defaults to 2X size)
So, back to rambo.json, and fill in those origins.
and now it works! it works so well that you can't tell it works.
but if you swap it in for XXXX you can see the text is at the right place.
Do more than one line and you'll discover there's a problem, though: the game's font may be 8x8, but it doesn't make each line touch each other. it uses every other line.
back to rambo.json, change height to 16.
and it works! well, up until we get to the rambo response.
It's at a completely different position. how can we handle that?
back to the image editor, a quick measurement to see where that line starts.
It's at 32x126.
Then we stick in an explicit-origins block to override the positioning of the 6th line.
(it's "5" because we start at 0.)
and there we go, Rambo's response is at the right place!
but wait, do we need to manually position the next couple lines?
Nope! It positions every line relative to the last one, so it's going to automatically be in the right place.
so now we move on to the next step:
it looks right, but is it right? who can say?
we can, that's who.
We finish up typing out the default text, and then click the SECRET JSON BUTTON
that just gives us a file that includes all state of this generator:
{"main-text":"Your mission is to\\nsneak into the\\nenemy camp and find\\nthem.\\nAre you up to it?\\nI'm not afraid of\\ndeath.\\n\\nI feel better in\\nprison."}
so we go into the rambo folder, and make a tests folder.
then copy the newly-downloaded json file in there, along with a copy of the blank image, then name them both something simple, like "i_feel_better_in_prison.png/json"
and now we can run testgenerator .py which'll find the image + json and try generating with those options, and confirming it matches the image (which, remember, is a screenshot from the emulator)

and it does match! 0 pixels different.
But that's easy: a blank textbox matches now
so we just need to go back into the "blank" file and make it blanker. Delete out the text!
so now it's fully blank.
Let's ask the testgenerator again...
Yep, still no differences.
We're 100% pixel accurate to the game.
if there were any differences, we could open up the results file and it'd show which pixels are different.
so, now we can release it, right?
it's the game PLACEHOLDER made by UNKNOWN.
that's not helpful. we need some metadata.
So we go over to generators.js (don't ask why it's .js and not .json, it just is)
and now we have a list of all the generators. We just need to fill in an entry for this one.
I filled in some of it.
the added date (today), the platform (NES), the name, and the default quote (which came from that json file)

but there's more here. Who made it, when did it come out?
TO MOBYGAMES!
Here we go.
Came out in '88, made by Pack-In-Video.
https://www.mobygames.com/game/rambo_ 
OK so fill that in Pack-in-Video, put the link to the wikipedia page on it, set the year to 88, put in the mobygames link in there, and then finally fix the series to "rambo" and not "road rash".
So we go back to the generator and refresh it and hey, we've got the correct name, the content link, the default text.
Looks good!
the "year" and "series" and "platform" stuff isn't used yet, but if you were on the new UI (which right now only I am) you'd be able to sort generators by platform, year, series.
So now we go over to the local github interface and select the files for the new generator (plus the changes to generator.js) and push it.
now we gotta do the most important part.
While we wait for it to autodeploy, we gotta make a slightly amusing example image to use.
How about some references to other Sylvester Stallone movies? that'll do.
Then we just type up a post to announce it.
but before we do that, there's a problem.
Which one of these is new?
it's Rambo.
Why isn't it special? it's just like Pilotwings or Railroad Tycoon that I did ages ago.
it turns out I typo'd the added date: it was 2020-06-26.
So let's fix it to September, not June...
push and refresh and there we go, it's got a little badge on it.
Hurray!
And now, to finish up, we go to the in-progress thread (this one), and link to the announcement post, so that people who were following along with this thread can jump over to there and get to use it.
Like so:
It's out! https://twitter.com/Foone/status/1310017449312399360
You can follow @Foone.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: