Standardize memory addresses across versions
This commit is contained in:
parent
40d8f25a6d
commit
4e58eb7a94
|
@ -206,7 +206,7 @@ function movePP(name)
|
|||
if not midx then
|
||||
return 0
|
||||
end
|
||||
return memory.raw(0xD02C + midx)
|
||||
return memory.raw(0x102C + midx)
|
||||
end
|
||||
battle.pp = movePP
|
||||
|
||||
|
|
|
@ -129,16 +129,16 @@ local function getMoves(who)--Get the moveset of us [0] or them [1]
|
|||
local moves = {}
|
||||
local base
|
||||
if who == 1 then
|
||||
base = 0xCFED
|
||||
base = 0x0FED
|
||||
else
|
||||
base = 0xD01C
|
||||
base = 0x101C
|
||||
end
|
||||
for idx=0, 3 do
|
||||
local val = memory.raw(base + idx)
|
||||
if val > 0 then
|
||||
local moveTable = movelist.get(val)
|
||||
if who == 0 then
|
||||
moveTable.pp = memory.raw(0xD02D + idx)
|
||||
moveTable.pp = memory.raw(0x102D + idx)
|
||||
end
|
||||
moves[idx + 1] = moveTable
|
||||
end
|
||||
|
@ -287,7 +287,7 @@ end
|
|||
combat.activePokemon = activePokemon
|
||||
|
||||
local function isSleeping()
|
||||
return memory.raw(0xD16F) > 1
|
||||
return memory.raw(0x116F) > 1
|
||||
end
|
||||
combat.isSleeping = isSleeping
|
||||
|
||||
|
|
4
main.lua
4
main.lua
|
@ -210,8 +210,8 @@ while true do
|
|||
end
|
||||
|
||||
if STREAMING_MODE then
|
||||
local newSecs = memory.raw(0xDA44)
|
||||
if newSecs ~= oldSecs and (newSecs > 0 or memory.raw(0xDA45) > 0) then
|
||||
local newSecs = memory.raw(0x1A44)
|
||||
if newSecs ~= oldSecs and (newSecs > 0 or memory.raw(0x1A45) > 0) then
|
||||
bridge.time(utils.elapsedTime())
|
||||
oldSecs = newSecs
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ local items = {
|
|||
rock_slide = 248,
|
||||
}
|
||||
|
||||
local ITEM_BASE = 0xD31E
|
||||
local ITEM_BASE = 0x131E
|
||||
|
||||
-- Data
|
||||
|
||||
|
@ -125,7 +125,7 @@ function inventory.teach(item, poke, replaceIdx, altPoke)
|
|||
end
|
||||
|
||||
function inventory.isFull()
|
||||
return memory.raw(0xD345) > 0
|
||||
return memory.raw(0x1345) > 0
|
||||
end
|
||||
|
||||
function inventory.use(item, poke, midfight)
|
||||
|
|
|
@ -85,7 +85,7 @@ local data = {
|
|||
}
|
||||
|
||||
local function getAddress(index)
|
||||
return 0xD16B + index * 0x2C
|
||||
return 0x116B + index * 0x2C
|
||||
end
|
||||
|
||||
local function index(index, offset)
|
||||
|
@ -125,7 +125,7 @@ pokemon.indexOf = indexOf
|
|||
function pokemon.battleMove(name)
|
||||
local mid = moveList[name]
|
||||
for i=1,4 do
|
||||
if mid == memory.raw(0xD01B + i) then
|
||||
if mid == memory.raw(0x101B + i) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
|
@ -233,7 +233,7 @@ function pokemon.isEvolving()
|
|||
end
|
||||
|
||||
function pokemon.getExp()
|
||||
return memory.raw(0xD17A) * 256 + memory.raw(0xD17B)
|
||||
return memory.raw(0x117A) * 256 + memory.raw(0x117B)
|
||||
end
|
||||
|
||||
function pokemon.inRedBar()
|
||||
|
|
|
@ -30,19 +30,19 @@ local memoryNames = {
|
|||
main = 0x1FF5,
|
||||
},
|
||||
player = {
|
||||
name = 0xD158,
|
||||
name2 = 0xD159,
|
||||
name = 0x1158,
|
||||
name2 = 0x1159,
|
||||
moving = 0x1528,
|
||||
x = 0xD362,
|
||||
y = 0xD361,
|
||||
x = 0x1362,
|
||||
y = 0x1361,
|
||||
facing = 0x152A,
|
||||
repel = 0x10DB,
|
||||
party_size = 0xD163,
|
||||
party_size = 0x1163,
|
||||
},
|
||||
game = {
|
||||
map = 0xD35E,
|
||||
frames = 0xDA45,
|
||||
battle = 0xD057,
|
||||
map = 0x135E,
|
||||
frames = 0x1A45,
|
||||
battle = 0x1057,
|
||||
textbox = 0x0FC4,
|
||||
},
|
||||
shop = {
|
||||
|
@ -52,9 +52,9 @@ local memoryNames = {
|
|||
trashcans = 0x1773,
|
||||
},
|
||||
pokemon = {
|
||||
exp1 = 0xD179,
|
||||
exp2 = 0xD17A,
|
||||
exp3 = 0xD17B,
|
||||
exp1 = 0x1179,
|
||||
exp2 = 0x117A,
|
||||
exp3 = 0x117B,
|
||||
},
|
||||
battle = {
|
||||
turns = 0x1067,
|
||||
|
@ -69,44 +69,49 @@ local memoryNames = {
|
|||
critical = 0x105E,
|
||||
|
||||
opponent_bide = 0x106F,
|
||||
opponent_id = 0xCFE5,
|
||||
opponent_level = 0xCFF3,
|
||||
opponent_type1 = 0xCFEA,
|
||||
opponent_type2 = 0xCFEB,
|
||||
opponent_id = 0x0FE5,
|
||||
opponent_level = 0x0FF3,
|
||||
opponent_type1 = 0x0FEA,
|
||||
opponent_type2 = 0x0FEB,
|
||||
|
||||
our_id = 0xD014,
|
||||
our_status = 0xD018,
|
||||
our_level = 0xD022,
|
||||
our_type1 = 0xD019,
|
||||
our_type2 = 0xD01A,
|
||||
our_id = 0x1014,
|
||||
our_status = 0x1018,
|
||||
our_level = 0x1022,
|
||||
our_type1 = 0x1019,
|
||||
our_type2 = 0x101A,
|
||||
},
|
||||
}
|
||||
|
||||
local doubleNames = {
|
||||
pokemon = {
|
||||
attack = 0xD17E,
|
||||
defense = 0xD181,
|
||||
speed = 0xD183,
|
||||
special = 0xD185,
|
||||
attack = 0x117E,
|
||||
defense = 0x1181,
|
||||
speed = 0x1183,
|
||||
special = 0x1185,
|
||||
},
|
||||
battle = {
|
||||
opponent_hp = 0xCFE6,
|
||||
opponent_max_hp = 0xCFF4,
|
||||
opponent_attack = 0xCFF6,
|
||||
opponent_defense = 0xCFF8,
|
||||
opponent_speed = 0xCFFA,
|
||||
opponent_special = 0xCFFC,
|
||||
opponent_hp = 0x0FE6,
|
||||
opponent_max_hp = 0x0FF4,
|
||||
opponent_attack = 0x0FF6,
|
||||
opponent_defense = 0x0FF8,
|
||||
opponent_speed = 0x0FFA,
|
||||
opponent_special = 0x0FFC,
|
||||
|
||||
our_hp = 0xD015,
|
||||
our_max_hp = 0xD023,
|
||||
our_attack = 0xD025,
|
||||
our_defense = 0xD027,
|
||||
our_speed = 0xD029,
|
||||
our_special = 0xD02B,
|
||||
our_hp = 0x1015,
|
||||
our_max_hp = 0x1023,
|
||||
our_attack = 0x1025,
|
||||
our_defense = 0x1027,
|
||||
our_speed = 0x1029,
|
||||
our_special = 0x102B,
|
||||
},
|
||||
}
|
||||
|
||||
local function raw(address)
|
||||
local yellow = YELLOW
|
||||
|
||||
local function raw(address, forYellow)
|
||||
if yellow and not forYellow and address > 0x0F12 and address < 0x1F00 then
|
||||
address = address - 1
|
||||
end
|
||||
return memory.readbyte(address)
|
||||
end
|
||||
Memory.raw = raw
|
||||
|
@ -130,12 +135,12 @@ function Memory.double(section, key)
|
|||
return raw(first) + raw(first + 1)
|
||||
end
|
||||
|
||||
function Memory.value(section, key)
|
||||
function Memory.value(section, key, forYellow)
|
||||
local memoryAddress = memoryNames[section]
|
||||
if key then
|
||||
memoryAddress = memoryAddress[key]
|
||||
end
|
||||
return raw(memoryAddress)
|
||||
return raw(memoryAddress, forYellow)
|
||||
end
|
||||
|
||||
return Memory
|
||||
|
|
|
@ -3,7 +3,7 @@ local menu = {}
|
|||
local input = require "util.input"
|
||||
local memory = require "util.memory"
|
||||
|
||||
local YELLOW = GAME_NAME == "yellow"
|
||||
local yellow = GAME_NAME == "yellow"
|
||||
|
||||
local sliding = false
|
||||
|
||||
|
@ -139,13 +139,13 @@ end
|
|||
-- Options
|
||||
|
||||
function menu.setOption(name, desired)
|
||||
if YELLOW then
|
||||
if yellow then
|
||||
local rowFor = {
|
||||
text_speed = 0,
|
||||
battle_animation = 1,
|
||||
battle_style = 2
|
||||
}
|
||||
local currentRow = memory.raw(0x0D3D)
|
||||
local currentRow = memory.raw(0x0D3D, true)
|
||||
if menu.balance(currentRow, rowFor[name], true, false, true) then
|
||||
input.press("Left")
|
||||
end
|
||||
|
|
|
@ -3,17 +3,17 @@ local settings = {}
|
|||
local memory = require "util.memory"
|
||||
local menu = require "util.menu"
|
||||
|
||||
local YELLOW = GAME_NAME == "yellow"
|
||||
local yellow = YELLOW
|
||||
|
||||
local settings_menu
|
||||
if YELLOW then
|
||||
if yellow then
|
||||
settings_menu = 93
|
||||
else
|
||||
settings_menu = 94
|
||||
end
|
||||
|
||||
local desired = {}
|
||||
if YELLOW then
|
||||
if yellow then
|
||||
desired.text_speed = 1
|
||||
desired.battle_animation = 128
|
||||
desired.battle_style = 64
|
||||
|
@ -24,13 +24,13 @@ else
|
|||
end
|
||||
|
||||
local function isEnabled(name)
|
||||
if YELLOW then
|
||||
if yellow then
|
||||
local matching = {
|
||||
text_speed = 0xF,
|
||||
battle_animation = 128,
|
||||
battle_style = 64
|
||||
}
|
||||
local settingMask = memory.value("setting", "yellow_bitmask")
|
||||
local settingMask = memory.value("setting", "yellow_bitmask", true)
|
||||
return bit.band(settingMask, matching[name]) == desired[name]
|
||||
else
|
||||
return memory.value("setting", name) == desired[name]
|
||||
|
|
|
@ -67,9 +67,9 @@ end
|
|||
-- TIME
|
||||
|
||||
function utils.igt()
|
||||
local secs = memory.raw(0xDA44)
|
||||
local mins = memory.raw(0xDA43)
|
||||
local hours = memory.raw(0xDA41)
|
||||
local secs = memory.raw(0x1A44)
|
||||
local mins = memory.raw(0x1A43)
|
||||
local hours = memory.raw(0x1A41)
|
||||
return secs + mins * 60 + hours * 3600
|
||||
end
|
||||
|
||||
|
@ -85,30 +85,30 @@ function utils.timeSince(prevTime)
|
|||
local diff = currTime - prevTime
|
||||
local timeString
|
||||
if diff > 0 then
|
||||
local secs = diff % 60
|
||||
local mins = math.floor(diff / 60)
|
||||
local secs = mins % 60
|
||||
timeString = clockSegment(mins)..":"..clockSegment(secs)
|
||||
end
|
||||
return currTime, timeString
|
||||
end
|
||||
|
||||
function utils.elapsedTime()
|
||||
local secs = memory.raw(0xDA44)
|
||||
local secs = memory.raw(0x1A44)
|
||||
if secs < 10 then
|
||||
secs = "0"..secs
|
||||
end
|
||||
local mins = memory.raw(0xDA43)
|
||||
local mins = memory.raw(0x1A43)
|
||||
if mins < 10 then
|
||||
mins = "0"..mins
|
||||
end
|
||||
return memory.raw(0xDA41)..":"..mins..":"..secs
|
||||
return memory.raw(0x1A41)..":"..mins..":"..secs
|
||||
end
|
||||
|
||||
function utils.frames()
|
||||
local totalFrames = memory.raw(0xDA41) * 60
|
||||
totalFrames = (totalFrames + memory.raw(0xDA43)) * 60
|
||||
totalFrames = (totalFrames + memory.raw(0xDA44)) * 60
|
||||
return totalFrames + memory.raw(0xDA45)
|
||||
local totalFrames = memory.raw(0x1A41) * 60
|
||||
totalFrames = (totalFrames + memory.raw(0x1A43)) * 60
|
||||
totalFrames = (totalFrames + memory.raw(0x1A44)) * 60
|
||||
return totalFrames + memory.raw(0x1A45)
|
||||
end
|
||||
|
||||
return utils
|
||||
|
|
Loading…
Reference in New Issue