aboutsummaryrefslogtreecommitdiff
path: root/asm/crt0.asm
diff options
context:
space:
mode:
Diffstat (limited to 'asm/crt0.asm')
-rw-r--r--asm/crt0.asm17
1 files changed, 16 insertions, 1 deletions
diff --git a/asm/crt0.asm b/asm/crt0.asm
index 6f92149..523c39e 100644
--- a/asm/crt0.asm
+++ b/asm/crt0.asm
@@ -10,7 +10,22 @@ start:
ld i, a
ld sp, #0x0000
di
-
+ ;; Init PIO and check for KEY2
+ ld a, #PIO_MODE_3
+ out (PORT_B_CTRL), a
+ ld a, #0x7F
+ out (PORT_B_CTRL), a
+ in a, (PORT_B_DATA)
+ and #0x02 ; is KEY2 pressed? If so, start booloader
+ jr NZ, main
+ ;; Load payload (bootloader)
+ ld HL, #0x7000
+ ld DE, #0x8000
+ ld BC, #0x1000
+ ldir
+ ;; Start bootloader
+ jp 0x8000
+main:
call gsinit
call _main
1$: