Skip to content

Instantly share code, notes, and snippets.

@matt-dray
Last active October 10, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-dray/efb38f717fe560bb37166d31eb532255 to your computer and use it in GitHub Desktop.
Save matt-dray/efb38f717fe560bb37166d31eb532255 to your computer and use it in GitHub Desktop.
Extract objects from locations in the pret/pokered disassembly (investigating base R v4.1)
files <- list.files(
"~/Desktop/pokered-master/data/maps/objects",
pattern = ".asm$",
full.names = TRUE
)
object_names <- gsub(".asm", "", basename(files))
locations <- lapply(files, function(x) readLines(x)) |>
setNames(object_names)
.get_objects <- function(lines = locations, loc = "PalletTown") {
warp <- lines[[loc]][grepl("\twarp", lines[[loc]])]
warp <- strsplit(gsub(" ", "", warp), ",")
warp <- unlist(lapply(warp, \(x) x[4]))
warp_df <- data.frame(location = loc, type = "warp", feature = warp)
obj <- lines[[loc]][grepl("\tobject", lines[[loc]])]
obj <- strsplit(gsub(",", "", obj), " ")
obj <- unlist(lapply(obj, \(x) x[2]))
obj_df <- data.frame(location = loc, type = "object", feature = obj)
rbind(warp_df, obj_df)
}
.get_objects()
.get_objects(loc = "AgathasRoom")
lapply(object_names[1:3], \(x) .get_objects(locations, x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment