Subversion Repositories Shiroi

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
34 nishi 1
/* $Id: shiroi_romcard_mk_i.c 34 2024-09-01 10:13:47Z nishi $ */
2
#include "shiroi_romcard_mk_i.h"
3
 
4
#include "shiroi.h"
5
 
6
#include <stdlib.h>
7
#include <stdio.h>
8
#include <signal.h>
9
 
10
void shiroi_romcard_mk_i_install(shiroi_t* shiroi, int slot) {
11
	shiroi->cards[slot].type = SHIROI_ROMCARD_MARK_I;
12
	shiroi->cards[slot].romcard.data = malloc(1 << 24);
13
	if(shiroi->cards[slot].romcard.data == NULL) {
14
		fprintf(stderr, "Could not allocate!\n");
15
#ifndef __MINGW32__
16
		raise(SIGABRT);
17
#endif
18
	}
19
	shiroi->cards[slot].romcardptr = &shiroi->cards[slot].romcard;
20
}
21
 
22
void shiroi_romcard_mk_i_reset(shiroi_t* shiroi, int slot) {}
23
 
24
void shiroi_romcard_mk_i(shiroi_t* shiroi) {
25
	int i;
26
 
27
	uint16_t io = Z80_GET_ADDR(shiroi->z80_pins);
28
	uint16_t addr = io & 0xff;
29
	uint16_t data = (io >> 8) & 0xff;
30
 
31
	for(i = 0; i < 256 / SHIROI_IO_PORTS; i++) {
32
		if(shiroi->cards[i].type == SHIROI_ROMCARD_MARK_I) {
33
			if(shiroi->z80_pins & Z80_RD) {
34
				/* I/O Read */
35
				if(addr == 16) {
36
					Z80_SET_DATA(shiroi->z80_pins, shiroi->cards[i].romcard.data[shiroi->cards[i].romcard.latch_addr]);
37
				} else if(addr == 17) {
38
					Z80_SET_DATA(shiroi->z80_pins, shiroi->cards[i].type);
39
				}
40
			} else if(shiroi->z80_pins & Z80_WR) {
41
				/* I/O Write */
42
				if(addr == 15) {
43
					shiroi->cards[i].romcard.latch_addr <<= 8;
44
					shiroi->cards[i].romcard.latch_addr |= data;
45
				}
46
			}
47
		}
48
	}
49
}
50
 
51
void shiroi_romcard_mk_i_tick(shiroi_t* shiroi) {}