]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/rtg/rtg.c
Update rtg.c
[pistorm] / platforms / amiga / rtg / rtg.c
index a4be06952d528bd5aa9392ca16ac390ae247b5bc..a3fe168262528fefc4aa9a397e63d096078704b3 100644 (file)
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: MIT
+
 #include <stdint.h>
 #include <endian.h>
 #include <stdio.h>
@@ -28,11 +30,14 @@ uint32_t framebuffer_addr = 0;
 uint32_t framebuffer_addr_adj = 0;
 
 static void handle_rtg_command(uint32_t cmd);
-static struct timespec f1, f2;
+//static struct timespec f1, f2;
 
 uint8_t realtime_graphics_debug = 0;
 extern int cpu_emulation_running;
+extern struct emulator_config *cfg;
+extern uint8_t rtg_on;
 
+/*
 static const char *op_type_names[OP_TYPE_NUM] = {
     "BYTE",
     "WORD",
@@ -46,7 +51,7 @@ static const char *rtg_format_names[RTGFMT_NUM] = {
     "32BPP RGB (RGBA)",
     "15BPP RGB (555)",
 };
-
+*/
 int init_rtg_data() {
     rtg_mem = calloc(1, 40 * SIZE_MEGA);
     if (!rtg_mem) {
@@ -54,11 +59,28 @@ int init_rtg_data() {
         return 0;
     }
 
+    m68k_add_ram_range(PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, rtg_mem);
+    add_mapping(cfg, MAPTYPE_RAM_NOALLOC, PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, -1, rtg_mem, "rtg_mem");
     return 1;
 }
 
-extern uint8_t busy, rtg_on;
-void rtg_update_screen();
+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_get_fb() {
+    return PIGFX_RTG_BASE + PIGFX_REG_SIZE + framebuffer_addr_adj;
+}
 
 unsigned int rtg_read(uint32_t address, uint8_t mode) {
     //printf("%s read from RTG: %.8X\n", op_type_names[mode], address);
@@ -178,7 +200,7 @@ void rtg_write(uint32_t address, uint32_t value, uint8_t mode) {
 #define gdebug(a) if (realtime_graphics_debug) { printf(a); m68k_end_timeslice(); cpu_emulation_running = 0; }
 
 static void handle_rtg_command(uint32_t cmd) {
-    //printf("Handling RTG command %d (%.8X)\n", cmd, cmd);
+  //printf("Handling RTG command %d (%.8X)\n", cmd, cmd);
     switch (cmd) {
         case RTGCMD_SETGC:
             rtg_display_format = rtg_format;