<itemize>
 <item>_dos_type
 <item>get_ostype
+<item>rebootafterexit
 </itemize>
 
 
 
 <itemize>
 <item>_dos_type
 <item>get_ostype
+<item>rebootafterexit
 <item>textframe
 <item>textframexy
 <item>videomode
 
 <itemize>
 <item>_dos_type
 <item><ref id="get_ostype" name="get_ostype">
+<item>rebootafterexit
 </itemize>
 
 
 <itemize>
 <item>_dos_type
 <item><ref id="get_ostype" name="get_ostype">
+<item>rebootafterexit
 <item>textframe
 <item>textframexy
 <item><ref id="videomode" name="videomode">
 
 unsigned char get_ostype (void);
 /* Get the machine type. Returns one of the APPLE_xxx codes. */
 
+void rebootafterexit (void);
+/* Reboot machine after program termination has completed. */
+
 /* The following #defines will cause the matching functions calls in conio.h
  * to be overlaid by macros with the same names, saving the function call
  * overhead.
 
         randomize.o     \
         rdkey.o         \
        read.o          \
+       reboot.o        \
        revers.o        \
        rwcommon.o      \
        syschdir.o      \
 
 ; Startup code for cc65 (Apple2 version)
 ;
 
-        .export         _exit
+        .export         _exit, done, return
         .export         __STARTUP__ : absolute = 1      ; Mark as startup
         .import         zerobss
         .import        initlib, donelib
         bne     basic
         
         ; Check ProDOS system bit map
-        lda     $BF58           ; protection for pages $00 - $07
-        and     #%11110000      ; ignore protection of text pages
-        cmp     #%11000000      ; only zero and stack pages are protected
-        bne     basic
         lda     $BF6F           ; protection for pages $B8 - $BF
         cmp     #%00000001      ; exactly system global page is protected
         bne     basic
         sta     SOFTEV+1
         eor     #$A5
         sta     PWREDUP
-        rts
+return: rts
 
         ; Quit to ProDOS dispatcher
 quit:   jsr     $BF00           ; MLI call entry point
 
--- /dev/null
+;
+; Oliver Schmidt, 14.09.2009
+;
+; void rebootafterexit (void);
+;
+
+        .constructor   initreboot
+        .export                _rebootafterexit
+        .import         done, return
+
+_rebootafterexit := return
+
+        .segment        "INIT"
+
+initreboot:
+        ; Quit to PWRUP
+        lda     #<$FAA6
+        ldx     #>$FAA6
+        sta     done
+        stx     done+1
+        rts
 
         randomize.o     \
         rdkey.o         \
        read.o          \
+       reboot.o        \
        revers.o        \
        rwcommon.o      \
        syschdir.o      \