--- /dev/null
+#include <conio.h>
+#include <cbm.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "relfile.h"
+
+void c128_perror(uint8_t c, char *msg) {
+ cprintf("\r\nError (Code %d) while: %s\r\nOS Error = %d\r\n", c, msg,
+ _oserror);
+}
+
+int main(void)
+{
+ char bla[25];
+ struct relfile rf;
+ uint8_t c=0;
+ uint8_t start_sec, start_tenth;
+ uint8_t end_sec, end_tenth;
+ uint8_t i,j;
+
+ videomode(VIDEOMODE_80x25);
+ fast();
+
+ __asm__("jsr initsystime");
+
+ rf.fd=2;
+ rf.devnr=8;
+ rf.sa=3;
+ rf.recsize=25;
+
+ if(relfile_open(&rf, "reldata"))
+ {
+ c128_perror(c, "relfile_open");
+ return 1;
+ }
+
+ start_tenth = CIA1.tod_10;
+ start_sec = CIA1.tod_sec;
+
+ for(i=1;i<=25;i++)
+ {
+ //cgetc();
+ /*
+ cprintf("P%d\r",i);
+ if(relfile_pos(&rf, i, 0))
+ {
+ c128_perror(c, "relfile_pos1");
+ return 2;
+ }
+ */
+ if(relfile_is_split_record(&rf, i))
+ {
+ cprintf("\r\nSPLIT: %d!\r\n",i);
+ }
+ /*
+ if(relfile_pos(&rf, i, 0))
+ {
+ c128_perror(c, "relfile_pos2");
+ return 2;
+ }
+ cprintf("C%d\r",i);
+ if(relfile_clear(&rf))
+ {
+ c128_perror(c, "relfile_clear");
+ return 2;
+ }
+ */
+ cprintf("W%d: ", i);
+ for(j=0;j<rf.recsize;j++)
+ {
+ bla[j]=(i-1==j) ? 0xFF : 0xAA;
+ cprintf("%02X",bla[j]);
+ }
+ cprintf("\r\n");
+
+ if(relfile_pos(&rf, i, 0))
+ {
+ c128_perror(c, "relfile_pos3");
+ return 2;
+ }
+ if(relfile_write(&rf, bla))
+ {
+ c128_perror(c, "relfile_write");
+ return 2;
+ }
+ }
+
+ relfile_close(&rf);
+ end_tenth = CIA1.tod_10;
+ end_sec = CIA1.tod_sec;
+ cprintf("\r\n%d.%d -> %d.%d\r\n",start_sec,start_tenth,end_sec,end_tenth);
+
+
+ if(relfile_open(&rf, "reldata"))
+ {
+ c128_perror(0, "relfile_open");
+ return 3;
+ }
+
+ start_tenth = CIA1.tod_10;
+ start_sec = CIA1.tod_sec;
+
+ for(i=1;i<=25;i++)
+ {
+ cprintf("P%d\r",i);
+ if(relfile_pos(&rf, i, 0))
+ {
+ c128_perror(0, "relfile_pos");
+ return 1;
+ }
+ if(relfile_is_split_record(&rf, i))
+ {
+ cprintf("\r\nSPLIT!\r\n");
+ }
+ cprintf("R%d\r",i);
+ if(relfile_read(&rf, bla))
+ {
+ c128_perror(0, "relfile_read");
+ return 1;
+ }
+
+ cprintf("?%d\r",i);
+ for(j=0;j<rf.recsize;j++)
+ {
+ uint8_t exp=(i-1==j) ? 0xFF : 0xAA;
+ if(bla[j] != exp)
+ {
+ cprintf("\r\nMISMATCH(%2d): IS: %2X EXP: %2X\r\n",j,bla[j],exp);
+ cgetc();
+ }
+ }
+ }
+
+ relfile_close(&rf);
+ end_tenth = CIA1.tod_10;
+ end_sec = CIA1.tod_sec;
+ cprintf("\r\n%d.%d -> %d.%d\r\n",start_sec,start_tenth,end_sec,end_tenth);
+
+ return 0;
+}
+