case MAPTYPE_ROM:
in = fopen(filename, "rb");
if (!in) {
- printf("[CFG] Failed to open file %s for ROM mapping.\n", filename);
+ printf("[CFG] Failed to open file %s for ROM mapping. Using onboard ROM instead, if available.\n", filename);
goto mapping_failed;
}
fseek(in, 0, SEEK_END);
fclose(in);
}
+void free_config_file(struct emulator_config *cfg) {
+ if (!cfg) {
+ printf("[CFG] Tried to free NULL config, aborting.\n");
+ }
+
+ if (cfg->platform) {
+ cfg->platform->shutdown(cfg);
+ free(cfg->platform);
+ cfg->platform = NULL;
+ }
+
+ for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
+ if (cfg->map_data[i]) {
+ free(cfg->map_data[i]);
+ cfg->map_data[i] = NULL;
+ }
+ if (cfg->map_id[i]) {
+ free(cfg->map_id[i]);
+ cfg->map_id[i] = NULL;
+ }
+ }
+ if (cfg->mouse_file) {
+ free(cfg->mouse_file);
+ cfg->mouse_file = NULL;
+ }
+ if (cfg->keyboard_file) {
+ free(cfg->keyboard_file);
+ cfg->keyboard_file = NULL;
+ }
+
+ m68k_clear_ranges();
+
+ printf("[CFG] Config file freed. Maybe.\n");
+}
+
struct emulator_config *load_config_file(char *filename) {
FILE *in = fopen(filename, "rb");
if (in == NULL) {
unsigned int get_m68k_cpu_type(char *name);
struct emulator_config *load_config_file(char *filename);
+void free_config_file(struct emulator_config *cfg);
int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type);
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);
#include "platforms/amiga/piscsi/piscsi-enums.h"
#include "platforms/amiga/net/pi-net.h"
#include "platforms/amiga/net/pi-net-enums.h"
+#include "platforms/amiga/pistorm-dev/pistorm-dev.h"
#include "gpio/ps_protocol.h"
#include <assert.h>
uint32_t do_disasm = 0, old_level;
uint32_t last_irq = 8, last_last_irq = 8;
-uint8_t end_signal = 0;
+uint8_t end_signal = 0, load_new_config = 0;
char disasm_buf[4096];
mouse_extra = 0x00;
}
+ if (load_new_config) {
+ printf("[CPU] Loading new config file.\n");
+ goto stop_cpu_emulation;
+ }
+
if (end_signal)
goto stop_cpu_emulation;
}
}
+switch_config:
+ if (load_new_config) {
+ load_new_config = 0;
+ free_config_file(cfg);
+ if (cfg) {
+ free(cfg);
+ cfg = NULL;
+ }
+
+ cfg = load_config_file(get_pistorm_devcfg_filename());
+ }
+
if (!cfg) {
printf("No config file specified. Trying to load default.cfg...\n");
cfg = load_config_file("default.cfg");
// wait for cpu task to end before closing up and finishing
pthread_join(cpu_tid, NULL);
- printf("[MAIN] All threads appear to have concluded; ending process\n");
+
+ if (!load_new_config)
+ printf("[MAIN] All threads appear to have concluded; ending process\n");
if (mouse_fd != -1)
close(mouse_fd);
if (mem_fd)
close(mem_fd);
+ if (load_new_config)
+ goto switch_config;
+
+ if (cfg->platform->shutdown) {
+ cfg->platform->shutdown(cfg);
+ }
+
return 0;
}
/* PiStorm speed hax */
void m68k_add_ram_range(uint32_t addr, uint32_t upper, unsigned char *ptr);
void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr);
+void m68k_clear_ranges();
/* Special call to simulate undocumented 68k behavior when move.l with a
* predecrement destination mode is executed.
}
}
+void m68k_clear_ranges()
+{
+ printf("[MUSASHI] Clearing all reads/write memory ranges.\n");
+ for (int i = 0; i < 8; i++) {
+ read_upper[i] = 0;
+ read_addr[i] = 0;
+ read_data[i] = NULL;
+ write_upper[i] = 0;
+ write_addr[i] = 0;
+ write_data[i] = NULL;
+ }
+ write_ranges = 0;
+ read_ranges = 0;
+}
+
/* ======================================================================== */
/* ============================== MAME STUFF ============================== */
/* ======================================================================== */
// PiStorm Device Interaction ROM
unsigned char ac_pistorm_rom[] = {
Z2_Z2, AC_MEM_SIZE_64KB, // 00/01, Z2, bootrom, 64 KB
- 0x6, 0xB, // 06/0A, product id
+ 0x6, 0xB, // 06/0B, product id
0x0, 0x0, // 00/0a, any space where it fits
0x0, 0x0, // 0c/0e, reserved
PISTORM_AC_MANUF_ID, // Manufacturer ID
extern void adjust_ranges_amiga(struct emulator_config *cfg);
+void autoconfig_reset_all() {
+ printf("[AUTOCONF] Resetting all autoconf data.\n");
+ for (int i = 0; i < AC_PIC_LIMIT; i++) {
+ ac_z2_type[i] = ACTYPE_NONE;
+ ac_z3_type[i] = ACTYPE_NONE;
+ ac_z2_index[i] = 0;
+ ac_z3_index[i] = 0;
+ }
+ ac_z3_pic_count = 0;
+ ac_z2_pic_count = 0;
+ ac_z2_current_pic = 0;
+ ac_z3_current_pic = 0;
+}
+
unsigned int autoconfig_read_memory_z3_8(struct emulator_config *cfg, unsigned int address) {
int index = ac_z3_index[ac_z3_current_pic];
unsigned char val = 0;
void autoconfig_write_memory_z3_8(struct emulator_config *cfg, unsigned int address, unsigned int value);
void autoconfig_write_memory_z3_16(struct emulator_config *cfg, unsigned int address, unsigned int value);
+void autoconfig_reset_all();
+
void add_z2_pic(uint8_t type, uint8_t index);
void remove_z2_pic(uint8_t type, uint8_t index);
int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val);
int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type);
int init_rtg_data();
+void shutdown_rtg();
extern int ac_z2_current_pic;
extern int ac_z2_done;
printf("Failed to write CDTV SRAM to disk.\n");
}
}
+ if (cfg->platform->subsys) {
+ free(cfg->platform->subsys);
+ }
+ if (piscsi_enabled) {
+ piscsi_shutdown();
+ piscsi_enabled = 0;
+ }
+ if (rtg_enabled) {
+ shutdown_rtg();
+ rtg_enabled = 0;
+ }
+ if (pinet_enabled) {
+ pinet_enabled = 0;
+ }
+
+ cdtv_mode = 0;
+
+ autoconfig_reset_all();
+ printf("[AMIGA] Platform shutdown completed.\n");
}
void create_platform_amiga(struct platform_config *cfg, char *subsys) {
devs[i].c = devs[i].h = devs[i].s = 0;
}
- FILE *in = fopen("./platforms/amiga/piscsi/piscsi.rom", "rb");
- if (in == NULL) {
- printf("[PISCSI] Could not open PISCSI Boot ROM file for reading!\n");
- // Zero out the boot ROM offset from the autoconfig ROM.
- ac_piscsi_rom[20] = 0;
- ac_piscsi_rom[21] = 0;
- ac_piscsi_rom[22] = 0;
- ac_piscsi_rom[23] = 0;
- return;
+ if (piscsi_rom_ptr == NULL) {
+ FILE *in = fopen("./platforms/amiga/piscsi/piscsi.rom", "rb");
+ if (in == NULL) {
+ printf("[PISCSI] Could not open PISCSI Boot ROM file for reading!\n");
+ // Zero out the boot ROM offset from the autoconfig ROM.
+ ac_piscsi_rom[20] = 0;
+ ac_piscsi_rom[21] = 0;
+ ac_piscsi_rom[22] = 0;
+ ac_piscsi_rom[23] = 0;
+ return;
+ }
+ fseek(in, 0, SEEK_END);
+ piscsi_rom_size = ftell(in);
+ fseek(in, 0, SEEK_SET);
+ piscsi_rom_ptr = malloc(piscsi_rom_size);
+ fread(piscsi_rom_ptr, piscsi_rom_size, 1, in);
+
+ fseek(in, PISCSI_DRIVER_OFFSET, SEEK_SET);
+ process_hunks(in, &piscsi_hinfo, piscsi_hreloc, PISCSI_DRIVER_OFFSET);
+
+ fclose(in);
+
+ printf("[PISCSI] Loaded Boot ROM.\n");
+ } else {
+ printf("[PISCSI] Boot ROM already loaded.\n");
}
- fseek(in, 0, SEEK_END);
- piscsi_rom_size = ftell(in);
- fseek(in, 0, SEEK_SET);
- piscsi_rom_ptr = malloc(piscsi_rom_size);
- fread(piscsi_rom_ptr, piscsi_rom_size, 1, in);
+ fflush(stdout);
+}
- fseek(in, PISCSI_DRIVER_OFFSET, SEEK_SET);
- process_hunks(in, &piscsi_hinfo, piscsi_hreloc, PISCSI_DRIVER_OFFSET);
+void piscsi_shutdown() {
+ printf("[PISCSI] Shutting down PiSCSI.\n");
+ for (int i = 0; i < 8; i++) {
+ if (devs[i].fd != -1) {
+ close(devs[i].fd);
+ devs[i].fd = -1;
+ }
+ }
- fclose(in);
- printf("[PISCSI] Loaded Boot ROM.\n");
+ for (int i = 0; i < NUM_FILESYSTEMS; i++) {
+ if (filesystems[i].binary_data) {
+ free(filesystems[i].binary_data);
+ filesystems[i].binary_data = NULL;
+ }
+ if (filesystems[i].fhb) {
+ free(filesystems[i].fhb);
+ filesystems[i].fhb = NULL;
+ }
+ filesystems[i].h_info.current_hunk = 0;
+ filesystems[i].h_info.reloc_hunks = 0;
+ filesystems[i].FS_ID = 0;
+ filesystems[i].handler = 0;
+ }
}
void piscsi_find_partitions(struct piscsi_dev *d) {
}
printf("[PISCSI] CHS: %d %d %d\n", d->c, d->h, d->s);
+ printf ("Finding partitions.\n");
piscsi_find_partitions(d);
+ printf ("Finding file systems.\n");
piscsi_find_filesystems(d);
+ printf ("Done.\n");
}
void piscsi_unmap_drive(uint8_t index) {
};
void piscsi_init();
+void piscsi_shutdown();
void piscsi_map_drive(char *filename, uint8_t index);
void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type);
PI_DBG_VAL6 = 0x1024, // [RW]
PI_DBG_VAL7 = 0x1028, // [RW]
PI_DBG_VAL8 = 0x102C, // [RW]
- PI_DBG_STR1 = 0x1030, // [RW] Pointers to debug strings (typically in "Amiga RAM")
- PI_DBG_STR2 = 0x1034, // [RW]
- PI_DBG_STR3 = 0x1038, // [RW]
- PI_DBG_STR4 = 0x103C, // [RW]
+ PI_DBG_STR1 = 0x1030, // [W] Pointers to debug strings (typically in "Amiga RAM")
+ PI_DBG_STR2 = 0x1034, // [W]
+ PI_DBG_STR3 = 0x1038, // [W]
+ PI_DBG_STR4 = 0x103C, // [W]
PI_BYTE1 = 0x2000, // [RW] // Bytes, words and longwords used as extended arguments.
PI_BYTE2 = 0x2001, // [RW] // for PiStorm interaction device commands.
PI_LONGWORD2 = 0x2014, // [RW]
PI_LONGWORD3 = 0x2018, // [RW]
PI_LONGWORD4 = 0x201C, // [RW]
- PI_STR1 = 0x2020, // [RW] Pointers to strings (typically in "Amiga RAM")
- PI_STR2 = 0x2024, // [RW]
- PI_STR3 = 0x2028, // [RW]
- PI_STR4 = 0x202C, // [RW]
+ PI_STR1 = 0x2020, // [W] Pointers to strings (typically in "Amiga RAM")
+ PI_STR2 = 0x2024, // [W]
+ PI_STR3 = 0x2028, // [W]
+ PI_STR4 = 0x202C, // [W]
PI_CMDRESULT = 0x2100, // [R] Check the result of any command that provides a "return value".
};
+
+enum pistorm_piscsi_ctrl_commands {
+ PISCSI_CTRL_NONE,
+ PISCSI_CTRL_MAP, // For hard drives
+ PISCSI_CTRL_UNMAP, //
+ PISCSI_CTRL_EJECT, // For optical media, not yet implemented
+ PISCSI_CTRL_INSERT, //
+ PISCSI_CTRL_NUM,
+};
+
+enum pistorm_config_commands {
+ PICFG_LOAD, // Load a config file from string at PI_STR1
+ PICFG_RELOAD, // Reload current config file, in case hard drives or ROM has been changed
+ PICFG_DEFAULT, // Load default.cfg if it exists
+ PICFG_NUM,
+};
#include "pistorm-dev.h"
#include "pistorm-dev-enums.h"
+#include "platforms/platforms.h"
+#include "gpio/ps_protocol.h"
+
#include <stdio.h>
+#include <string.h>
#define DEBUG_PISTORM_DEVICE
extern uint32_t pistorm_dev_base;
extern uint32_t do_reset;
-extern uint8_t rtg_enabled, rtg_on, pinet_enabled, piscsi_enabled;
+extern uint8_t rtg_enabled, rtg_on, pinet_enabled, piscsi_enabled, load_new_config;
+extern struct emulator_config *cfg;
+
+char cfg_filename[256];
+
+static uint8_t pi_byte[8];
+static uint16_t pi_word[4];
+static uint32_t pi_longword[4];
+static uint32_t pi_string[4];
+
+static uint32_t pi_dbg_val[4];
+static uint32_t pi_dbg_string[4];
+
+static uint32_t pi_cmd_result = 0;
+
+int32_t grab_amiga_string(uint32_t addr, uint8_t *dest, uint32_t str_max_len) {
+ int32_t r = get_mapped_item_by_address(cfg, addr);
+ uint32_t index = 0;
+
+ if (r == -1) {
+ DEBUG("[GRAB_AMIGA_STRING] No mapped range found for address $%.8X. Grabbing string data over the bus.\n", addr);
+ do {
+ dest[index] = read8(addr + index);
+ index++;
+ } while (dest[index - 1] != 0x00 && index < str_max_len);
+ }
+ else {
+ uint8_t *src = cfg->map_data[r] + (addr - cfg->map_offset[r]);
+ do {
+ dest[index] = src[index];
+ index++;
+ } while (dest[index - 1] != 0x00 && index < str_max_len);
+ }
+ if (index == str_max_len) {
+ memset(dest, 0x00, str_max_len + 1);
+ return -1;
+ }
+ DEBUG("[GRAB_AMIGA_STRING] Grabbed string: %s\n", dest);
+ return (int32_t)strlen((const char*)dest);
+}
+
+char *get_pistorm_devcfg_filename() {
+ return cfg_filename;
+}
+
+void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
+ uint32_t addr = (addr_ & 0xFFFF);
+
+ switch((addr)) {
+ case PI_DBG_MSG:
+ // Output debug message based on value written and data in val/str registers.
+ break;
+ case PI_DBG_VAL1: case PI_DBG_VAL2: case PI_DBG_VAL3: case PI_DBG_VAL4:
+ case PI_DBG_VAL5: case PI_DBG_VAL6: case PI_DBG_VAL7: case PI_DBG_VAL8:
+ DEBUG("[PISTORM-DEV] Set DEBUG VALUE %d to %d ($%.8X)\n", (addr - PI_DBG_VAL1) / 4, val, val);
+ pi_dbg_val[(addr - PI_DBG_VAL1) / 4] = val;
+ break;
+ case PI_DBG_STR1: case PI_DBG_STR2: case PI_DBG_STR3: case PI_DBG_STR4:
+ DEBUG("[PISTORM-DEV] Set DEBUG STRING POINTER %d to $%.8X\n", (addr - PI_DBG_STR1) / 4, val);
+ pi_dbg_string[(addr - PI_DBG_STR1) / 4] = val;
+ break;
+
+ case PI_BYTE1: case PI_BYTE2: case PI_BYTE3: case PI_BYTE4:
+ case PI_BYTE5: case PI_BYTE6: case PI_BYTE7: case PI_BYTE8:
+ DEBUG("[PISTORM-DEV] Set BYTE %d to %d ($%.2X)\n", addr - PI_BYTE1, (val & 0xFF), (val & 0xFF));
+ pi_byte[addr - PI_BYTE1] = (val & 0xFF);
+ break;
+ case PI_WORD1: case PI_WORD2: case PI_WORD3: case PI_WORD4:
+ DEBUG("[PISTORM-DEV] Set WORD %d to %d ($%.4X)\n", (addr - PI_WORD1) / 2, (val & 0xFFFF), (val & 0xFFFF));
+ pi_word[(addr - PI_WORD1) / 2] = (val & 0xFFFF);
+ break;
+ case PI_LONGWORD1: case PI_LONGWORD2: case PI_LONGWORD3: case PI_LONGWORD4:
+ DEBUG("[PISTORM-DEV] Set LONGWORD %d to %d ($%.8X)\n", (addr - PI_LONGWORD1) / 4, val, val);
+ pi_longword[(addr - PI_LONGWORD1) / 4] = val;
+ break;
+ case PI_STR1: case PI_STR2: case PI_STR3: case PI_STR4:
+ DEBUG("[PISTORM-DEV] Set STRING POINTER %d to $%.8X\n", (addr - PI_STR1) / 4, val);
+ pi_string[(addr - PI_STR1) / 4] = val;
+ break;
-void handle_pistorm_dev_write(uint32_t addr, uint32_t val, uint8_t type) {
- switch((addr & 0xFFFF)) {
case PI_CMD_RESET:
- DEBUG("[PISTORM-DEV] System reset called through PiStorm interaction device, code %d\n", (val & 0xFFFF));
+ DEBUG("[PISTORM-DEV] System reset called, code %d\n", (val & 0xFFFF));
do_reset = 1;
break;
+ case PI_CMD_SWITCHCONFIG:
+ DEBUG("[PISTORM-DEV] Config switch called, command: ");
+ switch (val) {
+ case PICFG_LOAD:
+ DEBUG("LOAD\n");
+ if (pi_string[0] == 0 || grab_amiga_string(pi_string[0], (uint8_t *)cfg_filename, 255) == -1) {
+ printf("[PISTORM-DEV] Failed to grab string for config filename. Aborting.\n");
+ } else {
+ FILE *tmp = fopen(cfg_filename, "rb");
+ if (tmp == NULL) {
+ printf("[PISTORM-DEV] Failed to open config file %s for reading. Aborting.\n", cfg_filename);
+ } else {
+ printf("[PISTORM-DEV] Attempting to load config file %s...\n", cfg_filename);
+ load_new_config = 1;
+ }
+ }
+ pi_string[0] = 0;
+ break;
+ case PICFG_RELOAD:
+ DEBUG("RELOAD\n");
+ break;
+ case PICFG_DEFAULT:
+ DEBUG("DEFAULT\n");
+ break;
+ default:
+ DEBUG("UNKNOWN. Command ignored.\n");
+ break;
+ }
+ break;
default:
DEBUG("[PISTORM-DEV] WARN: Unhandled %s register write to %.4X: %d\n", op_type_names[type], addr - pistorm_dev_base, val);
break;
}
}
-uint32_t handle_pistorm_dev_read(uint32_t addr, uint8_t type) {
- switch((addr & 0xFFFF)) {
+uint32_t handle_pistorm_dev_read(uint32_t addr_, uint8_t type) {
+ uint32_t addr = (addr_ & 0xFFFF);
+
+ switch((addr)) {
case PI_CMD_HWREV:
// Probably replace this with some read from the CPLD to get a simple hardware revision.
DEBUG("[PISTORM-DEV] %s Read from HWREV\n", op_type_names[type]);
DEBUG("[PISTORM-DEV] %s Read from PISCSI_CTRL\n", op_type_names[type]);
return piscsi_enabled;
break;
+
+ case PI_DBG_VAL1: case PI_DBG_VAL2: case PI_DBG_VAL3: case PI_DBG_VAL4:
+ case PI_DBG_VAL5: case PI_DBG_VAL6: case PI_DBG_VAL7: case PI_DBG_VAL8:
+ DEBUG("[PISTORM-DEV] Read DEBUG VALUE %d (%d / $%.8X)\n", (addr - PI_DBG_VAL1) / 4, pi_dbg_val[(addr - PI_DBG_VAL1) / 4], pi_dbg_val[(addr - PI_DBG_VAL1) / 4]);
+ return pi_dbg_val[(addr - PI_DBG_VAL1) / 4];
+ break;
+
+ case PI_BYTE1: case PI_BYTE2: case PI_BYTE3: case PI_BYTE4:
+ case PI_BYTE5: case PI_BYTE6: case PI_BYTE7: case PI_BYTE8:
+ DEBUG("[PISTORM-DEV] Read BYTE %d (%d / $%.2X)\n", addr - PI_BYTE1, pi_byte[addr - PI_BYTE1], pi_byte[addr - PI_BYTE1]);
+ return pi_byte[addr - PI_BYTE1];
+ break;
+ case PI_WORD1: case PI_WORD2: case PI_WORD3: case PI_WORD4:
+ DEBUG("[PISTORM-DEV] Read WORD %d (%d / $%.4X)\n", (addr - PI_WORD1) / 2, pi_word[(addr - PI_WORD1) / 2], pi_word[(addr - PI_WORD1) / 2]);
+ return pi_word[(addr - PI_WORD1) / 2];
+ break;
+ case PI_LONGWORD1: case PI_LONGWORD2: case PI_LONGWORD3: case PI_LONGWORD4:
+ DEBUG("[PISTORM-DEV] Read LONGWORD %d (%d / $%.8X)\n", (addr - PI_LONGWORD1) / 4, pi_longword[(addr - PI_LONGWORD1) / 4], pi_longword[(addr - PI_LONGWORD1) / 4]);
+ return pi_longword[(addr - PI_LONGWORD1) / 4];
+ break;
+
+ case PI_CMDRESULT:
+ DEBUG("[PISTORM-DEV] %s Read from CMDRESULT\n", op_type_names[type]);
+ return pi_cmd_result;
+ break;
+
default:
DEBUG("[PISTORM-DEV] WARN: Unhandled %s register read from %.4X\n", op_type_names[type], addr - pistorm_dev_base);
break;
void handle_pistorm_dev_write(uint32_t addr, uint32_t val, uint8_t type);
uint32_t handle_pistorm_dev_read(uint32_t addr, uint8_t type);
+char *get_pistorm_devcfg_filename();
#include <proto/disk.h>
#include <proto/expansion.h>
+#ifdef HAS_STDLIB
#include <stdio.h>
+#endif
unsigned int pistorm_base_addr = 0xFFFFFFFF;
#define WRITESHORT(cmd, val) *(unsigned short *)((unsigned int)(pistorm_base_addr+cmd)) = val;
#define WRITELONG(cmd, val) *(unsigned int *)((unsigned int)(pistorm_base_addr+cmd)) = val;
-#define WRITEBYTE(cmd, val) *(unsigned char *)((unsigned int)(pistorm_base_addrT+cmd)) = val;
+#define WRITEBYTE(cmd, val) *(unsigned char *)((unsigned int)(pistorm_base_addr+cmd)) = val;
#define READSHORT(cmd, var) var = *(volatile unsigned short *)(pistorm_base_addr + cmd);
#define READLONG(cmd, var) var = *(volatile unsigned int *)(pistorm_base_addr + cmd);
WRITESHORT(PI_CMD_RESET, reset_code);
}
+void pi_handle_config(unsigned char cmd, char *str) {
+ if (cmd == PICFG_LOAD) {
+ WRITELONG(PI_STR1, (unsigned int)str);
+ }
+ WRITESHORT(PI_CMD_SWITCHCONFIG, cmd);
+}
+
#define SIMPLEREAD_SHORT(a, b) \
unsigned short a() { READSHORT(b, short_val); return short_val; }
// SPDX-License-Identifier: MIT
-unsigned long pi_find_pistorm();
+unsigned int pi_find_pistorm();
unsigned short pi_get_hw_rev();
unsigned short pi_get_sw_rev();
unsigned short pi_get_rtg_status();
void pi_reset_amiga(unsigned short reset_code);
+void pi_handle_config(unsigned char cmd, char *str);
extern unsigned int pistorm_base_addr;
+unsigned short cmd_arg = 0;
+
int __stdargs main (int argc, char *argv[]) {
if (argc < 2) {
print_usage(argv[0]);
printf ("RTG: %s - %s\n", (pi_get_rtg_status() & 0x01) ? "Enabled" : "Disabled", (pi_get_rtg_status() & 0x02) ? "In use" : "Not in use");
printf ("NET: %s\n", pi_get_net_status() ? "Enabled" : "Disabled");
break;
+ case PI_CMD_SWITCHCONFIG:
+ if (cmd_arg == PICFG_LOAD) {
+ if (argc < 3) {
+ printf ("User asked to load config, but no config filename specified.\n");
+ }
+ }
+ pi_handle_config(cmd_arg, argv[2]);
+ break;
default:
printf ("Unhandled command %s.\n", argv[1]);
return 1;
if (strcmp(cmd, "--check") == 0 || strcmp(cmd, "--find") == 0 || strcmp(cmd, "--info") == 0) {
return PI_CMD_SWREV;
}
+ if (strcmp(cmd, "--config") == 0 || strcmp(cmd, "--config-file") == 0 || strcmp(cmd, "--cfg") == 0) {
+ cmd_arg = PICFG_LOAD;
+ return PI_CMD_SWITCHCONFIG;
+ }
return -1;
}
uint8_t realtime_graphics_debug = 0;
extern int cpu_emulation_running;
+extern uint8_t rtg_on;
+
/*
static const char *op_type_names[OP_TYPE_NUM] = {
"BYTE",
return 1;
}
-//extern uint8_t busy, rtg_on;
+void shutdown_rtg() {
+ printf("[RTG] Shutting down RTG.\n");
+ if (rtg_on) {
+ rtg_on = 0;
+ }
+ if (rtg_mem) {
+ free(rtg_mem);
+ rtg_mem = NULL;
+ }
+}
+
//void rtg_update_screen();
unsigned int rtg_read(uint32_t address, uint8_t mode) {