shithub: cstory

Download patch

ref: a3aa64ed7ee2f008698966ef0c08d156aaf16f8b
parent: 07792d58306205cc7cac1ad5d60b05fde42a79d7
author: Jacob Moody <moody@posixcafe.org>
date: Fri Dec 8 16:36:05 EST 2023

get it linking by copying the "Null" backend implementations over

--- /dev/null
+++ b/mkfile
@@ -1,0 +1,175 @@
+</$objtype/mkfile
+
+CFLAGS=-Fpw -I/sys/include/npe -I/sys/include/npe/SDL2 -D__plan9__ -D__${objtype}__
+BIN=/$objtype/bin/games
+TARG=cstory
+
+OFILES=\
+	src/ArmsItem.$O\
+	src/Back.$O\
+	src/Bitmap.$O\
+	src/Boss.$O\
+	src/BossAlmo1.$O\
+	src/BossAlmo2.$O\
+	src/BossBallos.$O\
+	src/BossFrog.$O\
+	src/BossIronH.$O\
+	src/BossLife.$O\
+	src/BossOhm.$O\
+	src/BossPress.$O\
+	src/BossTwinD.$O\
+	src/BossX.$O\
+	src/BulHit.$O\
+	src/Bullet.$O\
+	src/Caret.$O\
+	src/Config.$O\
+	src/Draw.$O\
+	src/Ending.$O\
+	src/Escape.$O\
+	src/Fade.$O\
+	src/File.$O\
+	src/Flags.$O\
+	src/Flash.$O\
+	src/Font.$O\
+	src/Frame.$O\
+	src/Game.$O\
+	src/Generic.$O\
+	src/GenericLoad.$O\
+	src/Input.$O\
+	src/KeyControl.$O\
+	src/Main.$O\
+	src/Map.$O\
+	src/MapName.$O\
+	src/MiniMap.$O\
+	src/MyChar.$O\
+	src/MycHit.$O\
+	src/MycParam.$O\
+	src/NpcAct000.$O\
+	src/NpcAct020.$O\
+	src/NpcAct040.$O\
+	src/NpcAct060.$O\
+	src/NpcAct080.$O\
+	src/NpcAct100.$O\
+	src/NpcAct120.$O\
+	src/NpcAct140.$O\
+	src/NpcAct160.$O\
+	src/NpcAct180.$O\
+	src/NpcAct200.$O\
+	src/NpcAct220.$O\
+	src/NpcAct240.$O\
+	src/NpcAct260.$O\
+	src/NpcAct280.$O\
+	src/NpcAct300.$O\
+	src/NpcAct320.$O\
+	src/NpcAct340.$O\
+	src/NpChar.$O\
+	src/NpcHit.$O\
+	src/NpcTbl.$O\
+	src/Organya.$O\
+	src/PixTone.$O\
+	src/Profile.$O\
+	src/Random.$O\
+	src/Resource.$O\
+	src/SelStage.$O\
+	src/Shoot.$O\
+	src/Sound.$O\
+	src/Stage.$O\
+	src/Star.$O\
+	src/TextScr.$O\
+	src/Triangle.$O\
+	src/ValueView.$O\
+	src/Backends/Platform/9front.$O\
+	src/Backends/Audio/9front.$O\
+	src/Backends/Controller/9front.$O\
+	src/Backends/Rendering/Software.$O\
+	src/Backends/Rendering/Window/Software/9front.$O\
+
+ASSETS=\
+	src/Resource/BITMAP/Credit01.bmp.h\
+	src/Resource/BITMAP/Credit02.bmp.h\
+	src/Resource/BITMAP/Credit03.bmp.h\
+	src/Resource/BITMAP/Credit04.bmp.h\
+	src/Resource/BITMAP/Credit05.bmp.h\
+	src/Resource/BITMAP/Credit06.bmp.h\
+	src/Resource/BITMAP/Credit07.bmp.h\
+	src/Resource/BITMAP/Credit08.bmp.h\
+	src/Resource/BITMAP/Credit09.bmp.h\
+	src/Resource/BITMAP/Credit10.bmp.h\
+	src/Resource/BITMAP/Credit11.bmp.h\
+	src/Resource/BITMAP/Credit12.bmp.h\
+	src/Resource/BITMAP/Credit14.bmp.h\
+	src/Resource/BITMAP/Credit15.bmp.h\
+	src/Resource/BITMAP/Credit16.bmp.h\
+	src/Resource/BITMAP/Credit17.bmp.h\
+	src/Resource/BITMAP/Credit18.bmp.h\
+	src/Resource/BITMAP/pixel.bmp.h\
+	src/Resource/BITMAP/pixel_jp.bmp.h\
+	src/Resource/CURSOR/CURSOR_IKA.png.h\
+	src/Resource/CURSOR/CURSOR_NORMAL.png.h\
+	src/Resource/ICON/GLFW_ICON.ico.h\
+	src/Resource/ICON/ICON_MINI.png.h\
+	src/Resource/ORG/Access.org.h\
+	src/Resource/ORG/Anzen.org.h\
+	src/Resource/ORG/Balcony.org.h\
+	src/Resource/ORG/Ballos.org.h\
+	src/Resource/ORG/BreakDown.org.h\
+	src/Resource/ORG/Cemetery.org.h\
+	src/Resource/ORG/Curly.org.h\
+	src/Resource/ORG/Dr.org.h\
+	src/Resource/ORG/Ending.org.h\
+	src/Resource/ORG/Escape.org.h\
+	src/Resource/ORG/Fanfale1.org.h\
+	src/Resource/ORG/Fanfale2.org.h\
+	src/Resource/ORG/Fanfale3.org.h\
+	src/Resource/ORG/FireEye.org.h\
+	src/Resource/ORG/Gameover.org.h\
+	src/Resource/ORG/Ginsuke.org.h\
+	src/Resource/ORG/Grand.org.h\
+	src/Resource/ORG/Gravity.org.h\
+	src/Resource/ORG/Hell.org.h\
+	src/Resource/ORG/Jenka.org.h\
+	src/Resource/ORG/Jenka2.org.h\
+	src/Resource/ORG/Kodou.org.h\
+	src/Resource/ORG/LastBtl.org.h\
+	src/Resource/ORG/LastBtl3.org.h\
+	src/Resource/ORG/LastCave.org.h\
+	src/Resource/ORG/MDown2.org.h\
+	src/Resource/ORG/Marine.org.h\
+	src/Resource/ORG/Maze.org.h\
+	src/Resource/ORG/Mura.org.h\
+	src/Resource/ORG/Oside.org.h\
+	src/Resource/ORG/Plant.org.h\
+	src/Resource/ORG/Requiem.org.h\
+	src/Resource/ORG/Toroko.org.h\
+	src/Resource/ORG/Vivi.org.h\
+	src/Resource/ORG/Wanpak2.org.h\
+	src/Resource/ORG/Wanpaku.org.h\
+	src/Resource/ORG/Weed.org.h\
+	src/Resource/ORG/White.org.h\
+	src/Resource/ORG/XXXX.org.h\
+	src/Resource/ORG/Zonbie.org.h\
+	src/Resource/ORG/ironH.org.h\
+	src/Resource/ORG/quiet.org.h\
+	src/Resource/WAVE/Wave.dat.h\
+
+CLEANFILES=\
+	$OFILES\
+	$O.bin2h\
+	bin2h/bin2h.$O\
+	$ASSETS\
+
+</sys/src/cmd/mkone
+
+%.$O:	%.cpp
+	$CC $CFLAGS -o $stem.$O $stem.cpp
+
+%.$O:	%.c
+	$CC $CFLAGS -o $stem.$O $stem.c
+
+$O.bin2h:	bin2h/bin2h.$O
+	$LD $LDFLAGS -o $target $prereq
+
+src/Resource/%.h:	$O.bin2h assets/resources/$stem
+	$O.bin2h assets/resources/$stem $target
+
+src/Resource.$O:	$ASSETS
--- /dev/null
+++ b/src/Backends/Audio/9front.cpp
@@ -1,0 +1,74 @@
+// Released under the MIT licence.
+// See LICENCE.txt for details.
+
+#include "../Audio.h"
+
+#include <stddef.h>
+
+int AudioBackend_Init(void)
+{
+	return 1;
+}
+
+void AudioBackend_Deinit(void)
+{
+	
+}
+
+AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length)
+{
+	(void)frequency;
+	(void)samples;
+	(void)length;
+
+	return NULL;
+}
+
+void AudioBackend_DestroySound(AudioBackend_Sound *sound)
+{
+	(void)sound;
+}
+
+void AudioBackend_PlaySound(AudioBackend_Sound *sound, int looping)
+{
+	(void)sound;
+	(void)looping;
+}
+
+void AudioBackend_StopSound(AudioBackend_Sound *sound)
+{
+	(void)sound;
+}
+
+void AudioBackend_RewindSound(AudioBackend_Sound *sound)
+{
+	(void)sound;
+}
+
+void AudioBackend_SetSoundFrequency(AudioBackend_Sound *sound, unsigned int frequency)
+{
+	(void)sound;
+	(void)frequency;
+}
+
+void AudioBackend_SetSoundVolume(AudioBackend_Sound *sound, long volume)
+{
+	(void)sound;
+	(void)volume;
+}
+
+void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan)
+{
+	(void)sound;
+	(void)pan;
+}
+
+void AudioBackend_SetOrganyaCallback(void (*callback)(void))
+{
+	(void)callback;
+}
+
+void AudioBackend_SetOrganyaTimer(unsigned int milliseconds)
+{
+	(void)milliseconds;
+}
--- /dev/null
+++ b/src/Backends/Controller/9front.cpp
@@ -1,0 +1,24 @@
+// Released under the MIT licence.
+// See LICENCE.txt for details.
+
+#include "../Controller.h"
+
+int ControllerBackend_Init(void)
+{
+	return 0;
+}
+
+void ControllerBackend_Deinit(void)
+{
+	
+}
+
+int ControllerBackend_GetJoystickStatus(int **buttons, unsigned int *button_count, short **axes, unsigned int *axis_count)
+{
+	(void)buttons;
+	(void)button_count;
+	(void)axes;
+	(void)axis_count;
+
+	return 0;
+}
--- /dev/null
+++ b/src/Backends/Platform/9front.cpp
@@ -1,0 +1,98 @@
+// Released under the MIT licence.
+// See LICENCE.txt for details.
+
+#include "../Misc.h"
+
+#include "../../Attributes.h"
+
+int Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(int focus))
+{
+	(void)drag_and_drop_callback;
+	(void)window_focus_callback;
+
+	return 1;
+}
+
+void Backend_Deinit(void)
+{
+	
+}
+
+void Backend_PostWindowCreation(void)
+{
+	
+}
+
+int Backend_GetPaths(char **module_path, char **data_path)
+{
+	(void)module_path;
+	(void)data_path;
+
+	return 0;
+}
+
+void Backend_HideMouse(void)
+{
+	
+}
+
+void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t height)
+{
+	(void)rgb_pixels;
+	(void)width;
+	(void)height;
+}
+
+void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height)
+{
+	(void)rgba_pixels;
+	(void)width;
+	(void)height;
+}
+
+void Backend_EnableDragAndDrop(void)
+{
+	
+}
+
+int Backend_SystemTask(int active)
+{
+	(void)active;
+
+	return 1;
+}
+
+void Backend_GetKeyboardState(int *keyboard_state)
+{
+	(void)keyboard_state;
+}
+
+void Backend_ShowMessageBox(const char *title, const char *message)
+{
+	(void)title;
+	(void)message;
+}
+
+ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...)
+{
+	(void)format;
+}
+
+ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintInfo(const char *format, ...)
+{
+	(void)format;
+}
+
+unsigned long Backend_GetTicks(void)
+{
+	static unsigned long fake_ticks = 0;
+
+	fake_ticks += 1000 / 50;
+
+	return fake_ticks;
+}
+
+void Backend_Delay(unsigned int ticks)
+{
+	(void)ticks;
+}
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -35,7 +35,7 @@
 static RenderBackend_Surface *glyph_destination_surface;
 static unsigned char glyph_colour_channels[3];
 
