Re: [cc65] Read 15x1 error channel?

From: MagerValp <MagerValp1cling.gu.se>
Date: 2005-09-13 14:00:18
>>>>> "RW" == Raj Wurttemberg <rajw@c64.us> writes:

RW> Does anyone have an example of reading the 15x1 error channel on a
RW> C64 with cc65?

#include <stdio.h>
#include <cbm.h>

int main(void) {
  unsigned char buf[128];
  unsigned char msg[100]; // should be large enough for all messages
  unsigned char e, t, s;

  if (cbm_open(1, 8, 15, "") == 0) {
    if (cbm_read(1, buf, sizeof(buf)) < 0) {
      puts("read error");
      return(1);
    }
    cbm_close(1);
  }
  if (sscanf(buf, "%hhu, %[^,], %hhu, %hhu", &e, msg, &t, &s) != 4) {
    puts("parse error");
    puts(buf);
    return(2);
  }
  printf("%hhu,%s,%hhu,%hhu\n", (int) e, msg, (int) t, (int) s);
  return(0);
}

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp@cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Sep 13 14:00:40 2005

This archive was generated by hypermail 2.1.8 : 2005-09-13 14:00:43 CEST