Skip to content

Instantly share code, notes, and snippets.

@UnmatchedBracket
Last active September 15, 2023 05:20
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 UnmatchedBracket/e66dd05f8f23cbe5e8d86b58ffbf1ae8 to your computer and use it in GitHub Desktop.
Save UnmatchedBracket/e66dd05f8f23cbe5e8d86b58ffbf1ae8 to your computer and use it in GitHub Desktop.
diff --git a/AndroidStudioProjects/AAAAXY/app/build.gradle b/AndroidStudioProjects/AAAAXY/app/build.gradle
index ed7fb57f..20ededcb 100644
--- a/AndroidStudioProjects/AAAAXY/app/build.gradle
+++ b/AndroidStudioProjects/AAAAXY/app/build.gradle
@@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId 'io.github.divverent.aaaaxy'
// minSdk 21 // What actually is required.
- minSdk 27 // For now, restrict to newer devices.
+ minSdk 26 // For now, restrict to newer devices.
targetSdk 33
def rootDir = new File("${project.rootDir}/../..")
def prefix =
@@ -22,10 +22,10 @@ android {
}
signingConfigs {
release {
- storeFile file("${aaaaxy_keystore}")
- storePassword "${aaaaxy_keystore_password}"
- keyAlias "${aaaaxy_key_alias}"
- keyPassword "${aaaaxy_key_password}"
+ storeFile file("my-release-key.keystore")
+ storePassword "aaaaxy"
+ keyAlias "my-alias"
+ keyPassword "aaaaxy"
}
}
buildTypes {
diff --git a/Makefile b/Makefile
index dc760e6b..56409003 100644
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ endif
CGO_CPPFLAGS ?= $(CPPFLAGS)
CGO_CFLAGS ?= $(CFLAGS)
CGO_CXXFLAGS ?= $(CXXFLAGS)
-CGO_LDFLAGS ?= $(LDFLAGS)
+CGO_LDFLAGS ?= $(LDFLAGS) -lglfw
CGO_ENV ?= \
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" \
CGO_CFLAGS="$(CGO_CFLAGS)" \
diff --git a/internal/aaaaxy/game.go b/internal/aaaaxy/game.go
index 2e524a8a..b34b76e2 100644
--- a/internal/aaaaxy/game.go
+++ b/internal/aaaaxy/game.go
@@ -71,6 +71,7 @@ var (
debugEnableDrawing = flag.Bool("debug_enable_drawing", true, "enable drawing the display; set to false for faster demo processing or similar")
showFPS = flag.Bool("show_fps", false, "show fps counter")
showTime = flag.Bool("show_time", false, "show game time")
+ hideTASData = flag.Bool("hide_tas_data", false, "hide the TAS data, for dumping")
debugLoadingScreenCpuprofile = flag.String("debug_loading_screen_cpuprofile", "", "write CPU profile of loading screen to file")
debugShowGC = flag.Bool("debug_show_gc", false, "show garbage collector pause info")
)
@@ -471,6 +472,29 @@ func (g *Game) drawAtGameSizeThenReturnTo(maybeScreen *ebiten.Image, to chan *eb
}
}
+ //theUnit := 65536 // in pixels
+ theUnit := 65536 * 16 // in tiles
+ if !*hideTASData {
+ pos := g.Menu.World.Player.Impl.(engine.PlayerEntityImpl).TruePos()
+ font.ByName["Small"].Draw(drawDest,
+ fmt.Sprintf(
+ "P: %f %f",
+ float64(pos.X)/float64(theUnit),
+ float64(pos.Y)/float64(theUnit),
+ ),
+ m.Pos{X: 4, Y: engine.GameHeight - 4}, font.Left,
+ palette.EGA(palette.White, 255), palette.EGA(palette.Black, 255))
+ vel := g.Menu.World.Player.Impl.(engine.PlayerEntityImpl).Vel()
+ font.ByName["Small"].Draw(drawDest,
+ fmt.Sprintf(
+ "V: %f %f",
+ float64(vel.DX)/float64(theUnit),
+ float64(vel.DY)/float64(theUnit),
+ ),
+ m.Pos{X: 4, Y: engine.GameHeight - 14}, font.Left,
+ palette.EGA(palette.White, 255), palette.EGA(palette.Black, 255))
+ }
+
timing.Section("demo_postdraw")
demo.PostDraw(drawDest)
diff --git a/internal/aaaaxy/init.go b/internal/aaaaxy/init.go
index 73067539..9169b5ad 100644
--- a/internal/aaaaxy/init.go
+++ b/internal/aaaaxy/init.go
@@ -159,7 +159,7 @@ func (g *Game) InitEarly() error {
palette.SetCurrent(palette.ByName(*paletteFlag), *paletteRemapColors)
// When dumping video or benchmarking, do precisely one render frame per update.
- if dump.Slow() || demo.Timedemo() {
+ if true {
ebiten.SetTPS(ebiten.SyncWithFPS)
} else {
ebiten.SetTPS(engine.GameTPS / *fpsDivisor)
diff --git a/internal/dump/dump.go b/internal/dump/dump.go
index 4374beff..7a20967d 100644
--- a/internal/dump/dump.go
+++ b/internal/dump/dump.go
@@ -28,7 +28,6 @@ import (
"github.com/divVerent/aaaaxy/internal/atexit"
"github.com/divVerent/aaaaxy/internal/audiowrap"
- "github.com/divVerent/aaaaxy/internal/demo"
"github.com/divVerent/aaaaxy/internal/engine"
"github.com/divVerent/aaaaxy/internal/flag"
"github.com/divVerent/aaaaxy/internal/log"
@@ -45,8 +44,8 @@ var (
dumpVideoCodecSettings = flag.String("dump_video_codec_settings", "-codec:v mjpeg -q:v 4", "FFmpeg settings for video encoding; set to \"\" to disable the video stream for -dump_media")
dumpAudioCodecSettings = flag.String("dump_audio_codec_settings", "-codec:a pcm_s16le", "FFmpeg settings for audio encoding; set to \"\" to disable the audio stream for -dump_media")
dumpMediaFormatSettings = flag.String("dump_media_format_settings", "-vsync vfr", "FFmpeg flags for muxing")
- cheatDumpSlowAndGood = flag.Bool("cheat_dump_slow_and_good", false, "non-realtime video dumping (slows down the game, thus considered a cheat))")
- dumpMediaFrameTimeout = flag.Duration("dump_media_frame_timeout", 300*time.Second, "maximum processing time per frame; after this time it is assumed that ffmpeg died and dumping ends")
+ //cheatDumpSlowAndGood = flag.Bool("cheat_dump_slow_and_good", false, "non-realtime video dumping (slows down the game, thus considered a cheat))")
+ dumpMediaFrameTimeout = flag.Duration("dump_media_frame_timeout", 300*time.Second, "maximum processing time per frame; after this time it is assumed that ffmpeg died and dumping ends")
)
type Params struct {
@@ -168,9 +167,9 @@ func Active() bool {
return audioWriter != nil || videoWriter != nil
}
-func Slow() bool {
- return Active() && (*cheatDumpSlowAndGood || demo.Playing())
-}
+// func Slow() bool {
+// return Active() && (*cheatDumpSlowAndGood || demo.Playing())
+// }
func ProcessFrameThenReturnTo(screen *ebiten.Image, to chan *ebiten.Image, frames int) {
if !Active() || frames == 0 {
diff --git a/internal/engine/entity.go b/internal/engine/entity.go
index fab5fe0c..21fd1256 100644
--- a/internal/engine/entity.go
+++ b/internal/engine/entity.go
@@ -277,4 +277,7 @@ type PlayerEntityImpl interface {
// Respawned() notifies the entity that the world respawned it.
Respawned()
+
+ TruePos() m.Pos
+ Vel() m.Delta
}
diff --git a/internal/engine/world.go b/internal/engine/world.go
index 092985ec..0bf8ea94 100644
--- a/internal/engine/world.go
+++ b/internal/engine/world.go
@@ -303,6 +303,9 @@ func (w *World) Init(saveState int) error {
// Load loads the current savegame.
// If this fails, the world may be in an undefined state; call w.Init() or w.Load() to resume.
func (w *World) Load() error {
+ if w.saveState == 7 { // make 7 a no-save state
+ return w.Init(w.saveState)
+ }
saveName := fmt.Sprintf("save-%d.json", w.saveState)
err := w.loadUnchecked(saveName)
if errors.Is(err, os.ErrNotExist) {
@@ -373,7 +376,11 @@ func (w *World) Save() error {
if is, cheats := flag.Cheating(); is {
return fmt.Errorf("not saving, as cheats are enabled: %s", cheats)
}
- return vfs.WriteState(vfs.SavedGames, fmt.Sprintf("save-%d.json", w.saveState), state)
+ if w.saveState != 7 { // make 7 a no-save state
+ return vfs.WriteState(vfs.SavedGames, fmt.Sprintf("save-%d.json", w.saveState), state)
+ } else {
+ return nil
+ }
}
// SpawnPlayer spawns the player in a newly initialized world.
diff --git a/internal/game/player/player.go b/internal/game/player/player.go
index 6e1814a0..f74b60fe 100644
--- a/internal/game/player/player.go
+++ b/internal/game/player/player.go
@@ -464,6 +464,17 @@ func (p *Player) EyePos() m.Pos {
}
}
+func (p *Player) TruePos() m.Pos {
+ return m.Pos{
+ p.Entity.Rect.Origin.X*65536 + p.Physics.SubPixel.DX,
+ p.Entity.Rect.Origin.Y*65536 + p.Physics.SubPixel.DY,
+ }
+}
+
+func (p *Player) Vel() m.Delta {
+ return p.Velocity
+}
+
// LookPos returns the position the player is focusing at.
func (p *Player) LookPos() m.Pos {
focus := m.Pos{
diff --git a/internal/menu/reset.go b/internal/menu/reset.go
index ee924d58..b291ba6b 100644
--- a/internal/menu/reset.go
+++ b/internal/menu/reset.go
@@ -39,7 +39,7 @@ const (
ResetCount
)
-const resetFrames = 300
+const resetFrames = 3
type ResetScreen struct {
Controller *Controller

Find the go-gl/glfw/v3.3/glfw@... path and make all the .go files within use //#include <GLFW/glfw3.h> instead of #include "glfw/...", except vulkan.go cuz it wont work if you do that ``

diff --git a/src/library/Makefile.am b/src/library/Makefile.am
index 505468c3..d6754eaf 100644
--- a/src/library/Makefile.am
+++ b/src/library/Makefile.am
@@ -76,6 +76,7 @@ libtas_so_SOURCES = \
fileio/SaveFileList.cpp \
fileio/stdiowrappers.cpp \
fileio/URandom.cpp \
+ glfw/glfwInputPatches.cpp \
inputs/evdev.cpp \
inputs/inputevents.cpp \
inputs/inputs.cpp \
diff --git a/src/library/mallocwrappers.cpp b/src/library/mallocwrappers.cpp
index 78beaadb..b10f033f 100644
--- a/src/library/mallocwrappers.cpp
+++ b/src/library/mallocwrappers.cpp
@@ -24,9 +24,33 @@
namespace libtas {
+DEFINE_ORIG_POINTER(free)
+
void *malloc (size_t size) __THROW
{
return calloc(1, size);
}
+void free (void *__ptr) __THROW
+{
+ static char linking_state = 0;
+ if (linking_state == 1) return;
+ if (linking_state == 0) {
+ linking_state = 1;
+ LINK_NAMESPACE_GLOBAL(free);
+ linking_state = 2;
+ }
+ static void *first = 0;
+ if (first == 0) {
+ first = __ptr;
+ return orig::free(__ptr);
+ } else {
+ if (__ptr >= first) {
+ return orig::free(__ptr);
+ } else if (__ptr != 0) {
+ debuglogstdio(LCF_SYSTEM, "free denied %p; minimum is %p", __ptr, first);
+ }
+ }
+}
+
}
diff --git a/src/library/mallocwrappers.h b/src/library/mallocwrappers.h
index 81783719..182eebf7 100644
--- a/src/library/mallocwrappers.h
+++ b/src/library/mallocwrappers.h
@@ -27,6 +27,7 @@ namespace libtas {
/* Allocate SIZE bytes of memory. */
OVERRIDE void *malloc (size_t size) __THROW;
+OVERRIDE void free (void *__ptr) __THROW;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment