|
|
1.1 root 1: /*
2: Hatari
3:
1.1.1.4 root 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: Reset emulation state.
1.1 root 8: */
1.1.1.6 ! root 9: char Reset_rcsid[] = "Hatari $Id: reset.c,v 1.7 2004/04/23 15:33:59 thothy Exp $";
1.1 root 10:
11: #include "main.h"
12: #include "cart.h"
13: #include "fdc.h"
14: #include "floppy.h"
15: #include "gemdos.h"
16: #include "ikbd.h"
17: #include "int.h"
18: #include "m68000.h"
19: #include "misc.h"
20: #include "mfp.h"
21: #include "psg.h"
22: #include "reset.h"
23: #include "screen.h"
24: #include "sound.h"
25: #include "stMemory.h"
26: #include "tos.h"
27: #include "video.h"
28:
1.1.1.2 root 29:
30: /*-----------------------------------------------------------------------*/
1.1 root 31: /*
32: Cold reset ST (reset memory, all registers and reboot)
33: */
1.1.1.4 root 34: int Reset_Cold(void)
1.1 root 35: {
1.1.1.4 root 36: return Reset_ST(TRUE);
1.1 root 37: }
38:
1.1.1.2 root 39:
40: /*-----------------------------------------------------------------------*/
1.1 root 41: /*
42: Warm reset ST (reset registers, leave in same state and reboot)
43: */
1.1.1.4 root 44: int Reset_Warm(void)
1.1 root 45: {
1.1.1.4 root 46: return Reset_ST(FALSE);
1.1 root 47: }
48:
1.1.1.2 root 49:
50: /*-----------------------------------------------------------------------*/
1.1 root 51: /*
52: Reset ST emulator states, chips, interrupts and registers
53: */
1.1.1.4 root 54: int Reset_ST(BOOL bCold)
1.1 root 55: {
1.1.1.4 root 56: if (bCold)
57: {
58: int ret;
59:
60: STMemory_Clear(0x00000000, 0x00400000); /* Clear First 4Mb */
61: STMemory_Clear(0x00e00000, 0x00ffffff); /* Clear Upper memory */
62: STMemory_WriteLong(4, 0x00fc0000); /* Set reset vector */
63: STMemory_WriteLong(0, 0x0000f000); /* And reset stack pointer */
1.1.1.2 root 64:
65: Floppy_GetBootDrive(); /* Find which device to boot from(A: or C:) */
66: Cart_LoadImage(); /* Load program into cartridge memory. Used for gemdos loading */
1.1.1.4 root 67:
68: ret = TOS_LoadImage(); /* Load TOS, writes into cartridge memory */
69: if(ret)
70: {
71: return ret; /* If we can not load a TOS image, return now! */
72: }
1.1 root 73: }
1.1.1.2 root 74: Int_Reset(); /* Reset interrupts */
75: MFP_Reset(); /* Setup MFP chip */
76: Video_Reset(); /* Reset video */
1.1.1.4 root 77:
1.1.1.5 root 78: GemDOS_Reset(); /* Reset GEMDOS emulation */
1.1.1.4 root 79: if (bCold)
80: {
1.1.1.2 root 81: FDC_Reset(); /* Reset FDC */
1.1 root 82: }
1.1.1.4 root 83:
1.1.1.2 root 84: PSG_Reset(); /* Reset PSG */
85: Sound_Reset(); /* Reset Sound */
86: IKBD_Reset(bCold); /* Keyboard */
87: Screen_Reset(); /* Reset screen */
88: M68000_Reset(bCold); /* Reset CPU */
1.1 root 89:
1.1.1.2 root 90: /* And VBL interrupt, MUST always be one interrupt ready to trigger */
1.1.1.4 root 91: Int_AddAbsoluteInterrupt(CYCLES_ENDLINE, INTERRUPT_VIDEO_ENDLINE);
92: Int_AddAbsoluteInterrupt(CYCLES_HBL, INTERRUPT_VIDEO_HBL);
93: Int_AddAbsoluteInterrupt(CYCLES_PER_FRAME, INTERRUPT_VIDEO_VBL);
1.1.1.2 root 94: /* And keyboard check for debugger */
1.1 root 95: #ifdef USE_DEBUGGER
1.1.1.4 root 96: Int_AddAbsoluteInterrupt(CYCLES_DEBUGGER, INTERRUPT_DEBUGGER);
1.1 root 97: #endif
1.1.1.4 root 98:
99: return 0;
1.1 root 100: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.