Annotation of hatari/src/uae-cpu/hatari-glue.c, revision 1.1.1.12

1.1.1.6   root        1: /*
                      2:   Hatari - hatari-glue.c
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      6: 
                      7:   This file contains some code to glue the UAE CPU core to the rest of the
                      8:   emulator and Hatari's "illegal" opcodes.
                      9: */
1.1.1.12! root       10: const char HatariGlue_rcsid[] = "Hatari $Id: hatari-glue.c,v 1.30 2008/07/12 15:55:41 npomarede Exp $";
1.1.1.6   root       11: 
1.1       root       12: 
                     13: #include <stdio.h>
                     14: 
                     15: #include "../includes/main.h"
1.1.1.11  root       16: #include "../includes/configuration.h"
1.1       root       17: #include "../includes/int.h"
                     18: #include "../includes/tos.h"
1.1.1.3   root       19: #include "../includes/gemdos.h"
                     20: #include "../includes/cart.h"
1.1.1.5   root       21: #include "../includes/vdi.h"
                     22: #include "../includes/stMemory.h"
1.1.1.12! root       23: #include "../includes/ikbd.h"
1.1       root       24: 
1.1.1.3   root       25: #include "sysdeps.h"
                     26: #include "maccess.h"
1.1.1.5   root       27: #include "memory.h"
1.1.1.3   root       28: #include "newcpu.h"
1.1.1.8   root       29: #include "hatari-glue.h"
1.1       root       30: 
                     31: #ifndef FALSE
                     32: #define FALSE 0
                     33: #define TRUE 1
                     34: #endif
                     35: 
                     36: 
1.1.1.11  root       37: struct uae_prefs currprefs, changed_prefs;
1.1       root       38: 
1.1.1.8   root       39: int pendingInterrupts = 0;
1.1.1.6   root       40: 
1.1       root       41: 
                     42: /* Reset custom chips */
                     43: void customreset(void)
                     44: {
1.1.1.8   root       45:   pendingInterrupts = 0;
1.1.1.12! root       46: 
        !            47:   /* In case the 6301 was executing a custom program from its RAM */
        !            48:   /* we must turn it back to the 'normal' mode. */
        !            49:   IKBD_Reset_ExeMode ();
1.1.1.6   root       50: }
                     51: 
                     52: 
1.1.1.8   root       53: /* Return interrupt number (1 - 7), -1 means no interrupt.
                     54:  * Note that the interrupt stays pending if it can't be executed yet
                     55:  * due to the interrupt level field in the SR. */
1.1.1.6   root       56: int intlev(void)
                     57: {
1.1.1.8   root       58:   /* There are only VBL and HBL autovector interrupts in the ST... */
                     59:   assert((pendingInterrupts & ~((1<<4)|(1<<2))) == 0);
1.1.1.6   root       60: 
1.1.1.8   root       61:   if(pendingInterrupts & (1 << 4))          /* VBL interrupt? */
                     62:   {
                     63:     if(regs.intmask < 4)
                     64:       pendingInterrupts &= ~(1 << 4);
                     65:     return 4;
                     66:   }
                     67:   else if(pendingInterrupts & (1 << 2))     /* HBL interrupt? */
                     68:   {
                     69:     if(regs.intmask < 2)
                     70:       pendingInterrupts &= ~(1 << 2);
                     71:     return 2;
                     72:   }
                     73: 
                     74:   return -1;
1.1       root       75: }
                     76: 
                     77: 
1.1.1.4   root       78: /* Initialize 680x0 emulation */
1.1       root       79: int Init680x0(void)
                     80: {
1.1.1.11  root       81:   currprefs.cpu_level = changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel;
                     82:   currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
                     83:   currprefs.address_space_24 = changed_prefs.address_space_24 = TRUE;
1.1       root       84: 
1.1.1.4   root       85:   init_m68k();
                     86:   return TRUE;
1.1       root       87: }
                     88: 
                     89: 
                     90: /* Deinitialize 680x0 emulation */
                     91: void Exit680x0(void)
                     92: {
1.1.1.7   root       93:   memory_uninit();
1.1.1.8   root       94: 
                     95:   free(table68k);
                     96:   table68k = NULL;
1.1       root       97: }
                     98: 
                     99: 
