Subversion Repositories Shiroi

Rev

Rev 10 | Rev 21 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* $Id: shiroi.h 12 2024-08-29 04:19:08Z nishi $ */
2
 
3
#ifndef __SHIROI_H__
4
#define __SHIROI_H__
5
 
6
#include "chips_common.h"
7
#include "z80.h"
8
#include "ay38910.h"
9
#include "tms9918.h"
7 nishi 10
#include "mc6847.h"
1 nishi 11
 
12
#include <stdint.h>
13
#include <stdbool.h>
14
 
15
#define SHIROI_IO_PORTS 3
16
 
17
enum SHIROI_CARD {
18
	SHIROI_VIDEO = 0x00,
19
	SHIROI_VIDEO_MARK_I,
7 nishi 20
	SHIROI_VIDEO_MARK_II,
1 nishi 21
	SHIROI_SOUND = 0x10,
22
	SHIROI_SOUND_MARK_I,
3 nishi 23
	SHIROI_SYSTEM = 0x20,
24
	SHIROI_MATH_MARK_I,
12 nishi 25
	SHIROI_TEXT_MARK_I,
26
	SHIROI_DEBUG
1 nishi 27
};
28
 
29
typedef struct {
7 nishi 30
	uint32_t fb[800 * 600];
1 nishi 31
	union {
32
		VrEmuTms9918* vdp;
7 nishi 33
		mc6847_t mc6847;
1 nishi 34
	};
7 nishi 35
	uint16_t vram_addr;
36
	uint8_t vram[64 * 1024];
1 nishi 37
	int width;
38
	int height;
39
	int tick;
40
} shiroi_video_t;
41
 
42
typedef struct {
43
	union {
44
		ay38910_t psg;
45
	};
46
	int tick;
47
} shiroi_sound_t;
48
 
49
typedef struct {
50
	union {
51
		void* am9511;
52
	};
53
	int tick;
54
} shiroi_math_t;
55
 
56
typedef struct {
3 nishi 57
	unsigned char key;
6 nishi 58
	bool caps;
3 nishi 59
	int tick;
60
} shiroi_text_t;
61
 
62
typedef struct {
12 nishi 63
	unsigned char latch[4];
64
	int latch_addr;
65
	int tick;
66
} shiroi_debug_t;
67
 
68
typedef struct {
1 nishi 69
	union {
70
		shiroi_video_t video;
71
		shiroi_sound_t sound;
72
		shiroi_math_t math;
3 nishi 73
		shiroi_text_t text;
12 nishi 74
		shiroi_debug_t debug;
1 nishi 75
	};
76
	shiroi_video_t* videoptr;
77
	shiroi_sound_t* soundptr;
78
	shiroi_math_t* mathptr;
3 nishi 79
	shiroi_text_t* textptr;
12 nishi 80
	shiroi_debug_t* debugptr;
1 nishi 81
	int type;
82
} shiroi_card_t;
83
 
84
typedef struct {
85
	uint8_t ram[64 * 1024];
86
	uint64_t z80_pins;
87
	z80_t z80;
88
	bool stop;
89
	void (*play_audio)(void* buffer, unsigned int frames);
90
	shiroi_card_t cards[256 / 3];
10 nishi 91
	bool reset;
1 nishi 92
} shiroi_t;
93
 
94
void shiroi_init(shiroi_t* shiroi);
95
void shiroi_init_cards(shiroi_t* shiroi);
96
void shiroi_loop(shiroi_t* shiroi);
97
void shiroi_install(shiroi_t* shiroi, int slot, int card);
98
shiroi_card_t* shiroi_get_video_card(shiroi_t* shiroi);
99
shiroi_card_t* shiroi_get_sound_card(shiroi_t* shiroi);
100
shiroi_card_t* shiroi_get_math_card(shiroi_t* shiroi);
3 nishi 101
shiroi_card_t* shiroi_get_text_card(shiroi_t* shiroi);
12 nishi 102
shiroi_card_t* shiroi_get_debug_card(shiroi_t* shiroi);
1 nishi 103
 
104
#endif