dMZX Forums: Help - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help

#1 User is offline   Jim diGriz 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 04-December 02
  • Location:Hell

Posted 07 January 2003 - 10:25 PM

Could someone help me with my code? Please.

It keeps on saying the SREGS and REGS is indifined. Woudl the interrupts be too old? This was ment for a 8086.

Plus GCC doesn't like the void main( void )

/* ReadDisk.c
 ? Reports errors on the 3 1/4 disk
*/

#include <dos.h>
#include <stdio.h>

unsigned char readDriveSectors( unsigned char, unsigned char,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char, unsigned char,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char, unsigned char far * );

unsigned char resetDrive( unsigned char );

#define LASTHEAD ? ? ? ? ?1
#define LASTTRACK ? ? ? ? 79
#define LASTSECTOR ? ? ? ?18
#define BYTESPERSECTOR ? ?512
#define driveToRead ? ? ? 0
#define MAXRETRIES ? ? ? ?3
#define NO_ERROR ? ? ? ? ?0

char diskBuffer[ BYTESPERSECTOR * LASTSECTOR ];

void main( void )
{
unsigned int currentHead,
 ? ? ? ? ? ? currentTrack;
unsigned char errorCode;
int retryCount;

for( currentTrack = 0;
 ? ? ? ?currentHead <= LASTHEAD;
 ? ? ? ? ? ? ? ?currentHead++ )
{
 ? ? ? ?for( retryCount = 0;
 ? ? ? ? ? ? ? ?retryCount < MAXRETRIES;
 ? ? ? ? ? ? ? ? ? ? ? ?retryCount++ )
{
 ? ? ? ?errorCode = readDisketteSectors( driveToRead,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? LASTSECTOR,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? currentHead,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? currentTrack,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? diskBuffer );
 ? ? ? ? ? ? ? ?if ( errorCode == NO_ERROR )
 ? ? ? ? ? ? ? ? ? ? ? ?break;
 ? ? ? ? ? ? ? ?resetDrive( driveToRead );
 ? ? ? ? ? ? ? ?}
 ? ? ? ?if ( errorCode != NO_ERROR )
 ? ? ? ? ? ? ? printf( "Error reading head %u\n\7",
 ? ? ? ? ? ? ? ? ? ? ? ?currentHead, currentTrack );
 ? ? ? ? ? }
 ? ? ?}
}

unsigned char readDisketteSectors( unsigned char drive,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char sectorsToRead,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char head,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char track,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char sector,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned char far *bufferPtr )
{
union REGS regs;
struct SREGS sregs;
regs.h.ah = 2;
regs.h.al = sectorsToRead;
regs.x.bx = FP_OFF(bufferPtr);
regs.h.dh = head;
regs.h.dl = drive;
regs.h.cl = track;
regs.h.cl = sector;
sregs.es ?= FP_SEG(bufferPtr);
int86x( 0x13, ?s,
 ? ? ? ??s, &sregs );
return( regs.h.ah );
}

unsigned char resetDrive( unsigned char drive )
{
union REGS regs;
regs.h.ah = 0;
regs.h.dl = drive;
int86( 0x13, ?s, ?s );
return( regs.h.ah );
}

This post has been edited by Jim diGriz: 07 January 2003 - 10:27 PM

0

#2 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 07 January 2003 - 11:23 PM

Well you will see there that they are not in fact defined, so that's obviously the problem. They're prototyped in the code but never actually defined. Whatever this was originally written for probably had them defined in dos.h. If you're going to be twiddling with registers and interrupts directly it's a much better idea to use inline ASM. But I hope you realize that using interrupts in 32bit x86 OS's is more of a privelage than a right.

As for main, define it as

int main(int argc, char *argv[])

And don't forget to return something (0 if successfully exiting the program)

While we're on the topic, could you explain to me exactly why you're trying to compile this (and why you're calling it your own code, at that)?

- Exo
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#3 User is offline   Jim diGriz 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 04-December 02
  • Location:Hell

Posted 08 January 2003 - 12:34 AM

Sorry sorry,

!THIS IS NOT MY CODE! Didn't mean to plagerize.(sp?)

I was doing some lessons out of the book. That and I wanted to make this to se if my disk was bad.

This post has been edited by Jim diGriz: 08 January 2003 - 12:36 AM

0

#4 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 08 January 2003 - 12:50 AM

Lesson #1: get a new book :ninja1:

- Exo
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#5 User is offline   Jim diGriz 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 04-December 02
  • Location:Hell

Posted 09 January 2003 - 12:13 AM

Yeah, these are my dad's books anyways. He has been C/C++ programmer for 25 years.
0

#6 User is offline   Exophase 

  • Laughing on the inside.
  • Group: DigiStaff
  • Posts: 7,155
  • Joined: 23-October 00
  • Gender:Male
  • Location:Cleveland, OH

Posted 09 January 2003 - 12:34 AM

So let him teach you... btw, C++ hasn't existed for that long.

- Exo
~ ex0 has a kickass battle engine, without it you sux0rz! without it you sux0rz! ~

"The fact that I say I've one of the best, is called honesty." -Akwende
"Megazeux is not ment to be just ASCII, it is ANSI!" - T-bone6
"I hate it when you get all exo on me." - emalkay

Exophase can what Rubi-cant.
exoware is ware ur ware is exoware
ps. not loking 4 new membrs kthx
0

#7 User is offline   Jim diGriz 

  • Member
  • PipPip
  • Group: Members
  • Posts: 116
  • Joined: 04-December 02
  • Location:Hell

Posted 09 January 2003 - 03:00 PM

I know, I am saying he started off as C. And then moved into C++.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users