aboutsummaryrefslogtreecommitdiff
path: root/src/splib.h
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-11-05 11:22:55 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-11-05 11:31:28 +0000
commit2fbdf974338bde8576efdae40a819a76b2391033 (patch)
tree64d41a37470143f142344f9a439d96de3e7918c2 /src/splib.h
downloadkitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz
kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip
Initial import of the open source release
Diffstat (limited to 'src/splib.h')
-rw-r--r--src/splib.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/splib.h b/src/splib.h
new file mode 100644
index 0000000..0fc4f1c
--- /dev/null
+++ b/src/splib.h
@@ -0,0 +1,82 @@
+/*
+ Kitsune's Curse
+ Copyright (C) 2020-2023 Juan J. Martinez <jjm@usebox.net>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#ifndef _SPLIB_H
+#define _SPLIB_H
+
+#include <stdint.h>
+
+// this is 160x160; 8x8 pixels tiles
+#define TMW 20
+#define TMH 20
+
+#define TW 8
+#define TH 8
+
+// All the buffer must be under 0x8000
+#define BUFF_ADDR 0x0100
+// CONFIGURE **
+
+#define SCREEN_ADDR(x, y) ((int)(0xc000 + x + ((y / 8) * 80) + ((y % 8) * 2048)))
+
+#define DIRTY_BIT 0x8000
+#define ADDR_BITS 0x7fff
+
+struct st_tile
+{
+ uint16_t baddr;
+ const uint8_t *t;
+ uint16_t saddr;
+ struct st_tile *n;
+};
+
+void init_tiles();
+void update_screen();
+void validate_screen();
+void invalidate_screen();
+
+struct st_tile *get_tile_xy(uint8_t x, uint8_t y);
+
+void invalidate_tile(struct st_tile *st) __z88dk_fastcall;
+uint8_t is_invalid_tile(struct st_tile *st) __z88dk_fastcall;
+uint8_t is_invalid_tile2(struct st_tile *st) __z88dk_fastcall;
+
+void erase_tile(struct st_tile *st) __z88dk_fastcall;
+void link_buffer(struct st_tile *st) __z88dk_fastcall;
+void link_buffer_xy(uint8_t x, uint8_t y);
+
+void put_tile(const uint8_t *t, struct st_tile *st);
+void put_sprite4(const uint8_t *s, uint8_t x, uint8_t y, uint8_t th, uint8_t inv);
+void erase_sprite(uint8_t x, uint8_t y, uint8_t th);
+
+void fill_screen(const uint8_t *t) __z88dk_fastcall;
+
+// misc
+void clear_screen();
+void wait_vsync();
+void set_hw_border(uint8_t c) __z88dk_fastcall;
+void set_hw_ink(uint8_t ink, uint8_t c);
+void pad_numbers(uint8_t *s, uint8_t limit, uint16_t number);
+uint16_t screen_addr(uint16_t x, uint16_t y);
+
+uint8_t abs_sub(uint8_t a, uint8_t b);
+
+// require spfont, 63 chars (starting on 31)
+void set_text_ink(uint8_t c, uint8_t c2, uint8_t c3);
+void put_text(const char *s, uint8_t x, uint8_t y);
+
+#endif // _SPLIB_H