summaryrefslogtreecommitdiff
path: root/2_scroll_planes/startup.c
blob: f2574cdf57f9e76110fb1d18c52a8bb9a7ee5d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
typedef void (*ptr_func_t)();

struct smd_header {
    char console_name[16];
    char copyright[16];
    char domestic_name[48];
    char international_name[48];
    char version[14];
    unsigned short checksum;
    char io_support[16];
    unsigned long rom_start;
    unsigned long rom_end;
    unsigned long ram_start;
    unsigned long ram_end;
    unsigned long sram_enabled;
    unsigned long unused1;
    unsigned long sram_start;
    unsigned long sram_end;
    unsigned long unused2;
    unsigned long unused3;
    char notes[40];
    char country_codes[16];
};

void INT_Null(void) __attribute__((weak, interrupt));
void CPU_EntryPoint(void) __attribute__((weak, alias ("INT_Null")));
void INT_HInterrupt(void) __attribute__((weak, alias ("INT_Null")));
void INT_VInterrupt(void) __attribute__((weak, alias ("INT_Null")));
void CPU_Exception(void) __attribute__((weak, interrupt));

extern unsigned __stacktop;
extern unsigned __rom_start;
extern unsigned __rom_end;

__attribute__((section(".stack"), used)) unsigned *__stack_init = &__stacktop;

__attribute__((section(".vectors"), used)) ptr_func_t __isr_vectors[] = {
    CPU_EntryPoint,
    CPU_Exception,
    CPU_Exception,
    CPU_Exception,
    CPU_Exception,
    CPU_Exception,
    CPU_Exception,
    CPU_Exception,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_HInterrupt,
    INT_Null,
    INT_VInterrupt,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
    INT_Null,
};

__attribute__((section(".smd_header"), used)) struct smd_header __smd_header = {
    .console_name = "SEGA MEGA DRIVE ",
    .copyright = "BIGEVILCORP.    ",
    .domestic_name = "HELLO WORLD                                     ",
    .international_name = "HELLO WORLD                                     ",
    .version = "GM XXXXXXXX-XX",
    .checksum = 0x0000,
    .io_support = "J               ",
    .rom_start = (unsigned long)&__rom_start,
    .rom_end = (unsigned long)&__rom_end-1,
    .ram_start = 0xff0000,
    .ram_end = 0xffffff,
    .sram_enabled = 0x00000000,
    .unused1 = 0x00000000,
    .sram_start = 0x00000000,
    .sram_end = 0x00000000,
    .unused2 = 0x00000000,
    .unused3 = 0x00000000,
    .notes = "                                        ",
    .country_codes = "  E             ",
};

void INT_Null(void) {}

void CPU_Exception(void)
{
     asm inline volatile ("  stop #2700");
}