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

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

unix.superglobalmegacorp.com

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