OVR: Add patch to make game render planets behind observer
[mercenary-reloaded.git] / src / mercenary / mercenary3.c
index 28751e2..7fe20c2 100644 (file)
@@ -110,6 +110,9 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x4F748,      STOP_AT_POLY_UKN2 },
        { 0x54362,      STOP_AT_EXPLOSION },                    /* explosion debris */
        { 0x4CA18,      STOP_AT_EXPLOSION },
+       { 0x53A6C,      STOP_AT_PATCH_RENDER },                 /* patch away planet check (behind observer) */
+       { 0x537B0,      STOP_AT_PATCH_RENDER },                 /* patch away planet check (behind observer) */
+       { 0x45806,      STOP_AT_PATCH_RENDER },                 /* patch away planet rendering (would crash without check above) */
        { 0x0,          STOP_AT_END },                          /* end */
 };
 
@@ -158,9 +161,10 @@ void mercenary_patch(void)
 //m68k_write_memory_16(0x58388, 0x4E75); /* rts */
 //m68k_write_memory_16(0x4FE3E, 0x4E75); /* rts */
 
-//test: loesche mit index 0
-//m68k_write_memory_16(0x5ABC2, 0x4e71); /* nop */
-//
+//m68k_write_memory_16(0x53A6C, 0x6008); /* bra */
+//m68k_write_memory_16(0x537B0, 0x6008); /* bra */
+//m68k_write_memory_16(0x45806, 0x4E75); /* rts */
+
 //m68k_write_memory_16(0x54342, 0x4e71); /* nop */
 //m68k_write_memory_16(0x54344, 0x4e71); /* nop */
 //m68k_write_memory_16(0x5059e, 0x3f0); /* nop */
@@ -192,6 +196,22 @@ m68k_write_memory_16(0x4FB6c, 0x4e71); /* nop */
        m68k_write_memory_32(0x55f5c, 1);
 }
 
+/* skip certain parts when rendering improved graphics */
+void mercenary_patch_render(void)
+{
+       switch (REG_PC) {
+       case 0x53A6C: /* take that branch, so planets get rendered behind obersver */
+               REG_PC += 10;
+               break;
+       case 0x537B0: /* take that branch, so planets get rendered behind obersver */
+               REG_PC += 10;
+               break;
+       case 0x45806: /* just RTS to avoid crashing of rendering functions when planets are behind obersver */
+               REG_PC -= 2;
+               break;
+       }
+}
+
 uint32_t mercenary_palette_view(void)
 {
        return m68k_read_memory_32(0x0072b0);