2018-11-10 23:16:32 +00:00
|
|
|
#ifndef sgb_h
|
|
|
|
#define sgb_h
|
2021-11-07 11:39:18 +00:00
|
|
|
#include "defs.h"
|
2018-11-15 23:53:01 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2018-11-10 23:16:32 +00:00
|
|
|
|
2018-11-16 15:41:23 +00:00
|
|
|
typedef struct GB_sgb_s GB_sgb_t;
|
2020-02-08 11:28:46 +00:00
|
|
|
typedef struct {
|
2021-11-06 23:10:58 +00:00
|
|
|
uint8_t tiles[0x100 * 8 * 4];
|
2022-01-14 23:26:11 +00:00
|
|
|
#ifdef GB_INTERNAL
|
2020-02-08 11:28:46 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16_t map[32 * 32];
|
|
|
|
uint16_t palette[16 * 4];
|
|
|
|
};
|
|
|
|
uint16_t raw_data[0x440];
|
|
|
|
};
|
2022-01-14 23:26:11 +00:00
|
|
|
#else
|
|
|
|
uint16_t raw_data[0x440];
|
|
|
|
#endif
|
2020-02-08 11:28:46 +00:00
|
|
|
} GB_sgb_border_t;
|
2018-11-24 11:21:00 +00:00
|
|
|
|
2018-11-10 23:16:32 +00:00
|
|
|
#ifdef GB_INTERNAL
|
2021-03-28 23:47:57 +00:00
|
|
|
#define GB_SGB_INTRO_ANIMATION_LENGTH 200
|
|
|
|
|
2018-11-16 15:41:23 +00:00
|
|
|
struct GB_sgb_s {
|
2018-11-15 23:53:01 +00:00
|
|
|
uint8_t command[16 * 7];
|
|
|
|
uint16_t command_write_index;
|
|
|
|
bool ready_for_pulse;
|
|
|
|
bool ready_for_write;
|
|
|
|
bool ready_for_stop;
|
|
|
|
bool disable_commands;
|
|
|
|
|
|
|
|
/* Screen buffer */
|
2018-11-16 10:42:52 +00:00
|
|
|
uint8_t screen_buffer[160 * 144]; // Live image from the Game Boy
|
|
|
|
uint8_t effective_screen_buffer[160 * 144]; // Image actually rendered to the screen
|
|
|
|
|
2018-11-15 23:53:01 +00:00
|
|
|
/* Multiplayer Input */
|
|
|
|
uint8_t player_count, current_player;
|
2018-11-16 10:42:52 +00:00
|
|
|
|
|
|
|
/* Mask */
|
|
|
|
uint8_t mask_mode;
|
2018-11-16 14:04:40 +00:00
|
|
|
|
2018-11-16 17:11:21 +00:00
|
|
|
/* Data Transfer */
|
2018-11-16 22:44:18 +00:00
|
|
|
uint8_t vram_transfer_countdown, transfer_dest;
|
2018-11-16 17:11:21 +00:00
|
|
|
|
|
|
|
/* Border */
|
2020-02-08 11:28:46 +00:00
|
|
|
GB_sgb_border_t border, pending_border;
|
2018-11-16 15:36:21 +00:00
|
|
|
uint8_t border_animation;
|
2018-11-16 17:11:21 +00:00
|
|
|
|
|
|
|
/* Colorization */
|
|
|
|
uint16_t effective_palettes[4 * 4];
|
|
|
|
uint16_t ram_palettes[4 * 512];
|
2018-11-16 20:05:35 +00:00
|
|
|
uint8_t attribute_map[20 * 18];
|
2021-04-12 22:09:29 +00:00
|
|
|
uint8_t attribute_files[0xFD2];
|
|
|
|
uint8_t attribute_files_padding[0xFE0 - 0xFD2];
|
2018-11-24 11:21:00 +00:00
|
|
|
|
|
|
|
/* Intro */
|
2018-12-01 11:39:43 +00:00
|
|
|
int16_t intro_animation;
|
2019-07-20 13:10:24 +00:00
|
|
|
|
|
|
|
/* GB Header */
|
|
|
|
uint8_t received_header[0x54];
|
2018-11-16 15:41:23 +00:00
|
|
|
};
|
2018-11-15 23:53:01 +00:00
|
|
|
|
2021-11-07 12:13:52 +00:00
|
|
|
internal void GB_sgb_write(GB_gameboy_t *gb, uint8_t value);
|
|
|
|
internal void GB_sgb_render(GB_gameboy_t *gb);
|
|
|
|
internal void GB_sgb_load_default_data(GB_gameboy_t *gb);
|
2018-11-15 23:53:01 +00:00
|
|
|
|
2018-11-10 23:16:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|