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

1.1       root        1: 
                      2: #include <stdio.h>
                      3: 
                      4: #include "../includes/main.h"
                      5: #include "../includes/int.h"
                      6: #include "../includes/tos.h"
1.1.1.3   root        7: #include "../includes/gemdos.h"
                      8: #include "../includes/cart.h"
1.1       root        9: 
1.1.1.3   root       10: #ifndef UAESYSDEPS
                     11: #include "sysdeps.h"
                     12: #endif
                     13: #ifndef UAEMEMORY
                     14: #include "memory.h"
                     15: #endif
                     16: #include "maccess.h"
                     17: #include "newcpu.h"
1.1       root       18: 
                     19: #ifndef FALSE
                     20: #define FALSE 0
                     21: #define TRUE 1
                     22: #endif
                     23: 
                     24: 
                     25: int illegal_mem = FALSE;
1.1.1.4 ! root       26: int address_space_24 = TRUE;
1.1       root       27: int cpu_level = 0;              /* 68000 (default) */
1.1.1.4 ! root       28: int cpu_compatible = FALSE;
1.1       root       29: 
1.1.1.4 ! root       30: long STmem_size = 0x400000;     /* 4MB */
1.1       root       31: long TTmem_size = 0;
                     32: 
                     33: 
                     34: /* Reset custom chips */
                     35: void customreset(void)
                     36: {
1.1.1.4 ! root       37: #if 0    /* Disabled since WinSTon ignores the RESET instruction, too */
        !            38:   /* Taken from Reset_ST in reset.c: */
        !            39:   Int_Reset();                           /* Reset interrupts */
        !            40:   MFP_Reset();                           /* Setup MFP chip */
        !            41:   Video_Reset();                         /* Reset video */
        !            42:   PSG_Reset();                           /* Reset PSG */
        !            43:   Sound_Reset();                         /* Reset Sound */
        !            44:   IKBD_Reset(FALSE);                     /* Keyboard */
        !            45:   Screen_Reset();                        /* Reset screen */
        !            46: 
        !            47:   /* And VBL interrupt, MUST always be one interrupt ready to trigger */
        !            48:   Int_AddAbsoluteInterrupt(CYCLES_ENDLINE,INTERRUPT_VIDEO_ENDLINE);
        !            49:   Int_AddAbsoluteInterrupt(CYCLES_HBL,INTERRUPT_VIDEO_HBL);
        !            50:   Int_AddAbsoluteInterrupt(CYCLES_PER_FRAME,INTERRUPT_VIDEO_VBL);
        !            51: #endif
1.1       root       52: }
                     53: 
                     54: 
1.1.1.4 ! root       55: /* Initialize 680x0 emulation */
1.1       root       56: int Init680x0(void)
                     57: {
1.1.1.4 ! root       58:   memory_init();
1.1       root       59: 
1.1.1.4 ! root       60:   init_m68k();
1.1       root       61: #ifdef USE_COMPILER
1.1.1.4 ! root       62:   compiler_init();
1.1       root       63: #endif
1.1.1.4 ! root       64:   return TRUE;
1.1       root       65: }
                     66: 
                     67: 
                     68: /* Deinitialize 680x0 emulation */
                     69: void Exit680x0(void)
                     70: {
                     71: }
                     72: 
                     73: 
                     74: /* Reset and start 680x0 emulation */
                     75: void Start680x0(void)
                     76: {
1.1.1.4 ! root       77:   m68k_reset();
        !            78:   m68k_go(TRUE);
        !            79: }
        !            80: 
        !            81: 
        !            82: /* Check if the CPU type has been changed */
        !            83: void check_prefs_changed_cpu(int new_level, int new_compatible)
        !            84: {
        !            85:   if(cpu_level!=new_level || cpu_compatible!=new_compatible)
        !            86:   {
        !            87:     cpu_level = new_level;
        !            88:     cpu_compatible = new_compatible;
        !            89:     build_cpufunctbl ();
        !            90:   }
1.1       root       91: }
                     92: 
                     93: 
