ok i promise i will actually start the rewrite
This commit is contained in:
parent
5b256e74cd
commit
57c6e52f86
18 changed files with 102889 additions and 135 deletions
8
Makefile
8
Makefile
|
@ -4,12 +4,14 @@ PREFIX ?= /usr/local
|
|||
CFLAGS := $(CFLAGS) `pkg-config --cflags --libs sdl3`
|
||||
LDFLAGS := $(LDFLAGS) -lm
|
||||
|
||||
SRCS = slutpet.c img.c samply.c sdl.c
|
||||
SRCS = sp.c
|
||||
|
||||
all: slutpet
|
||||
|
||||
slutpet: ${SRCS}
|
||||
slutpet: ${SRCS} s7.o
|
||||
|
||||
s7.o: s7.c
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f slutpet
|
||||
-rm -f slutpet s7.o
|
||||
|
|
15
dat.h
15
dat.h
|
@ -1,15 +0,0 @@
|
|||
typedef struct Action Action;
|
||||
typedef struct Image Image;
|
||||
|
||||
struct Action {
|
||||
// step
|
||||
// click
|
||||
};
|
||||
|
||||
struct Image {
|
||||
char *name;
|
||||
int w, h, bpp;
|
||||
unsigned char *data;
|
||||
SDL_Surface *sur;
|
||||
SDL_Texture *tex;
|
||||
};
|
7
fns.h
7
fns.h
|
@ -1,7 +0,0 @@
|
|||
#define babble(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||
#define info(...) SDL_Log(__VA_ARGS__)
|
||||
#define shit(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||
#define fuck(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||
|
||||
void free_image(Image *i);
|
||||
int load_image(Image *i, SDL_Renderer *ren);
|
59
img.c
59
img.c
|
@ -1,59 +0,0 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_MALLOC(sz) SDL_malloc(sz)
|
||||
#define STBI_REALLOC(p,newsz) SDL_realloc(p,newsz)
|
||||
#define STBI_FREE(p) SDL_free(p)
|
||||
#include <SDL3/SDL.h>
|
||||
#include "stb_image.h"
|
||||
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
|
||||
void
|
||||
free_image(Image *i)
|
||||
{
|
||||
if (i->tex) {
|
||||
babble("destroying texture for image %s...", i->name);
|
||||
SDL_DestroyTexture(i->tex);
|
||||
}
|
||||
if (i->sur) {
|
||||
babble("destroying surface for image %s...", i->name);
|
||||
SDL_DestroySurface(i->sur);
|
||||
}
|
||||
if (i->data) {
|
||||
babble("destroying data for image %s...", i->name);
|
||||
stbi_image_free(i->data);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
load_image(Image *i, SDL_Renderer *ren)
|
||||
{
|
||||
babble("opening image %s...", i->name);
|
||||
i->data = stbi_load(i->name, &i->w, &i->h, &i->bpp, 4);
|
||||
if (!i->data) {
|
||||
shit("stbi_load: %s", stbi_failure_reason());
|
||||
goto err;
|
||||
}
|
||||
|
||||
babble("creating surface for image %s...", i->name);
|
||||
i->sur = SDL_CreateSurfaceFrom(i->w, i->h, SDL_PIXELFORMAT_RGBA32,
|
||||
i->data, i->w * 4);
|
||||
if (!i->sur) {
|
||||
shit("SDL_CreateSurfaceFrom: %s", SDL_GetError());
|
||||
goto err;
|
||||
}
|
||||
|
||||
babble("creating texture for image %s...", i->name);
|
||||
i->tex = SDL_CreateTextureFromSurface(ren, i->sur);
|
||||
if (!i->tex) {
|
||||
shit("SDL_CreateTextureFromSurface: %s", SDL_GetError());
|
||||
goto err;
|
||||
}
|
||||
|
||||
babble("created image %s!", i->name);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
free_image(i);
|
||||
return -1;
|
||||
}
|
50
readme
50
readme
|
@ -1,12 +1,46 @@
|
|||
horny desktop pet thing.
|
||||
design (+ usage)
|
||||
|
||||
currently being rewritten to make structural sense.
|
||||
(this is for now just a design document and not describing the actual program.)
|
||||
|
||||
you need sdl3 to build it.
|
||||
i have not tried cross-compiling to windows yet.
|
||||
slutpet makes use of s7 scheme as a scripting language.
|
||||
(this, by the way, is why the program takes a weirdly long time to compile --
|
||||
s7.{c,h} contain the entire s7 scheme interpreter, over 100,000 lines.)
|
||||
if you don't know scheme,
|
||||
a) don't worry, it's pretty simple, and
|
||||
b) sorry in advance.
|
||||
|
||||
i think it's probably best to use some sort of extension language.
|
||||
i want people to be able to create their own pets without having to
|
||||
figure out how to recompile.
|
||||
c source files:
|
||||
|
||||
run it with `SDL_LOGGING=app=debug ./slutpet` for verbose logging
|
||||
sp.c: main entry, exit, event/render loops
|
||||
|
||||
a pet is implemented by setting the variable 'pet' to
|
||||
an alist (is this the correct term?) which contains some values.
|
||||
setting the pet variable should handle this automatically,
|
||||
but various hooks can then be set, which will be executed
|
||||
whenever a certain event has happened.
|
||||
|
||||
list of variables:
|
||||
pet: the pet that the program will use. this is a list of cons that define the pet.
|
||||
TODO: maybe this should be a macro that sets other variables.
|
||||
|
||||
pet-name: string containing the pet's name.
|
||||
|
||||
list of hooks:
|
||||
pre-init-hook: before anything has happened at all; right after s7 has been initialised.
|
||||
this is also before any init files have been read
|
||||
post-init-hook: when the window has been set up and things are ready to happen.
|
||||
the current pet should be set and initialised by this point.
|
||||
tick-hook: every program tick. the pet's drawing information should be set
|
||||
here so it can be rendered.
|
||||
TODO: figure out what to do about event hooks
|
||||
pre-quit-hook: the program is about to exit, no de-init things have been done yet.
|
||||
post-quit-hook: everything (except, obviously, the s7 interpreter) has been de-initialised.
|
||||
|
||||
list of functions:
|
||||
(load-image path): set up a new image, with the data taken from the given path.
|
||||
this will return the a list of cons pairs with the image data,
|
||||
in a form that can be used in the pet variable.
|
||||
(free-image image): free heap-allocated data in image.
|
||||
|
||||
list of c-types:
|
||||
pixmap: the data created from stb-image.
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "../dat.h"
|
||||
#include "samply.h"
|
BIN
samply/error.png
BIN
samply/error.png
Binary file not shown.
Before Width: | Height: | Size: 98 KiB |
BIN
samply/idle.png
BIN
samply/idle.png
Binary file not shown.
Before Width: | Height: | Size: 90 KiB |
|
@ -1,7 +0,0 @@
|
|||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "../dat.h"
|
||||
#include "samply.h"
|
||||
|
||||
struct Image samply_sprites[] = {
|
||||
};
|
|
@ -1,3 +0,0 @@
|
|||
theyre very hasty
|
||||
|
||||
h/t zyre for drawing these
|
|
@ -1,6 +0,0 @@
|
|||
typedef struct Samply Samply;
|
||||
|
||||
struct Samply {
|
||||
};
|
||||
|
||||
extern Image samply_sprites[];
|
BIN
samply/walk1.png
BIN
samply/walk1.png
Binary file not shown.
Before Width: | Height: | Size: 71 KiB |
BIN
samply/walk2.png
BIN
samply/walk2.png
Binary file not shown.
Before Width: | Height: | Size: 71 KiB |
23
slutpet.6
23
slutpet.6
|
@ -1,23 +0,0 @@
|
|||
.Dd June 28, 2025
|
||||
.Dt SLUTPET 6
|
||||
.Os
|
||||
.
|
||||
.Sh NAME
|
||||
.Nm slutpet
|
||||
.Nd a desktop pet for perverts
|
||||
.
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
.Em will
|
||||
be a desktop pet thing,
|
||||
but currently it doesn't actually exist.
|
||||
Try again later.
|
||||
.
|
||||
.Sh INTERNALS
|
||||
Currently this section is just notes on how I'm going to
|
||||
try to implement everything. Later this will just be
|
||||
describing the program's layout, to hopefully make
|
||||
it easier to figure out how to modify it.
|
4
sp.c
Normal file
4
sp.c
Normal file
|
@ -0,0 +1,4 @@
|
|||
#define SDL_MAIN_USE_CALLBACKS
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include "s7.h"
|
Loading…
Add table
Add a link
Reference in a new issue