summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-05-05 20:32:28 +0300
committerOxore <oxore@protonmail.com>2023-05-05 20:32:28 +0300
commit648e3d3c41aab7c08c3c44c52203cb8ed896820a (patch)
tree882765922b416aed508fdb9cd05949597079abda
parent79ff96cb2ffb140863c48803d21d10349881f907 (diff)
Add interrupt attributes
-rw-r--r--1_hello_world/main.c2
-rw-r--r--1_hello_world/startup.c34
2 files changed, 23 insertions, 13 deletions
diff --git a/1_hello_world/main.c b/1_hello_world/main.c
index 5852765..ee4ee64 100644
--- a/1_hello_world/main.c
+++ b/1_hello_world/main.c
@@ -218,7 +218,7 @@ static void VDP_LoadRegisters(void)
}
}
-void __start(void)
+int main(void)
{
// ==============================================================
// Initialise the Mega Drive
diff --git a/1_hello_world/startup.c b/1_hello_world/startup.c
index 3b3c017..06ca39e 100644
--- a/1_hello_world/startup.c
+++ b/1_hello_world/startup.c
@@ -22,9 +22,11 @@ struct smd_header {
char country_codes[16];
};
-extern void __start(void);
-static void HSYNC_handler(void);
-static void VSYNC_handler(void);
+extern int main(void);
+static __attribute__((interrupt)) void __start(void);
+static __attribute__((interrupt)) void HSYNC_handler(void);
+static __attribute__((interrupt)) void VSYNC_handler(void);
+static __attribute__((interrupt)) void CPUException_handler(void);
extern unsigned __stacktop;
@@ -32,13 +34,13 @@ __attribute__((section(".stack"), used)) unsigned *__stack_init = &__stacktop;
__attribute__((section(".vectors"), used)) ptr_func_t __isr_vectors[] = {
__start,
- __start,
- __start,
- __start,
- __start,
- __start,
- __start,
- __start,
+ CPUException_handler,
+ CPUException_handler,
+ CPUException_handler,
+ CPUException_handler,
+ CPUException_handler,
+ CPUException_handler,
+ CPUException_handler,
__start,
__start,
__start,
@@ -118,5 +120,13 @@ __attribute__((section(".smd_header"), used)) struct smd_header __smd_header = {
.country_codes = " E ",
};
-void HSYNC_handler(void) {}
-void VSYNC_handler(void) {}
+static void __start(void)
+{
+ main();
+}
+static void HSYNC_handler(void) {}
+static void VSYNC_handler(void) {}
+static void CPUException_handler(void)
+{
+ asm inline volatile (" stop #2700");
+}