1.1.1.4 ! root       94: 
1.1       root       95: /* ----------------------------------------------------------------------- */
                     96: /*
1.1.1.4 ! root       97:   We use an illegal opcode to set ConnectedDrives, as TOS (or an HD driver)
        !            98:   alters this value we cannot set it on init.
        !            99:   This opcode replaces the RTS at the end of the DMA bus boot routine
1.1       root      100: */
                    101: unsigned long OpCode_ConnectedDrive(uae_u32 opcode)
                    102: {
1.1.1.4 ! root      103:   fprintf(stderr, "OpCode_ConnectedDrive handled (%x)\n",ConnectedDriveMask );
        !           104:   /* Set connected drives */
        !           105:   STMemory_WriteLong(0x4c2, ConnectedDriveMask); 
        !           106:   /* do an RTS (the opcode we replaced) */
        !           107:   m68k_setpc(longget(m68k_areg(regs, 7)));
        !           108:   m68k_areg(regs, 7) += 4;
        !           109: 
        !           110:   fill_prefetch_0();
        !           111:   return 4;
1.1.1.3   root      112: }
                    113: 
                    114: /* ----------------------------------------------------------------------- */
                    115: /*
                    116:   Re-direct execution to old GEM calls, used in 'cart.s'
                    117: */
                    118: unsigned long OpCode_OldGemDos(uae_u32 opcode)
                    119: {
                    120:   m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) );    
                    121:   fill_prefetch_0();
                    122:   return 4;
                    123: }
                    124: 
                    125: /* ----------------------------------------------------------------------- */
                    126: /*
                    127:   Intercept GEMDOS calls (setup vector $84)
                    128:   The vector is setup when the gemdos-opcode is run the first time, by
                    129:   the cartridge routine. (after gemdos init, before booting floppies)
                    130: 
                    131:   After this, our vector will be used, and handled by the GemDOS_OpCode 
                    132:   routine in gemdos.c
                    133: */
                    134: unsigned long OpCode_GemDos(uae_u32 opcode)
                    135: {
                    136: 
                    137:   if(!bInitGemDOS)     
                    138:     GemDOS_Boot();      /* Init on boot - see cartimg.c */    
                    139:   else 
                    140:     GemDOS_OpCode();    /* handler code in gemdos.c */
                    141: 
1.1       root      142:  m68k_incpc(2);
1.1.1.3   root      143:  fill_prefetch_0();
                    144:  return 4;
1.1       root      145: }
                    146: 
                    147: /* ----------------------------------------------------------------------- */
                    148: /*
                    149:   Modify TimerD in GEMDos to gain more desktop performance
                    150: 
                    151:   Obviously, we need to emulate all timers correctly but GemDOS set's up Timer D at a very
                    152:   high rate(every couple of instructions). The interrupts isn't enabled but WinSTon still
                    153:   needs to process the interrupt table and this HALVES our frame rate!!! (It causes a cache
                    154:   reload each time). Some games actually reference this timer but don't set it up(eg Paradroid,
                    155:   Speedball I) so we simply intercept the Timer D setup code in GemDOS and fix the numbers
                    156:   with more 'laid-back' values. This still keeps 100% compatibility
                    157: */
                    158: unsigned long OpCode_TimerD(uae_u32 opcode)
                    159: {
1.1.1.3   root      160:  /*fprintf(stderr, "OpCode_TimerD handled\n");*/
1.1       root      161:  m68k_dreg(regs,0)=3;  /* 3 = Select Timer D */
                    162:  m68k_dreg(regs,1)=7;  /* 1 = /4 for 9600 baud(used /200) */
                    163:  m68k_dreg(regs,2)=100;        /* 2 = 9600 baud(100) */
                    164:  m68k_incpc(2);
1.1.1.3   root      165:  fill_prefetch_0();
                    166:  return 4;
1.1       root      167: }

unix.superglobalmegacorp.com

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