ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/main.cpp
(Generate patch)

Comparing Frodo4/Src/main.cpp (file contents):
Revision 1.1 by cebix, 2003-07-01T17:09:43Z vs.
Revision 1.8 by cebix, 2005-06-27T19:55:48Z

# Line 1 | Line 1
1   /*
2   *  main.cpp - Main program
3   *
4 < *  Frodo (C) 1994-1997,2002 Christian Bauer
4 > *  Frodo (C) 1994-1997,2002-2005 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 28 | Line 28
28  
29  
30   // Global variables
31 + C64 *TheC64 = NULL;             // Global C64 object
32   char AppDirPath[1024];  // Path of application directory
33  
34  
35   // ROM file names
36 + #ifndef DATADIR
37 + #define DATADIR
38 + #endif
39 +
40   #ifdef __riscos__
41   #define BASIC_ROM_FILE  "FrodoRsrc:Basic_ROM"
42   #define KERNAL_ROM_FILE "FrodoRsrc:Kernal_ROM"
43   #define CHAR_ROM_FILE   "FrodoRsrc:Char_ROM"
44 < #define FLOPPY_ROM_FILE "FrodoRsrc:1541_ROM"
44 > #define DRIVE_ROM_FILE  "FrodoRsrc:1541_ROM"
45   #else
46 < #define BASIC_ROM_FILE  "Basic ROM"
47 < #define KERNAL_ROM_FILE "Kernal ROM"
48 < #define CHAR_ROM_FILE   "Char ROM"
49 < #define FLOPPY_ROM_FILE "1541 ROM"
46 > #define BASIC_ROM_FILE DATADIR "Basic ROM"
47 > #define KERNAL_ROM_FILE DATADIR "Kernal ROM"
48 > #define CHAR_ROM_FILE DATADIR "Char ROM"
49 > #define DRIVE_ROM_FILE DATADIR "1541 ROM"
50   #endif
51  
52  
53 + // Builtin ROMs
54 + #include "Basic_ROM.h"
55 + #include "Kernal_ROM.h"
56 + #include "Char_ROM.h"
57 + #include "1541_ROM.h"
58 +
59 +
60   /*
61   *  Load C64 ROM files
62   */
63  
64 < #ifndef __PSXOS__
53 < bool Frodo::load_rom_files(void)
64 > void Frodo::load_rom(const char *which, const char *path, uint8 *where, size_t size, const uint8 *builtin)
65   {
66 <        FILE *file;
67 <
68 <        // Load Basic ROM
69 <        if ((file = fopen(BASIC_ROM_FILE, "rb")) != NULL) {
70 <                if (fread(TheC64->Basic, 1, 0x2000, file) != 0x2000) {
71 <                        ShowRequester("Can't read 'Basic ROM'.", "Quit");
61 <                        return false;
62 <                }
63 <                fclose(file);
64 <        } else {
65 <                ShowRequester("Can't find 'Basic ROM'.", "Quit");
66 <                return false;
67 <        }
68 <
69 <        // Load Kernal ROM
70 <        if ((file = fopen(KERNAL_ROM_FILE, "rb")) != NULL) {
71 <                if (fread(TheC64->Kernal, 1, 0x2000, file) != 0x2000) {
72 <                        ShowRequester("Can't read 'Kernal ROM'.", "Quit");
73 <                        return false;
74 <                }
75 <                fclose(file);
76 <        } else {
77 <                ShowRequester("Can't find 'Kernal ROM'.", "Quit");
78 <                return false;
66 >        FILE *f = fopen(path, "rb");
67 >        if (f) {
68 >                size_t actual = fread(where, 1, size, f);
69 >                fclose(f);
70 >                if (actual == size)
71 >                        return;
72          }
73  
74 <        // Load Char ROM
75 <        if ((file = fopen(CHAR_ROM_FILE, "rb")) != NULL) {
76 <                if (fread(TheC64->Char, 1, 0x1000, file) != 0x1000) {
77 <                        ShowRequester("Can't read 'Char ROM'.", "Quit");
85 <                        return false;
86 <                }
87 <                fclose(file);
88 <        } else {
89 <                ShowRequester("Can't find 'Char ROM'.", "Quit");
90 <                return false;
91 <        }
92 <
93 <        // Load 1541 ROM
94 <        if ((file = fopen(FLOPPY_ROM_FILE, "rb")) != NULL) {
95 <                if (fread(TheC64->ROM1541, 1, 0x4000, file) != 0x4000) {
96 <                        ShowRequester("Can't read '1541 ROM'.", "Quit");
97 <                        return false;
98 <                }
99 <                fclose(file);
100 <        } else {
101 <                ShowRequester("Can't find '1541 ROM'.", "Quit");
102 <                return false;
103 <        }
74 >        // Use builtin ROM
75 >        printf("%s ROM file (%s) not readable, using builtin.\n", which, path);
76 >        memcpy(where, builtin, size);
77 > }
78  
79 <        return true;
79 > void Frodo::load_rom_files()
80 > {
81 >        load_rom("Basic", BASIC_ROM_FILE, TheC64->Basic, BASIC_ROM_SIZE, builtin_basic_rom);
82 >        load_rom("Kernal", KERNAL_ROM_FILE, TheC64->Kernal, KERNAL_ROM_SIZE, builtin_kernal_rom);
83 >        load_rom("Char", CHAR_ROM_FILE, TheC64->Char, CHAR_ROM_SIZE, builtin_char_rom);
84 >        load_rom("1541", DRIVE_ROM_FILE, TheC64->ROM1541, DRIVE_ROM_SIZE, builtin_drive_rom);
85   }
107 #endif
86  
87  
88   #ifdef __BEOS__

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines