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

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

unix.superglobalmegacorp.com

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