Subversion Repositories Shiroi

Rev

Rev 1 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 3
Line 1... Line 1...
1
/* $Id: shiroi.c 1 2024-08-28 08:10:28Z nishi $ */
1
/* $Id: shiroi.c 3 2024-08-28 09:19:04Z 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_sound_mk_i.h"
6
#include "card/shiroi_sound_mk_i.h"
7
#include "card/shiroi_math_mk_i.h"
7
#include "card/shiroi_math_mk_i.h"
-
 
8
#include "card/shiroi_text_mk_i.h"
8
 
9
 
9
#include <stdio.h>
10
#include <stdio.h>
10
#include <stdlib.h>
11
#include <stdlib.h>
11
#include <math.h>
12
#include <math.h>
12
 
13
 
Line 41... Line 42...
41
 
42
 
42
shiroi_card_t* shiroi_get_math_card(shiroi_t* shiroi) {
43
shiroi_card_t* shiroi_get_math_card(shiroi_t* shiroi) {
43
	int i;
44
	int i;
44
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
45
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
45
		if(shiroi->cards[i].type == 0) continue;
46
		if(shiroi->cards[i].type == 0) continue;
46
		if((shiroi->cards[i].type & 0xf0) == SHIROI_MATH) return &shiroi->cards[i];
47
		if(shiroi->cards[i].type == SHIROI_MATH_MARK_I) return &shiroi->cards[i];
-
 
48
	}
-
 
49
	return NULL;
-
 
50
}
-
 
51
 
-
 
52
shiroi_card_t* shiroi_get_text_card(shiroi_t* shiroi) {
-
 
53
	int i;
-
 
54
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
-
 
55
		if(shiroi->cards[i].type == 0) continue;
-
 
56
		if(shiroi->cards[i].type == SHIROI_TEXT_MARK_I) return &shiroi->cards[i];
47
	}
57
	}
48
	return NULL;
58
	return NULL;
49
}
59
}
50
 
60
 
51
void shiroi_init_cards(shiroi_t* shiroi) {
61
void shiroi_init_cards(shiroi_t* shiroi) {
Line 60... Line 70...
60
		shiroi_video_mk_i_install(shiroi, slot);
70
		shiroi_video_mk_i_install(shiroi, slot);
61
	} else if(card == SHIROI_SOUND_MARK_I) {
71
	} else if(card == SHIROI_SOUND_MARK_I) {
62
		shiroi_sound_mk_i_install(shiroi, slot);
72
		shiroi_sound_mk_i_install(shiroi, slot);
63
	} else if(card == SHIROI_MATH_MARK_I) {
73
	} else if(card == SHIROI_MATH_MARK_I) {
64
		shiroi_math_mk_i_install(shiroi, slot);
74
		shiroi_math_mk_i_install(shiroi, slot);
-
 
75
	} else if(card == SHIROI_TEXT_MARK_I) {
-
 
76
		shiroi_text_mk_i_install(shiroi, slot);
65
	}
77
	}
66
}
78
}
67
 
79
 
68
void shiroi_init(shiroi_t* shiroi) {
80
void shiroi_init(shiroi_t* shiroi) {
69
	shiroi->z80_pins = z80_init(&shiroi->z80);
81
	shiroi->z80_pins = z80_init(&shiroi->z80);
Line 86... Line 98...
86
			uint16_t addr = Z80_GET_ADDR(shiroi->z80_pins);
98
			uint16_t addr = Z80_GET_ADDR(shiroi->z80_pins);
87
			if(shiroi->z80_pins & Z80_RD) {
99
			if(shiroi->z80_pins & Z80_RD) {
88
				uint8_t data = shiroi->ram[addr];
100
				uint8_t data = shiroi->ram[addr];
89
				Z80_SET_DATA(shiroi->z80_pins, data);
101
				Z80_SET_DATA(shiroi->z80_pins, data);
90
			} else if(shiroi->z80_pins & Z80_WR) {
102
			} else if(shiroi->z80_pins & Z80_WR) {
-
 
103
				if(addr >= 0x8000) {
91
				uint8_t data = Z80_GET_DATA(shiroi->z80_pins);
104
					uint8_t data = Z80_GET_DATA(shiroi->z80_pins);
92
				shiroi->ram[addr] = data;
105
					shiroi->ram[addr] = data;
-
 
106
				}
93
			}
107
			}
94
		} else if(shiroi->z80_pins & Z80_IORQ) {
108
		} else if(shiroi->z80_pins & Z80_IORQ) {
95
			uint16_t io = Z80_GET_ADDR(shiroi->z80_pins);
109
			uint16_t io = Z80_GET_ADDR(shiroi->z80_pins);
96
			uint16_t addr = io & 0xff;
110
			uint16_t addr = io & 0xff;
97
			uint16_t data = (io >> 8) & 0xff;
111
			uint16_t data = (io >> 8) & 0xff;
Line 99... Line 113...
99
			if(shiroi->z80_pins & Z80_M1) {
113
			if(shiroi->z80_pins & Z80_M1) {
100
			} else {
114
			} else {
101
				shiroi_video_mk_i(shiroi);
115
				shiroi_video_mk_i(shiroi);
102
				shiroi_sound_mk_i(shiroi);
116
				shiroi_sound_mk_i(shiroi);
103
				shiroi_math_mk_i(shiroi);
117
				shiroi_math_mk_i(shiroi);
-
 
118
				shiroi_text_mk_i(shiroi);
104
			}
119
			}
105
		}
120
		}
106
 
121
 
107
		shiroi_video_mk_i_tick(shiroi);
122
		shiroi_video_mk_i_tick(shiroi);
108
		shiroi_sound_mk_i_tick(shiroi);
123
		shiroi_sound_mk_i_tick(shiroi);
109
		shiroi_math_mk_i_tick(shiroi);
124
		shiroi_math_mk_i_tick(shiroi);
-
 
125
		shiroi_text_mk_i_tick(shiroi);
110
	}
126
	}
111
}
127
}