1.1.1.4   root      100: /* Check if the CPU type has been changed */
1.1.1.11  root      101: void check_prefs_changed_cpu(void)
1.1.1.4   root      102: {
1.1.1.11  root      103:   if (currprefs.cpu_level != changed_prefs.cpu_level
                    104:       || currprefs.cpu_compatible != changed_prefs.cpu_compatible)
1.1.1.4   root      105:   {
1.1.1.11  root      106:     currprefs.cpu_level = changed_prefs.cpu_level;
                    107:     currprefs.cpu_compatible = changed_prefs.cpu_compatible;
1.1.1.7   root      108:     set_special(SPCFLAG_MODE_CHANGE);
1.1.1.11  root      109:     build_cpufunctbl ();
1.1.1.4   root      110:   }
1.1       root      111: }
                    112: 
                    113: 
                    114: /* ----------------------------------------------------------------------- */
                    115: /*
1.1.1.7   root      116:   This function will be called at system init by the cartridge routine
                    117:   (after gemdos init, before booting floppies).
                    118:   
                    119:   The GEMDOS vector (#$84) is setup and we also initialize the connected
                    120:   drive mask and Line-A  variables (for an extended VDI resolution) from here.
1.1       root      121: */
1.1.1.7   root      122: unsigned long OpCode_SysInit(uae_u32 opcode)
1.1       root      123: {
1.1.1.7   root      124:   /* Initialize the connected drive mask */
                    125:   STMemory_WriteLong(0x4c2, ConnectedDriveMask);
                    126: 
                    127:   if(!bInitGemDOS)
                    128:   {
1.1.1.9   root      129:     /* Init on boot - see cart.c */
1.1.1.7   root      130:     GemDOS_Boot();
                    131: 
1.1.1.11  root      132:     /* Update LineA for extended VDI res
                    133:      * D0: LineA base, A1: Font base
                    134:      */
                    135:     VDI_LineA(regs.regs[0], regs.regs[9]);
1.1.1.7   root      136:   }
1.1.1.4   root      137: 
1.1.1.7   root      138:   m68k_incpc(2);
1.1.1.4   root      139:   fill_prefetch_0();
                    140:   return 4;
1.1.1.3   root      141: }
                    142: 
1.1.1.5   root      143: 
1.1.1.3   root      144: /* ----------------------------------------------------------------------- */
                    145: /*
1.1.1.7   root      146:   Intercept GEMDOS calls
1.1.1.3   root      147: 
1.1.1.7   root      148:   Used for GEMDOS HD emulation (see gemdos.c).
1.1.1.3   root      149: */
                    150: unsigned long OpCode_GemDos(uae_u32 opcode)
                    151: {
1.1.1.7   root      152:   GemDOS_OpCode();    /* handler code in gemdos.c */
1.1.1.3   root      153: 
1.1.1.5   root      154:   m68k_incpc(2);
                    155:   fill_prefetch_0();
                    156:   return 4;
1.1       root      157: }
                    158: 
1.1.1.5   root      159: 
                    160: /*-----------------------------------------------------------------------*/
                    161: /*
                    162:   This is called after completion of each VDI call
                    163: */
                    164: unsigned long OpCode_VDI(uae_u32 opcode)
                    165: {
                    166:   VDI_Complete();
                    167: 
                    168:   /* Set PC back to where originated from to continue instruction decoding */
                    169:   m68k_setpc(VDI_OldPC);
                    170: 
                    171:   fill_prefetch_0();
                    172:   return 4;
1.1       root      173: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.