2000-07-22 19:03:03 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* cbm.h */
|
2000-07-22 19:03:03 +00:00
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* CBM system-specific definitions */
|
2000-07-22 19:03:03 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2015-03-10 09:53:52 +00:00
|
|
|
/* (C) 1998-2015, Ullrich von Bassewitz */
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-07-22 19:03:03 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _CBM_H
|
|
|
|
#define _CBM_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-19 08:46:07 +00:00
|
|
|
/* Check for errors */
|
|
|
|
#if !defined(__CBM__)
|
2011-04-16 12:28:06 +00:00
|
|
|
# error This module may be used only when compiling for CBM machines!
|
2001-09-19 08:46:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
/* We need NULL. */
|
2018-02-02 11:28:22 +00:00
|
|
|
#include <stddef.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
|
|
|
|
/* Load the system-specific files here, if needed. */
|
|
|
|
#if defined(__C64__) && !defined(_C64_H)
|
2001-09-08 14:39:01 +00:00
|
|
|
# include <c64.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
#elif defined(__VIC20__) && !defined(_VIC20_H)
|
2002-08-07 05:18:13 +00:00
|
|
|
# include <vic20.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
#elif defined(__C128__) && !defined(_C128_H)
|
2001-09-08 14:39:01 +00:00
|
|
|
# include <c128.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
#elif defined(__PLUS4__) && !defined(_PLUS4_H)
|
2001-09-08 14:39:01 +00:00
|
|
|
# include <plus4.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
#elif defined(__C16__) && !defined(_C16_H)
|
2002-11-21 21:22:26 +00:00
|
|
|
# include <c16.h>
|
2001-09-13 21:27:32 +00:00
|
|
|
#elif defined(__CBM510__) && !defined(_CBM510_H)
|
|
|
|
# include <cbm510.h>
|
2001-09-08 14:39:01 +00:00
|
|
|
#elif defined(__CBM610__) && !defined(_CBM610_H)
|
|
|
|
# include <cbm610.h>
|
2011-04-16 12:28:06 +00:00
|
|
|
#elif defined(__PET__) && !defined(_PET_H)
|
2001-09-08 14:39:01 +00:00
|
|
|
# include <pet.h>
|
2019-09-27 07:38:51 +00:00
|
|
|
#elif defined(__CX16__) && !defined(_CX16_H)
|
|
|
|
# include <cx16.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#endif
|
|
|
|
|
2012-06-24 13:52:06 +00:00
|
|
|
/* Include definitions for CBM file types */
|
|
|
|
#include <cbm_filetype.h>
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
2017-08-19 17:11:28 +00:00
|
|
|
#define JOY_FIRE_MASK JOY_BTN_1_MASK
|
|
|
|
#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
|
2017-07-22 13:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-01 23:39:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Variables */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-16 21:39:40 +00:00
|
|
|
/* The file stream implementation and the POSIX I/O functions will
|
2014-06-30 09:10:35 +00:00
|
|
|
** use the following variable to determine the file type to use.
|
|
|
|
*/
|
2012-07-01 18:24:01 +00:00
|
|
|
extern char _filetype; /* Defaults to 's' */
|
2002-12-01 23:39:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Character-codes (CBM charset) */
|
2002-12-01 23:39:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
#define CH_HLINE 192
|
|
|
|
#define CH_VLINE 221
|
|
|
|
#define CH_ULCORNER 176
|
|
|
|
#define CH_URCORNER 174
|
|
|
|
#define CH_LLCORNER 173
|
|
|
|
#define CH_LRCORNER 189
|
|
|
|
#define CH_TTEE 178
|
|
|
|
#define CH_BTEE 177
|
|
|
|
#define CH_LTEE 171
|
|
|
|
#define CH_RTEE 179
|
|
|
|
#define CH_CROSS 219
|
|
|
|
#define CH_CURS_UP 145
|
|
|
|
#define CH_CURS_DOWN 17
|
|
|
|
#define CH_CURS_LEFT 157
|
|
|
|
#define CH_CURS_RIGHT 29
|
|
|
|
#define CH_PI 222
|
|
|
|
#define CH_HOME 19
|
|
|
|
#define CH_DEL 20
|
|
|
|
#define CH_INS 148
|
|
|
|
#define CH_ENTER 13
|
|
|
|
#define CH_STOP 3
|
|
|
|
#define CH_LIRA 92
|
|
|
|
#define CH_ESC 27
|
2019-10-01 08:16:44 +00:00
|
|
|
#define CH_FONT_LOWER 14
|
|
|
|
#define CH_FONT_UPPER 142
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2012-06-04 18:32:38 +00:00
|
|
|
|
2002-12-01 23:39:11 +00:00
|
|
|
|
2003-02-02 13:18:40 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Definitions for directory reading functions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* CBM FILE ACCESS */
|
|
|
|
#define CBM_A_RO 1 /* Read only */
|
2011-04-16 12:28:06 +00:00
|
|
|
#define CBM_A_WO 2 /* Write only */
|
2003-02-02 13:18:40 +00:00
|
|
|
#define CBM_A_RW 3 /* Read, Write */
|
|
|
|
|
2004-10-16 19:32:07 +00:00
|
|
|
struct cbm_dirent {
|
2011-04-16 12:28:06 +00:00
|
|
|
char name[17]; /* File name in PetSCII, limited to 16 chars */
|
|
|
|
unsigned int size; /* Size, in 254-/256-byte blocks */
|
2003-02-02 13:18:40 +00:00
|
|
|
unsigned char type;
|
|
|
|
unsigned char access;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-03 22:19:21 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Machine info */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-10-16 19:32:07 +00:00
|
|
|
#define TV_NTSC 0
|
|
|
|
#define TV_PAL 1
|
|
|
|
#define TV_OTHER 2
|
2002-12-03 22:19:21 +00:00
|
|
|
|
2011-07-07 20:19:35 +00:00
|
|
|
unsigned char get_tv (void);
|
2004-10-16 19:32:07 +00:00
|
|
|
/* Return the video mode the machine is using. */
|
2002-12-03 22:19:21 +00:00
|
|
|
|
2017-08-30 14:37:31 +00:00
|
|
|
#define KBREPEAT_CURSOR 0x00
|
|
|
|
#define KBREPEAT_NONE 0x40
|
|
|
|
#define KBREPEAT_ALL 0x80
|
2002-12-03 22:19:21 +00:00
|
|
|
|
2017-08-30 14:37:31 +00:00
|
|
|
unsigned char __fastcall__ kbrepeat (unsigned char mode);
|
|
|
|
/* Changes which keys have automatic repeat. */
|
2002-12-03 22:19:21 +00:00
|
|
|
|
2020-11-18 00:13:10 +00:00
|
|
|
#if !defined(__CBM610__)
|
2017-07-17 21:43:08 +00:00
|
|
|
void waitvsync (void);
|
2019-12-25 15:56:32 +00:00
|
|
|
/* Wait for the start of the next video field. */
|
2017-07-17 21:43:08 +00:00
|
|
|
#endif
|
2002-12-03 22:19:21 +00:00
|
|
|
|
2002-12-01 23:39:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* CBM kernal functions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Constants to use with cbm_open() for openning a file for reading or
|
2014-06-30 09:10:35 +00:00
|
|
|
** writing without the need to append ",r" or ",w" to the filename.
|
|
|
|
**
|
|
|
|
** e.g., cbm_open(2, 8, CBM_READ, "0:data,s");
|
|
|
|
*/
|
2013-05-09 11:56:54 +00:00
|
|
|
#define CBM_READ 0 /* default is ",p" */
|
|
|
|
#define CBM_WRITE 1 /* ditto */
|
|
|
|
#define CBM_SEQ 2 /* default is ",r" -- or ",s" when writing */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Kernal-level functions */
|
2012-07-01 12:36:44 +00:00
|
|
|
unsigned char cbm_k_acptr (void);
|
2011-04-16 12:28:06 +00:00
|
|
|
unsigned char cbm_k_basin (void);
|
2001-03-30 18:18:40 +00:00
|
|
|
void __fastcall__ cbm_k_bsout (unsigned char C);
|
2012-07-01 12:36:44 +00:00
|
|
|
unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
|
2021-02-15 13:50:34 +00:00
|
|
|
unsigned char cbm_k_chrin (void);
|
|
|
|
void __fastcall__ cbm_k_chrout (unsigned char C);
|
2012-07-01 12:36:44 +00:00
|
|
|
void __fastcall__ cbm_k_ciout (unsigned char C);
|
|
|
|
unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
|
2012-07-01 12:45:26 +00:00
|
|
|
void cbm_k_clall (void);
|
2012-07-01 12:36:44 +00:00
|
|
|
void __fastcall__ cbm_k_close (unsigned char FN);
|
|
|
|
void cbm_k_clrch (void);
|
|
|
|
unsigned char cbm_k_getin (void);
|
|
|
|
unsigned cbm_k_iobase (void);
|
|
|
|
void __fastcall__ cbm_k_listen (unsigned char dev);
|
|
|
|
unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
|
|
|
|
unsigned char cbm_k_open (void);
|
|
|
|
unsigned char cbm_k_readst (void);
|
|
|
|
unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
|
2016-08-07 19:47:45 +00:00
|
|
|
void cbm_k_scnkey (void);
|
2018-05-23 15:37:48 +00:00
|
|
|
void __fastcall__ cbm_k_second (unsigned char addr);
|
2012-07-01 12:45:26 +00:00
|
|
|
void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
|
2012-07-01 12:36:44 +00:00
|
|
|
unsigned char SA);
|
|
|
|
void __fastcall__ cbm_k_setnam (const char* Name);
|
2020-01-10 20:17:23 +00:00
|
|
|
void __fastcall__ cbm_k_settim (unsigned long timer);
|
2012-07-01 12:36:44 +00:00
|
|
|
void __fastcall__ cbm_k_talk (unsigned char dev);
|
2018-05-22 12:16:00 +00:00
|
|
|
void __fastcall__ cbm_k_tksa (unsigned char addr);
|
2016-08-07 19:47:45 +00:00
|
|
|
void cbm_k_udtim (void);
|
2012-07-01 12:36:44 +00:00
|
|
|
void cbm_k_unlsn (void);
|
2017-11-13 19:38:22 +00:00
|
|
|
void cbm_k_untlk (void);
|
2001-03-13 22:48:19 +00:00
|
|
|
|
2001-09-08 14:39:01 +00:00
|
|
|
|
|
|
|
|
2002-12-01 23:39:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* BASIC-like file I/O functions */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-28 19:36:22 +00:00
|
|
|
/* The cbm_* I/O functions below set __oserror (see errno.h),
|
2014-06-30 09:10:35 +00:00
|
|
|
** in case of an error.
|
|
|
|
**
|
|
|
|
** error-code BASIC error
|
|
|
|
** ---------- -----------
|
|
|
|
** 1 = too many files
|
|
|
|
** 2 = file open
|
|
|
|
** 3 = file not open
|
|
|
|
** 4 = file not found
|
|
|
|
** 5 = device not present
|
|
|
|
** 6 = not input-file
|
|
|
|
** 7 = not output-file
|
|
|
|
** 8 = missing file-name
|
|
|
|
** 9 = illegal device-number
|
|
|
|
**
|
|
|
|
** 10 = STOP-key pushed
|
|
|
|
** 11 = general I/O-error
|
|
|
|
*/
|
2001-09-08 14:39:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-13 09:46:40 +00:00
|
|
|
unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void* data);
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Loads file "name", from given device, to given address -- or, to the load
|
2014-06-30 09:10:35 +00:00
|
|
|
** address of the file if "data" is the null pointer (like load"name",8,1
|
|
|
|
** in BASIC).
|
|
|
|
** Returns number of bytes that were loaded if loading was successful;
|
2022-08-28 19:36:22 +00:00
|
|
|
** otherwise 0, "__oserror" contains an error-code, then (see table above).
|
2014-06-30 09:10:35 +00:00
|
|
|
*/
|
2001-03-13 22:48:19 +00:00
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
unsigned char __fastcall__ cbm_save (const char* name, unsigned char device,
|
|
|
|
const void* addr, unsigned int size);
|
|
|
|
/* Saves "size" bytes, starting at "addr", to a file.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Returns 0 if saving was successful, otherwise an error-code (see table
|
|
|
|
** above).
|
|
|
|
*/
|
2001-03-20 21:06:04 +00:00
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
unsigned char __fastcall__ cbm_open (unsigned char lfn, unsigned char device,
|
|
|
|
unsigned char sec_addr, const char* name);
|
2001-03-20 21:06:04 +00:00
|
|
|
/* Opens a file. Works just like the BASIC command.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Returns 0 if openning was successful, otherwise an error-code (see table
|
|
|
|
** above).
|
|
|
|
*/
|
2001-03-20 21:06:04 +00:00
|
|
|
|
|
|
|
void __fastcall__ cbm_close (unsigned char lfn);
|
|
|
|
/* Closes a file */
|
|
|
|
|
2002-06-22 11:17:33 +00:00
|
|
|
int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Reads up to "size" bytes from a file into "buffer".
|
2014-06-30 09:10:35 +00:00
|
|
|
** Returns the number of actually-read bytes, 0 if there are no bytes left.
|
2022-08-28 19:36:22 +00:00
|
|
|
** -1 in case of an error; then, __oserror contains an error-code (see table
|
2014-06-30 09:10:35 +00:00
|
|
|
** above). (Remember: 0 means end-of-file; -1 means error.)
|
|
|
|
*/
|
2001-03-30 18:18:40 +00:00
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
int __fastcall__ cbm_write (unsigned char lfn, const void* buffer,
|
|
|
|
unsigned int size);
|
2001-03-30 18:18:40 +00:00
|
|
|
/* Writes up to "size" bytes from "buffer" to a file.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Returns the number of actually-written bytes, or -1 in case of an error;
|
2022-08-28 19:36:22 +00:00
|
|
|
** __oserror contains an error-code, then (see above table).
|
2014-06-30 09:10:35 +00:00
|
|
|
*/
|
2003-02-02 13:18:40 +00:00
|
|
|
|
2012-06-04 18:32:38 +00:00
|
|
|
unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...);
|
|
|
|
/* Opens directory listing. Returns 0 if opening directory was successful;
|
2014-06-30 09:10:35 +00:00
|
|
|
** otherwise, an error-code corresponding to cbm_open(). As an optional
|
|
|
|
** argument, the name of the directory may be passed to the function. If
|
|
|
|
** no explicit name is specified, "$" is used.
|
|
|
|
*/
|
2003-02-02 13:18:40 +00:00
|
|
|
|
2011-04-16 12:28:06 +00:00
|
|
|
unsigned char __fastcall__ cbm_readdir (unsigned char lfn,
|
|
|
|
struct cbm_dirent* l_dirent);
|
2003-02-02 13:18:40 +00:00
|
|
|
/* Reads one directory line into cbm_dirent structure.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Returns 0 if reading directory-line was successful.
|
|
|
|
** Returns non-zero if reading directory failed, or no more file-names to read.
|
2021-02-15 13:50:34 +00:00
|
|
|
** Returns 2 on last line. Then, l_dirent->size = the number of "blocks free",
|
|
|
|
** "blocks used", or "mb free". Return codes:
|
|
|
|
** 0 = read file-name
|
|
|
|
** 1 = couldn't read directory
|
|
|
|
** 2 = read "blocks free", "blocks used", or "mb free"
|
|
|
|
** 3 = couldn't find start of file-name
|
|
|
|
** 4 = couldn't find end of file-name
|
|
|
|
** 5 = couldn't read file-type
|
|
|
|
** 6 = premature end of file
|
2014-06-30 09:10:35 +00:00
|
|
|
*/
|
2002-11-21 21:22:26 +00:00
|
|
|
|
2003-02-02 13:18:40 +00:00
|
|
|
void __fastcall__ cbm_closedir (unsigned char lfn);
|
2011-04-16 12:28:06 +00:00
|
|
|
/* Closes directory by cbm_close(lfn) */
|
2001-03-13 22:48:19 +00:00
|
|
|
|
2001-09-08 14:39:01 +00:00
|
|
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/* End of cbm.h */
|
|
|
|
#endif
|