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

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

unix.superglobalmegacorp.com

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