Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #848
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Newsgroups | comp.sys.apple2.programmer |
| Subject | Re: DOS 3.3 RWTS - C65 library function - please help |
| Date | 2013-08-30 22:16 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <kvrn7a$ck9$1@speranza.aioe.org> (permalink) |
| References | <kvqju7$lph$1@speranza.aioe.org> |
The following C language function implements DOS 3.3 RWTS (Read Write Track
Sector) for Aztec C65 3.2b. It will be added to the Apple33 distribution for
the next update complete with demo programs.
The rwts() function from the old CII DOS 3.3 compiler was entirely
incompatible with the new 3.2b compiler which also produces ProDOS 8
programs. (The CG65 variant of the 3.2b compiler produces programs for other
6502 platforms like the Commodore 64 and Atari 400/800 and ROMable 6502
code.)
Manx Software never included the rwts() function with the new compiler. This
version is far different from Manx's CII version and follows the more
advanced calling convention of version 3.2b. This is my original work, and
was a little tricky to write and debug. The final version only took a day to
write, but the research took much longer.
You are free to use this code for whatever purpose you wish as long as you
agree that I am not liable in any way whatsoever for its use.
Warning: this program is targetted to DOS 3.3 and C language expert
knowledge level. Use with caution!
Rubywand's DOS Mini-Manual - csa2 version:
http://apple2.org.za/gswv/a2zine/faqs/Csa2DOSMM.html
You can run quite a few DOS 3.3 programs from 3.5" disk, a large RAM disk,
or hard disk. However, there are numerous DOS 3.3 programs which will not
run this way, this one included, and some can even damage files and
directories on the larger media. DOS 3.3 was designed specifically to
support the Disk II drive. Hard disks, RAM disks, and 3.5 disks (like those
used in the Macintosh when it was released in 1984) could not be easily used
with DOS 3.3 (without doing major patching).
http://apple2history.org/history/ah15/
Problems are especially likely when a program modifies and CALLs machine
code routines such as Read/Write Track-Sector (RWTS) and/or makes
assumptions about the physical locations on disk of important DOS 3.3 areas
such as the Volume Table of Contents, CATALOG track, and DOS itself.
Consider yourself warned!
All the Best,
Bill Buckels, August 2013
Code follows:
=========
/* (C) Copyright Bill Buckels 2013.
All rights reserved. */
int rwts(tr, se, buf, cmd, sl, dr, vol)
unsigned tr,se,cmd,sl,dr,vol;
char *buf;
{
struct rwts_iob *r;
unsigned val;
/* read IOB - initialize structure */
val = riob();
/* load variant fields of IOB */
r = (struct rwts_iob *) val;
r->slot = (sl * 16);
r->drive = dr;
r->volume = vol;
r->track = tr;
r->sector = se;
r->buf_addr = (unsigned)&buf[0];
/* Portion of Sector to read
(to read all 256 bytes set to 0) */
r->sect_cnt = 0;
r->cmd_code = cmd;
/* call track sector IO */
val = tsio();
return val;
}
The assembly language functions below are called from the C language
function above and follow the standard C65 32.b and CG65 calling and return
convention:
* TrackSector I/O
* tsio.a65
* Copyright (c) 2013 by Bill Buckels
* the following 2 helper functions are called from
* the Aztec C65 3.2b DOS 3.3 function rwts()
* riob() - get IO buf address
* return IO buf address
* tsio() - track sector IO
* return 0 if success
* return -1 if error
R0 EQU 8
IOB EQU $48
riob_ cseg
public riob_
clc
jsr $3e3 ; get address of RWTS IOB
sta IOB+1 ; IOB address in Y/A)
sty IOB
sta R0+1
sty R0
rts
tsio_ cseg
public tsio_
clc
jsr $3e3 ; get address of RWTS IOB
jsr $3d9 ; call RWTS
ldy #0
bcc .1
dey
.1 sty R0
sty R0+1
rts
The following structures can be is used with the above:
/* Read/Write Track Sector IO Buf Structure */
struct rwts_iob {
unsigned char type;
unsigned char slot;
unsigned char drive;
unsigned char volume;
unsigned char track;
unsigned char sector;
unsigned dev_addr;
unsigned buf_addr;
unsigned char unused;
unsigned char sect_cnt;
unsigned char cmd_code;
unsigned char ret_code;
unsigned char last_v;
unsigned char last_s;
unsigned char last_d;
};
/* Device Characteristics Structure for rwts_iob */
struct rwts_dev {
unsigned char type;
unsigned char phases;
unsigned motor;
};
/* structures for rwts routines */
/* vtoc structure - 256 bytes (1 sector) */
struct vtoc {
char unused;
char ctrack;
char csector;
char version;
char unused2[2];
char volume;
char unused3[32];
char max;
char unused4[8];
char last;
char direction;
char unused5[2];
char tracks;
char sectors;
unsigned bytes;
char bitmap[4][50];
};
/* catalog sector structure - 256 bytes (1 sector) */
struct catsect{
char unused;
char track;
char sector;
char unused2[8];
char f1[35];
char f2[35];
char f3[35];
char f4[35];
char f5[35];
char f6[35];
char f7[35];
};
/* file entry structure - 35 bytes */
struct fentry {
char track;
char sector;
char type;
char name[30];
unsigned int sectors;
};
End of Listing
Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 12:14 -0500
Re: DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 12:19 -0500
Re: DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 12:28 -0500
Re: DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 13:19 -0500
Re: DOS 3.3 RWTS - C65 library function - please help Antoine Vignau <antoine.vignau@laposte.net> - 2013-08-30 12:35 -0700
Re: DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 17:07 -0500
Re: DOS 3.3 RWTS - C65 library function - please help "Bill Buckels" <bbuckels@mts.net> - 2013-08-30 22:16 -0500
csiph-web