diskbench
diskbench.s
-relfile
+data
+
relfile.s
+
+reltest
+reltest.s
CFLAGS= -t c128
-all: diskbench.d71 crctest relfile.d71
+all: diskbench.d71 crctest reltest.d71
diskbench.d71: diskbench
relfile.s: relfile.c
-relfile: relfile.o
+reltest.s: reltest.c
+
+reltest: reltest.o relfile.o
${LD} -t c128 $^ -o $@
-relfile.d71: relfile
- c1541 -format "relfile",rf d71 relfile.d71
- c1541 -attach relfile.d71 -write relfile
+reltest.d71: reltest
+ c1541 -format "reltest",rf d71 reltest.d71
+ c1541 -attach reltest.d71 -write reltest
clean:
rm -f bcd2dec.o crc16.o
rm -f diskbench.d71 diskbench diskbench.o diskbench.s data
rm -f crctest crctest.o crctest.s crctest.lbl
- rm -f relfile.d71 relfile relfile.o relfile.s
+ rm -f relfile.o relfile.s
+ rm -f reltest.d71 reltest reltest.o reltest.s
#include <cbm.h>
#include <errno.h>
#include <stdio.h>
-#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include "bcd2dec.h"
-
-struct relfile
-{
- uint8_t fd;
- uint8_t cmdfd;
- uint8_t devnr;
- uint8_t sa;
- uint8_t recsize;
-};
+#include "relfile.h"
#define RELFILENAME_MAX (FILENAME_MAX + 4) // FOO,L,\xFF\0
cbm_close(rf->fd);
}
-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;
-}
-
--- /dev/null
+#include <stdint.h>
+
+struct relfile
+{
+ uint8_t fd;
+ uint8_t cmdfd;
+ uint8_t devnr;
+ uint8_t sa;
+ uint8_t recsize;
+};
+
+uint8_t relfile_open(struct relfile *rf, char* name);
+uint8_t relfile_is_split_record(struct relfile *rf, uint16_t recnum);
+uint8_t relfile_pos(struct relfile *rf, uint16_t recnum, uint8_t offset);
+uint8_t relfile_read(struct relfile *rf, uint8_t *buf);
+uint8_t relfile_write(struct relfile *rf, uint8_t *buf);
+uint8_t relfile_clear(struct relfile *rf);
+void relfile_close(struct relfile *rf);
--- /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;
+}
+