-RenderBackend_Surface* RenderBackend_Init(const char *window_title, size_t screen_width, size_t screen_height, bool fullscreen)
+RenderBackend_Surface* RenderBackend_Init(const char *window_title, size_t screen_width, size_t screen_height, int fullscreen)
 {
 	if (WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen))
 	{
@@ -71,7 +71,7 @@
 	framebuffer.pixels = WindowBackend_Software_GetFramebuffer(&framebuffer.pitch);
 }
 
-RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height, bool render_target)
+RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height, int render_target)
 {
 	(void)render_target;
 
@@ -107,11 +107,11 @@
 	free(surface);
 }
 
-bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
+int RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
 {
 	(void)surface;
 
-	return false;
+	return 0;
 }
 
 void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
@@ -142,7 +142,7 @@
 #endif
 }
 
-ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
+ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, int colour_key)
 {
 	RenderBackend_Rect rect_clamped;
 
--- a/src/Backends/Rendering/Window/Software.h
+++ b/src/Backends/Rendering/Window/Software.h
@@ -5,7 +5,7 @@
 
 #include <stddef.h>
 
-bool WindowBackend_Software_CreateWindow(const char *window_title, size_t screen_width, size_t screen_height, bool fullscreen);
+int WindowBackend_Software_CreateWindow(const char *window_title, size_t screen_width, size_t screen_height, int fullscreen);
 void WindowBackend_Software_DestroyWindow(void);
 unsigned char* WindowBackend_Software_GetFramebuffer(size_t *pitch);
 void WindowBackend_Software_Display(void);
--- /dev/null
+++ b/src/Backends/Rendering/Window/Software/9front.cpp
@@ -1,0 +1,50 @@
+// Released under the MIT licence.
+// See LICENCE.txt for details.
+
+#include "../Software.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+static unsigned char *framebuffer;
+static size_t framebuffer_pitch;
+
+int WindowBackend_Software_CreateWindow(const char *window_title, size_t screen_width, size_t screen_height, int fullscreen)
+{
+	(void)window_title;
+	(void)fullscreen;
+
+	framebuffer = (unsigned char*)malloc(screen_width * screen_height * 3);
+
+	if (framebuffer != NULL)
+	{
+		framebuffer_pitch = screen_width * 3;
+
+		return 1;
+	}
+
+	return 0;
+}
+
+void WindowBackend_Software_DestroyWindow(void)
+{
+	free(framebuffer);
+}
+
+unsigned char* WindowBackend_Software_GetFramebuffer(size_t *pitch)
+{
+	*pitch = framebuffer_pitch;
+
+	return framebuffer;
+}
+
+void WindowBackend_Software_Display(void)
+{
+	
+}
+
+void WindowBackend_Software_HandleWindowResize(size_t width, size_t height)
+{
+	(void)width;
+	(void)height;
+}
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -105,7 +105,7 @@
 void OrgDataReleaseNote(void);	// NoteDataを開放 (Release NoteData)
 BOOL OrgDataInitMusicData(const char *path);
 void OrgDataPlayData(void);
-void OrgDataSetPlayPointer(long x);	// 再生ポインターを指定の位置に設定 (Set playback pointer to specified position)
+void SetPlayPointer(long x);	// 再生ポインターを指定の位置に設定 (Set playback pointer to specified position)
 
 AudioBackend_Sound *lpORGANBUFFER[8][8][2] = {NULL};
 
@@ -781,7 +781,7 @@
 	}
 }
 
