User File #68650558383198335

Upload All User Files

#68650558383198335 - Castlevania Adventure object viewer v1.3

CVA_object_view_v1.3.lua
323 downloads
Uploaded 1/8/2021 4:19 PM by ThunderAxe31 (see all 111)
This Lua script displays when and what objects spawn, as well as some timers related to the spawning timing of candles and enemies. Work for all versions of Castevania Adventure, both GB and GBC.
--Castlevania Adventure object viewer v1.3 by ThunderAxe31

local function reset_padding()
	client.SetGameExtraPadding(0, 0, 0, 0)
end
event.onexit(reset_padding)
client.SetGameExtraPadding(0, 0, 120, 0)

local spawn_timer  = 0xC009

local memory_block = 0x20

local memory_player       = 0xC500
local memory_candle_drops = 0xC580
local memory_enemies      = 0xC600
local memory_enemies_att  = 0xC6A0
local memory_level        = 0xC700
local memory_hud          = 0xC7C0

local slots_player        = 4
local slots_candle_drops  = 4
local slots_enemies       = 5
local slots_enemies_att   = 3
local slots_level         = 6
local slots_hud           = 2

local offset_type = 0x14
local offset_x    = 0x0B
local offset_y    = 0x12

local current_time = 0
local objects_list_1 = ""
local objects_list_2 = ""
local color = "white"

local spawn_candle = ""
local spawn_enemy  = ""
local spawn_level  = ""

local routine_candle  = 0x305B
local routine_enemy   = 0x5607
local routine_enemy_2 = 0x7134

local checksum = memory.read_u8(0x014D) --some addresses are different for the version Konami Collection Vol.1
if checksum == 123 or checksum == 113 then
	spawn_timer     = 0xC109
	routine_candle  = 0x66AF
	routine_enemy   = 0x6B57
	routine_enemy_2 = 0x6DFA
end

local function set_candle()
	spawn_candle = "*"
end
local function set_enemy()
	spawn_enemy  = "*"
end
local function set_enemy_2()
	spawn_enemy  = "**"
end
--local function set_level()
--	spawn_level  = "*"
--end

event.onmemoryexecute(set_candle,  routine_candle)
event.onmemoryexecute(set_enemy,   routine_enemy)
event.onmemoryexecute(set_enemy_2, routine_enemy_2)
--event.onmemoryexecute(set_level,   0x)

while true do
	objects_list_1 = "Type|  X |  Y \n\nPlayer\n"
	for i=0, slots_player-1 do
		if memory.read_u8(memory_player +i*memory_block) == 128 then
			objects_list_1 = objects_list_1 .. string.format(" %3u", memory.read_u8(memory_player +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_player +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_player +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_1 = objects_list_1 .. "  - |  - |  - \n"
		end
	end
	objects_list_1 = objects_list_1 .. "\nCandle/Drops" .. spawn_candle .. "\n"
	for i=0, slots_candle_drops-1 do
		if memory.read_u8(memory_candle_drops +i*memory_block) == 128 then
			objects_list_1 = objects_list_1 .. string.format(" %3u", memory.read_u8(memory_candle_drops +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_candle_drops +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_candle_drops +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_1 = objects_list_1 .. "  - |  - |  - \n"
		end
	end
	objects_list_1 = objects_list_1 .. "\nEnemies" .. spawn_enemy .. "\n"
	for i=0, slots_enemies-1 do
		if memory.read_u8(memory_enemies +i*memory_block) == 128 then
			objects_list_1 = objects_list_1 .. string.format(" %3u", memory.read_u8(memory_enemies +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_enemies +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_enemies +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_1 = objects_list_1 .. "  - |  - |  - \n"
		end
	end
	
	objects_list_2 = "Type|  X |  Y \n\nEnemy attacks\n"
	for i=0, slots_enemies_att-1 do
		if memory.read_u8(memory_enemies_att +i*memory_block) == 128 then
			objects_list_2 = objects_list_2 .. string.format(" %3u", memory.read_u8(memory_enemies_att +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_enemies_att +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_enemies_att +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_2 = objects_list_2 .. "  - |  - |  - \n"
		end
	end
	objects_list_2 = objects_list_2 .. "\nLevel objects" .. spawn_level .. "\n"
	for i=0, slots_level-1 do
		if memory.read_u8(memory_level +i*memory_block) == 128 then
			objects_list_2 = objects_list_2 .. string.format(" %3u", memory.read_u8(memory_level +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_level +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_level +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_2 = objects_list_2 .. "  - |  - |  - \n"
		end
	end
	objects_list_2 = objects_list_2 .. "\nHP display\n"
	for i=0, slots_hud-1 do
		if memory.read_u8(memory_hud +i*memory_block) == 128 then
			objects_list_2 = objects_list_2 .. string.format(" %3u", memory.read_u8(memory_hud +i*memory_block +offset_type)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_hud +i*memory_block    +offset_x)) ..
			"| " .. string.format("%3u", memory.read_u8(memory_hud +i*memory_block    +offset_y)) ..
			"\n"
		else
			objects_list_2 = objects_list_2 .. "  - |  - |  - \n"
		end
	end
	
	gui.pixelText(160, 0, objects_list_1)
	gui.pixelText(223, 0, objects_list_2)
	
	
	current_time = memory.read_u8(spawn_timer)
	gui.pixelText(223, 130, "SPAWNING TIMERS\n  " ..
--	3-(current_time%4-1)%4 .. " | " .. --currently unknown timer
	7-(current_time%8-2)%8 .. " | " .. --candle spawn timer
	7-(current_time%8-5)%8 .. " | " .. --enemy spawn timer
--	string.format("%2u", 15-(current_time%16-1)%16) .. " | " .. --enemy alternate type spawn timer
--	string.format("%2u", 31-(current_time%32-1)%32) .. " | " .. --currently unknown timer
	string.format("%3u", current_time)) 
	
	spawn_candle = ""
	spawn_enemy  = ""
	spawn_level  = ""
	
	emu.frameadvance()
end