@@ -118,29 +118,59 @@ int main(int argc, char *argv[]) {
118118 }
119119 }
120120
121- if ((IsoInfo -> boot_mode != BOOT_MODE_DIRECT ) ||
122- ((loader_end < CACHED_ADDR (IP_BIN_ADDR ) ||
123- loader_addr > CACHED_ADDR (APP_BIN_ADDR )) &&
124- (malloc_heap_pos () < CACHED_ADDR (IP_BIN_ADDR ) ||
125- malloc_heap_pos () > CACHED_ADDR (APP_BIN_ADDR )))
126- ) {
127- printf ("Loading IP.BIN...\n" );
128-
129- if (!Load_IPBin (IsoInfo -> boot_mode == BOOT_MODE_DIRECT ? 1 : 0 )) {
130- goto error ;
121+ if (IsoInfo -> image_type == IMAGE_TYPE_ROM_NAOMI ) {
122+
123+ /* Clear ROM DMA busy flag */
124+ * ((uint32_t * )NONCACHED_ADDR (0x0c0000ac )) = 0 ;
125+
126+ /* Set VBR address for IRQ vectors */
127+ boot_vbr = CACHED_ADDR (0x0c000000 );
128+ LOGF ("Setting VBR address to %08lx\n" , boot_vbr );
129+
130+ /* Set stack pointer */
131+ boot_stack = CACHED_ADDR (0x0cc00000 );
132+ LOGF ("Setting stack pointer to %08lx\n" , boot_stack );
133+
134+ /* Set SR value */
135+ boot_sr = 0x60000101 ;
136+ LOGF ("Setting SR to %08lx\n" , boot_sr );
137+
138+ uint8_t * dst = (uint8_t * ) NONCACHED_ADDR (SYSCALLS_FW_ADDR );
139+ uint8_t * src = (uint8_t * ) IsoInfo -> syscalls ;
140+ LOGF ("Loading IRQ vectors from %08lx to %08lx %d bytes\n" ,
141+ (uintptr_t )src , (uintptr_t )dst , 0x4f00 );
142+ memcpy (dst , src , 0x4f00 );
143+
144+ dst = (uint8_t * ) NONCACHED_ADDR (0x0c018000 );
145+ src = (uint8_t * ) IsoInfo -> syscalls + 0x4f00 ;
146+ LOGF ("Loading IRQ handlers from %08lx to %08lx %d bytes\n" ,
147+ (uintptr_t )src , (uintptr_t )dst , 0x7000 );
148+ memcpy (dst , src , 0x7000 );
149+ }
150+ else {
151+ if ((IsoInfo -> boot_mode != BOOT_MODE_DIRECT ) ||
152+ ((loader_end < CACHED_ADDR (IP_BIN_ADDR ) ||
153+ loader_addr > CACHED_ADDR (APP_BIN_ADDR )) &&
154+ (malloc_heap_pos () < CACHED_ADDR (IP_BIN_ADDR ) ||
155+ malloc_heap_pos () > CACHED_ADDR (APP_BIN_ADDR )))
156+ ) {
157+ printf ("Loading IP.BIN...\n" );
158+
159+ if (!Load_IPBin (IsoInfo -> boot_mode == BOOT_MODE_DIRECT ? 1 : 0 )) {
160+ goto error ;
161+ }
162+ }
163+ if (IsoInfo -> exec .type != BIN_TYPE_KOS ) {
164+ /* Patch GDC driver entry */
165+ gdc_syscall_patch ();
131166 }
132- }
133-
134- if (IsoInfo -> exec .type != BIN_TYPE_KOS ) {
135- /* Patch GDC driver entry */
136- gdc_syscall_patch ();
137- }
138167
139- if (!is_dreamcast () && IsoInfo -> exec .type == BIN_TYPE_KATANA ) {
140- argc = patch_memory (0xff800030 , (uint32 )(& IsoInfo -> cdda_offset [0 ]), 0 );
141- LOGF ("Patch GPIO register: %d\n" , argc );
142- argc = patch_memory (0xffe80000 , (uint32 )(& IsoInfo -> cdda_offset [1 ]), 0 );
143- LOGF ("Patch SCIF register: %d\n" , argc );
168+ if (!is_dreamcast () && IsoInfo -> exec .type == BIN_TYPE_KATANA ) {
169+ /* Patch GPIO register to prevent cable detection */
170+ argc = patch_memory (0xff800030 ,
171+ IsoInfo -> cdda_offset [(sizeof (IsoInfo -> cdda_offset ) / 4 ) - 1 ], 0 );
172+ LOGF ("Patch GPIO register: %d\n" , argc );
173+ }
144174 }
145175
146176#ifdef HAVE_EXPT
@@ -151,7 +181,7 @@ int main(int argc, char *argv[]) {
151181#endif
152182
153183#ifdef HAVE_EXT_SYSCALLS
154- if (IsoInfo -> syscalls ) {
184+ if (IsoInfo -> syscalls && IsoInfo -> image_type != IMAGE_TYPE_ROM_NAOMI ) {
155185 printf ("Loading syscalls...\n" );
156186 Load_Syscalls ();
157187 }
0 commit comments