pokershell blackboard

#id enumeration: /data/map_header_banks.asm ($mapname) /maps/$mapname.blk /data/mapHeaders/$mapname.asm /data/mapObjects/$mapname.asm /text/maps/$mapname.asm /scripts/$mapname.asm
map [MAPNAME] : summarizes MAPNAME data mapdata MAPNAME [data]: reads/writes map block data mapheaders MAPNAME [-t[ileset] [TILESET]] [-d[imensions] [(X,Y)]] : reads/writes map header info, excluding connections (handled by mapconnections) and Block/Text/Script/Object associations (the constants are assumed to share the mapname) mapconnections MAPNAME [-d[irections] [DIRECTIONS]] : Uncertainty. Possibly requires a list of map connection objects. mapobjects MAPNAME [-b[order] [BORDER]] [-w[arps] [WARPS]] [-s[igns] [SIGNS]] [-o[bjects] [OBJECTS]] : Read/write object data of a map. All arguments are lists of lists of the corresponding data
maptext MAPNAME [[-t[ext]] TEXT] : Read/writes text definitions for the map. Text in the disassembly is easy enough to read as a normal file, and will be used like a normal string. mapscript MAPNAME [[-s[cript]] SCRIPT] : Similar. All that can be done with the script is to treat it as text. Handle-Input ARGS : If ARGS is a filename, returns Get-Content ARGS, else if ARGS is an internet address, return Invoke-WebRequest ARGS, otherwise returns ARGS
mapmusic MAPNAME [[-m[usic] MUSIC] : get/set the music that plays on a particular map /constants/map_constants.asm : contains map width and height /constants/tilesets.asm : list of tilesets. /data/dungeon_tilesets.asm : list of dungeon tilesets. /data/map_header_banks.asm : don't touch? list of banks for map header data /data/map_header_pointers.asm : don't touch? list of pointers for map header data (order matters) /data/map_songs.asm : music played on the map, same order as the other pointer lists... "db CONST, BANK(Music_Bank)" /data/warp_tile_ids.asm : tiles defined as warps? /data/special_warps.asm /data/town_map_entries.asm /data/wild_mons.asm : associate wild data with map
#note the undeclared (read: unknown) types of various variables $basepath = $PWD.Path.substring(0,$PWD.Path.LastIndexOf("\pokered")+8) function map { param([Parameter(Mandatory=$False,Position=0)][String]$MapName, [Alias("b","p","path")][Parameter(Mandatory=$False)][String]$basepath) [String]$return = "" if (-not $MapName) { if (-not $MapDict) { # Create-MapDict } $return += "Known Maps:`n" $MapDict | ForEach-Object {$return += $_+"`n"} return $return } if ($basepath) { $Global:basepath = Convert-Path ($basepath -replace "[`/\\]`$","") } if ($MapDict -cnotcontains $MapName) { throw "Unknown map `"$MapName`"" } #Summarize data for map $MapName $headers = mapheaders $MapName $objects = mapobjects $MapName [String]$music = mapmusic $MapName $connections = mapconnections $MapName [Boolean]$wildmon = $MapDict.Item($MapName).WildMons -ne "NoMons" $return += $MapName+": " $return += $headers.x+"x"+$headers.y+" blocks ("+$headers.x*2+"x"+$headers.y+")`n" $return += "Tileset #"+$headers.tileset+", "+$objects.objects.length+" NPCs." $return += "Wild Pokemon: "+$wildmon+"`n" $return += "Music: "+$music $return += $mapdata+"`n" $return += "Exits: `n" $connections.Keys | ForEach-Object {$return += $_+" : "+$connections.Item($_).connectingMap+"`n"} return $return }
(desired 'map' output) ExampleMap: 3x3 blocks (6x6) Tileset: OVERWORLD, 0 NPCs. Wild Pokemon: False Music: Music_SilphCo 1, 1, 1, 1, 0, 1, 1, 1, 1 Exits: NORTH : ROUTE_1 EAST : LAVENDER_TOWN
mapheaders : cannot singular read elements by empty flags. Returns a hashtable with tileset, width, and height regardless of writing, after any writing operations.
LavenderTown_h: db OVERWORLD ; tileset db LAVENDER_TOWN_HEIGHT, LAVENDER_TOWN_WIDTH ; dimensions (y, x) dw LavenderTownBlocks, LavenderTownTextPointers, LavenderTownScript ; blocks, texts, scripts db NORTH | SOUTH | WEST ; connections NORTH_MAP_CONNECTION LAVENDER_TOWN, ROUTE_10, 0, 0, Route10Blocks SOUTH_MAP_CONNECTION LAVENDER_TOWN, ROUTE_12, 0, 0, Route12Blocks, 1 WEST_MAP_CONNECTION LAVENDER_TOWN, ROUTE_8, 0, 0, Route8Blocks dw LavenderTownObject ; objects
NORTH_MAP_CONNECTION LAVENDER_TOWN, ROUTE_10, 0, 0, Route10Blocks DIRECTIONCOMMAND THISMAP, MAP, XOFS, YOFS, BLOCKS[, ADDTHREE]
(map objects trainer:) object SPRITE_BUG_CATCHER, $c, $10, STAY, RIGHT, $2, OPP_YOUNGSTER, $3 object SPRITE_ID, X, Y, WALK/FACE(STAY), DIRECTION/range, Text ID, Trainer Class, Trainer Number (refer to data/trainerparties) scripts/.asm ld hl, TrainerHeader0 in init if first trainer Route3TrainerHeader0: dbEventFlagBit EVENT_BEAT_ROUTE_3_TRAINER_0 db ($2 .asm:) _Route3BattleText1:: text "Hey! I met you in" line "VIRIDIAN FOREST!" done _Route3EndBattleText1:: text "You" line "beat me again!" prompt _Route3AfterBattleText1:: text "There are other" line "kinds of #MON" cont "than those found" cont "in the forest!" done
(map objects trainer:) object SPRITE_BUG_CATCHER, $c, $10, STAY, RIGHT, $2, OPP_YOUNGSTER, $3 object SPRITE_ID, X, Y, WALK/FACE(STAY), DIRECTION/range, Text ID, Trainer Class, Trainer Number (refer to data/trainerparties) scripts/<map>.asm ld hl, <Map>TrainerHeader0 in init if first trainer Route3TrainerHeader0: dbEventFlagBit EVENT_BEAT_ROUTE_3_TRAINER_0 db ($2 << 4) ; trainer's view range. dwEventFlagAddress EVENT_BEAT_ROUTE_3_TRAINER_0 dw Route3BattleText1 ; TextBeforeBattle dw Route3AfterBattleText1 ; TextAfterBattle dw Route3EndBattleText1 ; TextEndBattle dw Route3EndBattleText1 ; TextEndBattle ;for some reason these text script pointers are one ahead of the header numbering Route3BattleText1: TX_FAR _Route3BattleText1 db "@" Route3EndBattleText1: TX_FAR _Route3EndBattleText1 db "@" Route3AfterBattleText1: TX_FAR _Route3AfterBattleText1 db "@" (text/maps/<map>.asm:) _Route3BattleText1:: text "Hey! I met you in" line "VIRIDIAN FOREST!" done _Route3EndBattleText1:: text "You" line "beat me again!" prompt _Route3AfterBattleText1:: text "There are other" line "kinds of #MON" cont "than those found" cont "in the forest!" done
>>11942 $basepath = $PWD.Path.substring(0,$PWD.Path.LastIndexOf("\pokered")+8) Set-Variable $POKERED_TILESET -option Constant -value 1 Set-Variable $POKERED_DIMENSIONS -option Constant -value 2 Set-Variable $POKERED_DEFS -option Constant -value 3 Set-Variable $POKERED_CONNECTIONS -option Constant -value 4 Set-Variable $POKERED_OBJECTS -option Constant -value 5 function map { param([Parameter(Mandatory=$False,Position=0)][String]$MapName, [Alias("b","p","path")][Parameter(Mandatory=$False)][String]$basepath) [String]$return = "" if (-not $MapName) { if (-not $MapDict) { # Create-MapDict } $return += "Known Maps:`n" $MapDict | ForEach-Object {$return += $_+"`n"} return $return } if ($basepath) { $Global:basepath = Convert-Path ($basepath -replace "[`/\\]`$","") } if ($MapDict -cnotcontains $MapName) { throw "Unknown map `"$MapName`"" } #Summarize data for map $MapName $headers = mapheaders $MapName $objects = mapobjects $MapName [String]$music = mapmusic $MapName $connections = mapconnections $MapName [Boolean]$wildmon = $MapDict.Item($MapName).WildMons -ne "NoMons" $return += $MapName+": " $return += $headers.width+"x"+$headers.height+" blocks ("+$headers.width*2+"x"+$headers.height+")`n" $return += "Tileset #"+$headers.tileset+", "+$objects.objects.length+" NPCs. " $return += "Wild Pokemon: $wildmon`n" $return += "Music: $music`n" $return += "$mapdata`n" $return += "Exits: `n" $connections.Keys | ForEach-Object {$return += $_+" : "+$connections.Item($_).connectingMap+"`n"} return $return } # "$basepath/data/mapHeaders/$MapName.asm" function mapheaders { param([Parameter(Mandatory=$True,Position=0)][String]$MapName, [Alias("t")][Parameter(Mandatory=$False)][String]$tileset, [Alias("d")][Parameter(Mandatory=$False)][Int[]]$dimensions) $dim = Get-MapDimensions $MapName $return = @{tileset = Get-MapTileset $MapName;width=$dim[1];height=$dim[0]} } # function mapconnections { param([Parameter(Mandatory=$True,Position=0)][String]$MapName, [Alias("d")][Parameter(Mandatory=$False)][String]$directions) } # function mapobjects { param([Parameter(Mandatory=$True,Position=0)][String]$MapName, [Alias("b")][Parameter(Mandatory=$False)][Int]$border, [Alias("w")][Parameter(Mandatory=$False)][Object[]]$warps, [Alias("s")][Parameter(Mandatory=$False)][Object[]]$signs, [Alias("o")][Parameter(Mandatory=$False)][Object[]]$objects) } function Get-ASMDataLine { param([Parameter(Mandatory=$True,Position=0)][String]$file, [Parameter(Mandatory=$True)][Int]$index) return ((Get-Content "$file") -replace ";.*$", "" -split "db|dw")[$index] } function Get-MapTileset { param([Parameter(Mandatory=$True,Position=0)][String]$MapName) (Get-ASMDataLine "$basepath/data/mapHeaders/$MapName.asm" $POKERED_TILESET) -match '(\w+)' return $Matches[0] } function Get-MapDimensions { param([Parameter(Mandatory=$True,Position=0)][String]$MapName) $mc = ((Get-Content "$basepath/constants/map_constants.asm").Substring(68) -replace ";.*`n","" -split "mapconst ") -match $MapName $mc -match "(\d)" return $Matches #weirdo dict: Height,Width } function Get-MapConnections { param([Parameter(Mandatory=$True,Position=0)][String]$MapName) $connection = Get-ASMDataLine "$basepath/data/mapHeaders/$MapName.asm" $POKERED_CONNECTIONS if ($connection.Trim().Equals('$00')) { return Create-MapConnectionsTable } $connection -split "`n" $directions = ([regex]::Matches($connection[0], "\w+"))[1..4] #omit "db" for ($i = 0; $i -lt $directions.length; $i++) { $ConnectionObject = ConvertFrom-Csv -InputObject ($connection[$i] -creplace ".*_MAP_CONNECTION","") -Header currentmap,connectedmap,connectionxoffset,connectionoffset,connectedblocks,addthree Set-Variable $directions[$i] -Value $ConnectionObject } return Create-MapConnectionsTable -North $NORTH -South $SOUTH -East $EAST -West $WEST } function Create-MapConnectionsTable { param([Parameter(Mandatory=$False,Position=0)][String]$North=$null, [Parameter(Mandatory=$False,Position=1)][String]$South=$null, [Parameter(Mandatory=$False,Position=2)][String]$East=$null, [Parameter(Mandatory=$False,Position=3)][String]$West=$null) return @{north = $North; south = $South; east = $East; west = $West} }
[X]mapheaders GET working [X](mapheaders chain)
[X]mapconnections GET working [X](mapconnections chain)
Now on Github. https://github.com/PatheticFish/pokeredmaps