Subversion Repositories Shiroi

Rev

Rev 32 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32 Rev 34
Line 1... Line 1...
1
/* $Id: shiroi.c 32 2024-09-01 08:51:40Z nishi $ */
1
/* $Id: shiroi.c 34 2024-09-01 10:13:47Z nishi $ */
2
 
2
 
3
#include "shiroi.h"
3
#include "shiroi.h"
4
 
4
 
5
#include "card/shiroi_video_mk_i.h"
5
#include "card/shiroi_video_mk_i.h"
6
#include "card/shiroi_video_mk_ii.h"
6
#include "card/shiroi_video_mk_ii.h"
7
#include "card/shiroi_sound_mk_i.h"
7
#include "card/shiroi_sound_mk_i.h"
8
#include "card/shiroi_math_mk_i.h"
8
#include "card/shiroi_math_mk_i.h"
9
#include "card/shiroi_text_mk_i.h"
9
#include "card/shiroi_text_mk_i.h"
10
#include "card/shiroi_debug.h"
10
#include "card/shiroi_debug.h"
-
 
11
#include "card/shiroi_romcard_mk_i.h"
11
 
12
 
12
#include <stdio.h>
13
#include <stdio.h>
13
#include <stdlib.h>
14
#include <stdlib.h>
14
#include <math.h>
15
#include <math.h>
15
#include <time.h>
16
#include <time.h>
Line 68... Line 69...
68
		if(shiroi->cards[i].type == SHIROI_DEBUG) return &shiroi->cards[i];
69
		if(shiroi->cards[i].type == SHIROI_DEBUG) return &shiroi->cards[i];
69
	}
70
	}
70
	return NULL;
71
	return NULL;
71
}
72
}
72
 
73
 
-
 
74
shiroi_card_t* shiroi_get_romcard_card(shiroi_t* shiroi) {
-
 
75
	int i;
-
 
76
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
-
 
77
		if(shiroi->cards[i].type == 0) continue;
-
 
78
		if(shiroi->cards[i].type == SHIROI_ROMCARD_MARK_I) return &shiroi->cards[i];
-
 
79
	}
-
 
80
	return NULL;
-
 
81
}
-
 
82
 
73
void shiroi_init_cards(shiroi_t* shiroi) {
83
void shiroi_init_cards(shiroi_t* shiroi) {
74
	int i;
84
	int i;
75
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
85
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
76
		shiroi->cards[i].type = 0;
86
		shiroi->cards[i].type = 0;
77
	}
87
	}
Line 88... Line 98...
88
		shiroi_math_mk_i_install(shiroi, slot);
98
		shiroi_math_mk_i_install(shiroi, slot);
89
	} else if(card == SHIROI_TEXT_MARK_I) {
99
	} else if(card == SHIROI_TEXT_MARK_I) {
90
		shiroi_text_mk_i_install(shiroi, slot);
100
		shiroi_text_mk_i_install(shiroi, slot);
91
	} else if(card == SHIROI_DEBUG) {
101
	} else if(card == SHIROI_DEBUG) {
92
		shiroi_debug_install(shiroi, slot);
102
		shiroi_debug_install(shiroi, slot);
-
 
103
	} else if(card == SHIROI_ROMCARD_MARK_I) {
-
 
104
		shiroi_romcard_mk_i_install(shiroi, slot);
93
	}
105
	}
94
}
106
}
95
 
107
 
96
void shiroi_reset_card(shiroi_t* shiroi, int slot) {
108
void shiroi_reset_card(shiroi_t* shiroi, int slot) {
97
	int card = shiroi->cards[slot].type;
109
	int card = shiroi->cards[slot].type;
Line 106... Line 118...
106
		shiroi_math_mk_i_reset(shiroi, slot);
118
		shiroi_math_mk_i_reset(shiroi, slot);
107
	} else if(card == SHIROI_TEXT_MARK_I) {
119
	} else if(card == SHIROI_TEXT_MARK_I) {
108
		shiroi_text_mk_i_reset(shiroi, slot);
120
		shiroi_text_mk_i_reset(shiroi, slot);
109
	} else if(card == SHIROI_DEBUG) {
121
	} else if(card == SHIROI_DEBUG) {
110
		shiroi_debug_reset(shiroi, slot);
122
		shiroi_debug_reset(shiroi, slot);
-
 
123
	} else if(card == SHIROI_ROMCARD_MARK_I) {
-
 
124
		shiroi_romcard_mk_i_reset(shiroi, slot);
111
	}
125
	}
112
}
126
}
113
 
127
 
114
void shiroi_init(shiroi_t* shiroi) {
128
void shiroi_init(shiroi_t* shiroi) {
115
	shiroi->z80_pins = z80_init(&shiroi->z80);
129
	shiroi->z80_pins = z80_init(&shiroi->z80);
Line 177... Line 191...
177
				shiroi_video_mk_ii(shiroi);
191
				shiroi_video_mk_ii(shiroi);
178
				shiroi_sound_mk_i(shiroi);
192
				shiroi_sound_mk_i(shiroi);
179
				shiroi_math_mk_i(shiroi);
193
				shiroi_math_mk_i(shiroi);
180
				shiroi_text_mk_i(shiroi);
194
				shiroi_text_mk_i(shiroi);
181
				shiroi_debug(shiroi);
195
				shiroi_debug(shiroi);
-
 
196
				shiroi_romcard_mk_i(shiroi);
182
			}
197
			}
183
		}
198
		}
184
 
199
 
185
		shiroi_video_mk_i_tick(shiroi);
200
		shiroi_video_mk_i_tick(shiroi);
186
		shiroi_video_mk_ii_tick(shiroi);
201
		shiroi_video_mk_ii_tick(shiroi);
187
		shiroi_sound_mk_i_tick(shiroi);
202
		shiroi_sound_mk_i_tick(shiroi);
188
		shiroi_math_mk_i_tick(shiroi);
203
		shiroi_math_mk_i_tick(shiroi);
189
		shiroi_text_mk_i_tick(shiroi);
204
		shiroi_text_mk_i_tick(shiroi);
190
		shiroi_debug_tick(shiroi);
205
		shiroi_debug_tick(shiroi);
-
 
206
		shiroi_romcard_mk_i_tick(shiroi);
191
#ifdef ACCURATE_CLOCK
207
#ifdef ACCURATE_CLOCK
192
		clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &deadline, NULL);
208
		clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &deadline, NULL);
193
#endif
209
#endif
194
	}
210
	}
195
}
211
}