TAS stuff

This commit is contained in:
lemon-sherbet 2020-08-18 23:28:16 +02:00
parent 306d9a4563
commit caf6205473
7 changed files with 67 additions and 6 deletions

View File

@ -13,6 +13,10 @@ else
LDFLAGS+=-lm
endif
ifneq ($(HACKED_BALLOONS),)
CFLAGS+=-DCELESTE_P8_HACKED_BALLOONS
endif
all: $(OUT)
$(OUT): sdl12main.c $(CELESTE_OBJ) celeste.h

View File

@ -45,6 +45,26 @@ devkitARM
\* note: toggling fullscreen on PC is currently only supported on linux (X11)
# TAS playback and the fixed point question
In order to playback a TAS, specify it as the first argument to the program when running it. On Windows you can drag the TAS file to the .exe to do this.
The format for the TAS should be a text file that looks like "0,0,3,5,1,34,0,", where each number is the input bitfield and each frame is ended by a comma.
The inputs in the TAS should start in the first loading frame of 100m (neglecting the title screen). When playing back a TAS the starting RNG seed will always be the same.
Most other Celeste Classic ports use floating point numbers, but PICO-8 actually uses 16.16 fixed point numbers.
For casual play and RTA speedrunning, the discrepancies are minor enough to be essentially negligible, however with TASing it might make a difference.
Defining the preprocessor macro `CELESTE_P8_FIXEDP` when compiling celeste.c will use a bunch of preprocessor hacks to replace the float type for all the
code of that file with a fixed point type that matches that of PICO-8. The use of this preprocessor macro requires compiling celeste.c with a C++ compiler, however (but not linking with the C++ standard library).
Using make you can compile this fixed point version with `make USE_FIXEDP=1`.
When playing back TASes made with other tools that work under the assumption of ideal RNG for balloons (since their hitbox depends on that), you can ensure that they do not desync by
defining the preprocessor macro `CELESTE_P8_HACKED_BALLOONS`, which will make balloons static and always expand their hitbox to their full range.
Using make you can turn on this feature with `make HACKED_BALLOONS=1`.
You can combine both of these with `make HACKED_BALLOONS=1 USE_FIXEDP=1`.
# credits
Sound wave files are taken from [https://github.com/JeffRuLz/Celeste-Classic-GBA/tree/master/maxmod_data](https://github.com/JeffRuLz/Celeste-Classic-GBA/tree/master/maxmod_data),

View File

@ -1052,7 +1052,12 @@ static void BALLOON_init(OBJ* this) {
static void BALLOON_update(OBJ* this) {
if (this->spr==22) {
this->offset+=0.01;
#ifdef CELESTE_P8_HACKED_BALLOONS
//hacked balloons: constant y coord and hitbox. for TASes
this->hitbox=(HITBOX){.x=-1,.y=-3,.w=10,.h=14};
#else
this->y=this->start+P8sin(this->offset)*2;
#endif
OBJ* hit = OBJ_collide(this, OBJ_PLAYER, 0,0);
if (hit != NULL && hit->djump<max_djump) {
psfx(6);

Binary file not shown.

View File

@ -3,6 +3,7 @@
#include <math.h>
#include <stdarg.h>
#include <assert.h>
#include <errno.h>
#include <time.h>
#ifdef _3DS
#include <3ds.h>
@ -256,6 +257,14 @@ int main(int argc, char** argv) {
ResetPalette();
SDL_ShowCursor(0);
FILE* TAS = NULL;
if (argc > 1) {
TAS = fopen(argv[1], "r");
if (!TAS) {
printf("couldn't open TAS file '%s': %s\n", argv[1], strerror(errno));
}
}
printf("game state size %gkb\n", Celeste_P8_get_state_size()/1024.);
printf("now loading...\n");
@ -301,7 +310,12 @@ int main(int argc, char** argv) {
void* initial_game_state = SDL_malloc(Celeste_P8_get_state_size());
if (initial_game_state) Celeste_P8_save_state(initial_game_state);
Celeste_P8_set_rndseed((unsigned)(time(NULL) + SDL_GetTicks()));
if (TAS) {
// a consistent seed for tas playback
Celeste_P8_set_rndseed(8);
} else {
Celeste_P8_set_rndseed((unsigned)(time(NULL) + SDL_GetTicks()));
}
Celeste_P8_init();
@ -401,13 +415,22 @@ int main(int argc, char** argv) {
b = 5; break;
default: break;
}
if (b >= 0) {
if (!TAS && b >= 0) {
if (down) buttons_state |= (1<<b);
else buttons_state &= ~(1<<b);
}
}
}
if (TAS && !paused) {
static int t = 0;
t++;
if (t==1) buttons_state = 1<<4;
else if (t > 80) {
fscanf(TAS, "%d,", &buttons_state);
} else buttons_state = 0;
}
if (paused) {
const int x0 = PICO8_W/2-3*4, y0 = 8;

1
test-tas.txt Normal file

File diff suppressed because one or more lines are too long

View File

@ -13,11 +13,19 @@ C () {
C mkdir -p win-build
C cd win-build
ZIGFLAGS="-O2 -g -target i386-windows-gnu -I $WSYSROOT/include/ -I $WSYSROOT/include/SDL/ -L $WSYSROOT/lib/ -Wno-ignored-attributes"
#CC="zig cc $ZIGFLAGS" CXX=zig\ c++ C make OUT=ccleste.exe -C ..
C zig cc $ZIGFLAGS -c ../celeste.c -o celeste.o
C zig cc $ZIGFLAGS -lSDLmain -lSDL -lSDL_mixer celeste.o ../sdl12main.c -o ccleste.exe
#normal
C zig cc $ZIGFLAGS -c ../celeste.c -o celeste.o
C zig cc $ZIGFLAGS -lSDLmain -lSDL -lSDL_mixer celeste.o ../sdl12main.c -o ccleste.exe
#fixed point
C zig c++ $ZIGFLAGS -DCELESTE_P8_FIXEDP -c -xc++ ../celeste.c -o celeste-fixedp.o
C zig cc $ZIGFLAGS -lSDLmain -lSDL -lSDL_mixer celeste-fixedp.o ../sdl12main.c -o ccleste-fixedp.exe
C zig cc $ZIGFLAGS -lSDLmain -lSDL -lSDL_mixer celeste-fixedp.o ../sdl12main.c -o ccleste-fixedp.exe
#fixed point + balloon hack
C zig c++ $ZIGFLAGS -DCELESTE_P8_FIXEDP -DCELESTE_P8_HACKED_BALLOONS -c -xc++ ../celeste.c -o celeste-fixedp-balloonhack.o
C zig cc $ZIGFLAGS -lSDLmain -lSDL -lSDL_mixer celeste-fixedp-balloonhack.o ../sdl12main.c -o ccleste-fixedp-balloonhack.exe
C rm -rf zig-cache *.o stdout.txt
C cp $WSYSROOT/bin/libgcc_s_*.dll .
C cp $WSYSROOT/bin/libogg*.dll .