<itemize>
 <item><ref id="c64mode" name="c64mode">
 <item><ref id="fast" name="fast">
-<item><ref id="toggle_videomode" name="toggle_videomode">
 <item><ref id="slow" name="slow">
+<item><ref id="toggle_videomode" name="toggle_videomode">
+<item><ref id="videomode" name="videomode">
 </itemize>
 
 
 <tag/Availability/C128
 <tag/See also/
 <ref id="slow" name="slow">,
-<ref id="toggle_videomode" name="toggle_videomode">
+<ref id="toggle_videomode" name="toggle_videomode">,
+<ref id="videomode" name="videomode">
 <tag/Example/None.
 </descrip>
 </quote>
 <tag/Availability/C128
 <tag/See also/
 <ref id="fast" name="fast">,
-<ref id="toggle_videomode" name="toggle_videomode">
+<ref id="toggle_videomode" name="toggle_videomode">,
+<ref id="videomode" name="videomode">
 <tag/Example/None.
 </descrip>
 </quote>
 with the mode.
 <tag/Limits/<itemize>
 <item>The function is specific to the C128.
+<item>This function is deprecated. Please use <ref id="videomode"
+name="videomode"> instead!
 </itemize>
 <tag/Availability/C128
 <tag/See also/
 <ref id="fast" name="fast">,
-<ref id="slow" name="slow">
+<ref id="slow" name="slow">,
+<ref id="videomode" name="videomode">
 <tag/Example/None.
 </descrip>
 </quote>
     printf ("We deleted %s successfully\n", FILENAME);
 } else {
     printf ("There was a problem deleting %s\n", FILENAME);
-}     
+}
 </verb>
 </descrip>
 </quote>
 </quote>
 
 
+<sect1>videomode<label id="videomode"><p>
+
+<quote>
+<descrip>
+<tag/Function/Switch to either 40 or 80 column mode.
+<tag/Header/<tt/<ref id="c128.h" name="c128.h">/
+<tag/Declaration/<tt/unsigned char __fastcall__ videomode (unsigned char Mode);/
+<tag/Description/Switch to 40 or 80 column mode depending on the argument. If
+the requested mode is already active, nothing happens. The old mode is returned
+from the call.
+<tag/Limits/<itemize>
+<item>The function is specific to the C128.
+<item>This function is replaces <ref id="toggle_videomode"
+name="toggle_videomode">.
+<item>The function is only available as fastcall function, so it may only be
+used in presence of a prototype.
+</itemize>
+<tag/Availability/C128
+<tag/See also/
+<ref id="fast" name="fast">,
+<ref id="slow" name="slow">,
+<ref id="toggle_videomode" name="toggle_videomode">
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>wherex<label id="wherex"><p>
 
 <quote>
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 #define CH_F7                  136
 #define CH_F8                  140
 
-
-
 /* Color defines */
 #define COLOR_BLACK            0x00
 #define COLOR_WHITE            0x01
 #define COLOR_CYAN             0x03
 #define COLOR_VIOLET           0x04
 #define COLOR_GREEN            0x05
-#define COLOR_BLUE             0x06
+#define COLOR_BLUE             0x06       
 #define COLOR_YELLOW           0x07
 #define COLOR_ORANGE           0x08
 #define COLOR_BROWN            0x09
 #define COLOR_LIGHTBLUE        0x0E
 #define COLOR_GRAY3            0x0F
 
+/* Video mode defines */
+#define VIDEOMODE_40COL         0x00
+#define VIDEOMODE_80COL         0x80
+
 
 
 /* Define hardware */
 
 
 
+unsigned char __fastcall__ videomode (unsigned char Mode);
+/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
+ * constants.
+ */
+
 void toggle_videomode (void);
-/* Toggle the video mode between 40 and 80 chars (calls SWAPPER) */
+/* Toggle the video mode between 40 and 80 chars (calls SWAPPER).
+ * THIS FUNCTION IS DEPRECATED, please use videomode instead!
+ */
 
 void c64mode (void);
 /* Switch the C128 into C64 mode. Note: This function will not return! */
 
--- /dev/null
+;
+; Ullrich von Bassewitz, 2009-09-07
+;
+; unsigned char __fastcall__ videomode (unsigned char Mode);
+; /* Set the video mode, return the old mode */
+;
+
+       .export         _videomode
+        .import         SWAPPER, BSOUT  
+
+        .include        "c128.inc"
+
+
+.proc   _videomode
+
+        cmp     MODE                    ; Do we have this mode already?
+        beq     @L9
+
+        lda     MODE                    ; Get current mode ...
+        pha                             ; ... and save it
+
+        jsr     SWAPPER                 ; Toggle the mode
+       lda     #14
+               jsr     BSOUT                   ; Switch to lower case chars
+        pla                             ; Get old mode into A
+
+; Done, old mode is in A
+
+@L9:    ldx     #$00                    ; Clear high byte
+        rts
+
+.endproc
+