redquark-amiberry-rb/src/include/custom.h

254 lines
6.7 KiB
C
Raw Normal View History

/*
* UAE - The Un*x Amiga Emulator
*
* custom chip support
*
* (c) 1995 Bernd Schmidt
*/
2016-11-30 22:25:43 +01:00
#ifndef UAE_CUSTOM_H
#define UAE_CUSTOM_H
2015-05-13 18:47:23 +00:00
2017-12-04 15:49:40 +01:00
#include "uae/types.h"
#include "machdep/rpt.h"
2015-05-13 18:47:23 +00:00
/* These are the masks that are ORed together in the chipset_mask option.
* If CSMASK_AGA is set, the ECS bits are guaranteed to be set as well. */
2015-05-13 18:47:23 +00:00
#define CSMASK_ECS_AGNUS 1
#define CSMASK_ECS_DENISE 2
#define CSMASK_AGA 4
#define CSMASK_MASK (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA)
2015-05-13 18:47:23 +00:00
#define CHIPSET_CLOCK_PAL 3546895
#define CHIPSET_CLOCK_NTSC 3579545
2016-11-30 22:25:43 +01:00
#define MAXHPOS_ROWS 256
#define MAXVPOS_LINES_ECS 2048
#define MAXVPOS_LINES_OCS 512
#define HPOS_SHIFT 3
2017-12-04 15:49:40 +01:00
extern int custom_init (void);
extern void custom_prepare (void);
extern void custom_reset (bool hardreset, bool keyboardreset);
extern int intlev (void);
2017-12-04 15:49:40 +01:00
extern void do_copper (void);
2015-05-13 18:47:23 +00:00
2017-12-04 15:49:40 +01:00
extern void notice_new_xcolors (void);
extern void notice_screen_contents_lost();
2017-12-04 15:49:40 +01:00
extern void init_row_map (void);
extern void init_hz_normal (void);
extern void init_custom (void);
2015-05-13 18:47:23 +00:00
2017-12-04 15:49:40 +01:00
extern unsigned long int hsync_counter;
2015-05-13 18:47:23 +00:00
extern uae_u16 dmacon;
2017-12-04 15:49:40 +01:00
extern uae_u16 intreq;
extern int vpos, lof_store;
2015-05-13 18:47:23 +00:00
2017-12-04 15:49:40 +01:00
STATIC_INLINE int dmaen (unsigned int dmamask)
{
2016-11-30 22:25:43 +01:00
return (dmamask & dmacon) && (dmacon & 0x200);
}
2015-05-13 18:47:23 +00:00
#define SPCFLAG_STOP 2
#define SPCFLAG_COPPER 4
#define SPCFLAG_INT 8
#define SPCFLAG_BRK 16
2019-01-12 17:39:42 +01:00
#define SPCFLAG_UAEINT 32
2015-05-13 18:47:23 +00:00
#define SPCFLAG_TRACE 64
#define SPCFLAG_DOTRACE 128
#define SPCFLAG_DOINT 256 /* arg, JIT fails without this.. */
2015-05-13 18:47:23 +00:00
#define SPCFLAG_BLTNASTY 512
#define SPCFLAG_EXEC 1024
#define SPCFLAG_ACTION_REPLAY 2048
2019-01-12 17:39:42 +01:00
#define SPCFLAG_TRAP 4096 /* enforcer-hack */
2015-05-13 18:47:23 +00:00
#define SPCFLAG_MODE_CHANGE 8192
#ifdef JIT
2015-05-13 18:47:23 +00:00
#define SPCFLAG_END_COMPILE 16384
#endif
#define SPCFLAG_CHECK 32768
2015-05-13 18:47:23 +00:00
extern uae_u16 adkcon;
2019-01-12 17:39:42 +01:00
extern unsigned int joy0dir, joy1dir;
extern int joy0button, joy1button;
2017-12-04 15:49:40 +01:00
extern void INTREQ (uae_u16);
extern bool INTREQ_0 (uae_u16);
extern void INTREQ_f (uae_u16);
STATIC_INLINE void send_interrupt (int num)
{
INTREQ_0 (0x8000 | (1 << num));
}
extern void rethink_uae_int(void);
STATIC_INLINE uae_u16 INTREQR (void)
{
return intreq;
}
2015-05-13 18:47:23 +00:00
2019-02-10 02:30:07 +01:00
STATIC_INLINE void safe_interrupt_set(bool i6)
{
uae_u16 v = i6 ? 0x2000 : 0x0008;
if (!(intreq & v)) {
INTREQ_0(0x8000 | v);
}
}
2015-05-13 18:47:23 +00:00
/* maximums for statically allocated tables */
#ifdef UAE_MINI
2019-01-12 17:39:42 +01:00
/* absolute minimums for basic A500/A1200-emulation */
2015-05-13 18:47:23 +00:00
#define MAXHPOS 227
2019-01-12 17:39:42 +01:00
#define MAXVPOS 312
#else
#define MAXHPOS 256
#define MAXVPOS 592
#endif
2015-05-13 18:47:23 +00:00
/* PAL/NTSC values */
#define MAXHPOS_PAL 227
#define MAXHPOS_NTSC 227
2016-11-30 22:25:43 +01:00
// short field maxvpos
2015-05-13 18:47:23 +00:00
#define MAXVPOS_PAL 312
#define MAXVPOS_NTSC 262
2016-11-30 22:25:43 +01:00
// following endlines = first visible line
#define VBLANK_ENDLINE_PAL 26
#define VBLANK_ENDLINE_NTSC 21
2016-11-30 22:25:43 +01:00
// line when sprite DMA fetches first control words
2015-05-13 18:47:23 +00:00
#define VBLANK_SPRITE_PAL 25
#define VBLANK_SPRITE_NTSC 20
#define VBLANK_HZ_PAL 50
#define VBLANK_HZ_NTSC 60
2016-11-30 22:25:43 +01:00
#define VSYNC_ENDLINE_PAL 5
#define VSYNC_ENDLINE_NTSC 6
#define EQU_ENDLINE_PAL 8
#define EQU_ENDLINE_NTSC 10
2015-05-13 18:47:23 +00:00
2019-01-12 17:39:42 +01:00
extern int maxhpos, maxhpos_short;
2016-11-30 22:25:43 +01:00
extern int maxvpos, maxvpos_nom, maxvpos_display;
extern int hsyncstartpos, hsyncendpos;
2019-01-12 17:39:42 +01:00
extern int minfirstline, vblank_endline, numscrlines;
2019-01-26 22:48:59 +01:00
extern float vblank_hz, fake_vblank_hz;
extern float hblank_hz;
2019-01-12 17:39:42 +01:00
extern int vblank_skip, doublescan;
extern bool programmedmode;
2015-05-13 18:47:23 +00:00
#define DMA_AUD0 0x0001
#define DMA_AUD1 0x0002
#define DMA_AUD2 0x0004
#define DMA_AUD3 0x0008
#define DMA_DISK 0x0010
#define DMA_SPRITE 0x0020
#define DMA_BLITTER 0x0040
#define DMA_COPPER 0x0080
#define DMA_BITPLANE 0x0100
#define DMA_MASTER 0x0200
#define DMA_BLITPRI 0x0400
2019-01-12 17:39:42 +01:00
#define CYCLE_REFRESH 1
#define CYCLE_STROBE 2
#define CYCLE_MISC 3
#define CYCLE_SPRITE 4
#define CYCLE_COPPER 5
#define CYCLE_BLITTER 6
#define CYCLE_CPU 7
#define CYCLE_CPUNASTY 8
#define CYCLE_COPPER_SPECIAL 0x10
#define CYCLE_MASK 0x0f
extern unsigned long frametime, timeframes;
extern uae_u16 htotal, vtotal, beamcon0;
2015-05-13 18:47:23 +00:00
/* 100 words give you 1600 horizontal pixels. Should be more than enough for
* superhires. Don't forget to update the definition in genp2c.c as well.
* needs to be larger for superhires support */
#ifdef CUSTOM_SIMPLE
#define MAX_WORDS_PER_LINE 50
#else
2015-05-13 18:47:23 +00:00
#define MAX_WORDS_PER_LINE 100
#endif
2015-05-13 18:47:23 +00:00
2019-01-12 17:39:42 +01:00
extern uae_u32 hirestab_h[256][2];
extern uae_u32 lorestab_h[256][4];
extern uae_u32 hirestab_l[256][1];
extern uae_u32 lorestab_l[256][2];
#ifdef AGA
2015-05-13 18:47:23 +00:00
/* AGA mode color lookup tables */
extern unsigned int xredcolors[256], xgreencolors[256], xbluecolors[256];
2019-01-12 17:39:42 +01:00
#endif
extern int xredcolor_s, xredcolor_b, xredcolor_m;
extern int xgreencolor_s, xgreencolor_b, xgreencolor_m;
extern int xbluecolor_s, xbluecolor_b, xbluecolor_m;
2015-05-13 18:47:23 +00:00
#define RES_LORES 0
#define RES_HIRES 1
#define RES_SUPERHIRES 2
#define RES_MAX 2
#define VRES_NONDOUBLE 0
#define VRES_DOUBLE 1
2019-01-12 17:39:42 +01:00
#define VRES_QUAD 2
#define VRES_MAX 1
2015-05-13 18:47:23 +00:00
2019-01-12 17:39:42 +01:00
/* calculate shift depending on resolution (replaced "decided_hires ? 4 : 8") */
#define RES_SHIFT(res) ((res) == RES_LORES ? 8 : (res) == RES_HIRES ? 4 : 2)
2015-05-13 18:47:23 +00:00
/* get resolution from bplcon0 */
STATIC_INLINE int GET_RES_DENISE (uae_u16 con0)
{
2019-01-12 17:39:42 +01:00
if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
con0 &= ~0x40; // SUPERHIRES
return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
STATIC_INLINE int GET_RES_AGNUS (uae_u16 con0)
{
2019-01-12 17:39:42 +01:00
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
con0 &= ~0x40; // SUPERHIRES
return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
2015-05-13 18:47:23 +00:00
/* get sprite width from FMODE */
#define GET_SPRITEWIDTH(FMODE) ((((FMODE) >> 2) & 3) == 3 ? 64 : (((FMODE) >> 2) & 3) == 0 ? 16 : 32)
/* Compute the number of bitplanes from a value written to BPLCON0 */
STATIC_INLINE int GET_PLANES(uae_u16 bplcon0)
{
2019-01-12 17:39:42 +01:00
if ((bplcon0 & 0x0010) && (bplcon0 & 0x7000))
return 0; // >8 planes = 0 planes
if (bplcon0 & 0x0010)
return 8; // AGA 8-planes bit
return (bplcon0 >> 12) & 7; // normal planes bits
}
2015-05-13 18:47:23 +00:00
2017-12-04 15:49:40 +01:00
extern void fpscounter_reset (void);
extern unsigned long idletime;
2019-09-20 23:20:45 +02:00
//extern int lightpen_x[2], lightpen_y[2];
//extern int lightpen_cx[2], lightpen_cy[2], lightpen_active, lightpen_enabled, lightpen_enabled2;
2017-12-04 15:49:40 +01:00
2019-01-12 17:39:42 +01:00
struct customhack {
uae_u16 v;
int vpos, hpos;
};
void customhack_put(struct customhack *ch, uae_u16 v, int hpos);
uae_u16 customhack_get(struct customhack *ch, int hpos);
extern void alloc_cycle_ext(int, int);
extern void alloc_cycle_blitter(int hpos, uaecptr *ptr, int);
extern bool ispal(void);
extern bool isvga(void);
2017-12-04 15:49:40 +01:00
extern int current_maxvpos (void);
2019-02-10 02:30:07 +01:00
extern struct chipset_refresh *get_chipset_refresh(struct uae_prefs*);
extern void compute_framesync(void);
//extern void getsyncregisters(uae_u16 *phsstrt, uae_u16 *phsstop, uae_u16 *pvsstrt, uae_u16 *pvsstop);
2019-01-12 17:39:42 +01:00
void custom_cpuchange(void);
struct custom_store
{
uae_u16 value;
uae_u32 pc;
};
extern struct custom_store custom_storage[256];
#endif /* UAE_CUSTOM_H */