Adopted Span for the setTiles wrapper in the library to adapt to Swift 6.4.
This commit is contained in:
@@ -24,6 +24,7 @@ enum Mock {
|
||||
nonisolated(unsafe) static let soundEffectAPI = UnsafeMutablePointer<playdate_sound_effect>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let lfoAPI = UnsafeMutablePointer<playdate_sound_lfo>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let delayLineAPI = UnsafeMutablePointer<playdate_sound_effect_delayline>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let tilemapAPI = UnsafeMutablePointer<playdate_tilemap>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let fileAPI = UnsafeMutablePointer<playdate_file>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let jsonAPI = UnsafeMutablePointer<playdate_json>.allocate(capacity: 1)
|
||||
nonisolated(unsafe) static let apiStruct = UnsafeMutablePointer<PlaydateAPI>.allocate(capacity: 1)
|
||||
@@ -38,6 +39,9 @@ enum Mock {
|
||||
/// Caps the bytes a file read returns (0 = end of file, negative =
|
||||
/// error); `nil` fills the whole request.
|
||||
nonisolated(unsafe) static var fileReadLimit: Int32?
|
||||
/// The index buffer and count last handed to `setTiles`.
|
||||
nonisolated(unsafe) static var tilesPointer: UnsafeMutablePointer<UInt16>?
|
||||
nonisolated(unsafe) static var tilesCount: Int32 = 0
|
||||
/// Userdata stored per sprite / menu item, as the OS would keep it.
|
||||
nonisolated(unsafe) static var spriteUserdata: [OpaquePointer: UnsafeMutableRawPointer] = [:]
|
||||
nonisolated(unsafe) static var menuUserdata: [OpaquePointer: UnsafeMutableRawPointer] = [:]
|
||||
@@ -87,6 +91,8 @@ enum Mock {
|
||||
buttonState = (0, 0, 0)
|
||||
patternBytes = []
|
||||
fileReadLimit = nil
|
||||
tilesPointer = nil
|
||||
tilesCount = 0
|
||||
spriteUserdata = [:]
|
||||
menuUserdata = [:]
|
||||
menuCallback = nil
|
||||
@@ -174,6 +180,19 @@ enum Mock {
|
||||
|
||||
private static func installGraphics() {
|
||||
gfxAPI.initialize(to: playdate_graphics())
|
||||
tilemapAPI.initialize(to: playdate_tilemap())
|
||||
gfxAPI.pointee.tilemap = UnsafePointer(tilemapAPI)
|
||||
|
||||
tilemapAPI.pointee.newTilemap = {
|
||||
Mock.record("newTilemap")
|
||||
return Mock.fakePointer()
|
||||
}
|
||||
tilemapAPI.pointee.freeTilemap = { _ in Mock.record("freeTilemap") }
|
||||
tilemapAPI.pointee.setTiles = { _, indexes, count, rowWidth in
|
||||
Mock.record("setTiles(\(count),\(rowWidth))")
|
||||
Mock.tilesPointer = indexes
|
||||
Mock.tilesCount = count
|
||||
}
|
||||
|
||||
gfxAPI.pointee.fillRect = { x, y, width, height, color in
|
||||
if color > 3, let pattern = UnsafeRawPointer(bitPattern: color) {
|
||||
|
||||
Reference in New Issue
Block a user