|
|
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;
26: int address_space_24 = 1;
27: int cpu_level = 0; /* 68000 (default) */
28: int cpu_compatible = 0;
29:
30: long STmem_size = 0x100000; /* 1MB */
31: long TTmem_size = 0;
32:
33:
34: /* Reset custom chips */
35: void customreset(void)
36: {
37: /* Taken from Reset_ST in reset.c: */
1.1.1.3 ! root 38: Int_Reset(); /* Reset interrupts */
! 39: MFP_Reset(); /* Setup MFP chip */
! 40: Video_Reset(); /* Reset video */
! 41: PSG_Reset(); /* Reset PSG */
! 42: Sound_Reset(); /* Reset Sound */
! 43: IKBD_Reset(FALSE); /* Keyboard */
! 44: Screen_Reset(); /* Reset screen */
1.1 root 45:
1.1.1.3 ! root 46: /* And VBL interrupt, MUST always be one interrupt ready to trigger */
1.1 root 47: Int_AddAbsoluteInterrupt(CYCLES_ENDLINE,INTERRUPT_VIDEO_ENDLINE);
48: Int_AddAbsoluteInterrupt(CYCLES_HBL,INTERRUPT_VIDEO_HBL);
49: Int_AddAbsoluteInterrupt(CYCLES_PER_FRAME,INTERRUPT_VIDEO_VBL);
50: }
51:
52:
53: /* Initialize 680x0 emulation, CheckROM() must have been called first */
54: int Init680x0(void)
55: {
56: memory_init();
1.1.1.3 ! root 57: fprintf(stderr, "TOS version: %x.%x\n", STMemory_ReadByte(2), STMemory_ReadByte(3));
! 58: fprintf(stderr, "PC start: $%lx\n", STMemory_ReadLong(4));
1.1 root 59:
60: init_m68k();
61: #ifdef USE_COMPILER
62: compiler_init();
63: #endif
64: return TRUE;
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: {
77: m68k_reset();
78: m68k_go(TRUE);
79: }
80:
81:
82: /* ----------------------------------------------------------------------- */
83: /*
84: We use an illegal opcode to set ConnectedDrives, as TOS clears this
85: value we cannot set it on init.
86: */
87: unsigned long OpCode_ConnectedDrive(uae_u32 opcode)
88: {
1.1.1.3 ! root 89: /*fprintf(stderr, "OpCode_ConnectedDrive handled\n");*/
1.1 root 90: /* Set connected drives */
1.1.1.3 ! root 91: STMemory_WriteWord(0x4c2, ConnectedDriveMask);
! 92: m68k_incpc(2);
! 93: fill_prefetch_0();
! 94: return 4;
! 95: }
! 96:
! 97: /* ----------------------------------------------------------------------- */
! 98: /*
! 99: Re-direct execution to old GEM calls, used in 'cart.s'
! 100: */
! 101: unsigned long OpCode_OldGemDos(uae_u32 opcode)
! 102: {
! 103: m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) );
! 104: fill_prefetch_0();
! 105: return 4;
! 106: }
! 107:
! 108: /* ----------------------------------------------------------------------- */
! 109: /*
! 110: Intercept GEMDOS calls (setup vector $84)
! 111: The vector is setup when the gemdos-opcode is run the first time, by
! 112: the cartridge routine. (after gemdos init, before booting floppies)
! 113:
! 114: After this, our vector will be used, and handled by the GemDOS_OpCode
! 115: routine in gemdos.c
! 116: */
! 117: unsigned long OpCode_GemDos(uae_u32 opcode)
! 118: {
! 119:
! 120: if(!bInitGemDOS)
! 121: GemDOS_Boot(); /* Init on boot - see cartimg.c */
! 122: else
! 123: GemDOS_OpCode(); /* handler code in gemdos.c */
! 124:
1.1 root 125: m68k_incpc(2);
1.1.1.3 ! root 126: fill_prefetch_0();
! 127: return 4;
1.1 root 128: }
129:
130: /* ----------------------------------------------------------------------- */
131: /*
132: Modify TimerD in GEMDos to gain more desktop performance
133:
134: Obviously, we need to emulate all timers correctly but GemDOS set's up Timer D at a very
135: high rate(every couple of instructions). The interrupts isn't enabled but WinSTon still
136: needs to process the interrupt table and this HALVES our frame rate!!! (It causes a cache
137: reload each time). Some games actually reference this timer but don't set it up(eg Paradroid,
138: Speedball I) so we simply intercept the Timer D setup code in GemDOS and fix the numbers
139: with more 'laid-back' values. This still keeps 100% compatibility
140: */
141: unsigned long OpCode_TimerD(uae_u32 opcode)
142: {
1.1.1.3 ! root 143: /*fprintf(stderr, "OpCode_TimerD handled\n");*/
1.1 root 144: m68k_dreg(regs,0)=3; /* 3 = Select Timer D */
145: m68k_dreg(regs,1)=7; /* 1 = /4 for 9600 baud(used /200) */
146: m68k_dreg(regs,2)=100; /* 2 = 9600 baud(100) */
147: m68k_incpc(2);
1.1.1.3 ! root 148: fill_prefetch_0();
! 149: return 4;
1.1 root 150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.