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

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

unix.superglobalmegacorp.com

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