Skip to content

Commit

Permalink
[WIP] Pile of stuff
Browse files Browse the repository at this point in the history
PiSCSI Boot ROM progress, various fixes and enhancements, TD64 support
Added updated open source RTL and bit stream by Niklas Ekström (https://github.com/niklasekstrom)
  • Loading branch information
beeanyew committed Feb 10, 2021
1 parent ed138fb commit e764148
Show file tree
Hide file tree
Showing 36 changed files with 24,718 additions and 148 deletions.
2 changes: 1 addition & 1 deletion 68new.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ reset_config srst_only srst_open_drain
transport select jtag
jtag newtap max2 tap -irlen 11 -expected-id 0x020a20dd
init
svf bitstream.svf -quiet
svf ./rtl/bitstream.svf -quiet
sleep 200
shutdown
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ MAINFILES = emulator.c \
memory_mapped.c \
config_file/config_file.c \
input/input.c \
gpio/gpio.c \
gpio/ps_protocol.c \
platforms/platforms.c \
platforms/amiga/amiga-autoconf.c \
platforms/amiga/amiga-platform.c \
platforms/amiga/amiga-registers.c \
platforms/dummy/dummy-platform.c \
platforms/dummy/dummy-registers.c \
platforms/amiga/Gayle.c \
platforms/amiga/hunk-reloc.c \
platforms/amiga/gayle-ide/ide.c \
platforms/amiga/cdtv-dmac.c \
platforms/amiga/rtg/rtg.c \
Expand All @@ -36,7 +37,7 @@ EXEPATH = ./

CC = gcc
WARNINGS = -Wall -Wextra -pedantic
CFLAGS = $(WARNINGS) -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3
CFLAGS = $(WARNINGS) -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
LFLAGS = $(WARNINGS) `sdl2-config --libs`

TARGET = $(EXENAME)$(EXE)
Expand Down
62 changes: 40 additions & 22 deletions emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "platforms/amiga/piscsi/piscsi-enums.h"
#include "platforms/amiga/net/pi-net.h"
#include "platforms/amiga/net/pi-net-enums.h"
#include "gpio/gpio.h"
#include "gpio/ps_protocol.h"

unsigned char read_ranges;
unsigned int read_addr[8];
Expand All @@ -45,10 +45,12 @@ int cpu_emulation_running = 1;
char mouse_dx = 0, mouse_dy = 0;
char mouse_buttons = 0;

extern uint8_t gayle_int;
extern uint8_t gayle_a4k_int;
extern volatile unsigned int *gpio;
extern volatile uint16_t srdata;
extern uint8_t realtime_graphics_debug;
uint8_t realtime_disassembly;
uint8_t realtime_disassembly, int2_enabled = 0;
uint32_t do_disasm = 0;

char disasm_buf[4096];
Expand Down Expand Up @@ -206,7 +208,7 @@ int main(int argc, char *argv[]) {
InitGayle();

signal(SIGINT, sigint_handler);
setup_io();
/*setup_io();
//goto skip_everything;
Expand Down Expand Up @@ -237,7 +239,16 @@ int main(int argc, char *argv[]) {
m68k_set_reg(M68K_REG_PC, 0xF80002);
} else {
m68k_set_reg(M68K_REG_PC, 0x0);
}
}*/
ps_setup_protocol();
ps_reset_state_machine();
ps_pulse_reset();

usleep(1500);
m68k_init();
printf("Setting CPU type to %d.\n", cpu_type);
m68k_set_cpu_type(cpu_type);
cpu_pulse_reset();

char c = 0, c_code = 0, c_type = 0;

Expand Down Expand Up @@ -275,14 +286,13 @@ int main(int argc, char *argv[]) {
unsigned int status = read_reg();
m68k_set_irq((status & 0xe000) >> 13);
}
else if (gayleirq) {
else if (gayleirq && int2_enabled) {
write16(0xdff09c, 0x8000 | (1 << 3));
//PAULA_SET_IRQ(3); // IRQ 3 = INT2
m68k_set_irq(2);
}
else {
m68k_set_irq(0);
}
/*else {
m68k_set_irq(0);
}*/

while (get_key_char(&c, &c_code, &c_type)) {
if (c && c == cfg->keyboard_toggle_key && !kb_hook_enabled) {
Expand Down Expand Up @@ -310,7 +320,7 @@ int main(int argc, char *argv[]) {
printf("unknown.\n");
break;
}*/
if (queue_keypress(c_code, c_type, cfg->platform->id)) {
if (queue_keypress(c_code, c_type, cfg->platform->id) && int2_enabled) {
m68k_set_irq(2);
}
}
Expand Down Expand Up @@ -361,9 +371,6 @@ int main(int argc, char *argv[]) {
}
}
}

//gpio_handle_irq();
//GPIO_HANDLE_IRQ;
}

stop_cpu_emulation:;
Expand All @@ -377,10 +384,11 @@ int main(int argc, char *argv[]) {
}

void cpu_pulse_reset(void) {
write_reg(0x00);
ps_pulse_reset();
//write_reg(0x00);
// printf("Status Reg%x\n",read_reg());
usleep(100000);
write_reg(0x02);
//usleep(100000);
//write_reg(0x02);
// printf("Status Reg%x\n",read_reg());
if (cfg->platform->handle_reset)
cfg->platform->handle_reset(cfg);
Expand Down Expand Up @@ -450,9 +458,13 @@ unsigned int m68k_read_memory_8(unsigned int address) {
}*/


if (address & 0xFF000000)
return 0;

unsigned char result = (unsigned int)read8((uint32_t)address);

if (mouse_hook_enabled) {
if (address == CIAAPRA) {
unsigned char result = (unsigned int)read8((uint32_t)address);
if (mouse_buttons & 0x01) {
//mouse_buttons -= 1;
return (unsigned int)(result ^ 0x40);
Expand All @@ -462,7 +474,6 @@ unsigned int m68k_read_memory_8(unsigned int address) {
}
}
if (kb_hook_enabled) {
unsigned char result = (unsigned int)read8((uint32_t)address);
if (address == CIAAICR) {
if (get_num_kb_queued() && (!send_keypress || send_keypress == 1)) {
result |= 0x08;
Expand All @@ -487,10 +498,7 @@ unsigned int m68k_read_memory_8(unsigned int address) {
}
}

if (address & 0xFF000000)
return 0;

return read8((uint32_t)address);
return result;
}

unsigned int m68k_read_memory_16(unsigned int address) {
Expand Down Expand Up @@ -640,6 +648,16 @@ void m68k_write_memory_16(unsigned int address, unsigned int value) {
char *beb = (char *)&value;
printf("%c%c", beb[1], beb[0]);
}
if (address == 0xDFF09A) {
if (!(value & 0x8000)) {
if (value & 0x04) {
int2_enabled = 0;
}
}
else if (value & 0x04) {
int2_enabled = 1;
}
}

if (address & 0xFF000000)
return;
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions gpio/gpio.h → gpio/gpio_old.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@
reset |= (1 << (no)); \
} while (0)

#define JOY0DAT 0xDFF00A
#define JOY1DAT 0xDFF00C
#define CIAAPRA 0xBFE001
#define CIAADAT 0xBFEC01
#define CIAAICR 0xBFED01
#define POTGOR 0xDFF016

// GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or
// SET_GPIO_ALT(x,y)
#define INP_GPIO(g) *(gpio + ((g) / 10)) &= ~(7 << (((g) % 10) * 3))
Expand Down Expand Up @@ -84,9 +77,6 @@
m68k_set_irq(0); \
}; \

extern uint8_t gayle_int;
extern uint8_t gayle_a4k_int;

void setup_io();
void gpio_enable_200mhz();
void gpio_handle_irq();
Expand Down
Loading

0 comments on commit e764148

Please sign in to comment.