diff --git a/doc/atmos.sgml b/doc/atmos.sgml
index 6b9755d4d..2de4b8d6f 100644
--- a/doc/atmos.sgml
+++ b/doc/atmos.sgml
@@ -62,6 +62,17 @@ Special locations:
Programs containing Atmos specific code may use the Atmos specific functions
+
+The functions listed below are special for the Atmos. See the for declaration and usage.
+
+
+- atmos_load
+
- atmos_save
+
+
+
Hardware access
The following pseudo variables declared in the Interrupts
-The runtime for the Atmos uses routines marked as
-(incomplete)
+
+[
+][
+]
@@ -138,6 +141,37 @@ function.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(incomplete)
+
+
@@ -1156,6 +1190,40 @@ used in presence of a prototype.
+atmos_load
+
+
+
+/
+
+
+
+
+
+atmos_save
+
+
+
+/
+
+
+atmos_save("hires", 0xa000, 0xc000);
+
+
+
+
+
atoi
diff --git a/include/atmos.h b/include/atmos.h
index a73b13a06..8155ee8b2 100644
--- a/include/atmos.h
+++ b/include/atmos.h
@@ -98,6 +98,12 @@
#define CH_LIRA 95
#define CH_ESC 27
+void __fastcall__ atmos_load(const char* name);
+/* Load Atmos tape. */
+
+void __fastcall__ atmos_save(const char* name, const void* start, const void* end);
+/* Save Atmos tape. */
+
/* End of atmos.h */
diff --git a/libsrc/atmos/Makefile b/libsrc/atmos/Makefile
index 5dd2ca158..e38da1261 100644
--- a/libsrc/atmos/Makefile
+++ b/libsrc/atmos/Makefile
@@ -45,6 +45,8 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
# Object files
OBJS = _scrsize.o \
+ atmos_load.o \
+ atmos_save.o \
cclear.o \
cgetc.o \
chline.o \
@@ -63,6 +65,7 @@ OBJS = _scrsize.o \
oserrlist.o \
oserror.o \
revers.o \
+ store_filename.o\
systime.o \
sysuname.o \
tgi_colors.o \
diff --git a/libsrc/atmos/atmos_load.s b/libsrc/atmos/atmos_load.s
new file mode 100644
index 000000000..30d67ab93
--- /dev/null
+++ b/libsrc/atmos/atmos_load.s
@@ -0,0 +1,25 @@
+; Stefan Haubenthal, 2012-05-06
+; based on code by Twilighte
+; void __fastcall__ atmos_load(const char* name);
+
+ .export _atmos_load
+ .import store_filename
+
+
+.proc _atmos_load
+
+ sei
+ jsr store_filename
+ ldx #$00
+ stx $02ad
+ stx $02ae
+ stx $025a
+ stx $025b
+ jsr cload_bit
+ cli
+ rts
+cload_bit:
+ pha
+ jmp $e874
+
+.endproc
diff --git a/libsrc/atmos/atmos_save.s b/libsrc/atmos/atmos_save.s
new file mode 100644
index 000000000..7a4e68aae
--- /dev/null
+++ b/libsrc/atmos/atmos_save.s
@@ -0,0 +1,28 @@
+; Stefan Haubenthal, 2012-05-06
+; based on code by Twilighte
+; void __fastcall__ atmos_save(const char* name, const void* start, const void* end);
+
+ .export _atmos_save
+ .import popax, store_filename
+
+
+.proc _atmos_save
+
+ sei
+ sta $02ab ; file end lo
+ stx $02ac ; file end hi
+ jsr popax
+ sta $02a9 ; file start lo
+ stx $02aa ; file start hi
+ jsr popax
+ jsr store_filename
+ lda #00
+ sta $02ad
+ jsr csave_bit
+ cli
+ rts
+csave_bit:
+ php
+ jmp $e92c
+
+.endproc
diff --git a/libsrc/atmos/store_filename.s b/libsrc/atmos/store_filename.s
new file mode 100644
index 000000000..a909bcf15
--- /dev/null
+++ b/libsrc/atmos/store_filename.s
@@ -0,0 +1,12 @@
+ .export store_filename
+ .importzp ptr1
+
+store_filename:
+ sta ptr1
+ stx ptr1+1
+ ldy #$0f ;store filename
+: lda (ptr1),y
+ sta $027f,y
+ dey
+ bpl :-
+ rts