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

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

unix.superglobalmegacorp.com

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