diff --git a/requesters/.gitignore b/requesters/.gitignore index ba2906d..5cd626f 100644 --- a/requesters/.gitignore +++ b/requesters/.gitignore @@ -1 +1,3 @@ main +dos_compat_test +file_list_test diff --git a/requesters/dos_compat.c b/requesters/dos_compat.c new file mode 100644 index 0000000..3ce684c --- /dev/null +++ b/requesters/dos_compat.c @@ -0,0 +1,40 @@ +#include +#include + +#include "dos_compat.h" + +const char *dc_PathPart(const char *path) +{ + if (path) { + int slen = strlen(path); + if (slen == 0) return path; + int i = slen - 1; + for (i = slen - 1; i > 0; i--) { + if (path[i] == '/') break; + if (path[i] == ':' && i < (slen - 1)) return &(path[i + 1]); + } + return &(path[i]); + } + return NULL; +} + +const char *dc_FilePart(const char *path) +{ + if (path) { + int slen = strlen(path); + if (slen == 0) return path; + int i = slen - 1; + for (i = slen - 1; i > 0; i--) { + if (path[i] == '/') return &(path[i + 1]); + if (path[i] == ':' && i < (slen - 1)) return &(path[i + 1]); + } + return &(path[i]); + } + return NULL; +} + +int dc_AddPart(char *dest_path, const char *part_to_add, int dest_size) +{ + if (dest_size == 0) return 0; + return 0; +} diff --git a/requesters/dos_compat.h b/requesters/dos_compat.h new file mode 100644 index 0000000..76b3aa2 --- /dev/null +++ b/requesters/dos_compat.h @@ -0,0 +1,13 @@ +#pragma once +#ifndef __DOS_COMPAT_H__ +#define __DOS_COMPAT_H__ + +// Compatibility functions to implement 2.x functionality on 1.x systems + +extern const char *dc_PathPart(const char *path); +extern const char *dc_FilePart(const char *path); + +extern int dc_AddPart(char *dest_path, const char *part_to_add, int dest_size); + +#endif /* __DOS_COMPAT_H__ */ + diff --git a/requesters/dos_compat_test.c b/requesters/dos_compat_test.c new file mode 100644 index 0000000..44ffe47 --- /dev/null +++ b/requesters/dos_compat_test.c @@ -0,0 +1,92 @@ +#include +#include + +#include "chibi.h" +#include "dos_compat.h" + +CHIBI_TEST(TestPathPartNull) +{ + chibi_assert(dc_PathPart(NULL) == NULL); +} + +CHIBI_TEST(TestPathPartEmpty) +{ + static char path[] = ""; + chibi_assert(dc_PathPart(path) == path); +} + +CHIBI_TEST(TestPathPartVolumeOnly) +{ + static char path[] = "Workbench:"; + chibi_assert(dc_PathPart(path) == path); +} + +CHIBI_TEST(TestPathPartVolumeAndFile) +{ + static char path[] = "Workbench:file1"; + chibi_assert(dc_PathPart(path) == &(path[10])); +} + +CHIBI_TEST(TestPathPartVolumeDirAndFile) +{ + static char path[] = "Workbench:dir/file1"; + chibi_assert(dc_PathPart(path) == &(path[13])); +} + +CHIBI_TEST(TestFilePartNull) +{ + chibi_assert(dc_FilePart(NULL) == NULL); +} + +CHIBI_TEST(TestFilePartEmpty) +{ + static char path[] = ""; + chibi_assert(dc_FilePart(path) == path); +} + +CHIBI_TEST(TestFilePartVolumeOnly) +{ + static char path[] = "Workbench:"; + chibi_assert(dc_FilePart(path) == path); +} + +CHIBI_TEST(TestFilePartVolumeAndFile) +{ + static char path[] = "Workbench:file1"; + chibi_assert(dc_FilePart(path) == &(path[10])); +} + +CHIBI_TEST(TestFilePartVolumeDirAndFile) +{ + static char path[] = "Workbench:dir/file1"; + chibi_assert(dc_FilePart(path) == &(path[14])); +} + +CHIBI_TEST(TestAddPartAllNull) +{ + chibi_assert(dc_AddPart(NULL, NULL, 0) == 0); +} + +int main(int argc, char **argv) +{ + chibi_summary_data summary; + chibi_suite *suite = chibi_suite_new(); + + chibi_suite_add_test(suite, TestPathPartNull); + chibi_suite_add_test(suite, TestPathPartEmpty); + chibi_suite_add_test(suite, TestPathPartVolumeOnly); + chibi_suite_add_test(suite, TestPathPartVolumeAndFile); + chibi_suite_add_test(suite, TestPathPartVolumeDirAndFile); + + chibi_suite_add_test(suite, TestFilePartNull); + chibi_suite_add_test(suite, TestFilePartEmpty); + chibi_suite_add_test(suite, TestFilePartVolumeOnly); + chibi_suite_add_test(suite, TestFilePartVolumeAndFile); + chibi_suite_add_test(suite, TestFilePartVolumeDirAndFile); + + chibi_suite_add_test(suite, TestAddPartAllNull); + + chibi_suite_run(suite, &summary); + chibi_suite_delete(suite); + return summary.num_failures; +} diff --git a/scrolling_tricks/cop_x.asm b/scrolling_tricks/cop_x.asm new file mode 100644 index 0000000..a1085e7 --- /dev/null +++ b/scrolling_tricks/cop_x.asm @@ -0,0 +1,226 @@ + + SECTION copperlist,DATA,CHIP + + XDEF _CopperList + XDEF _CopFETCHMODE + XDEF _CopBPLCON0 + XDEF _CopBPLCON1 + XDEF _CopBPLCON3 + XDEF _CopBPLMODA + XDEF _CopBPLMODB + XDEF _CopDIWSTART + XDEF _CopDIWSTOP + XDEF _CopDDFSTART + XDEF _CopDDFSTOP + XDEF _CopPLANE1H + XDEF _CopPLANE1L + XDEF _CopPLANE2H + XDEF _CopPLANE2L + XDEF _CopPLANE3H + XDEF _CopPLANE3L + XDEF _CopPLANE4H + XDEF _CopPLANE4L + XDEF _CopPLANE5H + XDEF _CopPLANE5L + XDEF _CopPLANE6H + XDEF _CopPLANE6L + XDEF _CopPLANE7H + XDEF _CopPLANE7L + XDEF _CopPLANE8H + XDEF _CopPLANE8L + XDEF _CopSKY + +_CopperList: + dc.w $180,0 + +_CopFETCHMODE: + dc.w $1FC,0 + +_CopBPLCON0: + dc.w $100,0 + +_CopBPLCON1: + dc.w $102,0 + +_CopBPLCON3: + dc.w $106,0 + +_CopBPLMODA: + dc.w $108,0 + +_CopBPLMODB: + dc.w $10A,0 + +_CopDIWSTART: + dc.w $8e,0 + +_CopDIWSTOP: + dc.w $90,0 + +_CopDDFSTART: + dc.w $92,0 + +_CopDDFSTOP: + dc.w $94,0 + +_CopPLANE1H: + dc.w $e0,0 + +_CopPLANE1L: + dc.w $e2,0 + +_CopPLANE2H: + dc.w $e4,0 + +_CopPLANE2L: + dc.w $e6,0 + +_CopPLANE3H: + dc.w $e8,0 + +_CopPLANE3L: + dc.w $ea,0 + +_CopPLANE4H: + dc.w $ec,0 + +_CopPLANE4L: + dc.w $ee,0 + +_CopPLANE5H: + dc.w $f0,0 + +_CopPLANE5L: + dc.w $f2,0 + +_CopPLANE6H: + dc.w $f4,0 + +_CopPLANE6L: + dc.w $f6,0 + +_CopPLANE7H: + dc.w $f8,0 + +_CopPLANE7L: + dc.w $fa,0 + +_CopPLANE8H: + dc.w $fc,0 + +_CopPLANE8L: + dc.w $fe,0 + +_CopSKY: + dc.w -1,-2 + dc.w $180,$FFF + + dc.w $390f,-2 + dc.w $180,$EEF + dc.w $3A0f,-2 + dc.w $180,$FFF + dc.w $3B0f,-2 + dc.w $180,$EEF + + dc.w $490f,-2 + dc.w $180,$DDF + dc.w $4a0f,-2 + dc.w $180,$EEF + dc.w $4b0f,-2 + dc.w $180,$DDF + + dc.w $590f,-2 + dc.w $180,$CCF + dc.w $5A0f,-2 + dc.w $180,$DDF + dc.w $5B0f,-2 + dc.w $180,$CCF + + dc.w $690f,-2 + dc.w $180,$BBF + dc.w $6A0f,-2 + dc.w $180,$CCF + dc.w $6B0f,-2 + dc.w $180,$BBF + + dc.w $790f,-2 + dc.w $180,$AAF + dc.w $7A0f,-2 + dc.w $180,$BBF + dc.w $7B0f,-2 + dc.w $180,$AAF + + dc.w $890f,-2 + dc.w $180,$99E + dc.w $8A0f,-2 + dc.w $180,$AAF + dc.w $8B0f,-2 + dc.w $180,$99E + + dc.w $990f,-2 + dc.w $180,$88E + dc.w $9A0f,-2 + dc.w $180,$99E + dc.w $9B0f,-2 + dc.w $180,$88E + + dc.w $A90f,-2 + dc.w $180,$77E + dc.w $AA0f,-2 + dc.w $180,$88E + dc.w $AB0f,-2 + dc.w $180,$77E + + dc.w $B90f,-2 + dc.w $180,$66E + dc.w $BA0f,-2 + dc.w $180,$77E + dc.w $BB0f,-2 + dc.w $180,$66E + + dc.w $C90f,-2 + dc.w $180,$55D + dc.w $CA0f,-2 + dc.w $180,$66E + dc.w $CB0f,-2 + dc.w $180,$55D + + dc.w $D90f,-2 + dc.w $180,$44D + dc.w $DA0f,-2 + dc.w $180,$55D + dc.w $DB0f,-2 + dc.w $180,$44D + + dc.w $E90f,-2 + dc.w $180,$33D + dc.w $EA0f,-2 + dc.w $180,$44D + dc.w $EB0f,-2 + dc.w $180,$33D + + dc.w $F90f,-2 + dc.w $180,$22C + dc.w $FA0f,-2 + dc.w $180,$33D + dc.w $FB0f,-2 + dc.w $180,$22C + + dc.w $FFDF,-2 + dc.w $090F,-2 + dc.w $180,$11C + dc.w $0A0F,-2 + dc.w $180,$22C + dc.w $0B0F,-2 + dc.w $180,$11C + + dc.w $190f,-2 + dc.w $180,$00B + dc.w $1A0f,-2 + dc.w $180,$11C + dc.w $1B0f,-2 + dc.w $180,$00B + + dc.w -1,-2 + END + diff --git a/scrolling_tricks/cop_x.h b/scrolling_tricks/cop_x.h new file mode 100644 index 0000000..4b392b7 --- /dev/null +++ b/scrolling_tricks/cop_x.h @@ -0,0 +1,29 @@ +extern WORD CopperList[]; +extern WORD CopFETCHMODE[]; +extern WORD CopBPLCON0[]; +extern WORD CopBPLCON1[]; +extern WORD CopBPLCON3[]; +extern WORD CopBPLMODA[]; +extern WORD CopBPLMODB[]; +extern WORD CopDIWSTART[]; +extern WORD CopDIWSTOP[]; +extern WORD CopDDFSTART[]; +extern WORD CopDDFSTOP[]; +extern WORD CopPLANE1H[]; +extern WORD CopPLANE1L[]; +extern WORD CopPLANE2H[]; +extern WORD CopPLANE2L[]; +extern WORD CopPLANE3H[]; +extern WORD CopPLANE3L[]; +extern WORD CopPLANE4H[]; +extern WORD CopPLANE4L[]; +extern WORD CopPLANE5H[]; +extern WORD CopPLANE5L[]; +extern WORD CopPLANE6H[]; +extern WORD CopPLANE6L[]; +extern WORD CopPLANE7H[]; +extern WORD CopPLANE7L[]; +extern WORD CopPLANE8H[]; +extern WORD CopPLANE8L[]; +extern WORD CopSKY[]; +