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

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.7 ! root       10: static char rcsid[] = "Hatari $Id: hatari-glue.c,v 1.19 2003/06/20 13:13:22 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       root       27: 
                     28: #ifndef FALSE
                     29: #define FALSE 0
                     30: #define TRUE 1
                     31: #endif
                     32: 
                     33: 
                     34: int illegal_mem = FALSE;
1.1.1.4   root       35: int address_space_24 = TRUE;
1.1       root       36: int cpu_level = 0;              /* 68000 (default) */
1.1.1.4   root       37: int cpu_compatible = FALSE;
1.1       root       38: 
1.1.1.6   root       39: int requestedInterrupt = -1;
                     40: 
1.1       root       41: 
                     42: /* Reset custom chips */
                     43: void customreset(void)
                     44: {
1.1.1.6   root       45:   requestedInterrupt = -1;
                     46: }
                     47: 
                     48: 
                     49: /* Return interrupt number (1 - 7), -1 means no interrupt. */
                     50: int intlev(void)
                     51: {
                     52:   int ret = requestedInterrupt;
                     53:   requestedInterrupt = -1;
                     54: 
                     55:   return ret;
1.1       root       56: }
                     57: 
                     58: 
1.1.1.4   root       59: /* Initialize 680x0 emulation */
1.1       root       60: int Init680x0(void)
                     61: {
1.1.1.7 ! root       62:   /* Note: memory_init() is now done in tos.c */
1.1       root       63: 
1.1.1.4   root       64:   init_m68k();
                     65:   return TRUE;
1.1       root       66: }
                     67: 
                     68: 
                     69: /* Deinitialize 680x0 emulation */
                     70: void Exit680x0(void)
                     71: {
1.1.1.7 ! root       72:   memory_uninit();
1.1       root       73: }
                     74: 
                     75: 
                     76: /* Reset and start 680x0 emulation */
                     77: void Start680x0(void)
                     78: {
1.1.1.4   root       79:   m68k_reset();
                     80:   m68k_go(TRUE);
                     81: }
                     82: 
                     83: 
                     84: /* Check if the CPU type has been changed */
                     85: void check_prefs_changed_cpu(int new_level, int new_compatible)
                     86: {
                     87:   if(cpu_level!=new_level || cpu_compatible!=new_compatible)
                     88:   {
                     89:     cpu_level = new_level;
                     90:     cpu_compatible = new_compatible;
1.1.1.7 ! root       91:     set_special(SPCFLAG_MODE_CHANGE);
        !            92:     if (table68k)
        !            93:       build_cpufunctbl ();
1.1.1.4   root       94:   }
1.1       root       95: }
                     96: 
                     97: 
                     98: /* ----------------------------------------------------------------------- */
                     99: /*
1.1.1.7 ! root      100:   This function will be called at system init by the cartridge routine
        !           101:   (after gemdos init, before booting floppies).
        !           102:   
        !           103:   The GEMDOS vector (#$84) is setup and we also initialize the connected
        !           104:   drive mask and Line-A  variables (for an extended VDI resolution) from here.
1.1       root      105: */
1.1.1.7 ! root      106: unsigned long OpCode_SysInit(uae_u32 opcode)
1.1       root      107: {
1.1.1.7 ! root      108:   /* Initialize the connected drive mask */
        !           109:   STMemory_WriteLong(0x4c2, ConnectedDriveMask);
        !           110: 
        !           111:   if(!bInitGemDOS)
        !           112:   {
        !           113:     /* Init on boot - see cartimg.c */
        !           114:     GemDOS_Boot();
        !           115: 
        !           116:     /* We use this to get pointer to Line-A structure details
        !           117:      * (to fix for extended VDI res) */
        !           118:     LineABase = regs.regs[0];  /* D0 */
        !           119:     FontBase = regs.regs[9];   /* A1 */
        !           120:     VDI_LineA();
        !           121:   }
1.1.1.4   root      122: 
1.1.1.7 ! root      123:   m68k_incpc(2);
1.1.1.4   root      124:   fill_prefetch_0();
                    125:   return 4;
1.1.1.3   root      126: }
                    127: 
1.1.1.5   root      128: 
1.1.1.3   root      129: /* ----------------------------------------------------------------------- */
                    130: /*
1.1.1.5   root      131:   Re-direct execution to old GEMDOS calls, used in 'cart.s'
1.1.1.3   root      132: */
                    133: unsigned long OpCode_OldGemDos(uae_u32 opcode)
                    134: {
1.1.1.7 ! root      135:   m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) );
1.1.1.3   root      136:   fill_prefetch_0();
                    137:   return 4;
                    138: }
                    139: 
1.1.1.5   root      140: 
1.1.1.3   root      141: /* ----------------------------------------------------------------------- */
                    142: /*
1.1.1.7 ! root      143:   Intercept GEMDOS calls
1.1.1.3   root      144: 
1.1.1.7 ! root      145:   Used for GEMDOS HD emulation (see gemdos.c).
1.1.1.3   root      146: */
                    147: unsigned long OpCode_GemDos(uae_u32 opcode)
                    148: {
1.1.1.7 ! root      149:   GemDOS_OpCode();    /* handler code in gemdos.c */
1.1.1.3   root      150: 
1.1.1.5   root      151:   m68k_incpc(2);
                    152:   fill_prefetch_0();
                    153:   return 4;
1.1       root      154: }
                    155: 
1.1.1.5   root      156: 
1.1       root      157: /* ----------------------------------------------------------------------- */
                    158: /*
                    159:   Modify TimerD in GEMDos to gain more desktop performance
                    160: 
                    161:   Obviously, we need to emulate all timers correctly but GemDOS set's up Timer D at a very
                    162:   high rate(every couple of instructions). The interrupts isn't enabled but WinSTon still
                    163:   needs to process the interrupt table and this HALVES our frame rate!!! (It causes a cache
                    164:   reload each time). Some games actually reference this timer but don't set it up(eg Paradroid,
                    165:   Speedball I) so we simply intercept the Timer D setup code in GemDOS and fix the numbers
                    166:   with more 'laid-back' values. This still keeps 100% compatibility
                    167: */
1.1.1.7 ! root      168: #if 0 /* This is now done by intercepting the Timer-D hardware registers */
1.1       root      169: unsigned long OpCode_TimerD(uae_u32 opcode)
                    170: {
1.1.1.5   root      171:   /*fprintf(stderr, "OpCode_TimerD handled\n");*/
                    172:   m68k_dreg(regs,0)=3; /* 3 = Select Timer D */
                    173:   m68k_dreg(regs,1)=7; /* 1 = /4 for 9600 baud(used /200) */
                    174:   m68k_dreg(regs,2)=100;       /* 2 = 9600 baud(100) */
                    175:   m68k_incpc(2);
                    176:   fill_prefetch_0();
                    177:   return 4;
                    178: }
1.1.1.7 ! root      179: #endif
1.1.1.5   root      180: 
                    181: 
                    182: /*-----------------------------------------------------------------------*/
                    183: /*
                    184:   This is called after completion of each VDI call
                    185: */
                    186: unsigned long OpCode_VDI(uae_u32 opcode)
                    187: {
                    188:   VDI_Complete();
                    189: 
                    190:   /* Set PC back to where originated from to continue instruction decoding */
                    191:   m68k_setpc(VDI_OldPC);
                    192: 
                    193:   fill_prefetch_0();
                    194:   return 4;
1.1       root      195: }

unix.superglobalmegacorp.com

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