#include "main.h"
#include "platforms/platforms.h"
#include "input/input.h"
-#include "gpio/gpio.h"
#include "platforms/amiga/Gayle.h"
#include "platforms/amiga/gayle-ide/ide.h"
#include "platforms/amiga/amiga-registers.h"
+#include "gpio/gpio.h"
int kb_hook_enabled = 0;
int mouse_hook_enabled = 0;
char mouse_dx = 0, mouse_dy = 0;
char mouse_buttons = 0;
+extern volatile unsigned int *gpio;
+extern volatile uint16_t srdata;
+
#define KICKBASE 0xF80000
#define KICKSIZE 0x7FFFF
m68k_set_reg(M68K_REG_PC, 0x0);
}
-/*
- pthread_t id;
- int err;
- err = pthread_create(&id, NULL, &iplThread, NULL);
- if (err != 0)
- printf("\ncan't create IPL thread :[%s]", strerror(err));
- else
- printf("\n IPL Thread created successfully\n");
-*/
char c = 0;
m68k_pulse_reset();
}
}
}*/
-/*
- if (toggle == 1){
- srdata = read_reg();
- m68k_set_irq((srdata >> 13) & 0xff);
- } else {
- m68k_set_irq(0);
- };
- usleep(1);
-*/
-
- gpio_handle_irq();
+
+ //gpio_handle_irq();
+ GPIO_HANDLE_IRQ;
}
stop_cpu_emulation:;
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "../m68k.h"
-#include "gpio.h"
#include "../platforms/amiga/Gayle.h"
+#include "../platforms/amiga/gayle-ide/ide.h"
+#include "gpio.h"
// I/O access
volatile unsigned int *gpio;
GPIO_SET = 1 << 7;
}
-void gpio_handle_irq() {
+inline void gpio_handle_irq() {
if (GET_GPIO(1) == 0) {
srdata = read_reg();
m68k_set_irq((srdata >> 13) & 0xff);
} else {
- if (CheckIrq() == 1) {
+ if ((gayle_int & 0x80) && get_ide(0)->drive->intrq) {
write16(0xdff09c, 0x8008);
m68k_set_irq(2);
}
#define GPIO_PULL *(gpio + 37) // Pull up/pull down
#define GPIO_PULLCLK0 *(gpio + 38) // Pull up/pull down clock
+#define GPIO_HANDLE_IRQ \
+ if (GET_GPIO(1) == 0) { \
+ srdata = read_reg(); \
+ m68k_set_irq((srdata >> 13) & 0xff); \
+ } else { \
+ if ((gayle_int & 0x80) && get_ide(0)->drive->intrq) { \
+ write16(0xdff09c, 0x8008); \
+ m68k_set_irq(2); \
+ } \
+ else \
+ m68k_set_irq(0); \
+ }; \
+
+extern uint8_t gayle_int;
+
void setup_io();
void gpio_enable_200mhz();
void gpio_handle_irq();
#define GAYLE_INT_BVD_LEV 0x02 /* BVD int level, 0=lev2,1=lev6 */
#define GAYLE_INT_BSY_LEV 0x01 /* BSY int level, 0=lev2,1=lev6 */
-#define GAYLE_MAX_HARDFILES 8
-
int counter;
-static uint8_t gayle_irq, gayle_int, gayle_cs, gayle_cs_mask, gayle_cfg;
+static uint8_t gayle_irq, gayle_cs, gayle_cs_mask, gayle_cfg;
static struct ide_controller *ide0;
int fd;
uint8_t cdtv_mode = 0;
unsigned char cdtv_sram[32 * SIZE_KILO];
+uint8_t gayle_int;
+
+struct ide_controller *get_ide(int index) {
+ //if (index) {}
+ return ide0;
+}
+
void set_hard_drive_image_file_amiga(uint8_t index, char *filename) {
if (hdd_image_file[index] != NULL)
free(hdd_image_file[index]);
#ifndef Gayle_h
#define Gayle_h
+#define GAYLE_MAX_HARDFILES 8
+
#include <stdio.h>
#include <stdint.h>
uint8_t readGayleB(unsigned int address);
uint16_t readGayle(unsigned int address);
uint32_t readGayleL(unsigned int address);
+
+struct ide_controller *get_ide(int index);
#endif /* Gayle_h */
#define IDE_CMD_IDENTIFY 0xEC
#define IDE_CMD_SETFEATURES 0xEF
-const uint8_t ide_magic[8] = {
- '1','D','E','D','1','5','C','0'
+const uint8_t ide_magic[9] = {
+ '1','D','E','D','1','5','C','0',0x00
};
static char *charmap(uint8_t v)
};
//extern ide_controller idectrl;
-extern const uint8_t ide_magic[8];
+extern const uint8_t ide_magic[9];
void ide_reset_begin(struct ide_controller *c);
uint8_t ide_read8(struct ide_controller *c, uint8_t r);