X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2F6502.h;h=642a608a8b06539e717e7fcc2e2ae7ab197b51c1;hb=5a9d908007b255c2d6896cdc73a50e5cad20bb25;hp=99641b21e137d1f22233cdd36c8f1b38f305e508;hpb=fb81235769e17883355e2bae66994d6e7f2891ab;p=cc65 diff --git a/include/6502.h b/include/6502.h index 99641b21e..642a608a8 100644 --- a/include/6502.h +++ b/include/6502.h @@ -1,15 +1,15 @@ /*****************************************************************************/ /* */ -/* 6502.h */ +/* 6502.h */ /* */ -/* 6502 specific declarations */ +/* 6502 specific declarations */ /* */ /* */ /* */ -/* (C) 1998-2001 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 1998-2012, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -38,10 +38,23 @@ +/* We need size_t */ +#ifndef _HAVE_size_t +#define _HAVE_size_t +typedef unsigned size_t; +#endif + + + /* Possible returns of getcpu() */ -#define CPU_6502 0 -#define CPU_65C02 1 -#define CPU_65816 2 +#define CPU_6502 0 +#define CPU_65C02 1 +#define CPU_65816 2 +#define CPU_4510 3 +#define CPU_65SC02 4 +#define CPU_65CE02 5 +#define CPU_HUC6280 6 +#define CPU_2A0x 7 unsigned char getcpu (void); /* Detect the CPU the program is running on */ @@ -49,77 +62,78 @@ unsigned char getcpu (void); /* Macros for CPU instructions */ -#define BRK() __asm__ ("brk") -#define CLI() __asm__ ("cli") -#define SEI() __asm__ ("sei") +#define BRK() __asm__ ("brk") +#define CLI() __asm__ ("cli") +#define SEI() __asm__ ("sei") /* Struct that holds the registers for the sys function */ struct regs { - unsigned char a; /* A register value */ - unsigned char x; /* X register value */ - unsigned char y; /* Y register value */ - unsigned char flags; /* Flags value */ - unsigned pc; /* Program counter */ + unsigned char a; /* A register value */ + unsigned char x; /* X register value */ + unsigned char y; /* Y register value */ + unsigned char flags; /* Flags value */ + unsigned pc; /* Program counter */ }; /* Defines for the flags in the regs structure */ -#ifdef __OBSOLETE_FLAGS__ -#define F_NEG 0x80 /* N flag */ -#define F_OVF 0x40 /* V flag */ -#define F_BRK 0x10 /* B flag */ -#define F_DEC 0x08 /* D flag */ -#define F_IEN 0x04 /* I flag */ -#define F_ZERO 0x02 /* Z flag */ -#define F_CARRY 0x01 /* C flag */ -#endif - -/* Defines for the flags in the regs structure */ -#define F6502_N 0x80 /* N flag */ -#define F6502_V 0x40 /* V flag */ -#define F6502_B 0x10 /* B flag */ -#define F6502_D 0x08 /* D flag */ -#define F6502_I 0x04 /* I flag */ -#define F6502_Z 0x02 /* Z flag */ -#define F6502_C 0x01 /* C flag */ +#define F6502_N 0x80 /* N flag */ +#define F6502_V 0x40 /* V flag */ +#define F6502_B 0x10 /* B flag */ +#define F6502_D 0x08 /* D flag */ +#define F6502_I 0x04 /* I flag */ +#define F6502_Z 0x02 /* Z flag */ +#define F6502_C 0x01 /* C flag */ /* Function to call any machine language subroutine. All registers in the - * regs structure are passed into the routine and the results are passed - * out. The B flag is ignored on input. The called routine must end with - * an RTS. - */ +** regs structure are passed into the routine and the results are passed +** out. The B flag is ignored on input. The called routine must end with +** an RTS. +*/ void __fastcall__ _sys (struct regs* r); /* Set and reset the break vector. The given user function is called if - * a break occurs. The values of the registers may be read from the brk_... - * variables. The value in brk_pc will point to the address that contains - * the brk instruction. - * The set_brk function will install an exit handler that will reset the - * vector if the program ends. - */ - -extern unsigned char brk_a; /* A register value */ -extern unsigned char brk_x; /* X register value */ -extern unsigned char brk_y; /* Y register value */ -extern unsigned char brk_sr; /* Status register */ -extern unsigned brk_pc; /* PC value */ +** a break occurs. The values of the registers may be read from the brk_... +** variables. The value in brk_pc will point to the address that contains +** the brk instruction. +** The set_brk function will install an exit handler that will reset the +** vector if the program ends. +*/ + +extern unsigned char brk_a; /* A register value */ +extern unsigned char brk_x; /* X register value */ +extern unsigned char brk_y; /* Y register value */ +extern unsigned char brk_sr; /* Status register */ +extern unsigned brk_pc; /* PC value */ typedef void (*brk_handler) (void); /* Type of the break handler */ void __fastcall__ set_brk (brk_handler f); -/* Set the break vector to the given address, return the old address */ +/* Set the break vector to the given address */ void reset_brk (void); /* Reset the break vector to the original value */ -/* End of 6502.h */ -#endif +/* Possible returns for irq_handler() */ +#define IRQ_NOT_HANDLED 0 +#define IRQ_HANDLED 1 + +typedef unsigned char (*irq_handler) (void); +/* Type of the C level interrupt request handler */ + +void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size); +/* Set the C level interrupt request vector to the given address */ +void reset_irq (void); +/* Reset the C level interrupt request vector */ + +/* End of 6502.h */ +#endif