# Learning Prompt

I want to learn the technical architecture of a data-driven creature-collector RPG, using Pokemon FireRed as the primary reference. Teach me the actual code systems behind a complete Pokemon-style game, not broad game-design theory.

The main goal is a top-down technical map that eventually lands directly in the FireRed source code. Start with the 5 or 6 highest-level systems, then recursively break each one into smaller subsystems, then break those subsystems down again, and keep going until the lesson reaches concrete code: files, functions, structs, data tables, state variables, callbacks, scripts, and control flow in Pokemon FireRed.

By the end, I want to be able to say from memory: a game like this needs these major systems, each system has these responsibilities, each system is built from these smaller subsystems and data structures, those subsystems are implemented by these specific code files and functions, and the systems communicate with each other in these ways during real gameplay.

Start by identifying the most important high-level systems required for a complete Pokemon-style game, not just the battle system. I expect systems such as overworld/map navigation, player and NPC movement, story progression, world events, blockers and unlocks, creature data, stats, moves, items, battles, save/load, party management, inventory, menus, and scripting. Do not be limited by my examples; correct my assumptions and choose the system breakdown that best matches how a real game like this is built.

For each major system, teach it in layers:

1. Name the system and explain its job in concrete code terms.
2. List the major subsystems inside it.
3. For each subsystem, list its smaller subsystems or moving parts.
4. Continue decomposing until further explanation would mostly be reading the code line by line.
5. Identify the FireRed source files, functions, structs, constants, data tables, scripts, or globals where that system is actually implemented.
6. Explain the runtime flow: what calls what, what data gets read or written, and how control moves through the system during real gameplay.
7. Show a small amount of representative code or pseudocode when it helps connect the architecture to the source.
8. Explain what a minimal clone version of that system would need to implement.

Do not stop at vague abstractions. If you say "overworld system," break it down into map loading, tile behavior, collision, object events, NPC movement, script triggers, warps, camera behavior, player input, flags, variables, and whatever else FireRed actually uses. If you say "battle system," break it down into battle setup, turn order, move selection, damage calculation, status effects, battle scripts, AI, party data, move data, animation hooks, win/loss handling, and the specific FireRed code that performs those jobs.

Avoid lessons that only describe concepts like "game feel," "player engagement," or "content pipeline" unless you immediately connect them to concrete systems and source code. I am not asking for a general design lecture. I am asking: if I were building this myself, what code systems would I actually need, how are they decomposed, where do they live in FireRed, and how do they run?

Use Pokemon FireRed as the main source of truth because it is a complete game. Help me understand its codebase technically, so that by the end of the course I can describe the project clearly: these are the main systems, these are their subsystems, this is the actual code behind them, and this is how they fit together.

Use Pokemon Showdown only as a secondary reference, mainly to clarify battle mechanics or data-driven battle modeling where FireRed is harder to learn from. Do not let Showdown replace FireRed as the main example, because FireRed represents the complete game structure I want to understand.
