Wikifang:Telefang 1 Translation Patch/RAM map
|Location||Length||Symbolic name||Purpose||Typical values||Added in patch?|
|These are registers to hold the values of things that need to be modified at Vblank time, either because they can't be touched during render time or because it makes more sense for it to be touched there.
Every Gameboy project will have at least one of these kinds of locations, since it's the only safe (non hardware-damaging) way to turn off the LCD.
|C3E0||1||SystemState||Game state table index||No|
|C3E1||1||SystemSubState||Game state table index||No|
|C3E2||1||SystemSubSubState||Game state table index||No|
|Per-frame functions are managed with state machines throughout Telefang, especially the main gameloop. There are three State bytes, because there can be up to three levels of state machines to reach a particular per-frame function.
Please note that this is not the only state machine in Telefang, though it is the largest.
|C3E8||1||GameboyType||Internal hardware detection||01 (DMG), 11 (MGB), FF (CGB)||No|
|This is another "every project has one" location. It is the contents of the A register on startup, which can be used to distinguish between operation on a DMG (brick) gameboy, MGB (pocket) gameboy, or Gameboy Color. This is needed to determine if CGB features are available.
This does NOT tell you if you're on a Super Gameboy, that's different.
|C423||1||SPILL_TempBank||Returning to previous banks||No|
|These variables are in use for managing bankswitching. There are two RST routines available for using these values:
|This stores the current letter being rendered in the VWF routines.|
|This stores the current Y pixel location of in-progress text renders, modulo 8.
It's used specifically to track how many shifts are needed when drawing text in the VWF routine.
|C7C3||2||VWF_CompositeArea||Text rendering||$D0CF||Not sure|
|Pointer to the compositing area used to store in-progress text rendering.
I am not sure if the compositing area is used in the original game.
|C7C5||1||VWF_OldTileMode||Text rendering||0, 1, 2||Yes|
|Internal VWF bookkeeping variable used to manage the contents of the compositing area.
When 0, the current drawing progress has not yet crossed a tile boundary, and the compositing area is drawn to freely. When 1, the current drawing progress has crossed a tile boundary, and the compositing area is globally moved left by one tile during drawing so that drawing can continue. State 2 is never set by the VWF itself, only other code. It indicates that a newline or other disruption in normal text flow has occured and thus the entire contents of the compositing area should be treated as garbage.
|C7C6||1||VWF_MainScriptHack||Text rendering||0, 1||Yes|
|This is a boolean value historically (in terms of the patch) used to track the main script state and enable some hacks which made newlines work properly. Most of the reason for this value's existence has been moved away since the main script was later hacked to properly manage it's own tiles in the face of a VWF.|
|C91E||1||MainScript_UIElementsTileBase||Tile graphics management||F0||No|
|Indicates the base location of certain UI graphics used for the main script window, in terms of tile IDs. This is mainly limited to selection arrows and "waiting for input" animations.|
|C91F||1||MainScript_TileBaseIdx||Tile graphics management||A0||No|
|Indicates the base location of the 2x16 tile main script area, in terms of tile IDs. This is where the main script window text gets drawn to.|
|C959||1||MainScript_SecondAnswerTile||Script window management||No?|
|This is part of a rather massive hack used to render answer selection arrows. When main script needs to ask a question to the user (Say, "would you like to hear what I said again" or something), it needs to draw an arrow. This is handled by altering the tilemap to show a particular animated graphic of an arrow. The second question has to be on the same line as the first, and we allow it to have it's own position in the text line. So, in order to know where to draw the arrow if the second answer is selected, we have a special full-width space which does two things:
|C987||1||VWF_LinesLeft||Tile graphics management||0-$10||No|
|Used to count how many lines left in a tile-copy operation.|
|The number of times (frames) that the Main Script interpreter has been called, modulo 256.|
|C9C6||2||MainScript_TextPtr||Text retrieval||$4000-$7FFF, $C000-$DFFF||No|
|C9C8||1||MainScript_TextPtrBank||Text retrieval||See text map||No|
|This is a far pointer (spans multiple banks) that indicates the current location of the main script interpreter relative to the script in ROM or (sometimes) Work RAM.|
|C9C9||1||MainScript_State||Interpreter functions management||0-8, $A||No|
|The Main Script routine is organized like a state machine, but is independent of the master gameloop state machine, since it can be run either continuously (loop until newline) or per-frame. The state can be changed by the current script with the opcode E1. The operand controls the state.
Notable states include:
State 1: The normal control code interpreter. Most script is executed here.
State A: User question management. This state is invoked in order to allow questions to be answered, and it handles 100% of all the UI during that period.
|C9CA||1||MainScript_WindowLocation||I don't remember what this does.||No|
|Records how many tiles have been drawn so far. The sub-tile Y location is stored in VWF_LetterShift.|
|C9CD||1||MainScript_TextSpeed||Text speed||0, some others||No|
|Controls how many frames are waited in between character draws. This controls the speed of the text. WaitFrames is how many frames left we have to wait before it's time to draw another letter. Opcodes are always processed even if it's not yet time to draw anything. When WaitFrames is 0, a letter is drawn and it's refilled with the value from TextSpeed.
0 frame wait is a special value: It causes the main script routine to operate in continuous mode, where it keeps drawing text continuously until it reaches a point in which user input is needed. This is notably abused by the SMS routine to hijack the main script routine to draw text into a non 2x16 sized window.
TextSpeed can be controlled with opcode E3. The operand is saved into TextSpeed.