Subversion Repositories Shiroi

Rev

Rev 22 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* $Id: shiroi.h 34 2024-09-01 10:13:47Z 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,
34 nishi 26
	SHIROI_DEBUG,
27
	SHIROI_ROMCARD_MARK_I
1 nishi 28
};
29
 
30
typedef struct {
7 nishi 31
	uint32_t fb[800 * 600];
1 nishi 32
	union {
33
		VrEmuTms9918* vdp;
7 nishi 34
		mc6847_t mc6847;
1 nishi 35
	};
7 nishi 36
	uint16_t vram_addr;
37
	uint8_t vram[64 * 1024];
1 nishi 38
	int width;
39
	int height;
40
	int tick;
41
} shiroi_video_t;
42
 
43
typedef struct {
44
	union {
45
		ay38910_t psg;
46
	};
47
	int tick;
48
} shiroi_sound_t;
49
 
50
typedef struct {
51
	union {
52
		void* am9511;
53
	};
54
	int tick;
55
} shiroi_math_t;
56
 
57
typedef struct {
3 nishi 58
	unsigned char key;
6 nishi 59
	bool caps;
3 nishi 60
	int tick;
61
} shiroi_text_t;
62
 
63
typedef struct {
12 nishi 64
	unsigned char latch[4];
65
	int latch_addr;
66
	int tick;
67
} shiroi_debug_t;
68
 
69
typedef struct {
34 nishi 70
	unsigned char* data;
71
	int latch_addr;
72
} shiroi_romcard_t;
73
 
74
typedef struct {
22 nishi 75
	union {
1 nishi 76
		shiroi_video_t video;
77
		shiroi_sound_t sound;
78
		shiroi_math_t math;
3 nishi 79
		shiroi_text_t text;
12 nishi 80
		shiroi_debug_t debug;
34 nishi 81
		shiroi_romcard_t romcard;
22 nishi 82
	};
1 nishi 83
	shiroi_video_t* videoptr;
84
	shiroi_sound_t* soundptr;
85
	shiroi_math_t* mathptr;
3 nishi 86
	shiroi_text_t* textptr;
12 nishi 87
	shiroi_debug_t* debugptr;
34 nishi 88
	shiroi_romcard_t* romcardptr;
1 nishi 89
	int type;
90
} shiroi_card_t;
91
 
92
typedef struct {
93
	uint8_t ram[64 * 1024];
94
	uint64_t z80_pins;
95
	z80_t z80;
96
	bool stop;
97
	void (*play_audio)(void* buffer, unsigned int frames);
98
	shiroi_card_t cards[256 / 3];
10 nishi 99
	bool reset;
1 nishi 100
} shiroi_t;
101
 
102
void shiroi_init(shiroi_t* shiroi);
103
void shiroi_init_cards(shiroi_t* shiroi);
104
void shiroi_loop(shiroi_t* shiroi);
105
void shiroi_install(shiroi_t* shiroi, int slot, int card);
106
shiroi_card_t* shiroi_get_video_card(shiroi_t* shiroi);
107
shiroi_card_t* shiroi_get_sound_card(shiroi_t* shiroi);
108
shiroi_card_t* shiroi_get_math_card(shiroi_t* shiroi);
3 nishi 109
shiroi_card_t* shiroi_get_text_card(shiroi_t* shiroi);
12 nishi 110
shiroi_card_t* shiroi_get_debug_card(shiroi_t* shiroi);
34 nishi 111
shiroi_card_t* shiroi_get_romcard_card(shiroi_t* shiroi);
1 nishi 112
 
113
#endif