2013-07-06 04:37:13 +00:00
|
|
|
/*
|
2013-06-11 07:08:15 +00:00
|
|
|
* Apple // emulator for Linux: Video definitions
|
|
|
|
*
|
|
|
|
* Copyright 1994 Alexander Jean-Claude Bottema
|
|
|
|
* Copyright 1995 Stephen Lee
|
|
|
|
* Copyright 1997, 1998 Aaron Culliney
|
|
|
|
* Copyright 1998, 1999, 2000 Michael Deutschmann
|
|
|
|
*
|
|
|
|
* This software package is subject to the GNU General Public License
|
2013-07-06 04:37:13 +00:00
|
|
|
* version 2 or later (your choice) as published by the Free Software
|
2013-06-11 07:08:15 +00:00
|
|
|
* Foundation.
|
|
|
|
*
|
2013-07-06 04:37:13 +00:00
|
|
|
* THERE ARE NO WARRANTIES WHATSOEVER.
|
2013-06-11 07:08:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef A2_VIDEO_H
|
|
|
|
#define A2_VIDEO_H
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
typedef struct video_backend_s {
|
2015-04-12 22:35:16 +00:00
|
|
|
|
|
|
|
// mandatory video backend functions
|
2015-03-23 01:53:13 +00:00
|
|
|
void (*init)(void *context);
|
|
|
|
void (*main_loop)(void);
|
|
|
|
void (*reshape)(int width, int height);
|
|
|
|
void (*render)(void);
|
|
|
|
void (*shutdown)(void);
|
2015-04-12 22:35:16 +00:00
|
|
|
|
|
|
|
// optional functions
|
|
|
|
void (*video_animation_show_cpuspeed)(void);
|
|
|
|
void (*video_animation_show_track_sector)(int drive, int track, int sect);
|
2015-03-23 01:53:13 +00:00
|
|
|
} video_backend_s;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2015-04-12 22:35:16 +00:00
|
|
|
/*
|
|
|
|
* The registered video backend (renderer).
|
|
|
|
*/
|
2015-04-18 04:40:56 +00:00
|
|
|
extern video_backend_s *video_backend;
|
2015-04-12 22:35:16 +00:00
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Color structure
|
|
|
|
*/
|
|
|
|
typedef struct A2Color_s {
|
2014-08-17 22:31:49 +00:00
|
|
|
uint8_t red;
|
|
|
|
uint8_t green;
|
|
|
|
uint8_t blue;
|
2015-03-23 01:53:13 +00:00
|
|
|
} A2Color_s;
|
2014-08-17 22:31:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reference to the internal 8bit-indexed color format
|
|
|
|
*/
|
2015-03-23 01:53:13 +00:00
|
|
|
extern A2Color_s colormap[];
|
2014-08-17 22:31:49 +00:00
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Prepare the video system, converting console to graphics mode, or
|
2013-07-06 04:37:13 +00:00
|
|
|
* opening X window, or whatever. This is called only once when the
|
2013-06-11 07:08:15 +00:00
|
|
|
* emulator is run
|
|
|
|
*/
|
|
|
|
void video_init(void);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Begin main video loop (does not return)
|
2014-09-07 03:04:32 +00:00
|
|
|
*/
|
|
|
|
void video_main_loop(void);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Undo anything done by video_init() and video_start(). Called before exiting the
|
2013-06-11 07:08:15 +00:00
|
|
|
* emulator.
|
|
|
|
*/
|
|
|
|
void video_shutdown(void);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Setup the display. This may be called multiple times in a run, and is
|
2013-06-11 07:08:15 +00:00
|
|
|
* used when graphics parameters (II+ vs //e, hires color representation) may
|
|
|
|
* have changed.
|
|
|
|
*
|
2013-07-06 04:37:13 +00:00
|
|
|
* In future, all relevant information will be communicated through
|
|
|
|
* FLAGS. For now, however, it is ignored and global variables are used
|
2013-06-11 07:08:15 +00:00
|
|
|
* instead.
|
|
|
|
*
|
2013-07-06 04:37:13 +00:00
|
|
|
* This function is responsible for inserting any needed video-specific hooks
|
|
|
|
* into the 6502 memory indirection table. It should *not* hook the
|
|
|
|
* soft-switches.
|
2013-06-11 07:08:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void video_set(int flags);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Set the font used by the display. QTY characters are loaded starting
|
2013-07-06 04:37:13 +00:00
|
|
|
* with FIRST, from DATA. DATA contains 8 bytes for each character, each
|
|
|
|
* byte representing a row (top-to-bottom). The row byte contains 7
|
2013-06-11 07:08:15 +00:00
|
|
|
* pixels in little-endian format.
|
|
|
|
*
|
|
|
|
* MODE selects the colors to use
|
|
|
|
*
|
|
|
|
* 0 - Normal text
|
|
|
|
* 1 - MouseText (usually treat as Normal)
|
|
|
|
* 2 - Inverse
|
|
|
|
* 3 - Flash
|
|
|
|
*
|
2013-07-06 04:37:13 +00:00
|
|
|
* The extra MouseText mode is in case we want to emulate certain RGB
|
|
|
|
* adaptors which color normal text and MouseText differently. I had one
|
2013-06-11 07:08:15 +00:00
|
|
|
* once for a //c.
|
|
|
|
*/
|
2014-05-18 21:40:53 +00:00
|
|
|
void video_loadfont(int first, int qty, const uint8_t *data, int mode);
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Redraw the display. This is called after exiting an interface display,
|
2013-06-11 07:08:15 +00:00
|
|
|
* when changes have been made to the Apple's emulated framebuffer that
|
|
|
|
* bypass the driver's hooks, or when the video mode has changed.
|
|
|
|
*/
|
|
|
|
void video_redraw(void);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Change the displayed video page to PAGE
|
2013-06-11 07:08:15 +00:00
|
|
|
* 0 - Page 1: $400-$7ff/$2000-$3fff
|
|
|
|
* 1 - Page 2: $800-$bff/$4000-$5fff
|
|
|
|
*/
|
|
|
|
void video_setpage(int page);
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Get a reference to current internal framebuffer
|
|
|
|
*/
|
|
|
|
const uint8_t * const video_current_framebuffer();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* True if anything changed in framebuffer and not yet drawn
|
2013-06-11 07:08:15 +00:00
|
|
|
*/
|
2015-03-23 01:53:13 +00:00
|
|
|
bool video_dirty(void);
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2015-01-10 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* VBL routines
|
|
|
|
*/
|
2015-01-31 21:57:10 +00:00
|
|
|
uint16_t video_scanner_get_address(bool *vblBarOut);
|
|
|
|
uint8_t floating_bus(void);
|
|
|
|
uint8_t floating_bus_hibit(const bool hibit);
|
2015-01-10 17:53:38 +00:00
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* 640x400 mode really isn't what it advertises. It's really 560x384 with 4
|
2013-06-11 07:08:15 +00:00
|
|
|
* extra bytes on each side for color interpolation hack. This is yet another
|
|
|
|
* area where I've traded the optimization gain (especially on older slower
|
|
|
|
* machines) for a standard resolution.
|
|
|
|
*/
|
2015-03-23 01:53:13 +00:00
|
|
|
#define _SCANWIDTH 560
|
2015-04-12 21:20:17 +00:00
|
|
|
#define _INTERPOLATED_PIXEL_ADJUSTMENT_PRE 4
|
|
|
|
#define _INTERPOLATED_PIXEL_ADJUSTMENT_POST 4
|
|
|
|
#define INTERPOLATED_PIXEL_ADJUSTMENT (_INTERPOLATED_PIXEL_ADJUSTMENT_PRE+_INTERPOLATED_PIXEL_ADJUSTMENT_POST)
|
2015-03-23 01:53:13 +00:00
|
|
|
#define SCANWIDTH (_SCANWIDTH+INTERPOLATED_PIXEL_ADJUSTMENT)
|
2013-06-11 07:08:15 +00:00
|
|
|
#define SCANHEIGHT 384
|
2015-03-23 01:53:13 +00:00
|
|
|
|
|
|
|
#define TEXT_ROWS 24
|
|
|
|
#define BEGIN_MIX 20
|
|
|
|
#define TEXT_COLS 40
|
|
|
|
#define TEXT80_COLS 80
|
|
|
|
|
2015-04-12 21:20:17 +00:00
|
|
|
#define FONT_GLYPH_X 8
|
|
|
|
#define FONT_GLYPH_Y FONT_GLYPH_X
|
2015-03-23 01:53:13 +00:00
|
|
|
|
|
|
|
#define FONT_HEIGHT_PIXELS 16
|
|
|
|
#define FONT_WIDTH_PIXELS 14
|
|
|
|
#define FONT80_WIDTH_PIXELS 7
|
|
|
|
|
|
|
|
#define MOUSETEXT_BEGIN 0x90
|
2015-04-02 02:57:12 +00:00
|
|
|
#define MOUSETEXT_UP (MOUSETEXT_BEGIN+0x0b)
|
|
|
|
#define MOUSETEXT_LEFT (MOUSETEXT_BEGIN+0x08)
|
|
|
|
#define MOUSETEXT_RIGHT (MOUSETEXT_BEGIN+0x15)
|
|
|
|
#define MOUSETEXT_DOWN (MOUSETEXT_BEGIN+0x0a)
|
|
|
|
#define MOUSETEXT_OPENAPPLE (MOUSETEXT_BEGIN + 0x01)
|
|
|
|
#define MOUSETEXT_CLOSEDAPPLE (MOUSETEXT_BEGIN + 0x00)
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2015-04-18 21:50:02 +00:00
|
|
|
#define ICONTEXT_BEGIN 0xB0
|
|
|
|
#define ICONTEXT_MENU_BEGIN ICONTEXT_BEGIN
|
|
|
|
#define ICONTEXT_MENU_END (ICONTEXT_MENU_BEGIN+0x0A)
|
|
|
|
|
|
|
|
#define ICONTEXT_DISK_UL (ICONTEXT_BEGIN+0x0B)
|
|
|
|
#define ICONTEXT_DISK_UR (ICONTEXT_BEGIN+0x0C)
|
|
|
|
#define ICONTEXT_DISK_LL (ICONTEXT_BEGIN+0x0D)
|
|
|
|
#define ICONTEXT_DISK_LR (ICONTEXT_BEGIN+0x0E)
|
|
|
|
#define ICONTEXT_UNLOCK (ICONTEXT_BEGIN+0x0F)
|
|
|
|
#define ICONTEXT_GOTO (ICONTEXT_BEGIN+0x10)
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_BLACK 0
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_RED 35
|
|
|
|
#define COLOR_MEDIUM_RED 36
|
|
|
|
#define COLOR_LIGHT_RED 37 /* hgr used */
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_GREEN 38
|
|
|
|
#define COLOR_MEDIUM_GREEN 39
|
|
|
|
#define COLOR_LIGHT_GREEN 40 /* hgr used */
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_YELLOW 41
|
|
|
|
#define COLOR_MEDIUM_YELLOW 42
|
|
|
|
#define COLOR_LIGHT_YELLOW 43
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_BLUE 44
|
|
|
|
#define COLOR_MEDIUM_BLUE 45
|
|
|
|
#define COLOR_LIGHT_BLUE 46 /* hgr used */
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_PURPLE 47
|
|
|
|
#define COLOR_MEDIUM_PURPLE 48
|
|
|
|
#define COLOR_LIGHT_PURPLE 49 /* hgr used */
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_CYAN 50
|
|
|
|
#define COLOR_MEDIUM_CYAN 51
|
|
|
|
#define COLOR_LIGHT_CYAN 52
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_DARK_WHITE 53
|
|
|
|
#define COLOR_MEDIUM_WHITE 54
|
|
|
|
#define COLOR_LIGHT_WHITE 55
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
#define COLOR_FLASHING_BLACK 56
|
|
|
|
#define COLOR_FLASHING_WHITE 57
|
|
|
|
#define COLOR_FLASHING_UNGREEN 58
|
|
|
|
#define COLOR_FLASHING_GREEN 59
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------
|
|
|
|
generic graphics globals
|
|
|
|
---------------------------------- */
|
|
|
|
|
2015-03-23 01:53:13 +00:00
|
|
|
/*
|
|
|
|
* Pointers to framebuffer (can be VGA memory or host buffer)
|
2013-06-11 07:08:15 +00:00
|
|
|
*/
|
2014-01-25 22:13:38 +00:00
|
|
|
extern uint8_t *video__fb1,*video__fb2;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-01-25 22:13:38 +00:00
|
|
|
extern uint8_t video__hires_even[0x800];
|
|
|
|
extern uint8_t video__hires_odd[0x800];
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-01-25 22:13:38 +00:00
|
|
|
extern uint8_t video__dhires1[256];
|
|
|
|
extern uint8_t video__dhires2[256];
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
extern int video__current_page; /* Current visual page */
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
extern int video__strictcolors;
|
|
|
|
|
|
|
|
/* --- Precalculated hi-res page offsets given addr --- */
|
2013-07-06 04:37:13 +00:00
|
|
|
extern unsigned int video__screen_addresses[8192];
|
2014-01-25 22:13:38 +00:00
|
|
|
extern uint8_t video__columns[8192];
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2014-01-25 22:13:38 +00:00
|
|
|
extern uint8_t video__odd_colors[2];
|
|
|
|
extern uint8_t video__even_colors[2];
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
/* Hooks */
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
void video__write_2e_text0(),
|
|
|
|
video__write_2e_text0_mixed(),
|
|
|
|
video__write_2e_text1(),
|
|
|
|
video__write_2e_text1_mixed(),
|
|
|
|
video__write_2e_odd0(),
|
|
|
|
video__write_2e_even0(),
|
|
|
|
video__write_2e_odd0_mixed(),
|
|
|
|
video__write_2e_even0_mixed(),
|
|
|
|
video__write_2e_odd1(),
|
|
|
|
video__write_2e_even1(),
|
|
|
|
video__write_2e_odd1_mixed(),
|
|
|
|
video__write_2e_even1_mixed();
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
#endif /* !A2_VIDEO_H */
|
2015-03-23 01:53:13 +00:00
|
|
|
|