-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
136 lines (106 loc) · 3.68 KB
/
Copy pathmain.py
File metadata and controls
136 lines (106 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
"""
main.py — Pokemon FireRed mGBA Tools
CLI menu logic. Called from the root ``main.py`` entry point.
Options:
1) Memory Scan — find text/bytes in GBA memory
2) Inject Test — replace NPC dialog text in-game
3) FP Collector — collect & classify dialog fingerprints
0) Exit
"""
from __future__ import annotations
import logging
import sys
from .config import DEFAULT_HOST, DEFAULT_PORT
def _configure_logging() -> None:
from .config import LOG_LEVEL
logging.basicConfig(
level=getattr(logging, LOG_LEVEL, logging.INFO),
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
datefmt="%H:%M:%S",
)
def print_banner() -> None:
print()
print("=" * 56)
print(" Pokemon FireRed — mGBA Tools (v4.0)")
print("=" * 56)
print()
print(" Select a mode:")
print()
print(" [1] Memory Scan")
print(" Scan GBA RAM for Pokemon-encoded text.")
print(" Lua: lua/memory_scan_bridge.lua")
print()
print(" [2] Inject Test")
print(" Replace NPC dialog text with a test message.")
print(" Lua: lua/dialog_injector.lua")
print()
print(" [3] Fingerprint Collector")
print(" Collect & classify dialog fingerprints by zone.")
print(" Lua: lua/fingerprint_collector.lua")
print()
print(" [4] LLM Inject")
print(" Replace NPC dialog with Gemini-generated text.")
print(" Lua: lua/dialog_injector.lua")
print()
print(" [0] Exit")
print()
print("-" * 56)
def get_connection_params() -> tuple[str, int]:
"""Ask for host/port or use defaults."""
host = input(f" Host [{DEFAULT_HOST}]: ").strip() or DEFAULT_HOST
port_str = input(f" Port [{DEFAULT_PORT}]: ").strip() or str(DEFAULT_PORT)
try:
port = int(port_str)
except ValueError:
print(f" Invalid port '{port_str}', using {DEFAULT_PORT}")
port = DEFAULT_PORT
return host, port
def run_memory_scan() -> None:
print("\n--- Memory Scan Mode ---\n")
host, port = get_connection_params()
from .apps.memory_scan_app import run
run(host=host, port=port)
def run_inject_test() -> None:
print("\n--- Inject Test Mode ---\n")
host, port = get_connection_params()
msg = input(" Test message [default]: ").strip()
if not msg:
msg = "Hola Carlos, bienvenido a esta nueva aventura."
from .apps.inject_test_app import run
run(host=host, port=port, test_message=msg)
def run_fingerprint_collector() -> None:
print("\n--- Fingerprint Collector Mode ---\n")
host, port = get_connection_params()
from .apps.fingerprint_collector_app import run
run(host=host, port=port)
def run_llm_inject() -> None:
print("\n--- LLM Inject Mode ---\n")
host, port = get_connection_params()
use_llm_input = input(" Use Gemini LLM? [Y/n]: ").strip().lower()
use_llm = use_llm_input != "n"
from .apps.llm_inject_app import run
run(host=host, port=port, use_llm=use_llm)
def main() -> None:
_configure_logging()
while True:
print_banner()
try:
choice = input(" >> ").strip()
except (EOFError, KeyboardInterrupt):
print("\nBye.")
sys.exit(0)
if choice == "0":
print("\nBye.")
sys.exit(0)
elif choice == "1":
run_memory_scan()
elif choice == "2":
run_inject_test()
elif choice == "3":
run_fingerprint_collector()
elif choice == "4":
run_llm_inject()
else:
print(f"\n Invalid option: {choice!r}. Enter 0\u20134.\n")
if __name__ == "__main__":
main()