File tree Expand file tree Collapse file tree 4 files changed +40
-4
lines changed Expand file tree Collapse file tree 4 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 1111#include <dw.h>
1212#include <fujinet-fuji-coco.h>
1313
14+
15+ #define DWWRT_VEC_DRG 0xD941
16+ #define DWREAD_VEC_DRG 0xD93F
17+ #define DWWRT_VEC_COCO 0xFA00
18+ #define DWREAD_VEC_COCO 0xF9FE
19+
20+ static gbDWInited = false;
21+ // default to coco read/write if not inited.
22+ dwvec dwreadvec = DWREAD_VEC_COCO ;
23+ dwvec dwwritevec = DWWRT_VEC_COCO ;
24+
25+ // detection logic for dragon stolen from: https://exileinparadise.com/tandy_color_computer:keyscn2
26+ //
27+ const uint16_t * RESET = 0xFFFE ; // Address of MPU Reset Vector
28+ const uint16_t VECCOCO = 0xA027 ; // CoCo 1/2 reset vector value
29+ const uint16_t VECDRGN = 0xB3B4 ; // Dragon32/64 reset vector value
30+ const uint16_t VECCOCO3 = 0x8C1B ; // CoCo3 reset vector value
31+
1432void bus_ready (void )
1533{
1634 struct _readycmd
@@ -19,6 +37,16 @@ void bus_ready(void)
1937 uint8_t command ;
2038 } rc ;
2139
40+ if (!gbDWInited )
41+ {
42+ if (* RESET == VECDRGN )
43+ {
44+ dwreadvec = DWREAD_VEC_DRG ;
45+ dwwritevec = DWWRT_VEC_DRG ;
46+ }
47+ gbDWInited = true;
48+ }
49+
2250 uint8_t z = 0 , r ;
2351
2452 rc .opcode = OP_FUJI ;
Original file line number Diff line number Diff line change 66 */
77
88#include <cmoc.h>
9-
10- typedef unsigned char byte ;
9+ #include <coco.h>
10+ #include "dw.h"
1111
1212byte dwread (byte * s , int l )
1313{
@@ -16,7 +16,7 @@ byte dwread(byte *s, int l)
1616 pshs x ,y
1717 ldx :s
1818 ldy :l
19- jsr [0xD93F ]
19+ jsr [dwreadvec ]
2020 puls y ,x
2121 tfr cc ,b
2222 lsrb
Original file line number Diff line number Diff line change 77
88#include <cmoc.h>
99#include <coco.h>
10+ #include "dw.h"
11+
1012
1113byte dwwrite (byte * s , int l )
1214{
@@ -15,7 +17,7 @@ byte dwwrite(byte *s, int l)
1517 pshs x ,y
1618 ldx :s
1719 ldy :l
18- jsr [0xD941 ]
20+ jsr [dwwritevec ]
1921 tfr cc ,d
2022 puls y ,x
2123 }
Original file line number Diff line number Diff line change 1010#define OP_FUJI 0xE2
1111#define OP_NET 0xE3
1212
13+ typedef unsigned char (* dwvec )(unsigned char );
14+
15+ extern dwvec dwreadvec ;
16+ extern dwvec dwwritevec ;
17+
18+
1319/**
1420 * @brief Read string to s from DriveWire with expected length l
1521 * @param s pointer to string buffer
You can’t perform that action at this time.
0 commit comments