This is the documentation of cc65's GEOSLib, but information contained here may be also
useful for writting GEOS applications in general.
@@ -27,10 +27,16 @@ is easy to use and program.
Coding GEOS in C? That's something new. It is possible now - with Ulrich von Bassewitz's cc65
package and my GEOSLib you are able to create GEOS applications in no-time.
-GEOSLib supports a subset of standard cc65 libraries. Memory and string functions are included
-but you should consider using native versions of these (e.g.
+
It is safe to use these includes:
@@ -992,8 +998,8 @@ Functions covered in this section are common for whole C world - copying memory
strings is one of the main computer tasks. GEOS also has interface to do this. These functions
are replacement for those like FillRam and ClearRam
-
Both functions are filling given memory range. MoveData
-
This functions copies one memory region to another. There are checks for overlap and the
non-destructive method is chosen. Be warned that this function destroys contents of
-InitRam
@@ -1066,6 +1072,7 @@ This is done with
These functions are interface to REU - Ram Expansion Unit. I think that they are self-explanatory.
+You can check for REU presence by taking value of Processes and Multitasking
diff --git a/include/geos/gdisk.h b/include/geos/gdisk.h
index 9fac4640a..68eea97e6 100644
--- a/include/geos/gdisk.h
+++ b/include/geos/gdisk.h
@@ -53,6 +53,7 @@ char __fastcall__ ChangeDiskDevice(char newdev);
#define OFF_GS_ID 173
/* disk errors */
#define ANY_FAULT 0xf0
+#define G_EOF 0
#define NO_BLOCKS 1
#define INV_TRACK 2
#define INSUFF_SPACE 3
diff --git a/include/geos/ggraph.h b/include/geos/ggraph.h
index 51caad7ba..d59947157 100644
--- a/include/geos/ggraph.h
+++ b/include/geos/ggraph.h
@@ -83,7 +83,6 @@ void __fastcall__ GraphicsString(char *myGfxString);
#define SCREENBYTEWIDTH 80
#define SCREENPIXELWIDTH 640
/* control characters for use as numbers, not chars */
-#define EOF 0
#define BACKSPACE 8
#define FORWARDSPACE 9
#define TAB 9
diff --git a/include/geos/gmemory.h b/include/geos/gmemory.h
index 805728864..e9398d5ca 100644
--- a/include/geos/gmemory.h
+++ b/include/geos/gmemory.h
@@ -19,9 +19,9 @@ char __fastcall__ CmpFString(char len, char *dest, char *source);
int __fastcall__ CRC(char *buffer, int len);
void __fastcall__ ClearRam(char *dest, int len);
-void __fastcall__ FillRam(char what, char *dest, int len);
+void __fastcall__ FillRam(char *dest, char what, int len);
-void __fastcall__ MoveData(char *source, char *dest, int len);
+void __fastcall__ MoveData(char *dest, char *source, int len);
void __fastcall__ InitRam(char *myInitTab);
diff --git a/libsrc/geos/Makefile b/libsrc/geos/Makefile
index 178c3d4f3..c38db30e4 100644
--- a/libsrc/geos/Makefile
+++ b/libsrc/geos/Makefile
@@ -4,7 +4,7 @@
#
# Maciej 'YTM/Elysium' Witkowiak
-OBJ_DIRS=devel disk dlgbox file graph menuicon memory mousesprite process system
+OBJ_DIRS=common devel disk dlgbox file graph menuicon memory mousesprite process system
all:
@for i in $(OBJ_DIRS); do $(MAKE) -C $$i; done
diff --git a/libsrc/geos/common/Makefile b/libsrc/geos/common/Makefile
new file mode 100644
index 000000000..8bea80e58
--- /dev/null
+++ b/libsrc/geos/common/Makefile
@@ -0,0 +1,21 @@
+#
+# Makefile for GEOS lib
+# for cc65
+#
+
+%.o: %.c
+ @$(CC) $(CFLAGS) $<
+ @$(AS) -g -o $@ $(AFLAGS) $(*).s
+
+%.o: %.s
+ @$(AS) -o $@ $(AFLAGS) $<
+
+C_OBJS = abort.o perror.o
+S_OBJS = copydata.o memcpy.o memset.o rand.o
+
+all: $(C_OBJS) $(S_OBJS)
+
+clean:
+ @rm -f *.~ $(S_OBJS) core
+ @rm -f $(C_OBJS:.o=.s)
+ @rm -f $(C_OBJS)
diff --git a/libsrc/geos/common/abort.c b/libsrc/geos/common/abort.c
new file mode 100644
index 000000000..fb52f88e1
--- /dev/null
+++ b/libsrc/geos/common/abort.c
@@ -0,0 +1,16 @@
+/*
+ * abort.c
+ *
+ * Maciej 'YTM/Elysium' Witkowiak 15.7.2001
+ */
+
+
+
+#include
+#include
+
+void abort (void)
+{
+ DlgBoxOk(CBOLDON "ABNORMAL PROGRAM", "TERMINATION." CPLAINTEXT);
+ exit(3);
+}
diff --git a/libsrc/geos/common/copydata.s b/libsrc/geos/common/copydata.s
new file mode 100644
index 000000000..2efd7c352
--- /dev/null
+++ b/libsrc/geos/common/copydata.s
@@ -0,0 +1,27 @@
+;
+; Maciej 'YTM/Elysium' Witkowiak 15.07.2001
+;
+; Copy the data segment from the LOAD to the RUN location
+;
+
+ .export copydata
+ .import __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__
+ .include "../inc/geossym.inc"
+ .include "../inc/jumptab.inc"
+
+copydata:
+ lda #<__DATA_SIZE__ ; no need to check if it is == 0
+ ldx #>__DATA_SIZE__
+ sta r2L
+ stx r2H
+
+ lda #<__DATA_RUN__
+ ldx #>__DATA_RUN__
+ sta r1L
+ stx r1H
+
+ lda #<__DATA_LOAD__
+ ldx #>__DATA_LOAD__
+ sta r0L
+ stx r0H
+ jmp MoveData
diff --git a/libsrc/geos/common/memcpy.s b/libsrc/geos/common/memcpy.s
new file mode 100644
index 000000000..442837d7e
--- /dev/null
+++ b/libsrc/geos/common/memcpy.s
@@ -0,0 +1,12 @@
+;
+; void* memcpy (void* dest, const void* src, size_t n);
+; void* memmove (void* dest, const void* src, size_t n);
+;
+; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
+;
+
+ .export _memcpy, _memmove
+ .import _MoveData
+
+_memcpy = _MoveData
+_memmove = _MoveData
diff --git a/libsrc/geos/common/memset.s b/libsrc/geos/common/memset.s
new file mode 100644
index 000000000..d4169c2b3
--- /dev/null
+++ b/libsrc/geos/common/memset.s
@@ -0,0 +1,10 @@
+;
+; void* memset (void* ptr, int c, size_t n);
+;
+; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
+;
+
+ .export _memset
+ .import _FillRam
+
+_memset = _FillRam
diff --git a/libsrc/geos/common/perror.c b/libsrc/geos/common/perror.c
new file mode 100644
index 000000000..6d64b25a2
--- /dev/null
+++ b/libsrc/geos/common/perror.c
@@ -0,0 +1,17 @@
+/*
+ * perror.c
+ *
+ * Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
+ */
+
+#include
+#include
+#include
+#include
+
+void perror(const char* msg)
+{
+
+ DlgBoxOk((char*)msg,strerror(errno));
+
+}
diff --git a/libsrc/geos/common/rand.s b/libsrc/geos/common/rand.s
new file mode 100644
index 000000000..ad2db1823
--- /dev/null
+++ b/libsrc/geos/common/rand.s
@@ -0,0 +1,20 @@
+;
+; Maciej 'YTM/Elysium' Witkowiak, 15.07.2001
+;
+;
+; int rand (void);
+; void srand (unsigned seed);
+;
+ .export _rand, _srand
+ .include "../inc/jumptab.inc"
+
+.code
+
+_rand:
+ jsr GetRandom
+ pha
+ jsr GetRandom
+ tax
+ pla
+_srand:
+ rts
diff --git a/libsrc/geos/memory/fillram.s b/libsrc/geos/memory/fillram.s
index c08b05e5c..72301c7fd 100644
--- a/libsrc/geos/memory/fillram.s
+++ b/libsrc/geos/memory/fillram.s
@@ -1,19 +1,23 @@
;
-; Maciej 'YTM/Alliance' Witkowiak
+; Maciej 'YTM/Elysium' Witkowiak
;
-; 30.10.99
+; 30.10.99, 15.07.2001
-; void FillRam (char what, char *dest, int length);
+; void FillRam (char *dest, char what, int length);
- .import DoublePop, popa
+ .import popa, popax
.export _FillRam
.include "../inc/jumptab.inc"
.include "../inc/geossym.inc"
_FillRam:
- jsr DoublePop
+ sta r0L
+ stx r0H
jsr popa
sta r2L
+ jsr popax
+ sta r1L
+ stx r1H
jmp FillRam
diff --git a/libsrc/geos/memory/movedata.s b/libsrc/geos/memory/movedata.s
index 79022593a..b16ef2392 100644
--- a/libsrc/geos/memory/movedata.s
+++ b/libsrc/geos/memory/movedata.s
@@ -1,10 +1,10 @@
;
-; Maciej 'YTM/Alliance' Witkowiak
+; Maciej 'YTM/Elysium' Witkowiak
;
-; 30.10.99
+; 30.10.99, 15.07.2001
-; void MoveData (char* source, char *dest, int length);
+; void MoveData (char* dest, char *source, int length);
.import popax
.export _MoveData
@@ -16,9 +16,9 @@ _MoveData:
sta r2L
stx r2H
jsr popax
- sta r1L
- stx r1H
- jsr popax
sta r0L
stx r0H
+ jsr popax
+ sta r1L
+ stx r1H
jmp MoveData