|
|
1.1 root 1:
2: #include <stdio.h>
3:
4: #include "newcpu.h"
5:
6: #include "../includes/main.h"
7: #include "../includes/int.h"
8: #include "../includes/tos.h"
9:
10:
11:
12: #ifndef FALSE
13: #define FALSE 0
14: #define TRUE 1
15: #endif
16:
17:
18: int illegal_mem = FALSE;
19: int address_space_24 = 1;
20: int cpu_level = 0; /* 68000 (default) */
21: int cpu_compatible = 0;
22: int m68k_speed = 0;
23:
24: long STmem_size = 0x100000; /* 1MB */
25: long TTmem_size = 0;
26:
27:
28: /* Reset custom chips */
29: void customreset(void)
30: {
31: /* Taken from Reset_ST in reset.c: */
32: Int_Reset(); // Reset interrupts
33: MFP_Reset(); // Setup MFP chip
34: Video_Reset(); // Reset video
35: PSG_Reset(); // Reset PSG
36: Sound_Reset(); // Reset Sound
37: IKBD_Reset(FALSE); // Keyboard
38: Screen_Reset(); // Reset screen
39:
40: // And VBL interrupt, MUST always be one interrupt ready to trigger
41: Int_AddAbsoluteInterrupt(CYCLES_ENDLINE,INTERRUPT_VIDEO_ENDLINE);
42: Int_AddAbsoluteInterrupt(CYCLES_HBL,INTERRUPT_VIDEO_HBL);
43: Int_AddAbsoluteInterrupt(CYCLES_PER_FRAME,INTERRUPT_VIDEO_VBL);
44: }
45:
46: int intlev (void) /* ??? */
47: {
48: return -1;
49: }
50:
51:
52: /* Initialize 680x0 emulation, CheckROM() must have been called first */
53: int Init680x0(void)
54: {
55: memory_init();
56: fprintf(stderr, "TOS version: %x.%x\n", STMemory_ReadByte(2), STMemory_ReadByte(3));
57: fprintf(stderr, "PC start: $%lx\n", STMemory_ReadLong(4));
58:
59: init_m68k();
60: #ifdef USE_COMPILER
61: compiler_init();
62: #endif
63: return TRUE;
64: }
65:
66:
67: /* Deinitialize 680x0 emulation */
68: void Exit680x0(void)
69: {
70: }
71:
72:
73: /* Reset and start 680x0 emulation */
74: void Start680x0(void)
75: {
76: m68k_reset();
77: m68k_go(TRUE);
78: }
79:
80:
81: /* ----------------------------------------------------------------------- */
82: /*
83: We use an illegal opcode to set ConnectedDrives, as TOS clears this
84: value we cannot set it on init.
85: */
86: unsigned long OpCode_ConnectedDrive(uae_u32 opcode)
87: {
88: fprintf(stderr, "OpCode_ConnectedDrive handled\n");
89: /* Set connected drives */
90: STMemory_WriteWord(0x4c2, ConnectedDriveMask);
91: m68k_incpc(2);
92: return 2;
93: }
94:
95: /* ----------------------------------------------------------------------- */
96: /*
97: Modify TimerD in GEMDos to gain more desktop performance
98:
99: Obviously, we need to emulate all timers correctly but GemDOS set's up Timer D at a very
100: high rate(every couple of instructions). The interrupts isn't enabled but WinSTon still
101: needs to process the interrupt table and this HALVES our frame rate!!! (It causes a cache
102: reload each time). Some games actually reference this timer but don't set it up(eg Paradroid,
103: Speedball I) so we simply intercept the Timer D setup code in GemDOS and fix the numbers
104: with more 'laid-back' values. This still keeps 100% compatibility
105: */
106: unsigned long OpCode_TimerD(uae_u32 opcode)
107: {
108: fprintf(stderr, "OpCode_TimerD handled\n");
109: m68k_dreg(regs,0)=3; /* 3 = Select Timer D */
110: m68k_dreg(regs,1)=7; /* 1 = /4 for 9600 baud(used /200) */
111: m68k_dreg(regs,2)=100; /* 2 = 9600 baud(100) */
112: m68k_incpc(2);
113: return 2;
114: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.