105 lines
2.9 KiB
C
105 lines
2.9 KiB
C
#ifndef _TABBY_PRINTER_H
|
|
#define _TABBY_PRINTER_H
|
|
|
|
#define TABBY_PRINTER_SYNC_1 0x88
|
|
#define TABBY_PRINTER_SYNC_2 0x33
|
|
|
|
#define TABBY_PRINTER_DEVICE_ID 0x81
|
|
#define TABBY_PRINTER_RETRY_COUNT 5
|
|
|
|
#define TABBY_PRINTER_PACKET_MAX_SIZE 640
|
|
|
|
#define TABBY_PRINTER_BAND_SIZE 640
|
|
#define TABBY_PRINTER_SHEET_BANDS 9
|
|
|
|
#define TABBY_PRINTER_SHEET_SIZE \
|
|
(TABBY_PRINTER_SHEET_BANDS * TABBY_PRINTER_BAND_SIZE)
|
|
|
|
typedef enum {
|
|
TABBY_PRINTER_LOWBAT = (1 << 7),
|
|
TABBY_PRINTER_ER2 = (1 << 6),
|
|
TABBY_PRINTER_ER1 = (1 << 5),
|
|
TABBY_PRINTER_ER0 = (1 << 4),
|
|
TABBY_PRINTER_UNTRAN = (1 << 3),
|
|
TABBY_PRINTER_FULL = (1 << 2),
|
|
TABBY_PRINTER_BUSY = (1 << 1),
|
|
TABBY_PRINTER_SUM = (1 << 0)
|
|
} tabby_printer_status;
|
|
|
|
typedef enum {
|
|
TABBY_PRINTER_PACKET_INIT = 0x01,
|
|
TABBY_PRINTER_PACKET_JOB = 0x02,
|
|
TABBY_PRINTER_PACKET_DATA = 0x04,
|
|
TABBY_PRINTER_PACKET_CANCEL = 0x08,
|
|
TABBY_PRINTER_PACKET_INQUIRY = 0x0f
|
|
} tabby_printer_packet_type;
|
|
|
|
typedef enum {
|
|
TABBY_PRINTER_COMPRESSION_NONE = 0x00,
|
|
TABBY_PRINTER_COMPRESSION_RLE = 0x01
|
|
} tabby_printer_compression;
|
|
|
|
/*
|
|
* Data definitions for packets sent from Game Boy to printer
|
|
*/
|
|
typedef struct _tabby_printer_packet {
|
|
union {
|
|
struct {
|
|
uint8_t preamble[2],
|
|
type,
|
|
compression;
|
|
|
|
uint16_t size;
|
|
};
|
|
|
|
uint8_t data[6];
|
|
};
|
|
} tabby_printer_packet;
|
|
|
|
typedef struct _tabby_printer_buffer {
|
|
tabby_printer_packet header;
|
|
uint8_t body[TABBY_PRINTER_PACKET_MAX_SIZE];
|
|
uint16_t sum;
|
|
} tabby_printer_buffer;
|
|
|
|
typedef struct _tabby_printer_response {
|
|
uint8_t device;
|
|
uint8_t status;
|
|
} tabby_printer_response;
|
|
|
|
int tabby_printer_link_init(int fd);
|
|
|
|
/*
|
|
* For receiving printer data packets from a Game Boy Camera
|
|
*/
|
|
int tabby_printer_packet_recv(int fd,
|
|
tabby_printer_packet *header,
|
|
void *body);
|
|
|
|
/*
|
|
* For sending printer data packets to a Game Boy Printer
|
|
*/
|
|
int tabby_printer_packet_send(int fd,
|
|
tabby_printer_packet *header,
|
|
void *body,
|
|
tabby_printer_response *response);
|
|
|
|
int tabby_printer_init(int fd,
|
|
tabby_printer_response *response);
|
|
|
|
int tabby_printer_send_inquiry(int fd,
|
|
tabby_printer_response *response);
|
|
|
|
int tabby_printer_job_start(int fd, uint8_t sheets,
|
|
uint8_t linefeeds,
|
|
uint8_t palette,
|
|
uint8_t density,
|
|
tabby_printer_response *response);
|
|
|
|
int tabby_printer_job_cancel(int fd,
|
|
tabby_printer_response *response);
|
|
|
|
int tabby_printer_send_sheet(int fd, void *data,
|
|
tabby_printer_response *response);
|
|
|
|
#endif /* _TABBY_PRINTER_H */
|