-void OrgDataSetPlayPointer(long x)
+void SetPlayPointer(long x)
 {
 	for (int i = 0; i < MAXTRACK; i++)
 	{
@@ -833,7 +833,7 @@
 	if (!audio_backend_initialised)
 		return;
 
-	OrgDataSetPlayPointer(x);
+	SetPlayPointer(x);
 	Volume = 100;
 	bFadeout = FALSE;
 }
--- a/src/mkfile
+++ /dev/null
@@ -1,85 +1,0 @@
-</$objtype/mkfile
-
-CFLAGS=-Fpw -I/sys/include/npe -I/sys/include/npe/SDL2 -D__plan9__ -D__${objtype}__ -I../assets
-BIN=/$objtype/bin/games
-TARG=cstory
-
-OFILES=\
-	ArmsItem.$O\
-	Back.$O\
-	Bitmap.$O\
-	Boss.$O\
-	BossAlmo1.$O\
-	BossAlmo2.$O\
-	BossBallos.$O\
-	BossFrog.$O\
-	BossIronH.$O\
-	BossLife.$O\
-	BossOhm.$O\
-	BossPress.$O\
-	BossTwinD.$O\
-	BossX.$O\
-	BulHit.$O\
-	Bullet.$O\
-	Caret.$O\
-	Config.$O\
-	Draw.$O\
-	Ending.$O\
-	Escape.$O\
-	Fade.$O\
-	File.$O\
-	Flags.$O\
-	Flash.$O\
-	Font.$O\
-	Frame.$O\
-	Game.$O\
-	Generic.$O\
-	GenericLoad.$O\
-	Input.$O\
-	KeyControl.$O\
-	Main.$O\
-	Map.$O\
-	MapName.$O\
-	MiniMap.$O\
-	MyChar.$O\
-	MycHit.$O\
-	MycParam.$O\
-	NpcAct000.$O\
-	NpcAct020.$O\
-	NpcAct040.$O\
-	NpcAct060.$O\
-	NpcAct080.$O\
-	NpcAct100.$O\
-	NpcAct120.$O\
-	NpcAct140.$O\
-	NpcAct160.$O\
-	NpcAct180.$O\
-	NpcAct200.$O\
-	NpcAct220.$O\
-	NpcAct240.$O\
-	NpcAct260.$O\
-	NpcAct280.$O\
-	NpcAct300.$O\
-	NpcAct320.$O\
-	NpcAct340.$O\
-	NpChar.$O\
-	NpcHit.$O\
-	NpcTbl.$O\
-	Organya.$O\
-	PixTone.$O\
-	Profile.$O\
-	Random.$O\
-#	Resource.$O\
-	SelStage.$O\
-	Shoot.$O\
-	Sound.$O\
-	Stage.$O\
-	Star.$O\
-	TextScr.$O\
-	Triangle.$O\
-	ValueView.$O\
-
-</sys/src/cmd/mkone
-
-%.$O:	%.cpp
-	$CC $CFLAGS -o $stem.$O $stem.cpp