2017-11-22 05:24:51 +00:00
|
|
|
#ifndef _VM_SCREEN_H_
|
|
|
|
#define _VM_SCREEN_H_
|
|
|
|
|
2017-12-17 04:45:39 +00:00
|
|
|
#include <stdbool.h>
|
2017-12-18 05:31:56 +00:00
|
|
|
#include <SDL.h>
|
2017-12-17 04:45:39 +00:00
|
|
|
|
2018-01-08 02:05:02 +00:00
|
|
|
#include "vm_area.h"
|
2018-01-17 07:07:31 +00:00
|
|
|
#include "vm_bits.h"
|
2017-12-27 22:31:02 +00:00
|
|
|
|
2018-03-12 04:28:28 +00:00
|
|
|
typedef struct {
|
|
|
|
/*
|
|
|
|
* Red, green, blue
|
|
|
|
*/
|
|
|
|
vm_8bit r, g, b;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is alpha, which would be the degree of transparency of the
|
|
|
|
* graphics. This is here only if needed--for example, the Apple II
|
|
|
|
* doesn't have any alpha channel.
|
|
|
|
*/
|
|
|
|
vm_8bit a;
|
|
|
|
} vm_color;
|
|
|
|
|
2017-11-22 05:24:51 +00:00
|
|
|
typedef struct {
|
2017-12-27 23:14:54 +00:00
|
|
|
/*
|
|
|
|
* This is the window in SDL that we're displaying. It's fine for a
|
|
|
|
* screen to be headless; that is, not to have a window. Screen
|
|
|
|
* functions which deal with SDL will simply not run that code if
|
|
|
|
* headless.
|
|
|
|
*/
|
2017-12-18 05:31:56 +00:00
|
|
|
SDL_Window *window;
|
2017-12-27 23:14:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In SDL, the renderer is comparable to the old SDL_Surface type
|
|
|
|
* (which is still there!). A renderer is a little more stateful; it
|
|
|
|
* contains its own color information to be used when rendering
|
|
|
|
* shapes, for example.
|
|
|
|
*/
|
2017-12-18 05:31:56 +00:00
|
|
|
SDL_Renderer *render;
|
|
|
|
|
2017-12-27 23:14:54 +00:00
|
|
|
/*
|
|
|
|
* These are the x and y coordinates of the window we're creating.
|
|
|
|
* FIXME: this should probably be renamed to width and height...
|
|
|
|
*/
|
2017-12-18 05:31:56 +00:00
|
|
|
int xcoords;
|
|
|
|
int ycoords;
|
2018-01-17 05:42:10 +00:00
|
|
|
|
|
|
|
/*
|
2018-01-17 07:07:31 +00:00
|
|
|
* Hang onto the last key pressed and the status of whether a key
|
|
|
|
* is pressed right now or not.
|
2018-01-17 05:42:10 +00:00
|
|
|
*/
|
2018-01-17 07:07:31 +00:00
|
|
|
vm_8bit last_key;
|
2018-01-17 05:42:10 +00:00
|
|
|
bool key_pressed;
|
2018-01-17 07:07:31 +00:00
|
|
|
|
2018-01-23 20:52:16 +00:00
|
|
|
/*
|
|
|
|
* Is the screen dirty? That is to say, has something about it
|
|
|
|
* changed that now requires we redraw the screen?
|
|
|
|
*/
|
|
|
|
bool dirty;
|
|
|
|
|
2018-02-05 06:35:04 +00:00
|
|
|
/*
|
|
|
|
* Should we exit (the next chance we get)?
|
|
|
|
*/
|
|
|
|
bool should_exit;
|
|
|
|
|
2017-12-17 22:42:05 +00:00
|
|
|
} vm_screen;
|
2017-11-22 05:24:51 +00:00
|
|
|
|
2017-12-26 22:47:34 +00:00
|
|
|
extern bool vm_screen_active(vm_screen *);
|
2018-01-23 20:52:16 +00:00
|
|
|
extern bool vm_screen_dirty(vm_screen *);
|
2018-01-17 05:42:10 +00:00
|
|
|
extern bool vm_screen_key_pressed(vm_screen *);
|
|
|
|
extern char vm_screen_last_key(vm_screen *);
|
2017-12-20 22:44:24 +00:00
|
|
|
extern int vm_screen_add_window(vm_screen *, int, int);
|
2017-12-26 22:47:34 +00:00
|
|
|
extern int vm_screen_init();
|
2017-12-20 22:44:24 +00:00
|
|
|
extern int vm_screen_xcoords(vm_screen *);
|
|
|
|
extern int vm_screen_ycoords(vm_screen *);
|
2017-12-26 22:47:34 +00:00
|
|
|
extern vm_screen *vm_screen_create();
|
2017-12-27 22:42:30 +00:00
|
|
|
extern void vm_screen_draw_rect(vm_screen *, vm_area *);
|
2017-12-26 22:47:34 +00:00
|
|
|
extern void vm_screen_finish();
|
2017-12-17 22:42:05 +00:00
|
|
|
extern void vm_screen_free(vm_screen *);
|
2018-01-25 02:05:19 +00:00
|
|
|
extern void vm_screen_prepare(vm_screen *);
|
2017-12-26 22:47:34 +00:00
|
|
|
extern void vm_screen_refresh(vm_screen *);
|
2018-03-12 04:28:28 +00:00
|
|
|
extern void vm_screen_set_color(vm_screen *, vm_color);
|
2017-12-26 22:47:34 +00:00
|
|
|
extern void vm_screen_set_logical_coords(vm_screen *, int, int);
|
2017-11-22 05:24:51 +00:00
|
|
|
|
|
|
|
#endif
|