Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

60 Zeilen
2.1KB

  1. <# Verifies the generated C64 tile world captured by tools/smoke.ps1. #>
  2. [CmdletBinding()]
  3. param(
  4. [string]$Path = (Join-Path $PSScriptRoot '../build/smoke/c64/world.bin'),
  5. [switch]$ShowMap
  6. )
  7. $ErrorActionPreference = 'Stop'
  8. $width = 80
  9. $height = 50
  10. $tiles = [IO.File]::ReadAllBytes((Resolve-Path -LiteralPath $Path).Path)
  11. if ($tiles.Length -ne $width * $height) {
  12. throw "Expected an 80x50 tile map, got $($tiles.Length) bytes."
  13. }
  14. # Tile IDs from src/tiles.inc. M1.2 uses straight roads and four-way crossings.
  15. $roadH = 13
  16. $roadV = 14
  17. $roadCross = 19
  18. $glyphs = '.gT#~~~~~~~~~-|+++++'
  19. $counts = [int[]]::new($glyphs.Length)
  20. foreach ($tile in $tiles) {
  21. if ($tile -ge $glyphs.Length) { throw "Invalid terrain tile ID $tile." }
  22. $counts[$tile]++
  23. }
  24. foreach ($tile in 0..12) {
  25. if ($counts[$tile] -eq 0) { throw "Missing terrain tile ID $tile." }
  26. }
  27. # Find the road columns and rows from their endpoints on the world edges.
  28. $roadColumns = @(0..($width - 1) | Where-Object { $tiles[$_] -eq $roadV })
  29. $roadRows = @(0..($height - 1) | Where-Object { $tiles[($_ * $width)] -eq $roadH })
  30. if ($roadColumns.Count -ne 2 -or $roadRows.Count -ne 2) {
  31. throw "Expected two east-west and two north-south roads."
  32. }
  33. for ($y = 0; $y -lt $height; $y++) {
  34. for ($x = 0; $x -lt $width; $x++) {
  35. $tile = $tiles[$y * $width + $x]
  36. $horizontal = $y -in $roadRows
  37. $vertical = $x -in $roadColumns
  38. if ($horizontal -or $vertical) {
  39. $expected = if ($horizontal -and $vertical) { $roadCross }
  40. elseif ($horizontal) { $roadH }
  41. else { $roadV }
  42. if ($tile -ne $expected) {
  43. throw "Broken road at ($x,$y): expected tile $expected, got $tile."
  44. }
  45. } elseif ($tile -ge $roadH) {
  46. throw "Disconnected road tile at ($x,$y)."
  47. }
  48. }
  49. if ($ShowMap) {
  50. $start = $y * $width
  51. -join ($tiles[$start..($start + $width - 1)] | ForEach-Object { $glyphs[$_] })
  52. }
  53. }
  54. Write-Output '[PASS] 80x50 world has all terrain types and four connected road crossings.'

Powered by TurnKey Linux.