Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor project for kotlin/native and multiplatform support
- Loading branch information
Showing
79 changed files
with
704 additions
and
408 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...ain/kotlin/com/felipecsl/android/Utils.kt → ...m/felipecsl/android/ExtensionFunctions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.felipecsl.knes | ||
|
||
external fun startConsole(cartridgeData: ByteArray) |
14 changes: 14 additions & 0 deletions
14
android/app/src/main/kotlin/com/felipecsl/knes/platform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.felipecsl.knes | ||
|
||
actual fun currentTimeMs(): Long { | ||
return System.currentTimeMillis() | ||
} | ||
|
||
actual class Bitmap actual constructor(width: Int, height: Int) { | ||
val delegate = android.graphics.Bitmap.createBitmap(width, height, | ||
android.graphics.Bitmap.Config.RGB_565) | ||
|
||
actual fun setPixel(x: Int, y: Int, color: Int) { | ||
delegate.setPixel(x, y, color) | ||
} | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apply plugin: 'konan' | ||
|
||
konan.targets = [ "android_arm64", "android_arm32"] | ||
|
||
konanArtifacts { | ||
dynamic("knes") { | ||
enableMultiplatform true | ||
} | ||
} | ||
|
||
def outDir = project(':android:app').file("src/main/jniLibs") | ||
def platforms = [ | ||
"armeabi-v7a": [konanTarget: "android_arm32"], | ||
"arm64-v8a" : [konanTarget: "android_arm64"] | ||
] | ||
|
||
task copyLibs(type: Copy) { | ||
dependsOn konanArtifacts.knes | ||
destinationDir outDir | ||
|
||
platforms.each { name, platform -> | ||
into(name) { | ||
from konanArtifacts.knes."${platform.konanTarget}".artifact | ||
} | ||
} | ||
} | ||
|
||
task deleteOut(type: Delete) { | ||
delete outDir | ||
} | ||
|
||
build { | ||
finalizedBy copyLibs | ||
} | ||
|
||
clean.dependsOn deleteOut | ||
|
||
tasks.matching { it.name == 'preBuild' }.all { | ||
it.dependsOn copyLibs | ||
} | ||
|
||
dependencies { | ||
expectedBy project(':common') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pkg = com.felipecsl.knes |
16 changes: 16 additions & 0 deletions
16
android/native-lib/src/main/kotlin/com/felipecsl/knes/api.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.felipecsl.knes | ||
|
||
import konan.internal.CName | ||
import kotlinx.cinterop.* | ||
import platform.android.* | ||
|
||
@CName(fullName = "Java_com_felipecsl_knes_JniKt_startConsole") | ||
fun startConsole(env: CPointer<JNIEnvVar>, self: jobject, cartridgeData: jbyteArray) { | ||
val jni = env.pointed.pointed!! | ||
val len = jni.GetArrayLength!!.invoke(env, cartridgeData) | ||
memScoped { | ||
val buffer = ByteArray(len) | ||
jni.GetByteArrayRegion!!.invoke(env, cartridgeData, 0, len, buffer.refTo(0).getPointer(this)) | ||
Director.startConsole(buffer) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
android/native-lib/src/main/kotlin/com/felipecsl/knes/platform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.felipecsl.knes | ||
|
||
import kotlinx.cinterop.* | ||
import platform.posix.* | ||
|
||
actual fun currentTimeMs(): Long { | ||
memScoped { | ||
val now = alloc<timeval>() | ||
gettimeofday(now.ptr, null) | ||
return (now.tv_sec.toLong() * 1000) + (now.tv_usec.toLong() / 1000) | ||
} | ||
} | ||
|
||
actual class Bitmap actual constructor(width: Int, height: Int) { | ||
actual fun setPixel(x: Int, y: Int, color: Int) { | ||
// TODO | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
app/src/main/kotlin/com/felipecsl/android/nes/INESFileParser.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.