Run clang-formats for merge

This commit is contained in:
RichardG867
2022-10-15 13:38:10 -03:00
parent ac68e1f562
commit e706fffb34
34 changed files with 10714 additions and 11082 deletions

View File

@@ -28,12 +28,11 @@
#include <86box/scsi_device.h>
#include <86box/sound.h>
/* The addresses sent from the guest are absolute, ie. a LBA of 0 corresponds to a MSF of 00:00:00. Otherwise, the counter displayed by the guest is wrong:
there is a seeming 2 seconds in which audio plays but counter does not move, while a data track before audio jumps to 2 seconds before the actual start
of the audio while audio still plays. With an absolute conversion, the counter is fine. */
#undef MSFtoLBA
#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f)
#define MSFtoLBA(m, s, f) ((((m * 60) + s) * 75) + f)
#define RAW_SECTOR_SIZE 2352
#define COOKED_SECTOR_SIZE 2048
@@ -42,9 +41,9 @@
#define MAX_SEEK 333333
#define CD_BCD(x) (((x) % 10) | (((x) / 10) << 4))
#define CD_DCB(x) ((((x) & 0xf0) >> 4) * 10 + ((x) & 0x0f))
#define CD_DCB(x) ((((x) &0xf0) >> 4) * 10 + ((x) &0x0f))
#pragma pack(push,1)
#pragma pack(push, 1)
typedef struct {
uint8_t user_data[2048],
ecc[288];
@@ -86,19 +85,15 @@ typedef union {
} sector_buffer_t;
#pragma pack(pop)
static int cdrom_sector_size;
static uint8_t raw_buffer[2856]; /* Needs to be the same size as sector_buffer_t in the structs. */
static uint8_t extra_buffer[296];
cdrom_t cdrom[CDROM_NUM];
#ifdef ENABLE_CDROM_LOG
int cdrom_do_log = ENABLE_CDROM_LOG;
void
cdrom_log(const char *fmt, ...)
{
@@ -111,10 +106,9 @@ cdrom_log(const char *fmt, ...)
}
}
#else
#define cdrom_log(fmt, ...)
# define cdrom_log(fmt, ...)
#endif
int
cdrom_lba_to_msf_accurate(int lba)
{
@@ -133,11 +127,10 @@ cdrom_lba_to_msf_accurate(int lba)
return ((m << 16) | (s << 8) | f);
}
static double
cdrom_get_short_seek(cdrom_t *dev)
{
switch(dev->cur_speed) {
switch (dev->cur_speed) {
case 0:
fatal("CD-ROM %i: 0x speed\n", dev->id);
return 0.0;
@@ -147,16 +140,37 @@ cdrom_get_short_seek(cdrom_t *dev)
return 160.0;
case 3:
return 150.0;
case 4: case 5: case 6: case 7: case 8:
case 9: case 10: case 11:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
return 112.0;
case 12: case 13: case 14: case 15:
case 12:
case 13:
case 14:
case 15:
return 75.0;
case 16: case 17: case 18: case 19:
case 16:
case 17:
case 18:
case 19:
return 58.0;
case 20: case 21: case 22: case 23:
case 40: case 41: case 42: case 43:
case 44: case 45: case 46: case 47:
case 20:
case 21:
case 22:
case 23:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
return 50.0;
default:
@@ -165,11 +179,10 @@ cdrom_get_short_seek(cdrom_t *dev)
}
}
static double
cdrom_get_long_seek(cdrom_t *dev)
{
switch(dev->cur_speed) {
switch (dev->cur_speed) {
case 0:
fatal("CD-ROM %i: 0x speed\n", dev->id);
return 0.0;
@@ -179,16 +192,37 @@ cdrom_get_long_seek(cdrom_t *dev)
return 1000.0;
case 3:
return 900.0;
case 4: case 5: case 6: case 7: case 8:
case 9: case 10: case 11:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
return 675.0;
case 12: case 13: case 14: case 15:
case 12:
case 13:
case 14:
case 15:
return 400.0;
case 16: case 17: case 18: case 19:
case 16:
case 17:
case 18:
case 19:
return 350.0;
case 20: case 21: case 22: case 23:
case 40: case 41: case 42: case 43:
case 44: case 45: case 46: case 47:
case 20:
case 21:
case 22:
case 23:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
return 300.0;
default:
@@ -197,7 +231,6 @@ cdrom_get_long_seek(cdrom_t *dev)
}
}
double
cdrom_seek_time(cdrom_t *dev)
{
@@ -214,7 +247,6 @@ cdrom_seek_time(cdrom_t *dev)
return cdrom_get_short_seek(dev) + ((cdrom_get_long_seek(dev) * ((double) diff)) / sd);
}
void
cdrom_stop(cdrom_t *dev)
{
@@ -222,7 +254,6 @@ cdrom_stop(cdrom_t *dev)
dev->cd_status = CD_STATUS_STOPPED;
}
void
cdrom_seek(cdrom_t *dev, uint32_t pos)
{
@@ -235,7 +266,6 @@ cdrom_seek(cdrom_t *dev, uint32_t pos)
cdrom_stop(dev);
}
int
cdrom_is_pre(cdrom_t *dev, uint32_t lba)
{
@@ -245,7 +275,6 @@ cdrom_is_pre(cdrom_t *dev, uint32_t lba)
return 0;
}
int
cdrom_audio_callback(cdrom_t *dev, int16_t *output, int len)
{
@@ -291,7 +320,6 @@ cdrom_audio_callback(cdrom_t *dev, int16_t *output, int len)
return ret;
}
uint8_t
cdrom_audio_play(cdrom_t *dev, uint32_t pos, uint32_t len, int ismsf)
{
@@ -354,7 +382,6 @@ cdrom_audio_play(cdrom_t *dev, uint32_t pos, uint32_t len, int ismsf)
return 1;
}
uint8_t
cdrom_audio_track_search(cdrom_t *dev, uint32_t pos, int type, uint8_t playbit)
{
@@ -387,7 +414,6 @@ cdrom_audio_track_search(cdrom_t *dev, uint32_t pos, int type, uint8_t playbit)
return 1;
}
uint8_t
cdrom_toshiba_audio_play(cdrom_t *dev, uint32_t pos, int type)
{
@@ -423,7 +449,6 @@ cdrom_toshiba_audio_play(cdrom_t *dev, uint32_t pos, int type)
return 1;
}
void
cdrom_audio_pause_resume(cdrom_t *dev, uint8_t resume)
{
@@ -431,7 +456,6 @@ cdrom_audio_pause_resume(cdrom_t *dev, uint8_t resume)
dev->cd_status = (dev->cd_status & 0xfe) | (resume & 0x01);
}
uint8_t
cdrom_get_current_subchannel(cdrom_t *dev, uint8_t *b, int msf)
{
@@ -488,7 +512,6 @@ cdrom_get_current_subchannel(cdrom_t *dev, uint8_t *b, int msf)
return ret;
}
uint8_t
cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b)
{
@@ -521,7 +544,6 @@ cdrom_get_current_subcodeq_playstatus(cdrom_t *dev, uint8_t *b)
return ret;
}
static int
read_toc_normal(cdrom_t *dev, unsigned char *b, unsigned char start_track, int msf)
{
@@ -592,7 +614,6 @@ read_toc_normal(cdrom_t *dev, unsigned char *b, unsigned char start_track, int m
return len;
}
static int
read_toc_session(cdrom_t *dev, unsigned char *b, int msf)
{
@@ -630,7 +651,6 @@ read_toc_session(cdrom_t *dev, unsigned char *b, int msf)
return len;
}
static int
read_toc_raw(cdrom_t *dev, unsigned char *b)
{
@@ -665,13 +685,12 @@ read_toc_raw(cdrom_t *dev, unsigned char *b)
return len;
}
int
cdrom_read_toc(cdrom_t *dev, unsigned char *b, int type, unsigned char start_track, int msf, int max_len)
{
int len;
switch(type) {
switch (type) {
case CD_TOC_NORMAL:
len = read_toc_normal(dev, b, start_track, msf);
break;
@@ -694,7 +713,6 @@ cdrom_read_toc(cdrom_t *dev, unsigned char *b, int type, unsigned char start_tra
return len;
}
/* A new API call for Mitsumi CD-ROM. */
void
cdrom_get_track_buffer(cdrom_t *dev, uint8_t *buf)
@@ -719,7 +737,6 @@ cdrom_get_track_buffer(cdrom_t *dev, uint8_t *buf)
memset(buf, 0x00, 9);
}
void
cdrom_read_disc_info_toc(cdrom_t *dev, unsigned char *b, unsigned char track, int type)
{
@@ -759,7 +776,6 @@ cdrom_read_disc_info_toc(cdrom_t *dev, unsigned char *b, unsigned char track, in
}
}
static int
track_type_is_valid(uint8_t id, int type, int flags, int audio, int mode2)
{
@@ -804,7 +820,6 @@ track_type_is_valid(uint8_t id, int type, int flags, int audio, int mode2)
return 1;
}
static void
read_sector_to_buffer(cdrom_t *dev, uint8_t *rbuf, uint32_t msf, uint32_t lba, int mode2, int len)
{
@@ -832,7 +847,6 @@ read_sector_to_buffer(cdrom_t *dev, uint8_t *rbuf, uint32_t msf, uint32_t lba, i
memset(bb, 0, 288);
}
static void
read_audio(cdrom_t *dev, uint32_t lba, uint8_t *b)
{
@@ -843,7 +857,6 @@ read_audio(cdrom_t *dev, uint32_t lba, uint8_t *b)
cdrom_sector_size = 2352;
}
static void
read_mode1(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t msf, int mode2, uint8_t *b)
{
@@ -898,7 +911,6 @@ read_mode1(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t msf, int
}
}
static void
read_mode2_non_xa(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t msf, int mode2, uint8_t *b)
{
@@ -943,7 +955,6 @@ read_mode2_non_xa(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t m
}
}
static void
read_mode2_xa_form1(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t msf, int mode2, uint8_t *b)
{
@@ -995,7 +1006,6 @@ read_mode2_xa_form1(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t
}
}
static void
read_mode2_xa_form2(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t msf, int mode2, uint8_t *b)
{
@@ -1039,7 +1049,6 @@ read_mode2_xa_form2(cdrom_t *dev, int cdrom_sector_flags, uint32_t lba, uint32_t
}
}
int
cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type,
int cdrom_sector_flags, int *len)
@@ -1184,7 +1193,6 @@ cdrom_readsector_raw(cdrom_t *dev, uint8_t *buffer, int sector, int ismsf, int c
return 1;
}
/* Peform a master init on the entire module. */
void
cdrom_global_init(void)
@@ -1193,7 +1201,6 @@ cdrom_global_init(void)
memset(cdrom, 0x00, sizeof(cdrom));
}
static void
cdrom_drive_reset(cdrom_t *dev)
{
@@ -1204,7 +1211,6 @@ cdrom_drive_reset(cdrom_t *dev)
dev->get_channel = NULL;
}
void
cdrom_hard_reset(void)
{
@@ -1220,7 +1226,7 @@ cdrom_hard_reset(void)
cdrom_drive_reset(dev);
switch(dev->bus_type) {
switch (dev->bus_type) {
case CDROM_BUS_ATAPI:
case CDROM_BUS_SCSI:
scsi_cdrom_drive_reset(i);
@@ -1240,7 +1246,6 @@ cdrom_hard_reset(void)
sound_cd_thread_reset();
}
void
cdrom_close(void)
{
@@ -1266,7 +1271,6 @@ cdrom_close(void)
}
}
/* Signal disc change to the emulated machine. */
void
cdrom_insert(uint8_t id)
@@ -1279,7 +1283,6 @@ cdrom_insert(uint8_t id)
}
}
/* The mechanics of ejecting a CD-ROM from a drive. */
void
cdrom_eject(uint8_t id)
@@ -1309,15 +1312,13 @@ cdrom_eject(uint8_t id)
config_save();
}
/* The mechanics of re-loading a CD-ROM drive. */
void
cdrom_reload(uint8_t id)
{
cdrom_t *dev = &cdrom[id];
if ((dev->host_drive == dev->prev_host_drive) ||
(dev->prev_host_drive == 0) || (dev->host_drive != 0)) {
if ((dev->host_drive == dev->prev_host_drive) || (dev->prev_host_drive == 0) || (dev->host_drive != 0)) {
/* Switch from empty to empty. Do nothing. */
return;
}

View File

@@ -33,11 +33,9 @@
#include <86box/cdrom.h>
#include <86box/cdrom_image.h>
#ifdef ENABLE_CDROM_IMAGE_LOG
int cdrom_image_do_log = ENABLE_CDROM_IMAGE_LOG;
void
cdrom_image_log(const char *fmt, ...)
{
@@ -50,30 +48,27 @@ cdrom_image_log(const char *fmt, ...)
}
}
#else
#define cdrom_image_log(fmt, ...)
# define cdrom_image_log(fmt, ...)
#endif
/* The addresses sent from the guest are absolute, ie. a LBA of 0 corresponds to a MSF of 00:00:00. Otherwise, the counter displayed by the guest is wrong:
there is a seeming 2 seconds in which audio plays but counter does not move, while a data track before audio jumps to 2 seconds before the actual start
of the audio while audio still plays. With an absolute conversion, the counter is fine. */
#define MSFtoLBA(m,s,f) ((((m * 60) + s) * 75) + f)
#define MSFtoLBA(m, s, f) ((((m * 60) + s) * 75) + f)
static void
image_get_tracks(cdrom_t *dev, int *first, int *last)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
TMSF tmsf;
cdi_get_audio_tracks(img, first, last, &tmsf);
}
static void
image_get_track_info(cdrom_t *dev, uint32_t track, int end, track_info_t *ti)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
TMSF tmsf;
cdi_get_audio_track_info(img, end, track, &ti->number, &tmsf, &ti->attr);
@@ -83,11 +78,10 @@ image_get_track_info(cdrom_t *dev, uint32_t track, int end, track_info_t *ti)
ti->f = tmsf.fr;
}
static void
image_get_subchannel(cdrom_t *dev, uint32_t lba, subchannel_t *subc)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
TMSF rel_pos, abs_pos;
cdi_get_audio_sub(img, lba, &subc->attr, &subc->track, &subc->index,
@@ -102,11 +96,10 @@ image_get_subchannel(cdrom_t *dev, uint32_t lba, subchannel_t *subc)
subc->rel_f = rel_pos.fr;
}
static int
image_get_capacity(cdrom_t *dev)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
int first_track, last_track;
int number, c;
unsigned char attr;
@@ -126,11 +119,10 @@ image_get_capacity(cdrom_t *dev)
return lb;
}
static int
image_is_track_audio(cdrom_t *dev, uint32_t pos, int ismsf)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
uint8_t attr;
TMSF tmsf;
int m, s, f;
@@ -156,11 +148,10 @@ image_is_track_audio(cdrom_t *dev, uint32_t pos, int ismsf)
}
}
static int
image_is_track_pre(cdrom_t *dev, uint32_t lba)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
int track;
/* GetTrack requires LBA. */
@@ -172,20 +163,18 @@ image_is_track_pre(cdrom_t *dev, uint32_t lba)
return 0;
}
static int
image_sector_size(struct cdrom *dev, uint32_t lba)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
return cdi_get_sector_size(img, lba);
}
static int
image_read_sector(struct cdrom *dev, int type, uint8_t *b, uint32_t lba)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
switch (type) {
case CD_READ_DATA:
@@ -203,11 +192,10 @@ image_read_sector(struct cdrom *dev, int type, uint8_t *b, uint32_t lba)
}
}
static int
image_track_type(cdrom_t *dev, uint32_t lba)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
if (img) {
if (image_is_track_audio(dev, lba, 0))
@@ -221,11 +209,10 @@ image_track_type(cdrom_t *dev, uint32_t lba)
return 0;
}
static void
image_exit(cdrom_t *dev)
{
cd_img_t *img = (cd_img_t *)dev->image;
cd_img_t *img = (cd_img_t *) dev->image;
cdrom_image_log("CDROM: image_exit(%s)\n", dev->image_path);
dev->cd_status = CD_STATUS_EMPTY;
@@ -238,7 +225,6 @@ image_exit(cdrom_t *dev)
dev->ops = NULL;
}
static const cdrom_ops_t cdrom_image_ops = {
image_get_tracks,
image_get_track_info,
@@ -250,7 +236,6 @@ static const cdrom_ops_t cdrom_image_ops = {
image_exit
};
static int
image_open_abort(cdrom_t *dev)
{
@@ -260,7 +245,6 @@ image_open_abort(cdrom_t *dev)
return 1;
}
int
cdrom_image_open(cdrom_t *dev, const char *fn)
{
@@ -304,7 +288,6 @@ cdrom_image_open(cdrom_t *dev, const char *fn)
return 0;
}
void
cdrom_image_close(cdrom_t *dev)
{

View File

@@ -36,7 +36,6 @@
#include <86box/plat.h>
#include <86box/cdrom_image_backend.h>
#define CDROM_BCD(x) (((x) % 10) | (((x) / 10) << 4))
#define MAX_LINE_LENGTH 512
@@ -428,8 +427,7 @@ cdi_read_sectors(cd_img_t *cdi, uint8_t *buffer, int raw, uint32_t sector, uint3
break;
/* Based on the DOSBox patch, but check all 8 bytes and makes sure it's not an
audio track. */
if (raw && sector < cdi->tracks[0].length && !cdi->tracks[0].mode2 &&
(cdi->tracks[0].attr != AUDIO_TRACK) && *(uint64_t *) &(buf[i * sector_size + 2068]))
if (raw && sector < cdi->tracks[0].length && !cdi->tracks[0].mode2 && (cdi->tracks[0].attr != AUDIO_TRACK) && *(uint64_t *) &(buf[i * sector_size + 2068]))
return 0;
}

View File

@@ -13,8 +13,7 @@
* Copyright 2016-2019 Miran Grca.
*/
#ifndef EMU_CDROM_H
# define EMU_CDROM_H
#define EMU_CDROM_H
#define CDROM_NUM 4
@@ -47,7 +46,6 @@
changing this one define will be enough. */
#define CDROM_EMPTY !dev->host_drive
#ifdef __cplusplus
extern "C" {
#endif
@@ -59,11 +57,9 @@ enum {
CDROM_BUS_USB
};
/* To shut up the GCC compilers. */
struct cdrom;
typedef struct {
uint8_t attr, track,
index,
@@ -129,7 +125,6 @@ typedef struct cdrom {
int16_t cd_buffer[BUF_SIZE];
} cdrom_t;
extern cdrom_t cdrom[CDROM_NUM];
extern int cdrom_lba_to_msf_accurate(int lba);
@@ -176,5 +171,4 @@ extern void scsi_cdrom_drive_reset(int c);
}
#endif
#endif /*EMU_CDROM_H*/

View File

@@ -16,7 +16,7 @@
* Copyright 2016-2022 Miran Grca.
*/
#ifndef CDROM_IMAGE_H
# define CDROM_IMAGE_H
#define CDROM_IMAGE_H
/* this header file lists the functions provided by
various platform specific cdrom-ioctl files */

View File

@@ -18,7 +18,7 @@
* Copyright 2002-2020 The DOSBox Team.
*/
#ifndef CDROM_IMAGE_BACKEND_H
# define CDROM_IMAGE_BACKEND_H
#define CDROM_IMAGE_BACKEND_H
#define RAW_SECTOR_SIZE 2352
#define COOKED_SECTOR_SIZE 2048
@@ -27,16 +27,16 @@
#define AUDIO_TRACK 0x10
#define CD_FPS 75
#define FRAMES_TO_MSF(f, M,S,F) { \
#define FRAMES_TO_MSF(f, M, S, F) \
{ \
uint64_t value = f; \
*(F) = (value%CD_FPS) & 0xff; \
*(F) = (value % CD_FPS) & 0xff; \
value /= CD_FPS; \
*(S) = (value%60) & 0xff; \
*(S) = (value % 60) & 0xff; \
value /= 60; \
*(M) = value & 0xff; \
}
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
}
#define MSF_TO_FRAMES(M, S, F) ((M) *60 * CD_FPS + (S) *CD_FPS + (F))
typedef struct SMSF {
uint16_t min;
@@ -68,7 +68,6 @@ typedef struct {
track_t *tracks;
} cd_img_t;
/* Binary file functions. */
extern void cdi_close(cd_img_t *cdi);
extern int cdi_set_device(cd_img_t *cdi, const char *path);
@@ -96,5 +95,4 @@ extern uint64_t viso_get_length(void *p);
extern void viso_close(void *p);
extern track_file_t *viso_init(const char *dirname, int *error);
#endif /*CDROM_IMAGE_BACKEND_H*/

View File

@@ -22,7 +22,7 @@
*/
#ifndef WIN_RESOURCE_H
# define WIN_RESOURCE_H
#define WIN_RESOURCE_H
/* Dialog IDs. */
#define DLG_ABOUT 101 /* top-level dialog */
@@ -174,7 +174,7 @@
#define IDC_COMBO_FPU 1015
#define IDC_COMBO_WS 1016
#ifdef USE_DYNAREC
#define IDC_CHECK_DYNAREC 1017
# define IDC_CHECK_DYNAREC 1017
#endif
#define IDC_MEMTEXT 1018
#define IDC_MEMSPIN 1019
@@ -354,9 +354,9 @@
#define IDM_ACTION_CTRL_ALT_ESC 40016
#define IDM_ACTION_PAUSE 40017
#ifdef MTR_ENABLED
#define IDM_ACTION_BEGIN_TRACE 40018
#define IDM_ACTION_END_TRACE 40019
#define IDM_ACTION_TRACE 40020
# define IDM_ACTION_BEGIN_TRACE 40018
# define IDM_ACTION_END_TRACE 40019
# define IDM_ACTION_TRACE 40020
#endif
#define IDM_CONFIG 40020
#define IDM_VID_HIDE_STATUS_BAR 40021
@@ -370,7 +370,7 @@
#define IDM_VID_SDL_OPENGL 40052
#define IDM_VID_OPENGL_CORE 40053
#ifdef USE_VNC
#define IDM_VID_VNC 40054
# define IDM_VID_VNC 40054
#endif
#define IDM_VID_SCALE_1X 40055
#define IDM_VID_SCALE_2X 40056
@@ -457,7 +457,6 @@
#define IDM_MO_EJECT 0x6500
#define IDM_MO_RELOAD 0x6600
/* Next default values for new objects */
#ifdef APSTUDIO_INVOKED
# ifndef APSTUDIO_READONLY_SYMBOLS
@@ -469,5 +468,4 @@
# endif
#endif
#endif /*WIN_RESOURCE_H*/

File diff suppressed because it is too large Load Diff

View File

@@ -61,14 +61,13 @@
#include <86box/version.h>
#include <86box/gdbstub.h>
#ifdef MTR_ENABLED
#include <minitrace/minitrace.h>
# include <minitrace/minitrace.h>
#endif
typedef struct {
WCHAR str[1024];
} rc_str_t;
/* Platform Public data, specific. */
HINSTANCE hinstance; /* application instance */
HANDLE ghMutex;
@@ -77,7 +76,6 @@ DWORD dwSubLangID;
int acp_utf8; /* Windows supports UTF-8 codepage */
volatile int cpu_thread_run = 1;
/* Local data. */
static HANDLE thMain;
static rc_str_t *lpRCstr2048 = NULL,
@@ -96,7 +94,6 @@ static int first_use = 1;
static LARGE_INTEGER StartingTime;
static LARGE_INTEGER Frequency;
static const struct {
const char *name;
int local;
@@ -108,23 +105,21 @@ static const struct {
void (*set_fs)(int fs);
void (*reload)(void);
} vid_apis[RENDERERS_NUM] = {
{ "SDL_Software", 1, (int(*)(void*))sdl_inits, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, sdl_reload },
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, sdl_reload },
{ "SDL_OpenGL", 1, (int(*)(void*))sdl_initho, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, sdl_reload }
,{ "OpenGL_Core", 1, (int(*)(void*))opengl_init, opengl_close, opengl_resize, opengl_pause, NULL, opengl_set_fs, opengl_reload}
{"SDL_Software", 1, (int (*)(void *)) sdl_inits, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, sdl_reload },
{ "SDL_Hardware", 1, (int (*)(void *)) sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, sdl_reload },
{ "SDL_OpenGL", 1, (int (*)(void *)) sdl_initho, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs,sdl_reload },
{ "OpenGL_Core", 1, (int (*)(void *)) opengl_init, opengl_close, opengl_resize, opengl_pause, NULL, opengl_set_fs, opengl_reload }
#ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL, NULL }
,
{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL, NULL}
#endif
};
extern int title_update;
#ifdef ENABLE_WIN_LOG
int win_do_log = ENABLE_WIN_LOG;
static void
win_log(const char *fmt, ...)
{
@@ -137,7 +132,7 @@ win_log(const char *fmt, ...)
}
}
#else
#define win_log(fmt, ...)
# define win_log(fmt, ...)
#endif
void
@@ -149,7 +144,6 @@ free_string(rc_str_t **str)
}
}
static void
LoadCommonStrings(void)
{
@@ -177,46 +171,48 @@ LoadCommonStrings(void)
lpRCstr6144 = calloc(STR_NUM_6144, sizeof(rc_str_t));
lpRCstr7168 = calloc(STR_NUM_7168, sizeof(rc_str_t));
for (i=0; i<STR_NUM_2048; i++)
LoadString(hinstance, 2048+i, lpRCstr2048[i].str, 1024);
for (i = 0; i < STR_NUM_2048; i++)
LoadString(hinstance, 2048 + i, lpRCstr2048[i].str, 1024);
for (i=0; i<STR_NUM_4096; i++)
LoadString(hinstance, 4096+i, lpRCstr4096[i].str, 1024);
for (i = 0; i < STR_NUM_4096; i++)
LoadString(hinstance, 4096 + i, lpRCstr4096[i].str, 1024);
for (i=0; i<STR_NUM_4352; i++)
LoadString(hinstance, 4352+i, lpRCstr4352[i].str, 1024);
for (i = 0; i < STR_NUM_4352; i++)
LoadString(hinstance, 4352 + i, lpRCstr4352[i].str, 1024);
for (i=0; i<STR_NUM_4608; i++)
LoadString(hinstance, 4608+i, lpRCstr4608[i].str, 1024);
for (i = 0; i < STR_NUM_4608; i++)
LoadString(hinstance, 4608 + i, lpRCstr4608[i].str, 1024);
for (i=0; i<STR_NUM_5120; i++)
LoadString(hinstance, 5120+i, lpRCstr5120[i].str, 1024);
for (i = 0; i < STR_NUM_5120; i++)
LoadString(hinstance, 5120 + i, lpRCstr5120[i].str, 1024);
for (i=0; i<STR_NUM_5376; i++) {
for (i = 0; i < STR_NUM_5376; i++) {
if ((i == 0) || (i > 3))
LoadString(hinstance, 5376+i, lpRCstr5376[i].str, 1024);
LoadString(hinstance, 5376 + i, lpRCstr5376[i].str, 1024);
}
for (i=0; i<STR_NUM_5632; i++) {
for (i = 0; i < STR_NUM_5632; i++) {
if ((i == 0) || (i > 3))
LoadString(hinstance, 5632+i, lpRCstr5632[i].str, 1024);
LoadString(hinstance, 5632 + i, lpRCstr5632[i].str, 1024);
}
for (i=0; i<STR_NUM_5888; i++)
LoadString(hinstance, 5888+i, lpRCstr5888[i].str, 1024);
for (i = 0; i < STR_NUM_5888; i++)
LoadString(hinstance, 5888 + i, lpRCstr5888[i].str, 1024);
for (i=0; i<STR_NUM_6144; i++)
LoadString(hinstance, 6144+i, lpRCstr6144[i].str, 1024);
for (i = 0; i < STR_NUM_6144; i++)
LoadString(hinstance, 6144 + i, lpRCstr6144[i].str, 1024);
for (i=0; i<STR_NUM_7168; i++)
LoadString(hinstance, 7168+i, lpRCstr7168[i].str, 1024);
for (i = 0; i < STR_NUM_7168; i++)
LoadString(hinstance, 7168 + i, lpRCstr7168[i].str, 1024);
}
size_t mbstoc16s(uint16_t dst[], const char src[], int len)
size_t
mbstoc16s(uint16_t dst[], const char src[], int len)
{
if (src == NULL) return 0;
if (len < 0) return 0;
if (src == NULL)
return 0;
if (len < 0)
return 0;
size_t ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, dst == NULL ? 0 : len);
@@ -227,11 +223,13 @@ size_t mbstoc16s(uint16_t dst[], const char src[], int len)
return ret;
}
size_t c16stombs(char dst[], const uint16_t src[], int len)
size_t
c16stombs(char dst[], const uint16_t src[], int len)
{
if (src == NULL) return 0;
if (len < 0) return 0;
if (src == NULL)
return 0;
if (len < 0)
return 0;
size_t ret = WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, dst == NULL ? 0 : len, NULL, NULL);
@@ -242,14 +240,12 @@ size_t c16stombs(char dst[], const uint16_t src[], int len)
return ret;
}
int
has_language_changed(uint32_t id)
{
return (lang_id != id);
}
/* Set (or re-set) the language for the application. */
void
set_language(uint32_t id)
@@ -279,34 +275,33 @@ set_language(uint32_t id)
}
}
wchar_t *
plat_get_string(int i)
{
LPTSTR str;
if ((i >= 2048) && (i <= 3071))
str = lpRCstr2048[i-2048].str;
str = lpRCstr2048[i - 2048].str;
else if ((i >= 4096) && (i <= 4351))
str = lpRCstr4096[i-4096].str;
str = lpRCstr4096[i - 4096].str;
else if ((i >= 4352) && (i <= 4607))
str = lpRCstr4352[i-4352].str;
str = lpRCstr4352[i - 4352].str;
else if ((i >= 4608) && (i <= 5119))
str = lpRCstr4608[i-4608].str;
str = lpRCstr4608[i - 4608].str;
else if ((i >= 5120) && (i <= 5375))
str = lpRCstr5120[i-5120].str;
str = lpRCstr5120[i - 5120].str;
else if ((i >= 5376) && (i <= 5631))
str = lpRCstr5376[i-5376].str;
str = lpRCstr5376[i - 5376].str;
else if ((i >= 5632) && (i <= 5887))
str = lpRCstr5632[i-5632].str;
str = lpRCstr5632[i - 5632].str;
else if ((i >= 5888) && (i <= 6143))
str = lpRCstr5888[i-5888].str;
str = lpRCstr5888[i - 5888].str;
else if ((i >= 6144) && (i <= 7167))
str = lpRCstr6144[i-6144].str;
str = lpRCstr6144[i - 6144].str;
else
str = lpRCstr7168[i-7168].str;
str = lpRCstr7168[i - 7168].str;
return((wchar_t *)str);
return ((wchar_t *) str);
}
#ifdef MTR_ENABLED
@@ -334,7 +329,7 @@ CreateConsole(int init)
fpos_t p;
int i;
if (! init) {
if (!init) {
if (force_debug)
FreeConsole();
return;
@@ -342,13 +337,14 @@ CreateConsole(int init)
/* Are we logging to a file? */
p = 0;
(void)fgetpos(stdout, &p);
if (p != -1) return;
(void) fgetpos(stdout, &p);
if (p != -1)
return;
/* Not logging to file, attach to console. */
if (! AttachConsole(ATTACH_PARENT_PROCESS)) {
if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
/* Parent has no console, create one. */
if (! AllocConsole()) {
if (!AllocConsole()) {
/* Cannot create console, just give up. */
return;
}
@@ -356,11 +352,11 @@ CreateConsole(int init)
fp = NULL;
if ((h = GetStdHandle(STD_OUTPUT_HANDLE)) != NULL) {
/* We got the handle, now open a file descriptor. */
if ((i = _open_osfhandle((intptr_t)h, _O_TEXT)) != -1) {
if ((i = _open_osfhandle((intptr_t) h, _O_TEXT)) != -1) {
/* We got a file descriptor, now allocate a new stream. */
if ((fp = _fdopen(i, "w")) != NULL) {
/* Got the stream, re-initialize stdout without it. */
(void)freopen("CONOUT$", "w", stdout);
(void) freopen("CONOUT$", "w", stdout);
setvbuf(stdout, NULL, _IONBF, 0);
fflush(stdout);
}
@@ -373,14 +369,12 @@ CreateConsole(int init)
}
}
static void
CloseConsole(void)
{
CreateConsole(0);
}
/* Process the commandline, and create standard argc/argv array. */
static int
ProcessCommandLine(char ***argv)
@@ -391,20 +385,20 @@ ProcessCommandLine(char ***argv)
if (acp_utf8) {
i = strlen(GetCommandLineA()) + 1;
argbuf = (char *)malloc(i);
argbuf = (char *) malloc(i);
strcpy(argbuf, GetCommandLineA());
} else {
i = c16stombs(NULL, GetCommandLineW(), 0) + 1;
argbuf = (char *)malloc(i);
argbuf = (char *) malloc(i);
c16stombs(argbuf, GetCommandLineW(), i);
}
argc = 0;
argc_max = 64;
args = (char **)malloc(sizeof(char *) * argc_max);
args = (char **) malloc(sizeof(char *) * argc_max);
if (args == NULL) {
free(argbuf);
return(0);
return (0);
}
/* parse commandline into argc/argv format */
@@ -425,15 +419,15 @@ ProcessCommandLine(char ***argv)
if (argc >= argc_max) {
argc_max += 64;
args = realloc(args, sizeof(char *)*argc_max);
args = realloc(args, sizeof(char *) * argc_max);
if (args == NULL) {
free(argbuf);
return(0);
return (0);
}
}
while ((argbuf[i]) && ((q)
? (argbuf[i]!=q) : (argbuf[i]!=' '))) i++;
while ((argbuf[i]) && ((q) ? (argbuf[i] != q) : (argbuf[i] != ' ')))
i++;
if (argbuf[i]) {
argbuf[i] = 0;
@@ -445,10 +439,9 @@ ProcessCommandLine(char ***argv)
args[argc] = NULL;
*argv = args;
return(argc);
return (argc);
}
/* For the Windows platform, this is the start of the application. */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
@@ -482,7 +475,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
argc = ProcessCommandLine(&argv);
/* Pre-initialize the system, this loads the config file. */
if (! pc_init(argc, argv)) {
if (!pc_init(argc, argv)) {
/* Detach from console. */
if (force_debug)
CreateConsole(0);
@@ -492,7 +485,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
free(argbuf);
free(argv);
return(1);
return (1);
}
extern int gfxcard_2;
@@ -502,7 +495,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
if (force_debug) {
CreateConsole(1);
atexit(CloseConsole);
}
}
/* Handle our GUI. */
i = ui_init(nCmdShow);
@@ -512,10 +505,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
free(argbuf);
free(argv);
return(i);
return (i);
}
void
main_thread(void *param)
{
@@ -567,7 +559,6 @@ main_thread(void *param)
is_quit = 1;
}
/*
* We do this here since there is platform-specific stuff
* going on here, and we do it in a function separate from
@@ -592,7 +583,6 @@ do_start(void)
SetThreadPriority(thMain, THREAD_PRIORITY_HIGHEST);
}
/* Cleanly stop the emulator. */
void
do_stop(void)
@@ -610,7 +600,6 @@ do_stop(void)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
}
void
plat_get_exe_name(char *s, int size)
{
@@ -626,7 +615,6 @@ plat_get_exe_name(char *s, int size)
}
}
void
plat_tempfile(char *bufp, char *prefix, char *suffix)
{
@@ -645,25 +633,23 @@ plat_tempfile(char *bufp, char *prefix, char *suffix)
suffix);
}
int
plat_getcwd(char *bufp, int max)
{
wchar_t *temp;
if (acp_utf8)
(void)_getcwd(bufp, max);
(void) _getcwd(bufp, max);
else {
temp = malloc(max * sizeof(wchar_t));
(void)_wgetcwd(temp, max);
(void) _wgetcwd(temp, max);
c16stombs(bufp, temp, max);
free(temp);
}
return(0);
return (0);
}
int
plat_chdir(char *path)
{
@@ -671,7 +657,7 @@ plat_chdir(char *path)
int len, ret;
if (acp_utf8)
return(_chdir(path));
return (_chdir(path));
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
@@ -684,7 +670,6 @@ plat_chdir(char *path)
}
}
FILE *
plat_fopen(const char *path, const char *mode)
{
@@ -712,7 +697,6 @@ plat_fopen(const char *path, const char *mode)
}
}
/* Open a file, using Unicode pathname, with 64bit pointers. */
FILE *
plat_fopen64(const char *path, const char *mode)
@@ -720,7 +704,6 @@ plat_fopen64(const char *path, const char *mode)
return plat_fopen(path, mode);
}
void
plat_remove(char *path)
{
@@ -741,7 +724,7 @@ plat_remove(char *path)
}
void
path_normalize(char* path)
path_normalize(char *path)
{
/* No-op */
}
@@ -750,36 +733,33 @@ path_normalize(char* path)
void
path_slash(char *path)
{
if ((path[strlen(path)-1] != '\\') &&
(path[strlen(path)-1] != '/')) {
if ((path[strlen(path) - 1] != '\\') && (path[strlen(path) - 1] != '/')) {
strcat(path, "\\");
}
}
/* Check if the given path is absolute or not. */
int
path_abs(char *path)
{
if ((path[1] == ':') || (path[0] == '\\') || (path[0] == '/'))
return(1);
return (1);
return(0);
return (0);
}
/* Return the 'directory' element of a pathname. */
void
path_get_dirname(char *dest, const char *path)
{
int c = (int)strlen(path);
int c = (int) strlen(path);
char *ptr;
ptr = (char *)path;
ptr = (char *) path;
while (c > 0) {
if (path[c] == '/' || path[c] == '\\') {
ptr = (char *)&path[c];
ptr = (char *) &path[c];
break;
}
c--;
@@ -791,7 +771,6 @@ path_get_dirname(char *dest, const char *path)
*dest = '\0';
}
char *
path_get_filename(char *s)
{
@@ -799,32 +778,30 @@ path_get_filename(char *s)
while (c > 0) {
if (s[c] == '/' || s[c] == '\\')
return(&s[c+1]);
return (&s[c + 1]);
c--;
}
return(s);
return (s);
}
char *
path_get_extension(char *s)
{
int c = strlen(s) - 1;
if (c <= 0)
return(s);
return (s);
while (c && s[c] != '.')
c--;
if (!c)
return(&s[strlen(s)]);
return (&s[strlen(s)]);
return(&s[c+1]);
return (&s[c + 1]);
}
void
path_append_filename(char *dest, const char *s1, const char *s2)
{
@@ -833,7 +810,6 @@ path_append_filename(char *dest, const char *s1, const char *s2)
strcat(dest, s2);
}
void
plat_put_backslash(char *s)
{
@@ -843,7 +819,6 @@ plat_put_backslash(char *s)
s[c] = '/';
}
int
plat_dir_check(char *path)
{
@@ -863,11 +838,9 @@ plat_dir_check(char *path)
free(temp);
}
return(((dwAttrib != INVALID_FILE_ATTRIBUTES &&
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) ? 1 : 0);
return (((dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) ? 1 : 0);
}
int
plat_dir_create(char *path)
{
@@ -875,13 +848,13 @@ plat_dir_create(char *path)
wchar_t *temp;
if (acp_utf8)
return (int)SHCreateDirectoryExA(NULL, path, NULL);
return (int) SHCreateDirectoryExA(NULL, path, NULL);
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, path, len);
ret = (int)SHCreateDirectoryExW(NULL, temp, NULL);
ret = (int) SHCreateDirectoryExW(NULL, temp, NULL);
free(temp);
@@ -889,14 +862,12 @@ plat_dir_create(char *path)
}
}
void *
plat_mmap(size_t size, uint8_t executable)
{
return VirtualAlloc(NULL, size, MEM_COMMIT, executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE);
}
void
plat_init_rom_paths()
{
@@ -927,7 +898,6 @@ plat_munmap(void *ptr, size_t size)
VirtualFree(ptr, 0, MEM_RELEASE);
}
uint64_t
plat_timer_read(void)
{
@@ -935,7 +905,7 @@ plat_timer_read(void)
QueryPerformanceCounter(&li);
return(li.QuadPart);
return (li.QuadPart);
}
static LARGE_INTEGER
@@ -966,13 +936,13 @@ plat_get_ticks_common(void)
uint32_t
plat_get_ticks(void)
{
return (uint32_t)(plat_get_ticks_common().QuadPart / 1000);
return (uint32_t) (plat_get_ticks_common().QuadPart / 1000);
}
uint32_t
plat_get_micro_ticks(void)
{
return (uint32_t)plat_get_ticks_common().QuadPart;
return (uint32_t) plat_get_ticks_common().QuadPart;
}
void
@@ -981,7 +951,6 @@ plat_delay_ms(uint32_t count)
Sleep(count);
}
/* Return the VIDAPI number for the given name. */
int
plat_vidapi(char *name)
@@ -989,28 +958,29 @@ plat_vidapi(char *name)
int i;
/* Default/System is SDL Hardware. */
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(1);
if (!strcasecmp(name, "default") || !strcasecmp(name, "system"))
return (1);
/* If DirectDraw or plain SDL was specified, return SDL Software. */
if (!strcasecmp(name, "ddraw") || !strcasecmp(name, "sdl")) return(1);
if (!strcasecmp(name, "ddraw") || !strcasecmp(name, "sdl"))
return (1);
for (i = 0; i < RENDERERS_NUM; i++) {
if (vid_apis[i].name &&
!strcasecmp(vid_apis[i].name, name)) return(i);
if (vid_apis[i].name && !strcasecmp(vid_apis[i].name, name))
return (i);
}
/* Default value. */
return(1);
return (1);
}
/* Return the VIDAPI name for the given number. */
char *
plat_vidapi_name(int api)
{
char *name = "default";
switch(api) {
switch (api) {
case 0:
name = "sdl_software";
break;
@@ -1032,10 +1002,9 @@ plat_vidapi_name(int api)
break;
}
return(name);
return (name);
}
int
plat_setvid(int api)
{
@@ -1054,30 +1023,30 @@ plat_setvid(int api)
ShowWindow(hwndRender, SW_HIDE);
/* Initialize the (new) API. */
i = vid_apis[vid_api].init((void *)hwndRender);
i = vid_apis[vid_api].init((void *) hwndRender);
endblit();
if (! i) return(0);
if (!i)
return (0);
device_force_redraw();
vid_api_inited = 1;
return(1);
return (1);
}
/* Tell the renderers about a new screen resolution. */
void
plat_vidsize(int x, int y)
{
if (!vid_api_inited || !vid_apis[vid_api].resize) return;
if (!vid_api_inited || !vid_apis[vid_api].resize)
return;
startblit();
vid_apis[vid_api].resize(x, y);
endblit();
}
void
plat_vidapi_enable(int enable)
{
@@ -1088,21 +1057,19 @@ plat_vidapi_enable(int enable)
vid_apis[vid_api].enable(enable != 0);
if (! i)
if (!i)
return;
if (enable)
device_force_redraw();
}
int
get_vidpause(void)
{
return(vid_apis[vid_api].pause());
return (vid_apis[vid_api].pause());
}
void
plat_setfullscreen(int on)
{
@@ -1200,7 +1167,6 @@ plat_setfullscreen(int on)
}
}
void
plat_vid_reload_options(void)
{
@@ -1210,17 +1176,15 @@ plat_vid_reload_options(void)
vid_apis[vid_api].reload();
}
void
plat_vidapi_reload(void)
{
vid_apis[vid_api].reload();
}
/* Sets up the program language before initialization. */
uint32_t
plat_language_code(char* langcode)
plat_language_code(char *langcode)
{
if (!strcmp(langcode, "system"))
return 0xFFFF;
@@ -1229,7 +1193,7 @@ plat_language_code(char* langcode)
wchar_t *temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, langcode, len);
LCID lcid = LocaleNameToLCID((LPWSTR)temp, 0);
LCID lcid = LocaleNameToLCID((LPWSTR) temp, 0);
free(temp);
return lcid;
@@ -1237,10 +1201,9 @@ plat_language_code(char* langcode)
/* Converts back the language code to LCID */
void
plat_language_code_r(uint32_t lcid, char* outbuf, int len)
plat_language_code_r(uint32_t lcid, char *outbuf, int len)
{
if (lcid == 0xFFFF)
{
if (lcid == 0xFFFF) {
strcpy(outbuf, "system");
return;
}
@@ -1260,9 +1223,9 @@ take_screenshot(void)
device_force_redraw();
}
/* LPARAM interface to plat_get_string(). */
LPARAM win_get_string(int id)
LPARAM
win_get_string(int id)
{
wchar_t *ret;
@@ -1270,14 +1233,12 @@ LPARAM win_get_string(int id)
return ((LPARAM) ret);
}
void /* plat_ */
startblit(void)
{
WaitForSingleObject(ghMutex, INFINITE);
}
void /* plat_ */
endblit(void)
{

View File

@@ -32,15 +32,14 @@
#include <86box/win.h>
#include <86box/version.h>
void
AboutDialogCreate(HWND hwnd)
{
int i;
TASKDIALOGCONFIG tdconfig = {0};
TASKDIALOGCONFIG tdconfig = { 0 };
TASKDIALOG_BUTTON tdbuttons[] = {
{IDOK, EMU_SITE_W},
{IDCANCEL, MAKEINTRESOURCE(IDS_2127)}
{IDOK, EMU_SITE_W },
{ IDCANCEL, MAKEINTRESOURCE(IDS_2127)}
};
wchar_t emu_version[256];

View File

@@ -44,7 +44,6 @@
#include <86box/ui.h>
#include <86box/win.h>
void
cassette_mount(char *fn, uint8_t wp)
{
@@ -60,7 +59,6 @@ cassette_mount(char *fn, uint8_t wp)
config_save();
}
void
cassette_eject(void)
{
@@ -72,7 +70,6 @@ cassette_eject(void)
config_save();
}
void
cartridge_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -84,7 +81,6 @@ cartridge_mount(uint8_t id, char *fn, uint8_t wp)
config_save();
}
void
cartridge_eject(uint8_t id)
{
@@ -95,7 +91,6 @@ cartridge_eject(uint8_t id)
config_save();
}
void
floppy_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -108,7 +103,6 @@ floppy_mount(uint8_t id, char *fn, uint8_t wp)
config_save();
}
void
floppy_eject(uint8_t id)
{
@@ -119,20 +113,19 @@ floppy_eject(uint8_t id)
config_save();
}
void
plat_cdrom_ui_update(uint8_t id, uint8_t reload)
{
cdrom_t *drv = &cdrom[id];
if (drv->host_drive == 0) {
ui_sb_update_icon_state(SB_CDROM|id, 1);
ui_sb_update_icon_state(SB_CDROM | id, 1);
} else {
ui_sb_update_icon_state(SB_CDROM|id, 0);
ui_sb_update_icon_state(SB_CDROM | id, 0);
}
media_menu_update_cdrom(id);
ui_sb_update_tip(SB_CDROM|id);
ui_sb_update_tip(SB_CDROM | id);
}
void
@@ -176,7 +169,6 @@ mo_eject(uint8_t id)
config_save();
}
void
mo_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -194,7 +186,6 @@ mo_mount(uint8_t id, char *fn, uint8_t wp)
config_save();
}
void
mo_reload(uint8_t id)
{
@@ -202,13 +193,13 @@ mo_reload(uint8_t id)
mo_disk_reload(dev);
if (strlen(mo_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_MO|id, 1);
ui_sb_update_icon_state(SB_MO | id, 1);
} else {
ui_sb_update_icon_state(SB_MO|id, 0);
ui_sb_update_icon_state(SB_MO | id, 0);
}
media_menu_update_mo(id);
ui_sb_update_tip(SB_MO|id);
ui_sb_update_tip(SB_MO | id);
config_save();
}
@@ -230,7 +221,6 @@ zip_eject(uint8_t id)
config_save();
}
void
zip_mount(uint8_t id, char *fn, uint8_t wp)
{
@@ -248,7 +238,6 @@ zip_mount(uint8_t id, char *fn, uint8_t wp)
config_save();
}
void
zip_reload(uint8_t id)
{
@@ -256,13 +245,13 @@ zip_reload(uint8_t id)
zip_disk_reload(dev);
if (strlen(zip_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_ZIP|id, 1);
ui_sb_update_icon_state(SB_ZIP | id, 1);
} else {
ui_sb_update_icon_state(SB_ZIP|id, 0);
ui_sb_update_icon_state(SB_ZIP | id, 0);
}
media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP|id);
ui_sb_update_tip(SB_ZIP | id);
config_save();
}

View File

@@ -30,12 +30,10 @@
#include <86box/win.h>
#include <windowsx.h>
static device_context_t config_device;
static uint8_t deviceconfig_changed = 0;
#if defined(__amd64__) || defined(__aarch64__)
static LRESULT CALLBACK
#else
@@ -87,7 +85,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
while (selection && selection->description && selection->description[0]) {
mbstowcs(lptsTemp, selection->description,
strlen(selection->description) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) lptsTemp);
if (val_int == selection->value)
SendMessage(h, CB_SETCURSEL, c, 0);
selection++;
@@ -105,7 +103,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
for (c = 0; c < num; c++) {
rtmidi_out_get_dev_name(c, s);
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) lptsTemp);
if (val_int == c)
SendMessage(h, CB_SETCURSEL, c, 0);
}
@@ -120,7 +118,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
for (c = 0; c < num; c++) {
rtmidi_in_get_dev_name(c, s);
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) lptsTemp);
if (val_int == c)
SendMessage(h, CB_SETCURSEL, c, 0);
}
@@ -133,7 +131,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
(char *) config->name, config->default_int);
_swprintf(ws, L"%i", val_int);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ws);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) ws);
id += 2;
break;
@@ -141,7 +139,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
wstr = config_get_wstring((char *) config_device.name,
(char *) config->name, 0);
if (wstr)
SendMessage(h, WM_SETTEXT, 0, (LPARAM)wstr);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) wstr);
id += 3;
break;
case CONFIG_HEX16:
@@ -152,7 +150,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
while (selection && selection->description && selection->description[0]) {
mbstowcs(lptsTemp, selection->description,
strlen(selection->description) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) lptsTemp);
if (val_int == selection->value)
SendMessage(h, CB_SETCURSEL, c, 0);
selection++;
@@ -169,7 +167,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
while (selection && selection->description && selection->description[0]) {
mbstowcs(lptsTemp, selection->description,
strlen(selection->description) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) lptsTemp);
if (val_int == selection->value)
SendMessage(h, CB_SETCURSEL, c, 0);
selection++;
@@ -243,8 +241,8 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
case CONFIG_FNAME:
str = config_get_string((char *) config_device.name,
(char *) config->name, (char*)"");
SendMessage(h, WM_GETTEXT, 511, (LPARAM)s);
(char *) config->name, (char *) "");
SendMessage(h, WM_GETTEXT, 511, (LPARAM) s);
if (strcmp(str, s))
changed = 1;
@@ -258,7 +256,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
else if (val_int < config->spinner.min)
val_int = config->spinner.min;
SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws);
SendMessage(h, WM_GETTEXT, 79, (LPARAM) ws);
wcstombs(s, ws, 512);
sscanf(s, "%i", &c);
@@ -342,13 +340,13 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
id += 2;
break;
case CONFIG_FNAME:
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ws);
SendMessage(h, WM_GETTEXT, 511, (LPARAM) ws);
config_set_wstring((char *) config_device.name, (char *) config->name, ws);
id += 3;
break;
case CONFIG_SPINNER:
SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws);
SendMessage(h, WM_GETTEXT, 79, (LPARAM) ws);
wcstombs(s, ws, 512);
sscanf(s, "%i", &c);
if (c > config->spinner.max)
@@ -402,10 +400,10 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
id += 2;
break;
case CONFIG_FNAME:
if (cid == id+1) {
if (cid == id + 1) {
s[0] = 0;
h = GetDlgItem(hdlg, id);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)s);
SendMessage(h, WM_GETTEXT, 511, (LPARAM) s);
file_filter[0] = 0;
strcat(file_filter, config->file_filter);
@@ -420,7 +418,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
}
if (!file_dlg(hdlg, ws, s, NULL, 0))
SendMessage(h, WM_SETTEXT, 0, (LPARAM)wopenfilestring);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) wopenfilestring);
}
break;
}
@@ -432,7 +430,6 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
uint8_t
deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
{
@@ -443,7 +440,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
DLGITEMTEMPLATE *item;
data_block = malloc(16384);
dlg = (DLGTEMPLATE *)data_block;
dlg = (DLGTEMPLATE *) data_block;
int y = 10;
int id = IDC_CONFIG_BASE;
@@ -457,7 +454,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
dlg->cx = 220;
dlg->cy = 70;
data = (uint16_t *)(dlg + 1);
data = (uint16_t *) (dlg + 1);
*data++ = 0; /*no menu*/
*data++ = 0; /*predefined dialog box class*/
@@ -467,13 +464,13 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
*data++ = 9; /*Point*/
data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 120);
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
while (config->type != -1) {
switch (config->type) {
case CONFIG_BINARY:
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y;
item->id = id++;
@@ -483,7 +480,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */
@@ -499,7 +496,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
case CONFIG_HEX16:
case CONFIG_HEX20:
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -509,18 +506,18 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -530,21 +527,21 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
break;
case CONFIG_SPINNER:
/*Spinner*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -555,19 +552,19 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_NUMBER;
item->dwExtendedStyle = WS_EX_CLIENTEDGE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0081; /* edit text class */
data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/* TODO: add up down class */
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -577,21 +574,21 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
break;
case CONFIG_FNAME:
/*File*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -602,18 +599,18 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE | ES_READONLY;
item->dwExtendedStyle = WS_EX_CLIENTEDGE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0081; /* edit text class */
data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/* Button */
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 175;
item->y = y;
item->id = id++;
@@ -623,18 +620,18 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */
data += MultiByteToWideChar(CP_ACP, 0, "Browse", -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -644,21 +641,21 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
break;
}
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
config++;
@@ -666,7 +663,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 100;
item->y = y + 5;
item->cx = 50;
@@ -674,17 +671,17 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->id = IDOK; /* OK button identifier */
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 160;
item->y = y + 5;
item->cx = 50;
@@ -692,7 +689,7 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
item->id = IDCANCEL; /* OK button identifier */
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */
@@ -710,7 +707,6 @@ deviceconfig_inst_open(HWND hwnd, const device_t *device, int inst)
return deviceconfig_changed;
}
uint8_t
deviceconfig_open(HWND hwnd, const device_t *device)
{

View File

@@ -33,39 +33,34 @@
#include <86box/ui.h>
#include <86box/win.h>
#define STRING_OR_RESOURCE(s) ((!(s)) ? (NULL) : ((((uintptr_t)s) < ((uintptr_t)65636)) ? (MAKEINTRESOURCE((uintptr_t)s)) : (s)))
#define STRING_OR_RESOURCE(s) ((!(s)) ? (NULL) : ((((uintptr_t) s) < ((uintptr_t) 65636)) ? (MAKEINTRESOURCE((uintptr_t) s)) : (s)))
WCHAR wopenfilestring[512];
char openfilestring[512];
uint8_t filterindex = 0;
int
ui_msgbox(int flags, void *message)
{
return ui_msgbox_ex(flags, NULL, message, NULL, NULL, NULL);
}
int
ui_msgbox_header(int flags, void *header, void *message)
{
return ui_msgbox_ex(flags, header, message, NULL, NULL, NULL);
}
int
ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, void *btn3) {
ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, void *btn3)
{
WCHAR temp[512];
TASKDIALOGCONFIG tdconfig = {0};
TASKDIALOGCONFIG tdconfig = { 0 };
TASKDIALOG_BUTTON tdbuttons[3],
tdb_yes = {IDYES, STRING_OR_RESOURCE(btn1)},
tdb_no = {IDNO, STRING_OR_RESOURCE(btn2)},
tdb_cancel = {IDCANCEL, STRING_OR_RESOURCE(btn3)},
tdb_exit = {IDCLOSE, MAKEINTRESOURCE(IDS_2119)};
tdb_yes = { IDYES, STRING_OR_RESOURCE(btn1) },
tdb_no = { IDNO, STRING_OR_RESOURCE(btn2) },
tdb_cancel = { IDCANCEL, STRING_OR_RESOURCE(btn3) },
tdb_exit = { IDCLOSE, MAKEINTRESOURCE(IDS_2119) };
int ret = 0, checked = 0;
/* Configure the default OK button. */
@@ -76,7 +71,7 @@ ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, voi
tdconfig.dwCommonButtons = TDCBF_OK_BUTTON;
/* Configure the message type. */
switch(flags & 0x1f) {
switch (flags & 0x1f) {
case MBX_INFO: /* just an informational message */
tdconfig.pszMainIcon = TD_INFORMATION_ICON;
break;
@@ -124,7 +119,7 @@ ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, voi
/* If the message is an ANSI string, convert it. */
tdconfig.pszContent = (WCHAR *) STRING_OR_RESOURCE(message);
if (flags & MBX_ANSI) {
mbstoc16s(temp, (char *)message, strlen((char *)message)+1);
mbstoc16s(temp, (char *) message, strlen((char *) message) + 1);
tdconfig.pszContent = temp;
}
@@ -144,17 +139,20 @@ ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, voi
TaskDialogIndirect(&tdconfig, &ret, NULL, &checked);
/* Convert return values to generic ones. */
if (ret == IDNO) ret = 1;
else if (ret == IDCANCEL) ret = -1;
else ret = 0;
if (ret == IDNO)
ret = 1;
else if (ret == IDCANCEL)
ret = -1;
else
ret = 0;
/* 10 is added to the return value if "don't show again" is checked. */
if (checked) ret += 10;
if (checked)
ret += 10;
return(ret);
return (ret);
}
int
file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save)
{
@@ -183,7 +181,7 @@ file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save)
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST;
if (! save)
if (!save)
ofn.Flags |= OFN_FILEMUSTEXIST;
if (title)
ofn.lpstrTitle = title;
@@ -203,13 +201,12 @@ file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save)
c16stombs(openfilestring, wopenfilestring, sizeof(openfilestring));
filterindex = ofn.nFilterIndex;
return(0);
return (0);
}
return(1);
return (1);
}
int
file_dlg(HWND hwnd, WCHAR *f, char *fn, char *title, int save)
{
@@ -220,10 +217,9 @@ file_dlg(HWND hwnd, WCHAR *f, char *fn, char *title, int save)
if (title)
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, f, fn ? ufn : NULL, title ? title_buf : NULL, save));
return (file_dlg_w(hwnd, f, fn ? ufn : NULL, title ? title_buf : NULL, save));
}
int
file_dlg_mb(HWND hwnd, char *f, char *fn, char *title, int save)
{
@@ -234,22 +230,20 @@ file_dlg_mb(HWND hwnd, char *f, char *fn, char *title, int save)
if (title)
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, uf, ufn, title ? title_buf : NULL, save));
return (file_dlg_w(hwnd, uf, ufn, title ? title_buf : NULL, save));
}
int
file_dlg_w_st(HWND hwnd, int id, WCHAR *fn, char *title, int save)
{
WCHAR title_buf[512];
if (title)
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, plat_get_string(id), fn, title ? title_buf : NULL, save));
return (file_dlg_w(hwnd, plat_get_string(id), fn, title ? title_buf : NULL, save));
}
int
file_dlg_st(HWND hwnd, int id, char *fn, char *title, int save)
{
return(file_dlg(hwnd, plat_get_string(id), fn, title, save));
return (file_dlg(hwnd, plat_get_string(id), fn, title, save));
}

View File

@@ -25,11 +25,9 @@
#include <86box/86box.h>
#include <86box/plat_dynld.h>
#ifdef ENABLE_DYNLD_LOG
int dynld_do_log = ENABLE_DYNLD_LOG;
static void
dynld_log(const char *fmt, ...)
{
@@ -42,10 +40,9 @@ dynld_log(const char *fmt, ...)
}
}
#else
#define dynld_log(fmt, ...)
# define dynld_log(fmt, ...)
#endif
void *
dynld_module(const char *name, dllimp_t *table)
{
@@ -56,32 +53,31 @@ dynld_module(const char *name, dllimp_t *table)
/* See if we can load the desired module. */
if ((h = LoadLibrary(name)) == NULL) {
dynld_log("DynLd(\"%s\"): library not found! (%08X)\n", name, GetLastError());
return(NULL);
return (NULL);
}
/* Now load the desired function pointers. */
for (imp=table; imp->name!=NULL; imp++) {
for (imp = table; imp->name != NULL; imp++) {
func = GetProcAddress(h, imp->name);
if (func == NULL) {
dynld_log("DynLd(\"%s\"): function '%s' not found! (%08X)\n",
name, imp->name, GetLastError());
FreeLibrary(h);
return(NULL);
return (NULL);
}
/* To overcome typing issues.. */
*(char **)imp->func = (char *)func;
*(char **) imp->func = (char *) func;
}
/* All good. */
dynld_log("loaded %s\n", name);
return((void *)h);
return ((void *) h);
}
void
dynld_close(void *handle)
{
if (handle != NULL)
FreeLibrary((HMODULE)handle);
FreeLibrary((HMODULE) handle);
}

View File

@@ -31,19 +31,20 @@
HICON hIcon[256]; /* icon data loaded from resources */
char icon_set[256] = ""; /* name of the iconset to be used */
void win_clear_icon_set()
void
win_clear_icon_set()
{
int i;
for (i = 0; i < 256; i++)
if (hIcon[i] != 0)
{
if (hIcon[i] != 0) {
DestroyIcon(hIcon[i]);
hIcon[i] = 0;
}
}
void win_system_icon_set()
void
win_system_icon_set()
{
int i, x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi);
@@ -54,66 +55,66 @@ void win_system_icon_set()
typedef struct
{
int id;
char* filename;
char *filename;
} _ICON_DATA;
const _ICON_DATA icon_files[] =
{
{16, "floppy_525.ico"},
{17, "floppy_525_active.ico"},
{24, "floppy_35.ico"},
{25, "floppy_35_active.ico"},
{32, "cdrom.ico"},
{33, "cdrom_active.ico"},
{48, "zip.ico"},
{49, "zip_active.ico"},
{56, "mo.ico"},
{57, "mo_active.ico"},
{64, "cassette.ico"},
{65, "cassette_active.ico"},
{80, "hard_disk.ico"},
{81, "hard_disk_active.ico"},
{96, "network.ico"},
{97, "network_active.ico"},
{104, "cartridge.ico"},
{144, "floppy_525_empty.ico"},
{145, "floppy_525_empty_active.ico"},
{152, "floppy_35_empty.ico"},
{153, "floppy_35_empty_active.ico"},
{160, "cdrom_empty.ico"},
{161, "cdrom_empty_active.ico"},
{176, "zip_empty.ico"},
{177, "zip_empty_active.ico"},
{184, "mo_empty.ico"},
{185, "mo_empty_active.ico"},
{192, "cassette_empty.ico"},
{193, "cassette_empty_active.ico"},
{200, "run.ico"},
{201, "pause.ico"},
{202, "send_cad.ico"},
{203, "send_cae.ico"},
{204, "hard_reset.ico"},
{205, "acpi_shutdown.ico"},
{206, "settings.ico"},
{232, "cartridge_empty.ico"},
{240, "machine.ico"},
{241, "display.ico"},
{242, "input_devices.ico"},
{243, "sound.ico"},
{244, "ports.ico"},
{245, "other_peripherals.ico"},
{246, "floppy_and_cdrom_drives.ico"},
{247, "other_removable_devices.ico"},
{248, "floppy_disabled.ico"},
{249, "cdrom_disabled.ico"},
{250, "zip_disabled.ico"},
{251, "mo_disabled.ico"},
{252, "storage_controllers.ico"}
};
const _ICON_DATA icon_files[] = {
{16, "floppy_525.ico" },
{ 17, "floppy_525_active.ico" },
{ 24, "floppy_35.ico" },
{ 25, "floppy_35_active.ico" },
{ 32, "cdrom.ico" },
{ 33, "cdrom_active.ico" },
{ 48, "zip.ico" },
{ 49, "zip_active.ico" },
{ 56, "mo.ico" },
{ 57, "mo_active.ico" },
{ 64, "cassette.ico" },
{ 65, "cassette_active.ico" },
{ 80, "hard_disk.ico" },
{ 81, "hard_disk_active.ico" },
{ 96, "network.ico" },
{ 97, "network_active.ico" },
{ 104, "cartridge.ico" },
{ 144, "floppy_525_empty.ico" },
{ 145, "floppy_525_empty_active.ico"},
{ 152, "floppy_35_empty.ico" },
{ 153, "floppy_35_empty_active.ico" },
{ 160, "cdrom_empty.ico" },
{ 161, "cdrom_empty_active.ico" },
{ 176, "zip_empty.ico" },
{ 177, "zip_empty_active.ico" },
{ 184, "mo_empty.ico" },
{ 185, "mo_empty_active.ico" },
{ 192, "cassette_empty.ico" },
{ 193, "cassette_empty_active.ico" },
{ 200, "run.ico" },
{ 201, "pause.ico" },
{ 202, "send_cad.ico" },
{ 203, "send_cae.ico" },
{ 204, "hard_reset.ico" },
{ 205, "acpi_shutdown.ico" },
{ 206, "settings.ico" },
{ 232, "cartridge_empty.ico" },
{ 240, "machine.ico" },
{ 241, "display.ico" },
{ 242, "input_devices.ico" },
{ 243, "sound.ico" },
{ 244, "ports.ico" },
{ 245, "other_peripherals.ico" },
{ 246, "floppy_and_cdrom_drives.ico"},
{ 247, "other_removable_devices.ico"},
{ 248, "floppy_disabled.ico" },
{ 249, "cdrom_disabled.ico" },
{ 250, "zip_disabled.ico" },
{ 251, "mo_disabled.ico" },
{ 252, "storage_controllers.ico" }
};
void win_get_icons_path(char* path_root)
void
win_get_icons_path(char *path_root)
{
char roms_root[1024] = {0};
char roms_root[1024] = { 0 };
if (rom_path[0])
strcpy(roms_root, rom_path);
else
@@ -123,7 +124,8 @@ void win_get_icons_path(char* path_root)
path_slash(path_root);
}
void win_load_icon_set()
void
win_load_icon_set()
{
win_clear_icon_set();
win_system_icon_set();
@@ -133,8 +135,8 @@ void win_load_icon_set()
return;
}
char path_root[2048] = {0}, temp[2048] = {0};
wchar_t wtemp[2048] = {0};
char path_root[2048] = { 0 }, temp[2048] = { 0 };
wchar_t wtemp[2048] = { 0 };
win_get_icons_path(path_root);
strcat(path_root, icon_set);
@@ -142,15 +144,13 @@ void win_load_icon_set()
int i, count = sizeof(icon_files) / sizeof(_ICON_DATA),
x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi);
for (i = 0; i < count; i++)
{
for (i = 0; i < count; i++) {
path_append_filename(temp, path_root, icon_files[i].filename);
mbstoc16s(wtemp, temp, strlen(temp) + 1);
HICON ictemp;
ictemp = LoadImageW(NULL, (LPWSTR)wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR);
if (ictemp)
{
ictemp = LoadImageW(NULL, (LPWSTR) wtemp, IMAGE_ICON, x, y, LR_LOADFROMFILE | LR_DEFAULTCOLOR);
if (ictemp) {
if (hIcon[icon_files[i].id])
DestroyIcon(hIcon[icon_files[i].id]);
hIcon[icon_files[i].id] = ictemp;

View File

@@ -36,7 +36,6 @@
#ifdef ENABLE_JOYSTICK_LOG
int joystick_do_log = ENABLE_JOYSTICK_LOG;
static void
joystick_log(const char *fmt, ...)
{
@@ -49,7 +48,7 @@ joystick_log(const char *fmt, ...)
}
}
#else
#define joystick_log(fmt, ...)
# define joystick_log(fmt, ...)
#endif
typedef struct {
@@ -81,17 +80,24 @@ int joysticks_present = 0;
raw_joystick_t raw_joystick_state[MAX_PLAT_JOYSTICKS];
/* We only use the first 32 buttons reported, from Usage ID 1-128 */
void joystick_add_button(raw_joystick_t* rawjoy, plat_joystick_t* joy, USAGE usage) {
if (joy->nr_buttons >= 32) return;
if (usage < 1 || usage > 128) return;
void
joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage)
{
if (joy->nr_buttons >= 32)
return;
if (usage < 1 || usage > 128)
return;
rawjoy->usage_button[usage] = joy->nr_buttons;
sprintf(joy->button[joy->nr_buttons].name, "Button %d", usage);
joy->nr_buttons++;
}
void joystick_add_axis(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE_CAPS prop) {
if (joy->nr_axes >= 8) return;
void
joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop)
{
if (joy->nr_axes >= 8)
return;
switch (prop->Range.UsageMin) {
case HID_USAGE_GENERIC_X:
@@ -136,10 +142,13 @@ void joystick_add_axis(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE
joy->nr_axes++;
}
void joystick_add_pov(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE_CAPS prop) {
if (joy->nr_povs >= 4) return;
void
joystick_add_pov(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop)
{
if (joy->nr_povs >= 4)
return;
sprintf(joy->pov[joy->nr_povs].name, "POV %d", joy->nr_povs+1);
sprintf(joy->pov[joy->nr_povs].name, "POV %d", joy->nr_povs + 1);
rawjoy->pov[joy->nr_povs].usage = prop->Range.UsageMin;
rawjoy->pov[joy->nr_povs].link = prop->LinkCollection;
rawjoy->pov[joy->nr_povs].min = prop->LogicalMin;
@@ -148,7 +157,9 @@ void joystick_add_pov(raw_joystick_t* rawjoy, plat_joystick_t* joy, PHIDP_VALUE_
joy->nr_povs++;
}
void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) {
void
joystick_get_capabilities(raw_joystick_t *rawjoy, plat_joystick_t *joy)
{
UINT size = 0;
PHIDP_BUTTON_CAPS btn_caps = NULL;
PHIDP_VALUE_CAPS val_caps = NULL;
@@ -170,11 +181,12 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) {
goto end;
}
/* We only detect generic stuff */
for (int c=0; c<caps.NumberInputButtonCaps; c++) {
if (btn_caps[c].UsagePage != HID_USAGE_PAGE_BUTTON) continue;
for (int c = 0; c < caps.NumberInputButtonCaps; c++) {
if (btn_caps[c].UsagePage != HID_USAGE_PAGE_BUTTON)
continue;
int button_count = btn_caps[c].Range.UsageMax - btn_caps[c].Range.UsageMin + 1;
for (int b=0; b<button_count; b++) {
for (int b = 0; b < button_count; b++) {
joystick_add_button(rawjoy, joy, b + btn_caps[c].Range.UsageMin);
}
}
@@ -188,8 +200,9 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) {
goto end;
}
/* We only detect generic stuff */
for (int c=0; c<caps.NumberInputValueCaps; c++) {
if (val_caps[c].UsagePage != HID_USAGE_PAGE_GENERIC) continue;
for (int c = 0; c < caps.NumberInputValueCaps; c++) {
if (val_caps[c].UsagePage != HID_USAGE_PAGE_GENERIC)
continue;
if (val_caps[c].Range.UsageMin == HID_USAGE_GENERIC_HATSWITCH)
joystick_add_pov(rawjoy, joy, &val_caps[c]);
@@ -198,15 +211,17 @@ void joystick_get_capabilities(raw_joystick_t* rawjoy, plat_joystick_t* joy) {
}
}
end:
end:
free(btn_caps);
free(val_caps);
}
void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID_DEVICE_INFO info) {
void
joystick_get_device_name(raw_joystick_t *rawjoy, plat_joystick_t *joy, PRID_DEVICE_INFO info)
{
UINT size = 0;
char *device_name = NULL;
WCHAR device_desc_wide[200] = {0};
WCHAR device_desc_wide[200] = { 0 };
GetRawInputDeviceInfoA(rawjoy->hdevice, RIDI_DEVICENAME, device_name, &size);
device_name = calloc(size, sizeof(char));
@@ -230,7 +245,8 @@ void joystick_get_device_name(raw_joystick_t* rawjoy, plat_joystick_t* joy, PRID
info->hid.dwProductId);
}
void joystick_init()
void
joystick_init()
{
UINT size = 0;
atexit(joystick_close);
@@ -244,11 +260,13 @@ void joystick_init()
PRAWINPUTDEVICELIST deviceList = calloc(raw_devices, sizeof(RAWINPUTDEVICELIST));
GetRawInputDeviceList(deviceList, &raw_devices, sizeof(RAWINPUTDEVICELIST));
for (int i=0; i<raw_devices; i++) {
for (int i = 0; i < raw_devices; i++) {
PRID_DEVICE_INFO info = NULL;
if (joysticks_present >= MAX_PLAT_JOYSTICKS) break;
if (deviceList[i].dwType != RIM_TYPEHID) continue;
if (joysticks_present >= MAX_PLAT_JOYSTICKS)
break;
if (deviceList[i].dwType != RIM_TYPEHID)
continue;
/* Get device info: hardware IDs and usage IDs */
GetRawInputDeviceInfoA(deviceList[i].hDevice, RIDI_DEVICEINFO, NULL, &size);
@@ -258,9 +276,10 @@ void joystick_init()
goto end_loop;
/* If this is not a joystick/gamepad, skip */
if (info->hid.usUsagePage != HID_USAGE_PAGE_GENERIC) goto end_loop;
if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK &&
info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD) goto end_loop;
if (info->hid.usUsagePage != HID_USAGE_PAGE_GENERIC)
goto end_loop;
if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD)
goto end_loop;
plat_joystick_t *joy = &plat_joystick_state[joysticks_present];
raw_joystick_t *rawjoy = &raw_joystick_state[joysticks_present];
@@ -274,7 +293,7 @@ void joystick_init()
joysticks_present++;
end_loop:
end_loop:
free(info);
}
@@ -296,7 +315,8 @@ void joystick_init()
fatal("plat_joystick_init: RegisterRawInputDevices failed\n");
}
void joystick_close()
void
joystick_close()
{
RAWINPUTDEVICE ridev[2];
ridev[0].dwFlags = RIDEV_REMOVE;
@@ -312,50 +332,51 @@ void joystick_close()
RegisterRawInputDevices(ridev, 2, sizeof(RAWINPUTDEVICE));
}
void win_joystick_handle(PRAWINPUT raw)
void
win_joystick_handle(PRAWINPUT raw)
{
HRESULT r;
int j = -1; /* current joystick index, -1 when not found */
/* If the input is not from a known device, we ignore it */
for (int i=0; i<joysticks_present; i++) {
for (int i = 0; i < joysticks_present; i++) {
if (raw_joystick_state[i].hdevice == raw->header.hDevice) {
j = i;
break;
}
}
if (j == -1) return;
if (j == -1)
return;
/* Read buttons */
USAGE usage_list[128] = {0};
USAGE usage_list[128] = { 0 };
ULONG usage_length = plat_joystick_state[j].nr_buttons;
memset(plat_joystick_state[j].b, 0, 32 * sizeof(int));
r = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON, 0, usage_list, &usage_length,
raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
raw_joystick_state[j].data, (PCHAR) raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
if (r == HIDP_STATUS_SUCCESS) {
for (int i=0; i<usage_length; i++) {
for (int i = 0; i < usage_length; i++) {
int button = raw_joystick_state[j].usage_button[usage_list[i]];
plat_joystick_state[j].b[button] = 128;
}
}
/* Read axes */
for (int a=0; a<plat_joystick_state[j].nr_axes; a++) {
struct raw_axis_t* axis = &raw_joystick_state[j].axis[a];
for (int a = 0; a < plat_joystick_state[j].nr_axes; a++) {
struct raw_axis_t *axis = &raw_joystick_state[j].axis[a];
ULONG uvalue = 0;
LONG value = 0;
LONG center = (axis->max - axis->min + 1) / 2;
r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, axis->link, axis->usage, &uvalue,
raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
raw_joystick_state[j].data, (PCHAR) raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
if (r == HIDP_STATUS_SUCCESS) {
if (axis->min < 0) {
/* extend signed uvalue to LONG */
if (uvalue & (1 << (axis->bitsize-1))) {
if (uvalue & (1 << (axis->bitsize - 1))) {
ULONG mask = (1 << axis->bitsize) - 1;
value = -1U ^ mask;
value |= uvalue;
@@ -364,24 +385,25 @@ void win_joystick_handle(PRAWINPUT raw)
}
} else {
/* Assume unsigned when min >= 0, convert to a signed value */
value = (LONG)uvalue - center;
value = (LONG) uvalue - center;
}
if (abs(value) == 1) value = 0;
if (abs(value) == 1)
value = 0;
value = value * 32768 / center;
}
plat_joystick_state[j].a[a] = value;
//joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]);
// joystick_log("%s %-06d ", plat_joystick_state[j].axis[a].name, plat_joystick_state[j].a[a]);
}
/* read povs */
for (int p=0; p<plat_joystick_state[j].nr_povs; p++) {
struct raw_pov_t* pov = &raw_joystick_state[j].pov[p];
for (int p = 0; p < plat_joystick_state[j].nr_povs; p++) {
struct raw_pov_t *pov = &raw_joystick_state[j].pov[p];
ULONG uvalue = 0;
LONG value = -1;
r = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, pov->link, pov->usage, &uvalue,
raw_joystick_state[j].data, (PCHAR)raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
raw_joystick_state[j].data, (PCHAR) raw->data.hid.bRawData, raw->data.hid.dwSizeHid);
if (r == HIDP_STATUS_SUCCESS && (uvalue >= pov->min && uvalue <= pov->max)) {
value = (uvalue - pov->min) * 36000;
@@ -391,48 +413,41 @@ void win_joystick_handle(PRAWINPUT raw)
plat_joystick_state[j].p[p] = value;
//joystick_log("%s %-3d ", plat_joystick_state[j].pov[p].name, plat_joystick_state[j].p[p]);
// joystick_log("%s %-3d ", plat_joystick_state[j].pov[p].name, plat_joystick_state[j].p[p]);
}
//joystick_log("\n");
// joystick_log("\n");
}
static int joystick_get_axis(int joystick_nr, int mapping)
static int
joystick_get_axis(int joystick_nr, int mapping)
{
if (mapping & POV_X)
{
if (mapping & POV_X) {
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return sin((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else if (mapping & POV_Y)
{
return sin((2 * M_PI * (double) pov) / 36000.0) * 32767;
} else if (mapping & POV_Y) {
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return -cos((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else
return -cos((2 * M_PI * (double) pov) / 36000.0) * 32767;
} else
return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id];
}
void joystick_process(void)
void
joystick_process(void)
{
int c, d;
if (joystick_type == 7) return;
if (joystick_type == 7)
return;
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
if (joystick_state[c].plat_joystick_nr)
{
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) {
if (joystick_state[c].plat_joystick_nr) {
int joystick_nr = joystick_state[c].plat_joystick_nr - 1;
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
@@ -440,25 +455,22 @@ void joystick_process(void)
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]];
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
for (d = 0; d < joystick_get_pov_count(joystick_type); d++) {
int x, y;
double angle, magnitude;
x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]);
y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]);
angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI);
magnitude = sqrt((double)x*(double)x + (double)y*(double)y);
angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
if (magnitude < 16384)
joystick_state[c].pov[d] = -1;
else
joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360;
joystick_state[c].pov[d] = ((int) angle + 90 + 360) % 360;
}
}
else
{
} else {
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
joystick_state[c].axis[d] = 0;
for (d = 0; d < joystick_get_button_count(joystick_type); d++)

View File

@@ -55,7 +55,6 @@
#ifdef ENABLE_JOYSTICK_LOG
int joystick_do_log = ENABLE_JOYSTICK_LOG;
static void
joystick_log(const char *fmt, ...)
{
@@ -68,7 +67,7 @@ joystick_log(const char *fmt, ...)
}
}
#else
#define joystick_log(fmt, ...)
# define joystick_log(fmt, ...)
#endif
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
@@ -77,7 +76,8 @@ int joysticks_present = 0;
XINPUT_STATE controllers[XINPUT_MAX_JOYSTICKS];
void joystick_init()
void
joystick_init()
{
int c;
@@ -87,9 +87,10 @@ void joystick_init()
memset(controllers, 0, sizeof(XINPUT_STATE) * XINPUT_MAX_JOYSTICKS);
for (c=0; c<XINPUT_MAX_JOYSTICKS; c++) {
for (c = 0; c < XINPUT_MAX_JOYSTICKS; c++) {
int value = XInputGetState(c, &controllers[c]);
if (value != ERROR_SUCCESS) continue;
if (value != ERROR_SUCCESS)
continue;
memcpy(plat_joystick_state[c].name, XINPUT_NAME, sizeof(XINPUT_NAME));
plat_joystick_state[c].nr_axes = 8;
@@ -137,22 +138,25 @@ void joystick_init()
joystick_log("joystick_init: joysticks_present=%i\n", joysticks_present);
}
void joystick_close()
void
joystick_close()
{
}
void joystick_poll(void)
void
joystick_poll(void)
{
for (int c=0; c<joysticks_present; c++) {
for (int c = 0; c < joysticks_present; c++) {
int value = XInputGetState(c, &controllers[c]);
if (value != ERROR_SUCCESS) continue;
if (value != ERROR_SUCCESS)
continue;
plat_joystick_state[c].a[0] = controllers[c].Gamepad.sThumbLX;
plat_joystick_state[c].a[1] = - controllers[c].Gamepad.sThumbLY;
plat_joystick_state[c].a[1] = -controllers[c].Gamepad.sThumbLY;
plat_joystick_state[c].a[3] = controllers[c].Gamepad.sThumbRX;
plat_joystick_state[c].a[4] = - controllers[c].Gamepad.sThumbRY;
plat_joystick_state[c].a[6] = (double)controllers[c].Gamepad.bLeftTrigger / 255 * 32767;
plat_joystick_state[c].a[7] = (double)controllers[c].Gamepad.bRightTrigger / 255 * 32767;
plat_joystick_state[c].a[4] = -controllers[c].Gamepad.sThumbRY;
plat_joystick_state[c].a[6] = (double) controllers[c].Gamepad.bLeftTrigger / 255 * 32767;
plat_joystick_state[c].a[7] = (double) controllers[c].Gamepad.bRightTrigger / 255 * 32767;
plat_joystick_state[c].b[0] = (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_A) ? 128 : 0;
plat_joystick_state[c].b[1] = (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_B) ? 128 : 0;
@@ -169,18 +173,18 @@ void joystick_poll(void)
int dpad_x = 0, dpad_y = 0;
if (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
dpad_y-=32767;
dpad_y -= 32767;
if (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
dpad_y+=32767;
dpad_y += 32767;
if (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
dpad_x-=32767;
dpad_x -= 32767;
if (controllers[c].Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
dpad_x+=32767;
dpad_x += 32767;
plat_joystick_state[c].a[2] = dpad_x;
plat_joystick_state[c].a[5] = dpad_y;
for (int a=0; a<8; a++) {
for (int a = 0; a < 8; a++) {
if (plat_joystick_state[c].a[a] == -32768)
plat_joystick_state[c].a[a] = -32767;
if (plat_joystick_state[c].a[a] == 32768)
@@ -189,42 +193,39 @@ void joystick_poll(void)
}
}
static int joystick_get_axis(int joystick_nr, int mapping)
static int
joystick_get_axis(int joystick_nr, int mapping)
{
if (mapping & POV_X)
{
if (mapping & POV_X) {
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return sin((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else if (mapping & POV_Y)
{
return sin((2 * M_PI * (double) pov) / 36000.0) * 32767;
} else if (mapping & POV_Y) {
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return -cos((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else
return -cos((2 * M_PI * (double) pov) / 36000.0) * 32767;
} else
return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id];
}
void joystick_process(void)
void
joystick_process(void)
{
int c, d;
if (!joystick_type) return;
if (!joystick_type)
return;
joystick_poll();
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
if (joystick_state[c].plat_joystick_nr)
{
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) {
if (joystick_state[c].plat_joystick_nr) {
int joystick_nr = joystick_state[c].plat_joystick_nr - 1;
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
@@ -232,25 +233,22 @@ void joystick_process(void)
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]];
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
for (d = 0; d < joystick_get_pov_count(joystick_type); d++) {
int x, y;
double angle, magnitude;
x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]);
y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]);
angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI);
magnitude = sqrt((double)x*(double)x + (double)y*(double)y);
angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
if (magnitude < 16384)
joystick_state[c].pov[d] = -1;
else
joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360;
joystick_state[c].pov[d] = ((int) angle + 90 + 360) % 360;
}
}
else
{
} else {
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
joystick_state[c].axis[d] = 0;
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
@@ -261,4 +259,7 @@ void joystick_process(void)
}
}
void win_joystick_handle(PRAWINPUT raw) {}
void
win_joystick_handle(PRAWINPUT raw)
{
}

View File

@@ -14,16 +14,15 @@
#include <86box/plat.h>
#include <86box/win.h>
static int joystick_nr;
static int joystick_config_type;
#define AXIS_STRINGS_MAX 3
static char *axis_strings[AXIS_STRINGS_MAX] = {"X Axis", "Y Axis", "Z Axis"};
static char *axis_strings[AXIS_STRINGS_MAX] = { "X Axis", "Y Axis", "Z Axis" };
static uint8_t joystickconfig_changed = 0;
static void rebuild_axis_button_selections(HWND hdlg)
static void
rebuild_axis_button_selections(HWND hdlg)
{
int id = IDC_CONFIG_BASE + 2;
HWND h;
@@ -34,106 +33,90 @@ static void rebuild_axis_button_selections(HWND hdlg)
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
joystick = SendMessage(h, CB_GETCURSEL, 0, 0);
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++) {
int sel = c;
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
if (c < AXIS_STRINGS_MAX)
{
if (!stricmp(axis_strings[c], plat_joystick_state[joystick-1].axis[d].name))
if (joystick) {
for (d = 0; d < plat_joystick_state[joystick - 1].nr_axes; d++) {
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) plat_joystick_state[joystick - 1].axis[d].name);
if (c < AXIS_STRINGS_MAX) {
if (!stricmp(axis_strings[c], plat_joystick_state[joystick - 1].axis[d].name))
sel = d;
}
}
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
{
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
for (d = 0; d < plat_joystick_state[joystick - 1].nr_povs; d++) {
sprintf(s, "%s (X axis)", plat_joystick_state[joystick - 1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick - 1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) s);
}
for (d = 0; d < plat_joystick_state[joystick - 1].nr_sliders; d++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick - 1].slider[d].name);
for (d = 0; d < plat_joystick_state[joystick - 1].nr_sliders; d++) {
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) plat_joystick_state[joystick - 1].slider[d].name);
}
SendMessage(h, CB_SETCURSEL, sel, 0);
EnableWindow(h, TRUE);
}
else
} else
EnableWindow(h, FALSE);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_buttons; d++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].button[d].name);
if (joystick) {
for (d = 0; d < plat_joystick_state[joystick - 1].nr_buttons; d++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) plat_joystick_state[joystick - 1].button[d].name);
SendMessage(h, CB_SETCURSEL, c, 0);
EnableWindow(h, TRUE);
}
else
} else
EnableWindow(h, FALSE);
id += 2;
}
for (c = 0; c < joystick_get_pov_count(joystick_config_type)*2; c++)
{
for (c = 0; c < joystick_get_pov_count(joystick_config_type) * 2; c++) {
int sel = c;
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
{
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
if (joystick) {
for (d = 0; d < plat_joystick_state[joystick - 1].nr_povs; d++) {
sprintf(s, "%s (X axis)", plat_joystick_state[joystick - 1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick - 1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) s);
}
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
for (d = 0; d < plat_joystick_state[joystick - 1].nr_axes; d++) {
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) plat_joystick_state[joystick - 1].axis[d].name);
}
SendMessage(h, CB_SETCURSEL, sel, 0);
EnableWindow(h, TRUE);
}
else
} else
EnableWindow(h, FALSE);
id += 2;
}
}
static int get_axis(HWND hdlg, int id)
static int
get_axis(HWND hdlg, int id)
{
HWND h = GetDlgItem(hdlg, id);
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
int nr_axes = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_axes;
int nr_axes = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr - 1].nr_axes;
int nr_povs = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr - 1].nr_povs;
if (axis_sel < nr_axes)
return axis_sel;
axis_sel -= nr_axes;
if (axis_sel < nr_povs * 2)
{
if (axis_sel < nr_povs * 2) {
if (axis_sel & 1)
return POV_Y | (axis_sel >> 1);
else
@@ -144,14 +127,14 @@ static int get_axis(HWND hdlg, int id)
return SLIDER | (axis_sel >> 1);
}
static int get_pov(HWND hdlg, int id)
static int
get_pov(HWND hdlg, int id)
{
HWND h = GetDlgItem(hdlg, id);
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
int nr_povs = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_povs*2;
int nr_povs = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr - 1].nr_povs * 2;
if (axis_sel < nr_povs)
{
if (axis_sel < nr_povs) {
if (axis_sel & 1)
return POV_Y | (axis_sel >> 1);
else
@@ -176,68 +159,63 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
int nr_povs;
int mapping;
switch (message)
{
switch (message) {
case WM_INITDIALOG:
{
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
id = IDC_CONFIG_BASE + 2;
joystick = joystick_state[joystick_nr].plat_joystick_nr;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "None");
for (c = 0; c < joysticks_present; c++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) plat_joystick_state[c].name);
SendMessage(h, CB_SETCURSEL, joystick, 0);
rebuild_axis_button_selections(hdlg);
if (joystick_state[joystick_nr].plat_joystick_nr)
{
nr_axes = plat_joystick_state[joystick-1].nr_axes;
nr_povs = plat_joystick_state[joystick-1].nr_povs;
if (joystick_state[joystick_nr].plat_joystick_nr) {
nr_axes = plat_joystick_state[joystick - 1].nr_axes;
nr_povs = plat_joystick_state[joystick - 1].nr_povs;
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++) {
int mapping = joystick_state[joystick_nr].axis_mapping[c];
h = GetDlgItem(hdlg, id);
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0);
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3) * 2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0);
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3) * 2 + 1, 0);
else if (mapping & SLIDER)
SendMessage(h, CB_SETCURSEL, nr_axes + nr_povs * 2 + (mapping & 3), 0);
else
SendMessage(h, CB_SETCURSEL, mapping, 0);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_SETCURSEL, joystick_state[joystick_nr].button_mapping[c], 0);
id += 2;
}
for (c = 0; c < joystick_get_pov_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_pov_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][0];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
SendMessage(h, CB_SETCURSEL, (mapping & 3) * 2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
SendMessage(h, CB_SETCURSEL, (mapping & 3) * 2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
SendMessage(h, CB_SETCURSEL, mapping + nr_povs * 2, 0);
id += 2;
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
SendMessage(h, CB_SETCURSEL, (mapping & 3) * 2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
SendMessage(h, CB_SETCURSEL, (mapping & 3) * 2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
SendMessage(h, CB_SETCURSEL, mapping + nr_povs * 2, 0);
id += 2;
}
}
@@ -245,8 +223,7 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
switch (LOWORD(wParam)) {
case IDC_CONFIG_BASE:
if (HIWORD(wParam) == CBN_SELCHANGE)
rebuild_axis_button_selections(hdlg);
@@ -259,21 +236,17 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
joystick_state[joystick_nr].plat_joystick_nr = SendMessage(h, CB_GETCURSEL, 0, 0);
if (joystick_state[joystick_nr].plat_joystick_nr)
{
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
if (joystick_state[joystick_nr].plat_joystick_nr) {
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++) {
joystick_state[joystick_nr].axis_mapping[c] = get_axis(hdlg, id);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
joystick_state[joystick_nr].button_mapping[c] = SendMessage(h, CB_GETCURSEL, 0, 0);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
joystick_state[joystick_nr].pov_mapping[c][0] = get_pov(hdlg, id);
id += 2;
@@ -296,11 +269,12 @@ joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
uint8_t
joystickconfig_open(HWND hwnd, int joy_nr, int type)
{
uint16_t *data_block = malloc(16384);
uint16_t *data;
DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block;
DLGTEMPLATE *dlg = (DLGTEMPLATE *) data_block;
DLGITEMTEMPLATE *item;
int y = 10;
int id = IDC_CONFIG_BASE;
@@ -320,7 +294,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
dlg->cx = 220;
dlg->cy = 70;
data = (uint16_t *)(dlg + 1);
data = (uint16_t *) (dlg + 1);
*data++ = 0; /*no menu*/
*data++ = 0; /*predefined dialog box class*/
@@ -329,12 +303,11 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
*data++ = 9; /*Point*/
data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 50);
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -344,18 +317,18 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -365,23 +338,21 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
for (c = 0; c < joystick_get_axis_count(type); c++)
{
for (c = 0; c < joystick_get_axis_count(type); c++) {
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -391,18 +362,18 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -412,23 +383,22 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
}
for (c = 0; c < joystick_get_button_count(type); c++)
{
for (c = 0; c < joystick_get_button_count(type); c++) {
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -438,18 +408,18 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -459,23 +429,22 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
}
for (c = 0; c < joystick_get_pov_count(type)*2; c++)
{
for (c = 0; c < joystick_get_pov_count(type) * 2; c++) {
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 70;
item->y = y;
item->id = id++;
@@ -485,22 +454,22 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
if (c & 1)
sprintf(s, "%s (Y axis)", joystick_get_pov_name(type, c/2));
sprintf(s, "%s (Y axis)", joystick_get_pov_name(type, c / 2));
else
sprintf(s, "%s (X axis)", joystick_get_pov_name(type, c/2));
sprintf(s, "%s (X axis)", joystick_get_pov_name(type, c / 2));
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 10;
item->y = y + 2;
item->id = id++;
@@ -510,14 +479,14 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
y += 20;
@@ -525,7 +494,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 100;
item->y = y + 5;
item->cx = 50;
@@ -533,17 +502,17 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->id = IDOK; /* OK button identifier */
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
if (((uintptr_t) data) & 2)
data++;
item = (DLGITEMTEMPLATE *)data;
item = (DLGITEMTEMPLATE *) data;
item->x = 160;
item->y = y + 5;
item->cx = 50;
@@ -551,7 +520,7 @@ uint8_t joystickconfig_open(HWND hwnd, int joy_nr, int type)
item->id = IDCANCEL; /* Cancel button identifier */
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
data = (uint16_t *) (item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; /* button class */

View File

@@ -30,10 +30,8 @@
#include <86box/plat.h>
#include <86box/win.h>
static uint16_t scancode_map[768];
/* This is so we can disambiguate scan codes that would otherwise conflict and get
passed on incorrectly. */
static UINT16
@@ -53,7 +51,6 @@ convert_scan_code(UINT16 scan_code)
return scan_code;
}
void
keyboard_getkeymap(void)
{
@@ -86,7 +83,7 @@ keyboard_getkeymap(void)
scMapCount = bufEx2[2];
if ((bufSize != 0) && (scMapCount != 0)) {
bufEx = (UINT16 *) (buf + 12);
for (j = 0; j < scMapCount*2; j += 2) {
for (j = 0; j < scMapCount * 2; j += 2) {
/* Each scan code is 32-bit: 16 bits of remapped scan code,
and 16 bits of original scan code. */
scancode_unmapped = bufEx[j + 1];
@@ -106,7 +103,6 @@ keyboard_getkeymap(void)
}
}
void
keyboard_handle(PRAWINPUT raw)
{
@@ -137,10 +133,7 @@ keyboard_handle(PRAWINPUT raw)
We use scan code 0xFFFF to mean a mapping that
has a prefix other than E0 and that is not E1 1D,
which is, for our purposes, invalid. */
if ((scancode == 0x00F) &&
!(rawKB.Flags & RI_KEY_BREAK) &&
(recv_lalt || recv_ralt) &&
!mouse_capture) {
if ((scancode == 0x00F) && !(rawKB.Flags & RI_KEY_BREAK) && (recv_lalt || recv_ralt) && !mouse_capture) {
/* We received a TAB while ALT was pressed, while the mouse
is not captured, suppress the TAB and send an ALT key up. */
if (recv_lalt) {
@@ -159,16 +152,13 @@ keyboard_handle(PRAWINPUT raw)
keyboard_input(0, 0x138);
recv_ralt = 0;
}
} else if (((scancode == 0x038) || (scancode == 0x138)) &&
!(rawKB.Flags & RI_KEY_BREAK) &&
recv_tab &&
!mouse_capture) {
} else if (((scancode == 0x038) || (scancode == 0x138)) && !(rawKB.Flags & RI_KEY_BREAK) && recv_tab && !mouse_capture) {
/* We received an ALT while TAB was pressed, while the mouse
is not captured, suppress the ALT and send a TAB key up. */
keyboard_input(0, 0x00F);
recv_tab = 0;
} else {
switch(scancode) {
switch (scancode) {
case 0x00F:
recv_tab = !(rawKB.Flags & RI_KEY_BREAK);
break;

View File

@@ -35,13 +35,11 @@
#define ZIP_FIRST CDROM_FIRST + CDROM_NUM
#define MO_FIRST ZIP_FIRST + ZIP_NUM
static HMENU media_menu, stbar_menu;
static HMENU menus[1 + 2 + FDD_NUM + CDROM_NUM + ZIP_NUM + MO_NUM];
static char index_map[255];
static void
media_menu_set_ids(HMENU hMenu, int id)
{
@@ -51,15 +49,13 @@ media_menu_set_ids(HMENU hMenu, int id)
mii.fMask = MIIM_ID;
mii.cbSize = sizeof(mii);
for(int i = 0; i < c; i++)
{
for (int i = 0; i < c; i++) {
GetMenuItemInfo(hMenu, i, TRUE, &mii);
mii.wID |= id;
SetMenuItemInfo(hMenu, i, TRUE, &mii);
}
}
/* Loads the submenu from resource by name */
static HMENU
media_menu_load_resource(wchar_t *lpName)
@@ -70,13 +66,12 @@ media_menu_load_resource(wchar_t *lpName)
HMENU actual = GetSubMenu(loaded, 0);
/* Now that we have our submenu, we can destroy the parent menu */
RemoveMenu(loaded, (UINT_PTR)actual, MF_BYCOMMAND);
RemoveMenu(loaded, (UINT_PTR) actual, MF_BYCOMMAND);
DestroyMenu(loaded);
return actual;
}
static void
media_menu_set_name_cassette(void)
{
@@ -94,10 +89,9 @@ media_menu_set_name_cassette(void)
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[CASSETTE_FIRST], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[CASSETTE_FIRST], FALSE, &mii);
}
static void
media_menu_set_name_cartridge(int drive)
{
@@ -117,10 +111,9 @@ media_menu_set_name_cartridge(int drive)
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[CARTRIDGE_FIRST + drive], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[CARTRIDGE_FIRST + drive], FALSE, &mii);
}
static void
media_menu_set_name_floppy(int drive)
{
@@ -142,10 +135,9 @@ media_menu_set_name_floppy(int drive)
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[FDD_FIRST + drive], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[FDD_FIRST + drive], FALSE, &mii);
}
static void
media_menu_set_name_cdrom(int drive)
{
@@ -160,23 +152,22 @@ media_menu_set_name_cdrom(int drive)
if (cdrom[drive].host_drive == 200) {
if (strlen(cdrom[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_5120),
drive+1, temp, plat_get_string(IDS_2057));
drive + 1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, cdrom[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_5120),
drive+1, temp, fn);
drive + 1, temp, fn);
}
} else
_swprintf(name, plat_get_string(IDS_5120), drive+1, temp, plat_get_string(IDS_2057));
_swprintf(name, plat_get_string(IDS_5120), drive + 1, temp, plat_get_string(IDS_2057));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[CDROM_FIRST + drive], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[CDROM_FIRST + drive], FALSE, &mii);
}
static void
media_menu_set_name_zip(int drive)
{
@@ -192,21 +183,20 @@ media_menu_set_name_zip(int drive)
if (strlen(zip_drives[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_2054),
type, drive+1, temp, plat_get_string(IDS_2057));
type, drive + 1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, zip_drives[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_2054),
type, drive+1, temp, fn);
type, drive + 1, temp, fn);
}
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[ZIP_FIRST + drive], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[ZIP_FIRST + drive], FALSE, &mii);
}
static void
media_menu_set_name_mo(int drive)
{
@@ -220,21 +210,20 @@ media_menu_set_name_mo(int drive)
if (strlen(mo_drives[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_2115),
drive+1, temp, plat_get_string(IDS_2057));
drive + 1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, mo_drives[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_2115),
drive+1, temp, fn);
drive + 1, temp, fn);
}
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING;
mii.dwTypeData = name;
SetMenuItemInfo(media_menu, (UINT_PTR)menus[MO_FIRST + drive], FALSE, &mii);
SetMenuItemInfo(media_menu, (UINT_PTR) menus[MO_FIRST + drive], FALSE, &mii);
}
void
media_menu_update_cassette(void)
{
@@ -266,7 +255,6 @@ media_menu_update_cassette(void)
media_menu_set_name_cassette();
}
void
media_menu_update_cartridge(int id)
{
@@ -280,7 +268,6 @@ media_menu_update_cartridge(int id)
media_menu_set_name_cartridge(id);
}
void
media_menu_update_floppy(int id)
{
@@ -297,13 +284,12 @@ media_menu_update_floppy(int id)
media_menu_set_name_floppy(id);
}
void
media_menu_update_cdrom(int id)
{
int i = CDROM_FIRST + id;
if (! cdrom[id].sound_on)
if (!cdrom[id].sound_on)
CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_BYCOMMAND | MF_CHECKED);
else
CheckMenuItem(menus[i], IDM_CDROM_MUTE | id, MF_BYCOMMAND | MF_UNCHECKED);
@@ -319,7 +305,7 @@ media_menu_update_cdrom(int id)
CheckMenuItem(menus[i], IDM_CDROM_EMPTY | id, MF_BYCOMMAND | MF_CHECKED);
}
if(cdrom[id].prev_host_drive == 0)
if (cdrom[id].prev_host_drive == 0)
EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
@@ -327,7 +313,6 @@ media_menu_update_cdrom(int id)
media_menu_set_name_cdrom(id);
}
void
media_menu_update_zip(int id)
{
@@ -338,7 +323,7 @@ media_menu_update_zip(int id)
else
EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
if(strlen(zip_drives[id].prev_image_path) == 0)
if (strlen(zip_drives[id].prev_image_path) == 0)
EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
@@ -346,7 +331,6 @@ media_menu_update_zip(int id)
media_menu_set_name_zip(id);
}
void
media_menu_update_mo(int id)
{
@@ -357,7 +341,7 @@ media_menu_update_mo(int id)
else
EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
if(strlen(mo_drives[id].prev_image_path) == 0)
if (strlen(mo_drives[id].prev_image_path) == 0)
EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
@@ -365,7 +349,6 @@ media_menu_update_mo(int id)
media_menu_set_name_mo(id);
}
static void
media_menu_load_submenus()
{
@@ -376,152 +359,133 @@ media_menu_load_submenus()
menus[curr] = media_menu_load_resource(CASSETTE_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], 0);
for(int i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
menus[curr] = media_menu_load_resource(CARTRIDGE_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], i);
}
for(int i = 0; i < FDD_NUM; i++) {
for (int i = 0; i < FDD_NUM; i++) {
menus[curr] = media_menu_load_resource(FLOPPY_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], i);
}
for(int i = 0; i < CDROM_NUM; i++) {
for (int i = 0; i < CDROM_NUM; i++) {
menus[curr] = media_menu_load_resource(CDROM_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], i);
}
for(int i = 0; i < ZIP_NUM; i++) {
for (int i = 0; i < ZIP_NUM; i++) {
menus[curr] = media_menu_load_resource(ZIP_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], i);
}
for(int i = 0; i < MO_NUM; i++) {
for (int i = 0; i < MO_NUM; i++) {
menus[curr] = media_menu_load_resource(MO_SUBMENU_NAME);
media_menu_set_ids(menus[curr++], i);
}
}
static inline int
is_valid_cartridge(void)
{
return (machine_has_cartridge(machine));
}
static inline int
is_valid_fdd(int i)
{
return fdd_get_type(i) != 0;
}
static inline int
is_valid_cdrom(int i)
{
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !MACHINE_HAS_IDE &&
memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) &&
memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;
return cdrom[i].bus_type != 0;
}
static inline int
is_valid_zip(int i)
{
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !MACHINE_HAS_IDE &&
memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) &&
memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;
return zip_drives[i].bus_type != 0;
}
static inline int
is_valid_mo(int i)
{
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !MACHINE_HAS_IDE &&
memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) &&
memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !MACHINE_HAS_IDE && memcmp(hdc_get_internal_name(hdc_current), "xtide", 5) && memcmp(hdc_get_internal_name(hdc_current), "ide", 3))
return 0;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !MACHINE_HAS_SCSI &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !MACHINE_HAS_SCSI && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
return 0;
return mo_drives[i].bus_type != 0;
}
void
media_menu_reset()
{
/* Remove existing entries. */
int c = GetMenuItemCount(media_menu);
for(int i = 0; i < c; i++)
for (int i = 0; i < c; i++)
RemoveMenu(media_menu, 0, MF_BYPOSITION);
/* Add new ones. */
int curr = 0;
if(cassette_enable) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
if (cassette_enable) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_cassette();
}
curr++;
for(int i = 0; i < 2; i++) {
if(is_valid_cartridge()) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
for (int i = 0; i < 2; i++) {
if (is_valid_cartridge()) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_cartridge(i);
}
curr++;
}
for(int i = 0; i < FDD_NUM; i++) {
if(is_valid_fdd(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
for (int i = 0; i < FDD_NUM; i++) {
if (is_valid_fdd(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_floppy(i);
}
curr++;
}
for(int i = 0; i < CDROM_NUM; i++) {
if(is_valid_cdrom(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
for (int i = 0; i < CDROM_NUM; i++) {
if (is_valid_cdrom(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_cdrom(i);
}
curr++;
}
for(int i = 0; i < ZIP_NUM; i++) {
if(is_valid_zip(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
for (int i = 0; i < ZIP_NUM; i++) {
if (is_valid_zip(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_zip(i);
}
curr++;
}
for(int i = 0; i < MO_NUM; i++) {
if(is_valid_mo(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR)menus[curr], L"Test");
for (int i = 0; i < MO_NUM; i++) {
if (is_valid_mo(i)) {
AppendMenu(media_menu, MF_POPUP | MF_STRING, (UINT_PTR) menus[curr], L"Test");
media_menu_update_mo(i);
}
curr++;
}
}
/* Initializes the Media menu in the main menu bar. */
static void
media_menu_main_init()
@@ -538,14 +502,13 @@ media_menu_main_init()
GetMenuString(hMenu, IDM_MEDIA, lpMenuName, len + 1, MF_BYCOMMAND);
/* Replace the placeholder menu item */
ModifyMenu(hMenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR)media_menu, lpMenuName);
ModifyMenu(hMenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR) media_menu, lpMenuName);
/* Clean up */
DrawMenuBar(hwndMain);
free(lpMenuName);
}
void
media_menu_init()
{
@@ -554,7 +517,7 @@ media_menu_init()
/* Initialize the dummy status bar menu. */
stbar_menu = CreateMenu();
AppendMenu(stbar_menu, MF_POPUP, (UINT_PTR)media_menu, NULL);
AppendMenu(stbar_menu, MF_POPUP, (UINT_PTR) media_menu, NULL);
/* Load the submenus for each drive type. */
media_menu_load_submenus();
@@ -563,7 +526,6 @@ media_menu_init()
media_menu_reset();
}
int
media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -574,7 +536,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (LOWORD(wParam) & 0xff00) {
case IDM_CASSETTE_IMAGE_NEW:
ret = file_dlg_st(hwnd, IDS_2149, "", NULL, 1);
if (! ret) {
if (!ret) {
if (strlen(openfilestring) == 0)
cassette_mount(NULL, wp);
else
@@ -604,7 +566,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* FALLTHROUGH */
case IDM_CASSETTE_IMAGE_EXISTING:
ret = file_dlg_st(hwnd, IDS_2149, cassette_fname, NULL, 0);
if (! ret) {
if (!ret) {
if (strlen(openfilestring) == 0)
cassette_mount(NULL, wp);
else
@@ -618,7 +580,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_CARTRIDGE_IMAGE:
ret = file_dlg_st(hwnd, IDS_2151, cart_fns[id], NULL, 0);
if (! ret)
if (!ret)
cartridge_mount(id, openfilestring, wp);
break;
@@ -635,7 +597,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* FALLTHROUGH */
case IDM_FLOPPY_IMAGE_EXISTING:
ret = file_dlg_st(hwnd, IDS_2109, floppyfns[id], NULL, 0);
if (! ret)
if (!ret)
floppy_mount(id, openfilestring, wp);
break;
@@ -645,7 +607,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_FLOPPY_EXPORT_TO_86F:
ret = file_dlg_st(hwnd, IDS_2076, floppyfns[id], NULL, 1);
if (! ret) {
if (!ret) {
plat_pause(1);
ret = d86f_export(id, openfilestring);
if (!ret)
@@ -705,7 +667,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* FALLTHROUGH */
case IDM_ZIP_IMAGE_EXISTING:
ret = file_dlg_st(hwnd, IDS_2058, zip_drives[id].image_path, NULL, 0);
if (! ret)
if (!ret)
zip_mount(id, openfilestring, wp);
break;
@@ -726,7 +688,7 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* FALLTHROUGH */
case IDM_MO_IMAGE_EXISTING:
ret = file_dlg_st(hwnd, IDS_2116, mo_drives[id].image_path, NULL, 0);
if (! ret)
if (!ret)
mo_mount(id, openfilestring, wp);
break;
@@ -739,48 +701,42 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
default:
return(0);
return (0);
}
return(1);
return (1);
}
HMENU
media_menu_get_cassette(void)
{
return menus[CASSETTE_FIRST];
}
HMENU
media_menu_get_cartridge(int id)
{
return menus[CARTRIDGE_FIRST + id];
}
HMENU
media_menu_get_floppy(int id)
{
return menus[FDD_FIRST + id];
}
HMENU
media_menu_get_cdrom(int id)
{
return menus[CDROM_FIRST + id];
}
HMENU
media_menu_get_zip(int id)
{
return menus[ZIP_FIRST + id];
}
HMENU
media_menu_get_mo(int id)
{

View File

@@ -52,7 +52,7 @@ win_mouse_init(void)
ridev.hwndTarget = NULL;
ridev.usUsagePage = 0x01;
ridev.usUsage = 0x02;
if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev)))
if (!RegisterRawInputDevices(&ridev, 1, sizeof(ridev)))
fatal("plat_mouse_init: RegisterRawInputDevices failed\n");
memset(&mousestate, 0, sizeof(MOUSESTATE));
@@ -81,19 +81,18 @@ win_mouse_handle(PRAWINPUT raw)
mousestate.buttons &= ~2;
if (state.usButtonFlags & RI_MOUSE_WHEEL) {
mousestate.dwheel += (SHORT)state.usButtonData / 120;
mousestate.dwheel += (SHORT) state.usButtonData / 120;
}
if (state.usFlags & MOUSE_MOVE_ABSOLUTE) {
/* absolute mouse, i.e. RDP or VNC
* seems to work fine for RDP on Windows 10
* Not sure about other environments.
*/
mousestate.dx += (state.lLastX - x)/25;
mousestate.dy += (state.lLastY - y)/25;
x=state.lLastX;
y=state.lLastY;
mousestate.dx += (state.lLastX - x) / 25;
mousestate.dy += (state.lLastY - y) / 25;
x = state.lLastX;
y = state.lLastY;
} else {
/* relative mouse, i.e. regular mouse */
mousestate.dx += state.lLastX;
@@ -122,11 +121,11 @@ mouse_poll(void)
mouse_y += mousestate.dy;
mouse_z = mousestate.dwheel;
mousestate.dx=0;
mousestate.dy=0;
mousestate.dwheel=0;
mousestate.dx = 0;
mousestate.dy = 0;
mousestate.dwheel = 0;
//pclog("dx=%d, dy=%d, dwheel=%d\n", mouse_x, mouse_y, mouse_z);
// pclog("dx=%d, dy=%d, dwheel=%d\n", mouse_x, mouse_y, mouse_z);
}
if (b != mousestate.buttons) {

View File

@@ -34,7 +34,6 @@
#include <86box/zip.h>
#include <86box/win.h>
typedef struct {
int hole;
int sides;
@@ -51,30 +50,29 @@ typedef struct {
int root_dir_entries;
} disk_size_t;
static const disk_size_t disk_sizes[14] = {
// { 1, 1, 2, 1, 1, 77, 26, 0, 0, 4, 2, 6, 68 }, /* 250k 8" */
// { 1, 2, 2, 1, 1, 77, 26, 0, 0, 4, 2, 6, 68 }, /* 500k 8" */
// { 1, 1, 2, 1, 1, 77, 8, 3, 0, 1, 2, 2, 192 }, /* 616k 8" */
// { 1, 2, 0, 1, 1, 77, 8, 3, 0, 1, 2, 2, 192 }, /* 1232k 8" */
{ 0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 1, 2, 1, 64 }, /* 160k */
// { 1, 1, 2, 1, 1, 77, 26, 0, 0, 4, 2, 6, 68 }, /* 250k 8" */
// { 1, 2, 2, 1, 1, 77, 26, 0, 0, 4, 2, 6, 68 }, /* 500k 8" */
// { 1, 1, 2, 1, 1, 77, 8, 3, 0, 1, 2, 2, 192 }, /* 616k 8" */
// { 1, 2, 0, 1, 1, 77, 8, 3, 0, 1, 2, 2, 192 }, /* 1232k 8" */
{0, 1, 2, 1, 0, 40, 8, 2, 0xfe, 1, 2, 1, 64 }, /* 160k */
{ 0, 1, 2, 1, 0, 40, 9, 2, 0xfc, 1, 2, 2, 64 }, /* 180k */
{ 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112 }, /* 320k */
{ 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112 }, /* 360k */
{ 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112 }, /* 640k */
{ 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112 }, /* 720k */
{ 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224 }, /* 1.2M */
{ 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192 }, /* 1.25M */
{ 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224 }, /* 1.44M */
{ 0, 2, 2, 1, 0, 40, 8, 2, 0xff, 2, 2, 1, 112}, /* 320k */
{ 0, 2, 2, 1, 0, 40, 9, 2, 0xfd, 2, 2, 2, 112}, /* 360k */
{ 0, 2, 2, 1, 0, 80, 8, 2, 0xfb, 2, 2, 2, 112}, /* 640k */
{ 0, 2, 2, 1, 0, 80, 9, 2, 0xf9, 2, 2, 3, 112}, /* 720k */
{ 1, 2, 0, 1, 1, 80, 15, 2, 0xf9, 1, 2, 7, 224}, /* 1.2M */
{ 1, 2, 0, 1, 1, 77, 8, 3, 0xfe, 1, 2, 2, 192}, /* 1.25M */
{ 1, 2, 0, 1, 0, 80, 18, 2, 0xf0, 1, 2, 9, 224}, /* 1.44M */
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 2, 2, 5, 16 }, /* DMF cluster 1024 */
{ 1, 2, 0, 1, 0, 80, 21, 2, 0xf0, 4, 2, 3, 16 }, /* DMF cluster 2048 */
{ 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240 }, /* 2.88M */
{ 2, 2, 3, 1, 0, 80, 36, 2, 0xf0, 2, 2, 9, 240}, /* 2.88M */
{ 0, 64, 0, 0, 0, 96, 32, 2, 0, 0, 0, 0, 0 }, /* ZIP 100 */
{ 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 } }; /* ZIP 250 */
{ 0, 64, 0, 0, 0, 239, 32, 2, 0, 0, 0, 0, 0 }
}; /* ZIP 250 */
static unsigned char *empty;
static int
create_86f(char *file_name, disk_size_t disk_size, uint8_t rpm_mode)
{
@@ -106,7 +104,7 @@ create_86f(char *file_name, disk_size_t disk_size, uint8_t rpm_mode)
case 0:
case 1:
default:
switch(rpm_mode) {
switch (rpm_mode) {
case 1:
array_size = 25250;
break;
@@ -122,7 +120,7 @@ create_86f(char *file_name, disk_size_t disk_size, uint8_t rpm_mode)
}
break;
case 2:
switch(rpm_mode) {
switch (rpm_mode) {
case 1:
array_size = 50500;
break;
@@ -177,11 +175,9 @@ create_86f(char *file_name, disk_size_t disk_size, uint8_t rpm_mode)
return 1;
}
static int is_zip;
static int is_mo;
static int
create_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_fdi)
{
@@ -287,7 +283,6 @@ create_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_fdi)
return 1;
}
static int
create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, HWND hwnd)
{
@@ -524,7 +519,6 @@ create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi,
return 1;
}
static int
create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND hwnd)
{
@@ -647,13 +641,11 @@ create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND h
return 1;
}
static int fdd_id, sb_part;
static int file_type = 0; /* 0 = IMG, 1 = Japanese FDI, 2 = 86F */
static char fd_file_name[1024];
/* Show a MessageBox dialog. This is nasty, I know. --FvK */
static int
new_floppy_msgbox_header(HWND hwnd, int flags, void *header, void *message)
@@ -668,10 +660,9 @@ new_floppy_msgbox_header(HWND hwnd, int flags, void *header, void *message)
hwndMain = h;
return(i);
return (i);
}
static int
new_floppy_msgbox_ex(HWND hwnd, int flags, void *header, void *message, void *btn1, void *btn2, void *btn3)
{
@@ -685,10 +676,9 @@ new_floppy_msgbox_ex(HWND hwnd, int flags, void *header, void *message, void *bt
hwndMain = h;
return(i);
return (i);
}
#if defined(__amd64__) || defined(__aarch64__)
static LRESULT CALLBACK
#else
@@ -861,10 +851,9 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
return(FALSE);
return (FALSE);
}
void
NewFloppyDialogCreate(HWND hwnd, int id, int part)
{
@@ -876,5 +865,5 @@ NewFloppyDialogCreate(HWND hwnd, int id, int part)
fatal("Attempting to create a new image dialog that is for both ZIP and MO at the same time\n");
return;
}
DialogBox(hinstance, (LPCTSTR)DLG_NEW_FLOPPY, hwnd, NewFloppyDialogProcedure);
DialogBox(hinstance, (LPCTSTR) DLG_NEW_FLOPPY, hwnd, NewFloppyDialogProcedure);
}

View File

@@ -27,13 +27,11 @@
#include <86box/plat.h>
#include <86box/plat_dir.h>
#define SUFFIX "\\*"
#define FINDATA struct _finddata_t
#define FINDFIRST _findfirst
#define FINDNEXT _findnext
/* Open a directory. */
DIR *
opendir(const char *name)
@@ -43,17 +41,17 @@ opendir(const char *name)
/* Create a new control structure. */
p = (DIR *) malloc(sizeof(DIR));
if (p == NULL)
return(NULL);
return (NULL);
memset(p, 0x00, sizeof(DIR));
p->flags = (DIR_F_LOWER | DIR_F_SANE);
p->offset = 0;
p->sts = 0;
/* Create a work area. */
p->dta = (char *)malloc(sizeof(FINDATA));
p->dta = (char *) malloc(sizeof(FINDATA));
if (p->dta == NULL) {
free(p);
return(NULL);
return (NULL);
}
memset(p->dta, 0x00, sizeof(struct _finddata_t));
@@ -66,24 +64,23 @@ opendir(const char *name)
p->flags |= DIR_F_ISROOT;
/* Start the searching by doing a FindFirst. */
p->handle = FINDFIRST(p->dir, (FINDATA *)p->dta);
p->handle = FINDFIRST(p->dir, (FINDATA *) p->dta);
if (p->handle < 0L) {
free(p->dta);
free(p);
return(NULL);
return (NULL);
}
/* All OK. */
return(p);
return (p);
}
/* Close an open directory. */
int
closedir(DIR *p)
{
if (p == NULL)
return(0);
return (0);
_findclose(p->handle);
@@ -91,10 +88,9 @@ closedir(DIR *p)
free(p->dta);
free(p);
return(0);
return (0);
}
/*
* Read the next entry from a directory.
* Note that the DOS (FAT), Windows (FAT, FAT32) and Windows NTFS
@@ -108,26 +104,26 @@ readdir(DIR *p)
FINDATA *ffp;
if (p == NULL || p->sts == 1)
return(NULL);
return (NULL);
/* Format structure with current data. */
ffp = (FINDATA *)p->dta;
ffp = (FINDATA *) p->dta;
p->dent.d_ino = 1L;
p->dent.d_off = p->offset++;
switch(p->offset) {
switch (p->offset) {
case 1: /* . */
strncpy(p->dent.d_name, ".", MAXNAMLEN+1);
strncpy(p->dent.d_name, ".", MAXNAMLEN + 1);
p->dent.d_reclen = 1;
break;
case 2: /* .. */
strncpy(p->dent.d_name, "..", MAXNAMLEN+1);
strncpy(p->dent.d_name, "..", MAXNAMLEN + 1);
p->dent.d_reclen = 2;
break;
default: /* regular entry. */
strncpy(p->dent.d_name, ffp->name, MAXNAMLEN+1);
p->dent.d_reclen = (char)strlen(p->dent.d_name);
strncpy(p->dent.d_name, ffp->name, MAXNAMLEN + 1);
p->dent.d_reclen = (char) strlen(p->dent.d_name);
}
/* Read next entry. */
@@ -135,31 +131,29 @@ readdir(DIR *p)
/* Fake the "." and ".." entries here.. */
if ((p->flags & DIR_F_ISROOT) && (p->offset <= 2))
return(&(p->dent));
return (&(p->dent));
/* Get the next entry if we did not fake the above. */
if (FINDNEXT(p->handle, ffp) < 0)
p->sts = 1;
return(&(p->dent));
return (&(p->dent));
}
/* Report current position within the directory. */
long
telldir(DIR *p)
{
return(p->offset);
return (p->offset);
}
void
seekdir(DIR *p, long newpos)
{
short pos;
/* First off, rewind to start of directory. */
p->handle = FINDFIRST(p->dir, (FINDATA *)p->dta);
p->handle = FINDFIRST(p->dir, (FINDATA *) p->dta);
if (p->handle < 0L) {
p->sts = 1;
return;
@@ -168,13 +162,14 @@ seekdir(DIR *p, long newpos)
p->sts = 0;
/* If we are rewinding, that's all... */
if (newpos == 0L) return;
if (newpos == 0L)
return;
/* Nope.. read entries until we hit the right spot. */
pos = (short) newpos;
while (p->offset != pos) {
p->offset++;
if (FINDNEXT(p->handle, (FINDATA *)p->dta) < 0) {
if (FINDNEXT(p->handle, (FINDATA *) p->dta) < 0) {
p->sts = 1;
return;
}

View File

@@ -45,11 +45,11 @@
#include <string.h>
#if !defined(_MSC_VER) || defined(__clang__)
#include <stdatomic.h>
# include <stdatomic.h>
#else
typedef LONG atomic_flag;
#define atomic_flag_clear(OBJ) InterlockedExchange(OBJ, 0)
#define atomic_flag_test_and_set(OBJ) InterlockedExchange(OBJ, 1)
# define atomic_flag_clear(OBJ) InterlockedExchange(OBJ, 0)
# define atomic_flag_test_and_set(OBJ) InterlockedExchange(OBJ, 1)
#endif
#include <86box/86box.h>
@@ -71,29 +71,28 @@ static const int ROW_LENGTH = 2048; /* Source buffer row lenght (including padd
/**
* @brief A dedicated OpenGL thread.
* OpenGL context's don't handle multiple threads well.
*/
static thread_t* thread = NULL;
*/
static thread_t *thread = NULL;
/**
* @brief A window usable with an OpenGL context
*/
static SDL_Window* window = NULL;
*/
static SDL_Window *window = NULL;
/**
* @brief SDL window handle
*/
*/
static HWND window_hwnd = NULL;
/**
* @brief Parent window handle (hwndRender from win_ui)
*/
*/
static HWND parent = NULL;
/**
* @brief Events listened in OpenGL thread.
*/
static union
{
*/
static union {
struct
{
HANDLE closing;
@@ -106,37 +105,37 @@ static union
/**
* @brief Blit event parameters.
*/
*/
typedef struct
{
int w, h;
void* buffer; /* Buffer for pixel transfer, allocated by gpu driver. */
void *buffer; /* Buffer for pixel transfer, allocated by gpu driver. */
volatile atomic_flag in_use; /* Is buffer currently in use. */
GLsync sync; /* Fence sync object used by opengl thread to track pixel transfer completion. */
} blit_info_t;
/**
* @brief Array of blit_infos, one for each buffer.
*/
static blit_info_t* blit_info = NULL;
*/
static blit_info_t *blit_info = NULL;
/**
* @brief Buffer index of next write operation.
*/
*/
static int write_pos = 0;
/**
* @brief Resize event parameters.
*/
*/
static struct
{
int width, height, fullscreen, scaling_mode;
mutex_t* mutex;
mutex_t *mutex;
} resize_info = { 0 };
/**
* @brief Renderer options
*/
*/
static struct
{
int vsync; /* Vertical sync; 0 = off, 1 = on */
@@ -145,7 +144,7 @@ static struct
int shaderfile_changed; /* Has shader file path changed. To prevent unnecessary shader recompilation. */
int filter; /* 0 = Nearest, 1 = Linear */
int filter_changed; /* Has filter changed. */
mutex_t* mutex;
mutex_t *mutex;
} options = { 0 };
/**
@@ -173,18 +172,16 @@ typedef struct
* Modifies the window style and sets the parent window.
* WS_EX_NOACTIVATE keeps the window from stealing input focus.
*/
static void set_parent_binding(int enable)
static void
set_parent_binding(int enable)
{
long style = GetWindowLong(window_hwnd, GWL_STYLE);
long ex_style = GetWindowLong(window_hwnd, GWL_EXSTYLE);
if (enable)
{
if (enable) {
style |= WS_CHILD;
ex_style |= WS_EX_NOACTIVATE;
}
else
{
} else {
style &= ~WS_CHILD;
ex_style &= ~WS_EX_NOACTIVATE;
}
@@ -202,19 +199,18 @@ static void set_parent_binding(int enable)
* @param lParam
* @param fullscreen
* @return Was message handled
*/
static int handle_window_messages(UINT message, WPARAM wParam, LPARAM lParam, int fullscreen)
*/
static int
handle_window_messages(UINT message, WPARAM wParam, LPARAM lParam, int fullscreen)
{
switch (message)
{
switch (message) {
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:
if (!fullscreen)
{
if (!fullscreen) {
/* Bring main window to front. */
SetForegroundWindow(GetAncestor(parent, GA_ROOT));
@@ -226,25 +222,22 @@ static int handle_window_messages(UINT message, WPARAM wParam, LPARAM lParam, in
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
if (fullscreen)
{
if (fullscreen) {
PostMessage(parent, message, wParam, lParam);
}
return 1;
case WM_INPUT:
if (fullscreen)
{
if (fullscreen) {
/* Raw input handler from win_ui.c : input_proc */
UINT size = 0;
PRAWINPUT raw = NULL;
/* Here we read the raw input data */
GetRawInputData((HRAWINPUT)(LPARAM)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
raw = (PRAWINPUT)malloc(size);
if (GetRawInputData((HRAWINPUT)(LPARAM)lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)) == size) {
switch (raw->header.dwType)
{
GetRawInputData((HRAWINPUT) (LPARAM) lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
raw = (PRAWINPUT) malloc(size);
if (GetRawInputData((HRAWINPUT) (LPARAM) lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)) == size) {
switch (raw->header.dwType) {
case RIM_TYPEKEYBOARD:
keyboard_handle(raw);
break;
@@ -260,8 +253,7 @@ static int handle_window_messages(UINT message, WPARAM wParam, LPARAM lParam, in
}
return 1;
case WM_MOUSELEAVE:
if (fullscreen)
{
if (fullscreen) {
/* Leave fullscreen if mouse leaves the renderer window. */
PostMessage(GetAncestor(parent, GA_ROOT), WM_LEAVEFULLSCREEN, 0, 0);
}
@@ -274,8 +266,9 @@ static int handle_window_messages(UINT message, WPARAM wParam, LPARAM lParam, in
/**
* @brief (Re-)apply shaders to OpenGL context.
* @param gl Identifiers from initialize
*/
static void apply_shaders(gl_identifiers* gl)
*/
static void
apply_shaders(gl_identifiers *gl)
{
GLuint old_shader_ID = 0;
@@ -297,29 +290,25 @@ static void apply_shaders(gl_identifiers* gl)
glDeleteProgram(old_shader_ID);
GLint vertex_coord = glGetAttribLocation(gl->shader_progID, "VertexCoord");
if (vertex_coord != -1)
{
if (vertex_coord != -1) {
glEnableVertexAttribArray(vertex_coord);
glVertexAttribPointer(vertex_coord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0);
}
GLint tex_coord = glGetAttribLocation(gl->shader_progID, "TexCoord");
if (tex_coord != -1)
{
if (tex_coord != -1) {
glEnableVertexAttribArray(tex_coord);
glVertexAttribPointer(tex_coord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat)));
glVertexAttribPointer(tex_coord, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (2 * sizeof(GLfloat)));
}
GLint color = glGetAttribLocation(gl->shader_progID, "Color");
if (color != -1)
{
if (color != -1) {
glEnableVertexAttribArray(color);
glVertexAttribPointer(color, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(4 * sizeof(GLfloat)));
glVertexAttribPointer(color, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void *) (4 * sizeof(GLfloat)));
}
GLint mvp_matrix = glGetUniformLocation(gl->shader_progID, "MVPMatrix");
if (mvp_matrix != -1)
{
if (mvp_matrix != -1) {
static const GLfloat mvp[] = {
1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
@@ -342,8 +331,9 @@ static void apply_shaders(gl_identifiers* gl)
/**
* @brief Initialize OpenGL context
* @return Identifiers
*/
static int initialize_glcontext(gl_identifiers* gl)
*/
static int
initialize_glcontext(gl_identifiers *gl)
{
/* Vertex, texture 2d coordinates and color (white) making a quad as triangle strip */
static const GLfloat surface[] = {
@@ -376,17 +366,14 @@ static int initialize_glcontext(gl_identifiers* gl)
glGenBuffers(1, &gl->unpackBufferID);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, gl->unpackBufferID);
void* buf_ptr = NULL;
void *buf_ptr = NULL;
if (GLAD_GL_ARB_buffer_storage)
{
if (GLAD_GL_ARB_buffer_storage) {
/* Create persistent buffer for pixel transfer. */
glBufferStorage(GL_PIXEL_UNPACK_BUFFER, BUFFERBYTES * BUFFERCOUNT, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
buf_ptr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, BUFFERBYTES * BUFFERCOUNT, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
}
else
{
} else {
/* Fallback; create our own buffer. */
buf_ptr = malloc(BUFFERBYTES * BUFFERCOUNT);
@@ -397,9 +384,8 @@ static int initialize_glcontext(gl_identifiers* gl)
return 0; /* Most likely out of memory. */
/* Split the buffer area for each blit_info and set them available for use. */
for (int i = 0; i < BUFFERCOUNT; i++)
{
blit_info[i].buffer = (byte*)buf_ptr + BUFFERBYTES * i;
for (int i = 0; i < BUFFERCOUNT; i++) {
blit_info[i].buffer = (byte *) buf_ptr + BUFFERBYTES * i;
atomic_flag_clear(&blit_info[i].in_use);
}
@@ -413,8 +399,9 @@ static int initialize_glcontext(gl_identifiers* gl)
/**
* @brief Clean up OpenGL context
* @param gl Identifiers from initialize
*/
static void finalize_glcontext(gl_identifiers* gl)
*/
static void
finalize_glcontext(gl_identifiers *gl)
{
if (GLAD_GL_ARB_buffer_storage)
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
@@ -431,8 +418,9 @@ static void finalize_glcontext(gl_identifiers* gl)
/**
* @brief Renders a frame and swaps the buffer
* @param gl Identifiers from initialize
*/
static void render_and_swap(gl_identifiers* gl)
*/
static void
render_and_swap(gl_identifiers *gl)
{
static int frame_counter = 0;
@@ -448,17 +436,17 @@ static void render_and_swap(gl_identifiers* gl)
/**
* @brief Handle failure in OpenGL thread.
* Keeps the thread sleeping until closing.
*/
static void opengl_fail()
*/
static void
opengl_fail()
{
if (window != NULL)
{
if (window != NULL) {
SDL_DestroyWindow(window);
window = NULL;
}
wchar_t* message = plat_get_string(IDS_2152);
wchar_t* header = plat_get_string(IDS_2153);
wchar_t *message = plat_get_string(IDS_2152);
wchar_t *header = plat_get_string(IDS_2153);
MessageBox(parent, header, message, MB_OK);
WaitForSingleObject(sync_objects.closing, INFINITE);
@@ -466,7 +454,7 @@ static void opengl_fail()
_endthread();
}
static void __stdcall opengl_debugmsg_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
static void __stdcall opengl_debugmsg_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
{
pclog("OpenGL: %s\n", message);
}
@@ -476,8 +464,9 @@ static void __stdcall opengl_debugmsg_callback(GLenum source, GLenum type, GLuin
*
* OpenGL context should be accessed only from this single thread.
* Events are used to synchronize communication.
*/
static void opengl_main(void* param)
*/
static void
opengl_main(void *param)
{
/* Initialize COM library for this thread before SDL does so. */
CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -497,8 +486,7 @@ static void opengl_main(void* param)
window = SDL_CreateWindow("86Box OpenGL Renderer", 0, 0, resize_info.width, resize_info.height, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
if (window == NULL)
{
if (window == NULL) {
pclog("OpenGL: failed to create OpenGL window.\n");
opengl_fail();
}
@@ -511,8 +499,7 @@ static void opengl_main(void* param)
SDL_VERSION(&wmi.version);
SDL_GetWindowWMInfo(window, &wmi);
if (wmi.subsystem != SDL_SYSWM_WINDOWS)
{
if (wmi.subsystem != SDL_SYSWM_WINDOWS) {
pclog("OpenGL: subsystem is not SDL_SYSWM_WINDOWS.\n");
opengl_fail();
}
@@ -526,23 +513,20 @@ static void opengl_main(void* param)
SDL_GLContext context = SDL_GL_CreateContext(window);
if (context == NULL)
{
if (context == NULL) {
pclog("OpenGL: failed to create OpenGL context.\n");
opengl_fail();
}
SDL_GL_SetSwapInterval(options.vsync);
if (!gladLoadGLLoader(SDL_GL_GetProcAddress))
{
if (!gladLoadGLLoader(SDL_GL_GetProcAddress)) {
pclog("OpenGL: failed to set OpenGL loader.\n");
SDL_GL_DeleteContext(context);
opengl_fail();
}
if (GLAD_GL_ARB_debug_output && log_path[0] != '\0')
{
if (GLAD_GL_ARB_debug_output && log_path[0] != '\0') {
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageControlARB(GL_DONT_CARE, GL_DEBUG_TYPE_PERFORMANCE_ARB, GL_DONT_CARE, 0, 0, GL_FALSE);
glDebugMessageCallbackARB(opengl_debugmsg_callback, NULL);
@@ -556,8 +540,7 @@ static void opengl_main(void* param)
/* Check that the driver actually reports version 3.0 or later */
GLint major = -1;
glGetIntegerv(GL_MAJOR_VERSION, &major);
if (major < 3)
{
if (major < 3) {
pclog("OpenGL: Minimum OpenGL version 3.0 is required.\n");
SDL_GL_DeleteContext(context);
opengl_fail();
@@ -565,16 +548,13 @@ static void opengl_main(void* param)
/* Check if errors have been generated at this point */
GLenum gl_error = glGetError();
if (gl_error != GL_NO_ERROR)
{
if (gl_error != GL_NO_ERROR) {
/* Log up to 10 errors */
int i = 0;
do
{
do {
pclog("OpenGL: Error %u\n", gl_error);
i++;
}
while((gl_error = glGetError()) != GL_NO_ERROR && i < 10);
} while ((gl_error = glGetError()) != GL_NO_ERROR && i < 10);
SDL_GL_DeleteContext(context);
opengl_fail();
@@ -582,8 +562,7 @@ static void opengl_main(void* param)
gl_identifiers gl = { 0 };
if (!initialize_glcontext(&gl))
{
if (!initialize_glcontext(&gl)) {
pclog("OpenGL: failed to initialize.\n");
finalize_glcontext(&gl);
SDL_GL_DeleteContext(context);
@@ -601,28 +580,23 @@ static void opengl_main(void* param)
/* Render loop */
int closing = 0;
while (!closing)
{
while (!closing) {
/* Rendering is done right after handling an event. */
if (frametime < 0)
render_and_swap(&gl);
DWORD wait_result = WAIT_TIMEOUT;
do
{
do {
/* Rendering is timed by frame capping. */
if (frametime >= 0)
{
if (frametime >= 0) {
uint32_t ticks = plat_get_micro_ticks();
uint32_t elapsed = ticks - last_swap;
if (elapsed + 1000 > frametime)
{
if (elapsed + 1000 > frametime) {
/* Spin the remaining time (< 1ms) to next frame */
while (elapsed < frametime)
{
while (elapsed < frametime) {
Sleep(0); /* Yield processor time */
ticks = plat_get_micro_ticks();
elapsed = ticks - last_swap;
@@ -633,13 +607,10 @@ static void opengl_main(void* param)
}
}
if (GLAD_GL_ARB_sync)
{
if (GLAD_GL_ARB_sync) {
/* Check if commands that use buffers have been completed. */
for (int i = 0; i < BUFFERCOUNT; i++)
{
if (blit_info[i].sync != NULL && glClientWaitSync(blit_info[i].sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0) != GL_TIMEOUT_EXPIRED)
{
for (int i = 0; i < BUFFERCOUNT; i++) {
if (blit_info[i].sync != NULL && glClientWaitSync(blit_info[i].sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0) != GL_TIMEOUT_EXPIRED) {
glDeleteSync(blit_info[i].sync);
blit_info[i].sync = NULL;
atomic_flag_clear(&blit_info[i].in_use);
@@ -649,10 +620,8 @@ static void opengl_main(void* param)
/* Handle window messages */
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.hwnd != window_hwnd || !handle_window_messages(msg.message, msg.wParam, msg.lParam, fullscreen))
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.hwnd != window_hwnd || !handle_window_messages(msg.message, msg.wParam, msg.lParam, fullscreen)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -665,16 +634,12 @@ static void opengl_main(void* param)
HANDLE sync_event = sync_objects.asArray[wait_result - WAIT_OBJECT_0];
if (sync_event == sync_objects.closing)
{
if (sync_event == sync_objects.closing) {
closing = 1;
}
else if (sync_event == sync_objects.blit_waiting)
{
blit_info_t* info = &blit_info[read_pos];
} else if (sync_event == sync_objects.blit_waiting) {
blit_info_t *info = &blit_info[read_pos];
if (video_width != info->w || video_height != info->h)
{
if (video_width != info->w || video_height != info->h) {
video_width = info->w;
video_height = info->h;
@@ -687,8 +652,7 @@ static void opengl_main(void* param)
SetEvent(sync_objects.resize);
}
if (!GLAD_GL_ARB_buffer_storage)
{
if (!GLAD_GL_ARB_buffer_storage) {
/* Fallback method, copy data to pixel buffer. */
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, BUFFERBYTES * read_pos, info->h * ROW_LENGTH * sizeof(uint32_t), info->buffer);
}
@@ -698,13 +662,10 @@ static void opengl_main(void* param)
glPixelStorei(GL_UNPACK_ROW_LENGTH, ROW_LENGTH);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, info->w, info->h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
if (GLAD_GL_ARB_sync)
{
if (GLAD_GL_ARB_sync) {
/* Add fence to track when above gl commands are complete. */
info->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
else
{
} else {
/* No sync objects; block until commands are complete. */
glFinish();
atomic_flag_clear(&info->in_use);
@@ -717,21 +678,17 @@ static void opengl_main(void* param)
glUniform2f(gl.input_size, video_width, video_height);
if (gl.texture_size != -1)
glUniform2f(gl.texture_size, video_width, video_height);
}
else if (sync_event == sync_objects.resize)
{
} else if (sync_event == sync_objects.resize) {
thread_wait_mutex(resize_info.mutex);
if (fullscreen != resize_info.fullscreen)
{
if (fullscreen != resize_info.fullscreen) {
fullscreen = resize_info.fullscreen;
set_parent_binding(!fullscreen);
SDL_SetWindowFullscreen(window, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
if (fullscreen)
{
if (fullscreen) {
SetForegroundWindow(window_hwnd);
SetFocus(window_hwnd);
@@ -739,23 +696,19 @@ static void opengl_main(void* param)
RECT rect;
GetWindowRect(window_hwnd, &rect);
ClipCursor(&rect);
}
else
} else
ClipCursor(NULL);
}
if (fullscreen)
{
if (fullscreen) {
int width, height, pad_x = 0, pad_y = 0, px_size = 1;
float ratio = 0;
const float ratio43 = 4.f / 3.f;
SDL_GetWindowSize(window, &width, &height);
if (video_width > 0 && video_height > 0)
{
switch (resize_info.scaling_mode)
{
if (video_width > 0 && video_height > 0) {
switch (resize_info.scaling_mode) {
case FULLSCR_SCALE_INT:
px_size = max(min(width / video_width, height / video_height), 1);
@@ -764,14 +717,14 @@ static void opengl_main(void* param)
break;
case FULLSCR_SCALE_KEEPRATIO:
ratio = (float)video_width / (float)video_height;
ratio = (float) video_width / (float) video_height;
case FULLSCR_SCALE_43:
if (ratio == 0)
ratio = ratio43;
if (ratio < ((float)width / (float)height))
pad_x = width - (int)roundf((float)height * ratio);
if (ratio < ((float) width / (float) height))
pad_x = width - (int) roundf((float) height * ratio);
else
pad_y = height - (int)roundf((float)width / ratio);
pad_y = height - (int) roundf((float) width / ratio);
break;
case FULLSCR_SCALE_FULL:
@@ -787,9 +740,7 @@ static void opengl_main(void* param)
if (gl.output_size != -1)
glUniform2f(gl.output_size, output_width, output_height);
}
else
{
} else {
SDL_SetWindowSize(window, resize_info.width, resize_info.height);
/* SWP_NOZORDER is needed for child window and SDL doesn't enable it. */
@@ -805,17 +756,14 @@ static void opengl_main(void* param)
}
thread_release_mutex(resize_info.mutex);
}
else if (sync_event == sync_objects.reload)
{
} else if (sync_event == sync_objects.reload) {
thread_wait_mutex(options.mutex);
frametime = options.frametime;
SDL_GL_SetSwapInterval(options.vsync);
if (options.shaderfile_changed)
{
if (options.shaderfile_changed) {
/* Change shader program. */
apply_shaders(&gl);
@@ -832,8 +780,7 @@ static void opengl_main(void* param)
options.shaderfile_changed = 0;
}
if (options.filter_changed)
{
if (options.filter_changed) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, options.filter ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, options.filter ? GL_LINEAR : GL_NEAREST);
@@ -849,10 +796,8 @@ static void opengl_main(void* param)
SDL_ShowCursor(show_cursor);
}
if (GLAD_GL_ARB_sync)
{
for (int i = 0; i < BUFFERCOUNT; i++)
{
if (GLAD_GL_ARB_sync) {
for (int i = 0; i < BUFFERCOUNT; i++) {
if (blit_info[i].sync != NULL)
glDeleteSync(blit_info[i].sync);
}
@@ -871,13 +816,12 @@ static void opengl_main(void* param)
CoUninitialize();
}
static void opengl_blit(int x, int y, int w, int h, int monitor_index)
static void
opengl_blit(int x, int y, int w, int h, int monitor_index)
{
int row;
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || (thread == NULL) ||
atomic_flag_test_and_set(&blit_info[write_pos].in_use) || monitor_index >= 1)
{
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || (thread == NULL) || atomic_flag_test_and_set(&blit_info[write_pos].in_use) || monitor_index >= 1) {
video_blit_complete_monitor(monitor_index);
return;
}
@@ -898,15 +842,17 @@ static void opengl_blit(int x, int y, int w, int h, int monitor_index)
ReleaseSemaphore(sync_objects.blit_waiting, 1, NULL);
}
static int framerate_to_frametime(int framerate)
static int
framerate_to_frametime(int framerate)
{
if (framerate < 0)
return -1;
return (int)ceilf(1.e6f / (float)framerate);
return (int) ceilf(1.e6f / (float) framerate);
}
int opengl_init(HWND hwnd)
int
opengl_init(HWND hwnd)
{
if (thread != NULL)
return 0;
@@ -939,7 +885,7 @@ int opengl_init(HWND hwnd)
options.filter_changed = 0;
options.mutex = thread_create_mutex();
blit_info = (blit_info_t*)malloc(BUFFERCOUNT * sizeof(blit_info_t));
blit_info = (blit_info_t *) malloc(BUFFERCOUNT * sizeof(blit_info_t));
memset(blit_info, 0, BUFFERCOUNT * sizeof(blit_info_t));
/* Buffers are not yet allocated, set them as in use. */
@@ -948,7 +894,7 @@ int opengl_init(HWND hwnd)
write_pos = 0;
thread = thread_create(opengl_main, (void*)NULL);
thread = thread_create(opengl_main, (void *) NULL);
atexit(opengl_close);
@@ -957,12 +903,14 @@ int opengl_init(HWND hwnd)
return 1;
}
int opengl_pause(void)
int
opengl_pause(void)
{
return 0;
}
void opengl_close(void)
void
opengl_close(void)
{
if (thread == NULL)
return;
@@ -978,16 +926,16 @@ void opengl_close(void)
free(blit_info);
for (int i = 0; i < sizeof(sync_objects) / sizeof(HANDLE); i++)
{
for (int i = 0; i < sizeof(sync_objects) / sizeof(HANDLE); i++) {
CloseHandle(sync_objects.asArray[i]);
sync_objects.asArray[i] = (HANDLE)NULL;
sync_objects.asArray[i] = (HANDLE) NULL;
}
parent = NULL;
}
void opengl_set_fs(int fs)
void
opengl_set_fs(int fs)
{
if (thread == NULL)
return;
@@ -1002,7 +950,8 @@ void opengl_set_fs(int fs)
SetEvent(sync_objects.resize);
}
void opengl_resize(int w, int h)
void
opengl_resize(int w, int h)
{
if (thread == NULL)
return;
@@ -1018,7 +967,8 @@ void opengl_resize(int w, int h)
SetEvent(sync_objects.resize);
}
void opengl_reload(void)
void
opengl_reload(void)
{
if (thread == NULL)
return;
@@ -1028,14 +978,12 @@ void opengl_reload(void)
options.vsync = video_vsync;
options.frametime = framerate_to_frametime(video_framerate);
if (strcmp(video_shader, options.shaderfile) != 0)
{
if (strcmp(video_shader, options.shaderfile) != 0) {
strcpy_s(options.shaderfile, sizeof(options.shaderfile), video_shader);
options.shaderfile_changed = 1;
}
if (video_filter_method != options.filter)
{
if (video_filter_method != options.filter) {
options.filter = video_filter_method;
options.filter_changed = 1;
}

View File

@@ -40,10 +40,10 @@
#include <86box/plat.h>
#include <86box/win_opengl_glslp.h>
/**
/**
* @brief Default vertex shader.
*/
static const GLchar* vertex_shader = "#version 130\n\
static const GLchar *vertex_shader = "#version 130\n\
in vec2 VertexCoord;\n\
in vec2 TexCoord;\n\
out vec2 tex;\n\
@@ -55,7 +55,7 @@ void main(){\n\
/**
* @brief Default fragment shader.
*/
static const GLchar* fragment_shader = "#version 130\n\
static const GLchar *fragment_shader = "#version 130\n\
in vec2 tex;\n\
uniform sampler2D texsampler;\n\
out vec4 color;\n\
@@ -65,9 +65,8 @@ void main() {\n\
/**
* @brief OpenGL shader program build targets
*/
typedef enum
{
*/
typedef enum {
OPENGL_BUILD_TARGET_VERTEX,
OPENGL_BUILD_TARGET_FRAGMENT,
OPENGL_BUILD_TARGET_LINK
@@ -77,22 +76,22 @@ typedef enum
* @brief Reads a whole file into a null terminated string.
* @param Path Path to the file relative to executable path.
* @return Pointer to the string or NULL on error. Remember to free() after use.
*/
static char* read_file_to_string(const char* path)
*/
static char *
read_file_to_string(const char *path)
{
FILE* file_handle = plat_fopen(path, "rb");
FILE *file_handle = plat_fopen(path, "rb");
if (file_handle != NULL)
{
if (file_handle != NULL) {
/* get file size */
fseek(file_handle, 0, SEEK_END);
size_t file_size = (size_t)ftell(file_handle);
size_t file_size = (size_t) ftell(file_handle);
fseek(file_handle, 0, SEEK_SET);
/* read to buffer and close */
char* content = (char*)malloc(sizeof(char) * (file_size + 1));
char *content = (char *) malloc(sizeof(char) * (file_size + 1));
if (!content)
return NULL;
@@ -108,7 +107,8 @@ static char* read_file_to_string(const char* path)
return NULL;
}
static int check_status(GLuint id, opengl_build_target_t build_target, const char* shader_path)
static int
check_status(GLuint id, opengl_build_target_t build_target, const char *shader_path)
{
GLint status = GL_FALSE;
@@ -117,8 +117,7 @@ static int check_status(GLuint id, opengl_build_target_t build_target, const cha
else
glGetProgramiv(id, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
if (status == GL_FALSE) {
int info_log_length;
if (build_target != OPENGL_BUILD_TARGET_LINK)
@@ -126,17 +125,16 @@ static int check_status(GLuint id, opengl_build_target_t build_target, const cha
else
glGetProgramiv(id, GL_INFO_LOG_LENGTH, &info_log_length);
GLchar* info_log_text = (GLchar*)malloc(sizeof(GLchar) * info_log_length);
GLchar *info_log_text = (GLchar *) malloc(sizeof(GLchar) * info_log_length);
if (build_target != OPENGL_BUILD_TARGET_LINK)
glGetShaderInfoLog(id, info_log_length, NULL, info_log_text);
else
glGetProgramInfoLog(id, info_log_length, NULL, info_log_text);
const char* reason = NULL;
const char *reason = NULL;
switch (build_target)
{
switch (build_target) {
case OPENGL_BUILD_TARGET_VERTEX:
reason = "compiling vertex shader";
break;
@@ -149,7 +147,7 @@ static int check_status(GLuint id, opengl_build_target_t build_target, const cha
}
/* Shader compilation log can be lengthy, mark begin and end */
const char* line = "--------------------";
const char *line = "--------------------";
pclog("OpenGL: Error when %s in %s:\n%sBEGIN%s\n%s\n%s END %s\n", reason, shader_path, line, line, info_log_text, line, line);
@@ -164,30 +162,28 @@ static int check_status(GLuint id, opengl_build_target_t build_target, const cha
/**
* @brief Compile custom shaders into a program.
* @return Shader program identifier.
*/
GLuint load_custom_shaders(const char* path)
*/
GLuint
load_custom_shaders(const char *path)
{
char* shader = read_file_to_string(path);
char *shader = read_file_to_string(path);
if (shader != NULL)
{
if (shader != NULL) {
int success = 1;
const char* vertex_sources[3] = { "#version 130\n", "#define VERTEX\n", shader };
const char* fragment_sources[3] = { "#version 130\n", "#define FRAGMENT\n", shader };
const char *vertex_sources[3] = { "#version 130\n", "#define VERTEX\n", shader };
const char *fragment_sources[3] = { "#version 130\n", "#define FRAGMENT\n", shader };
/* Check if the shader program defines version directive */
char* version_start = strstr(shader, "#version");
char *version_start = strstr(shader, "#version");
/* If the shader program contains a version directive,
it must be captured and placed as the first statement. */
if (version_start != NULL)
{
if (version_start != NULL) {
/* Version directive found, search the line end */
char* version_end = strchr(version_start, '\n');
char *version_end = strchr(version_start, '\n');
if (version_end != NULL)
{
if (version_end != NULL) {
char version[30] = "";
size_t version_len = MIN(version_end - version_start + 1, 29);
@@ -219,8 +215,7 @@ GLuint load_custom_shaders(const char* path)
GLuint prog_id = 0;
if (success)
{
if (success) {
prog_id = glCreateProgram();
glAttachShader(prog_id, vertex_id);
@@ -243,8 +238,9 @@ GLuint load_custom_shaders(const char* path)
/**
* @brief Compile default shaders into a program.
* @return Shader program identifier.
*/
GLuint load_default_shaders()
*/
GLuint
load_default_shaders()
{
GLuint vertex_id = glCreateShader(GL_VERTEX_SHADER);
GLuint fragment_id = glCreateShader(GL_FRAGMENT_SHADER);

View File

@@ -35,7 +35,7 @@
/* Language */
static LCID temp_language;
static char temp_icon_set[256] = {0};
static char temp_icon_set[256] = { 0 };
int enum_helper, c;
@@ -48,8 +48,8 @@ EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLan
LCIDToLocaleName(wIDLanguage, temp, LOCALE_NAME_MAX_LENGTH, 0);
wchar_t dispname[MAX_PATH + 1];
GetLocaleInfoEx(temp, LOCALE_SENGLISHDISPLAYNAME, dispname, MAX_PATH);
SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)dispname);
SendMessage((HWND)lParam, CB_SETITEMDATA, c, (LPARAM)wIDLanguage);
SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) dispname);
SendMessage((HWND) lParam, CB_SETITEMDATA, c, (LPARAM) wIDLanguage);
if (wIDLanguage == lang_id)
enum_helper = c;
@@ -69,10 +69,11 @@ preferences_fill_languages(HWND hdlg)
SendMessage(lang_combo, CB_ADDSTRING, 0, win_get_string(IDS_7168));
SendMessage(lang_combo, CB_SETITEMDATA, 0, 0xFFFF);
enum_helper = 0; c = 1;
//if no one is selected, then it was 0xFFFF or unsupported language, in either case go with index enum_helper=0
//also start enum index from c=1
EnumResourceLanguages(hinstance, RT_MENU, L"MainMenu", &EnumResLangProc, (LPARAM)lang_combo);
enum_helper = 0;
c = 1;
// if no one is selected, then it was 0xFFFF or unsupported language, in either case go with index enum_helper=0
// also start enum index from c=1
EnumResourceLanguages(hinstance, RT_MENU, L"MainMenu", &EnumResLangProc, (LPARAM) lang_combo);
SendMessage(lang_combo, CB_SETCURSEL, enum_helper, 0);
}
@@ -89,8 +90,8 @@ preferences_fill_iconsets(HWND hdlg)
wcscat(buffer, L")");
SendMessage(icon_combo, CB_RESETCONTENT, 0, 0);
SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)buffer);
SendMessage(icon_combo, CB_SETITEMDATA, 0, (LPARAM)strdup(""));
SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM) buffer);
SendMessage(icon_combo, CB_SETITEMDATA, 0, (LPARAM) strdup(""));
int combo_index = -1;
@@ -105,25 +106,21 @@ preferences_fill_iconsets(HWND hdlg)
mbstoc16s(search, icon_path_root, strlen(icon_path_root) + 1);
wcscat(search, L"*.*");
hFind = FindFirstFile((LPCWSTR)search, &data);
hFind = FindFirstFile((LPCWSTR) search, &data);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..") &&
(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
wchar_t temp[512] = {0}, dispname[512] = {0};
if (wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..") && (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
wchar_t temp[512] = { 0 }, dispname[512] = { 0 };
mbstoc16s(temp, icon_path_root, strlen(icon_path_root) + 1);
wcscat(temp, data.cFileName);
wcscat(temp, L"\\iconinfo.txt");
wcscpy(dispname, data.cFileName);
FILE *fp = _wfopen(temp, L"r");
if (fp)
{
char line[512] = {0};
if (fgets(line, 511, fp))
{
if (fp) {
char line[512] = { 0 };
if (fgets(line, 511, fp)) {
mbstoc16s(dispname, line, strlen(line) + 1);
}
@@ -133,8 +130,8 @@ preferences_fill_iconsets(HWND hdlg)
char filename[512];
c16stombs(filename, data.cFileName, 511);
int index = SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM)dispname);
SendMessage(icon_combo, CB_SETITEMDATA, index, (LPARAM)(strdup(filename)));
int index = SendMessage(icon_combo, CB_ADDSTRING, 0, (LPARAM) dispname);
SendMessage(icon_combo, CB_SETITEMDATA, index, (LPARAM) (strdup(filename)));
if (!strcmp(filename, icon_set))
combo_index = index;
@@ -143,8 +140,7 @@ preferences_fill_iconsets(HWND hdlg)
FindClose(hFind);
}
if (combo_index == -1)
{
if (combo_index == -1) {
combo_index = 0;
strcpy(temp_icon_set, "");
}
@@ -242,11 +238,12 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == CBN_SELCHANGE) {
HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON);
int index = SendMessage(combo, CB_GETCURSEL, 0, 0);
strcpy(temp_icon_set, (char*)SendMessage(combo, CB_GETITEMDATA, index, 0));
strcpy(temp_icon_set, (char *) SendMessage(combo, CB_GETITEMDATA, index, 0));
}
break;
case IDC_BUTTON_DEFAULT: {
case IDC_BUTTON_DEFAULT:
{
HWND combo = GetDlgItem(hdlg, IDC_COMBO_LANG);
int index = preferences_indexof(combo, DEFAULT_LANGUAGE);
SendMessage(combo, CB_SETCURSEL, index, 0);
@@ -254,7 +251,8 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
case IDC_BUTTON_DEFICON: {
case IDC_BUTTON_DEFICON:
{
SendMessage(GetDlgItem(hdlg, IDC_COMBO_ICON), CB_SETCURSEL, 0, 0);
strcpy(temp_icon_set, "");
break;
@@ -264,30 +262,27 @@ PreferencesDlgProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case WM_DESTROY: {
case WM_DESTROY:
{
int i;
LRESULT temp;
HWND combo = GetDlgItem(hdlg, IDC_COMBO_ICON);
for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++)
{
for (i = 0; i < SendMessage(combo, CB_GETCOUNT, 0, 0); i++) {
temp = SendMessage(combo, CB_GETITEMDATA, i, 0);
if (temp)
{
free((void*)temp);
if (temp) {
free((void *) temp);
SendMessage(combo, CB_SETITEMDATA, i, 0);
}
}
}
break;
}
return(FALSE);
return (FALSE);
}
void
PreferencesDlgCreate(HWND hwnd)
{
DialogBox(hinstance, (LPCTSTR)DLG_PREFERENCES, hwnd, PreferencesDlgProcedure);
DialogBox(hinstance, (LPCTSTR) DLG_PREFERENCES, hwnd, PreferencesDlgProcedure);
}

View File

@@ -72,12 +72,10 @@
#include <86box/win_sdl.h>
#include <86box/version.h>
#define RENDERER_FULL_SCREEN 1
#define RENDERER_HARDWARE 2
#define RENDERER_OPENGL 4
static SDL_Window *sdl_win = NULL;
static SDL_Renderer *sdl_render = NULL;
static SDL_Texture *sdl_tex = NULL;
@@ -85,10 +83,9 @@ static HWND sdl_parent_hwnd = NULL;
static int sdl_w, sdl_h;
static int sdl_fs, sdl_flags = -1;
static int cur_w, cur_h;
static int cur_wx = 0, cur_wy = 0, cur_ww =0, cur_wh = 0;
static int cur_wx = 0, cur_wy = 0, cur_ww = 0, cur_wh = 0;
static volatile int sdl_enabled = 0;
static SDL_mutex* sdl_mutex = NULL;
static SDL_mutex *sdl_mutex = NULL;
typedef struct
{
@@ -131,11 +128,9 @@ typedef struct
SDL_Window *next;
} SDL_Window_Ex;
#ifdef ENABLE_SDL_LOG
int sdl_do_log = ENABLE_SDL_LOG;
static void
sdl_log(const char *fmt, ...)
{
@@ -148,10 +143,9 @@ sdl_log(const char *fmt, ...)
}
}
#else
#define sdl_log(fmt, ...)
# define sdl_log(fmt, ...)
#endif
static void
sdl_integer_scale(double *d, double *g)
{
@@ -166,7 +160,6 @@ sdl_integer_scale(double *d, double *g)
}
}
static void
sdl_stretch(int *w, int *h, int *x, int *y)
{
@@ -227,7 +220,6 @@ sdl_stretch(int *w, int *h, int *x, int *y)
}
}
static void
sdl_blit(int x, int y, int w, int h, int monitor_index)
{
@@ -267,7 +259,6 @@ sdl_blit(int x, int y, int w, int h, int monitor_index)
SDL_UnlockMutex(sdl_mutex);
}
static void
sdl_blit_ex(int x, int y, int w, int h, int monitor_index)
{
@@ -310,7 +301,6 @@ sdl_blit_ex(int x, int y, int w, int h, int monitor_index)
SDL_UnlockMutex(sdl_mutex);
}
static void
sdl_destroy_window(void)
{
@@ -320,7 +310,6 @@ sdl_destroy_window(void)
}
}
static void
sdl_destroy_texture(void)
{
@@ -336,7 +325,6 @@ sdl_destroy_texture(void)
}
}
void
sdl_close(void)
{
@@ -369,18 +357,15 @@ sdl_close(void)
sdl_flags = -1;
}
static int old_capture = 0;
static void
sdl_select_best_hw_driver(void)
{
int i;
SDL_RendererInfo renderInfo;
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i)
{
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
SDL_GetRenderDriverInfo(i, &renderInfo);
if (renderInfo.flags & SDL_RENDERER_ACCELERATED) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name);
@@ -389,7 +374,6 @@ sdl_select_best_hw_driver(void)
}
}
static void
sdl_init_texture(void)
{
@@ -403,7 +387,6 @@ sdl_init_texture(void)
SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
}
static void
sdl_reinit_texture(void)
{
@@ -414,7 +397,6 @@ sdl_reinit_texture(void)
sdl_init_texture();
}
void
sdl_set_fs(int fs)
{
@@ -470,7 +452,6 @@ sdl_set_fs(int fs)
SDL_UnlockMutex(sdl_mutex);
}
static int
sdl_init_common(int flags)
{
@@ -486,7 +467,7 @@ sdl_init_common(int flags)
/* Initialize the SDL system. */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
sdl_log("SDL: initialization failed (%s)\n", sdl_GetError());
return(0);
return (0);
}
if (flags & RENDERER_HARDWARE) {
@@ -512,7 +493,7 @@ sdl_init_common(int flags)
sdl_log("SDL: unable to CreateWindowFrom (%s)\n", SDL_GetError());
}
sdl_win = SDL_CreateWindowFrom((void *)hwndRender);
sdl_win = SDL_CreateWindowFrom((void *) hwndRender);
sdl_init_texture();
sdl_set_fs(video_fullscreen & 1);
@@ -525,38 +506,33 @@ sdl_init_common(int flags)
sdl_enabled = 1;
sdl_mutex = SDL_CreateMutex();
return(1);
return (1);
}
int
sdl_inits(HWND h)
{
return sdl_init_common(0);
}
int
sdl_inith(HWND h)
{
return sdl_init_common(RENDERER_HARDWARE);
}
int
sdl_initho(HWND h)
{
return sdl_init_common(RENDERER_HARDWARE | RENDERER_OPENGL);
}
int
sdl_pause(void)
{
return(0);
return (0);
}
void
sdl_resize(int x, int y)
{
@@ -594,7 +570,6 @@ sdl_resize(int x, int y)
SDL_UnlockMutex(sdl_mutex);
}
void
sdl_enable(int enable)
{
@@ -612,7 +587,6 @@ sdl_enable(int enable)
SDL_UnlockMutex(sdl_mutex);
}
void
sdl_reload(void)
{

File diff suppressed because it is too large Load Diff

View File

@@ -31,10 +31,8 @@
#include <86box/sound.h>
#include <86box/win.h>
static uint8_t old_gain;
#if defined(__amd64__) || defined(__aarch64__)
static LRESULT CALLBACK
#else
@@ -48,23 +46,23 @@ SoundGainDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
old_gain = sound_gain;
h = GetDlgItem(hdlg, IDC_SLIDER_GAIN);
SendMessage(h, TBM_SETRANGE, (WPARAM)1, (LPARAM)MAKELONG(0, 9));
SendMessage(h, TBM_SETPOS, (WPARAM)1, 9 - (sound_gain >> 1));
SendMessage(h, TBM_SETTICFREQ, (WPARAM)1, 0);
SendMessage(h, TBM_SETLINESIZE, (WPARAM)0, 1);
SendMessage(h, TBM_SETPAGESIZE, (WPARAM)0, 2);
SendMessage(h, TBM_SETRANGE, (WPARAM) 1, (LPARAM) MAKELONG(0, 9));
SendMessage(h, TBM_SETPOS, (WPARAM) 1, 9 - (sound_gain >> 1));
SendMessage(h, TBM_SETTICFREQ, (WPARAM) 1, 0);
SendMessage(h, TBM_SETLINESIZE, (WPARAM) 0, 1);
SendMessage(h, TBM_SETPAGESIZE, (WPARAM) 0, 2);
break;
case WM_VSCROLL:
h = GetDlgItem(hdlg, IDC_SLIDER_GAIN);
sound_gain = (9 - SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1;
sound_gain = (9 - SendMessage(h, TBM_GETPOS, (WPARAM) 0, 0)) << 1;
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
h = GetDlgItem(hdlg, IDC_SLIDER_GAIN);
sound_gain = (9 - SendMessage(h, TBM_GETPOS, (WPARAM)0, 0)) << 1;
sound_gain = (9 - SendMessage(h, TBM_GETPOS, (WPARAM) 0, 0)) << 1;
config_save();
EndDialog(hdlg, 0);
return TRUE;
@@ -81,12 +79,11 @@ SoundGainDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
return(FALSE);
return (FALSE);
}
void
SoundGainDialogCreate(HWND hwnd)
{
DialogBox(hinstance, (LPCTSTR)DLG_SND_GAIN, hwnd, SoundGainDialogProcedure);
DialogBox(hinstance, (LPCTSTR) DLG_SND_GAIN, hwnd, SoundGainDialogProcedure);
}

View File

@@ -32,7 +32,6 @@
#include <86box/sound.h>
#include <86box/win.h>
#if defined(__amd64__) || defined(__aarch64__)
static LRESULT CALLBACK
#else
@@ -55,20 +54,20 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
h = GetDlgItem(hdlg, IDC_WIDTHSPIN);
h2 = GetDlgItem(hdlg, IDC_EDIT_WIDTH);
SendMessage(h, UDM_SETBUDDY, (WPARAM)h2, 0);
SendMessage(h, UDM_SETBUDDY, (WPARAM) h2, 0);
SendMessage(h, UDM_SETRANGE, 0, (120 << 16) | 2048);
accel.nSec = 0;
accel.nInc = 8;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel);
SendMessage(h, UDM_SETACCEL, 1, (LPARAM) &accel);
SendMessage(h, UDM_SETPOS, 0, r.right - r.left);
h = GetDlgItem(hdlg, IDC_HEIGHTSPIN);
h2 = GetDlgItem(hdlg, IDC_EDIT_HEIGHT);
SendMessage(h, UDM_SETBUDDY, (WPARAM)h2, 0);
SendMessage(h, UDM_SETBUDDY, (WPARAM) h2, 0);
SendMessage(h, UDM_SETRANGE, 0, (120 << 16) | 2048);
accel2.nSec = 0;
accel2.nInc = 8;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel2);
SendMessage(h, UDM_SETACCEL, 1, (LPARAM) &accel2);
SendMessage(h, UDM_SETPOS, 0, r.bottom - r.top);
h = GetDlgItem(hdlg, IDC_CHECK_LOCK_SIZE);
@@ -79,7 +78,7 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
switch (LOWORD(wParam)) {
case IDOK:
lptsTemp = (LPTSTR) malloc(512 * sizeof(WCHAR));
stransi = (char *)malloc(512);
stransi = (char *) malloc(512);
h = GetDlgItem(hdlg, IDC_EDIT_WIDTH);
SendMessage(h, WM_GETTEXT, 255, (LPARAM) lptsTemp);
@@ -168,12 +167,11 @@ SpecifyDimensionsDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM
break;
}
return(FALSE);
return (FALSE);
}
void
SpecifyDimensionsDialogCreate(HWND hwnd)
{
DialogBox(hinstance, (LPCTSTR)DLG_SPECIFY_DIM, hwnd, SpecifyDimensionsDialogProcedure);
DialogBox(hinstance, (LPCTSTR) DLG_SPECIFY_DIM, hwnd, SpecifyDimensionsDialogProcedure);
}

View File

@@ -54,11 +54,9 @@
#include <86box/ui.h>
#include <86box/win.h>
HWND hwndSBAR;
int update_icons = 1, reset_occurred = 1;
static LONG_PTR OriginalProcedure;
static WCHAR **sbTips;
static int *iStatusWidths;
@@ -77,17 +75,26 @@ fdd_type_to_icon(int type)
{
int ret = 248;
switch(type) {
switch (type) {
case 0:
break;
case 1: case 2: case 3: case 4:
case 5: case 6:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
ret = 16;
break;
case 7: case 8: case 9: case 10:
case 11: case 12: case 13:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
ret = 24;
break;
@@ -95,10 +102,9 @@ fdd_type_to_icon(int type)
break;
}
return(ret);
return (ret);
}
/* FIXME: should be hdd_count() in hdd.c */
static int
hdd_count(int bus)
@@ -106,15 +112,14 @@ hdd_count(int bus)
int c = 0;
int i;
for (i=0; i<HDD_NUM; i++) {
for (i = 0; i < HDD_NUM; i++) {
if (hdd[i].bus == bus)
c++;
}
return(c);
return (c);
}
void
ui_sb_timer_callback(int pane)
{
@@ -123,7 +128,7 @@ ui_sb_timer_callback(int pane)
if (sb_part_icons && sb_part_icons[pane]) {
SendMessage(hwndSBAR, SB_SETICON, pane,
(LPARAM)hIcon[sb_part_icons[pane]]);
(LPARAM) hIcon[sb_part_icons[pane]]);
}
} else
reset_occurred &= ~1;
@@ -131,8 +136,6 @@ ui_sb_timer_callback(int pane)
reset_occurred &= ~2;
}
/* API */
/* API: update one of the icons after activity. */
void
@@ -151,15 +154,13 @@ ui_sb_update_icon(int tag, int active)
sb_part_icons[found] |= 1;
PostMessage(hwndSBAR, SB_SETICON, found,
(LPARAM)hIcon[sb_part_icons[found]]);
(LPARAM) hIcon[sb_part_icons[found]]);
reset_occurred = 2;
SetTimer(hwndMain, 0x8000 | found, 75, NULL);
}
}
/* API: This is for the drive state indicator. */
void
ui_sb_update_icon_state(int tag, int state)
@@ -175,11 +176,10 @@ ui_sb_update_icon_state(int tag, int state)
sb_part_icons[found] |= (state ? 128 : 0);
SendMessage(hwndSBAR, SB_SETICON, found,
(LPARAM)hIcon[sb_part_icons[found]]);
(LPARAM) hIcon[sb_part_icons[found]]);
}
}
static void
StatusBarCreateCassetteTip(int part)
{
@@ -197,11 +197,10 @@ StatusBarCreateCassetteTip(int part)
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateCartridgeTip(int part)
{
@@ -211,22 +210,21 @@ StatusBarCreateCartridgeTip(int part)
if (strlen(cart_fns[drive]) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2150),
drive+1, plat_get_string(IDS_2057));
drive + 1, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, cart_fns[drive], sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2150),
drive+1, fn);
drive + 1, fn);
}
if (sbTips[part] != NULL) {
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateFloppyTip(int part)
{
@@ -240,22 +238,21 @@ StatusBarCreateFloppyTip(int part)
strlen(fdd_getname(fdd_get_type(drive))) + 1);
if (strlen(floppyfns[drive]) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2108),
drive+1, wtext, plat_get_string(IDS_2057));
drive + 1, wtext, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, floppyfns[drive], sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2108),
drive+1, wtext, fn);
drive + 1, wtext, fn);
}
if (sbTips[part] != NULL) {
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateCdromTip(int part)
{
@@ -272,24 +269,23 @@ StatusBarCreateCdromTip(int part)
if (cdrom[drive].host_drive == 200) {
if (strlen(cdrom[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_5120),
drive+1, szText, plat_get_string(IDS_2057));
drive + 1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, cdrom[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_5120),
drive+1, szText, fn);
drive + 1, szText, fn);
}
} else
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
_swprintf(tempTip, plat_get_string(IDS_5120), drive + 1, szText, plat_get_string(IDS_2057));
if (sbTips[part] != NULL) {
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 4);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 4);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateZIPTip(int part)
{
@@ -307,22 +303,21 @@ StatusBarCreateZIPTip(int part)
if (strlen(zip_drives[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, plat_get_string(IDS_2057));
type, drive + 1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, zip_drives[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, fn);
type, drive + 1, szText, fn);
}
if (sbTips[part] != NULL) {
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateMOTip(int part)
{
@@ -338,22 +333,21 @@ StatusBarCreateMOTip(int part)
if (strlen(mo_drives[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2115),
drive+1, szText, plat_get_string(IDS_2057));
drive + 1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, mo_drives[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2115),
drive+1, szText, fn);
drive + 1, szText, fn);
}
if (sbTips[part] != NULL) {
free(sbTips[part]);
sbTips[part] = NULL;
}
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateDiskTip(int part)
{
@@ -368,11 +362,10 @@ StatusBarCreateDiskTip(int part)
_swprintf(tempTip, plat_get_string(IDS_4096), szText);
if (sbTips[part] != NULL)
free(sbTips[part]);
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateNetworkTip(int part)
{
@@ -382,11 +375,10 @@ StatusBarCreateNetworkTip(int part)
if (sbTips[part] != NULL)
free(sbTips[part]);
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
static void
StatusBarCreateSoundTip(int part)
{
@@ -396,11 +388,10 @@ StatusBarCreateSoundTip(int part)
if (sbTips[part] != NULL)
free(sbTips[part]);
sbTips[part] = (WCHAR *)malloc((wcslen(tempTip) << 1) + 2);
sbTips[part] = (WCHAR *) malloc((wcslen(tempTip) << 1) + 2);
wcscpy(sbTips[part], tempTip);
}
/* API */
void
ui_sb_update_tip(int meaning)
@@ -413,7 +404,7 @@ ui_sb_update_tip(int meaning)
part = sb_map[meaning];
if (part != 0xff) {
switch(meaning & 0xf0) {
switch (meaning & 0xf0) {
case SB_CASSETTE:
StatusBarCreateCassetteTip(part);
break;
@@ -454,21 +445,22 @@ ui_sb_update_tip(int meaning)
break;
}
SendMessage(hwndSBAR, SB_SETTIPTEXT, part, (LPARAM)sbTips[part]);
SendMessage(hwndSBAR, SB_SETTIPTEXT, part, (LPARAM) sbTips[part]);
}
}
static void
StatusBarDestroyTips(void)
{
int i;
if (sb_parts == 0) return;
if (sb_parts == 0)
return;
if (! sbTips) return;
if (!sbTips)
return;
for (i=0; i<sb_parts; i++) {
for (i = 0; i < sb_parts; i++) {
if (sbTips[i]) {
free(sbTips[i]);
sbTips[i] = NULL;
@@ -479,7 +471,6 @@ StatusBarDestroyTips(void)
sbTips = NULL;
}
/* API: mark the status bar as not ready. */
/* Values: -1 - not ready, but don't clear POST text
0 - not ready
@@ -498,7 +489,6 @@ ui_sb_set_ready(int ready)
sb_ready = ready;
}
/* API: update the status bar panes. */
void
ui_sb_update_panes(void)
@@ -536,8 +526,8 @@ ui_sb_update_panes(void)
if (sb_parts > 0) {
for (i = 0; i < sb_parts; i++)
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)NULL);
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)0, (LPARAM)NULL);
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM) NULL);
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM) 0, (LPARAM) NULL);
if (iStatusWidths) {
free(iStatusWidths);
@@ -561,46 +551,37 @@ ui_sb_update_panes(void)
sb_parts++;
if (cart_int)
sb_parts += 2;
for (i=0; i<FDD_NUM; i++) {
for (i = 0; i < FDD_NUM; i++) {
if (fdd_get_type(i) != 0)
sb_parts++;
}
hdc_name = hdc_get_internal_name(hdc_current);
for (i=0; i<CDROM_NUM; i++) {
for (i = 0; i < CDROM_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (cdrom[i].bus_type != 0)
sb_parts++;
}
for (i=0; i<ZIP_NUM; i++) {
for (i = 0; i < ZIP_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (zip_drives[i].bus_type != 0)
sb_parts++;
}
for (i=0; i<MO_NUM; i++) {
for (i = 0; i < MO_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (mo_drives[i].bus_type != 0)
sb_parts++;
@@ -617,20 +598,19 @@ ui_sb_update_panes(void)
sb_parts++;
if (c_ide && (ide_int || !memcmp(hdc_name, "xtide", 5) || !memcmp(hdc_name, "ide", 3)))
sb_parts++;
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)))
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) || (scsi_card_current[2] != 0) || (scsi_card_current[3] != 0)))
sb_parts++;
if (do_net)
sb_parts++;
sb_parts += 2;
iStatusWidths = (int *)malloc(sb_parts * sizeof(int));
iStatusWidths = (int *) malloc(sb_parts * sizeof(int));
memset(iStatusWidths, 0, sb_parts * sizeof(int));
sb_part_meanings = (int *)malloc(sb_parts * sizeof(int));
sb_part_meanings = (int *) malloc(sb_parts * sizeof(int));
memset(sb_part_meanings, 0, sb_parts * sizeof(int));
sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t));
sb_part_icons = (uint8_t *) malloc(sb_parts * sizeof(uint8_t));
memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t));
sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *));
sbTips = (WCHAR **) malloc(sb_parts * sizeof(WCHAR *));
memset(sbTips, 0, sb_parts * sizeof(WCHAR *));
sb_parts = 0;
@@ -641,7 +621,7 @@ ui_sb_update_panes(void)
sb_map[SB_CASSETTE] = sb_parts;
sb_parts++;
}
for (i=0; i<2; i++) {
for (i = 0; i < 2; i++) {
if (cart_int) {
edge += icon_width;
iStatusWidths[sb_parts] = edge;
@@ -650,7 +630,7 @@ ui_sb_update_panes(void)
sb_parts++;
}
}
for (i=0; i<FDD_NUM; i++) {
for (i = 0; i < FDD_NUM; i++) {
if (fdd_get_type(i) != 0) {
edge += icon_width;
iStatusWidths[sb_parts] = edge;
@@ -659,14 +639,11 @@ ui_sb_update_panes(void)
sb_parts++;
}
}
for (i=0; i<CDROM_NUM; i++) {
for (i = 0; i < CDROM_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (cdrom[i].bus_type != 0) {
edge += icon_width;
@@ -676,14 +653,11 @@ ui_sb_update_panes(void)
sb_parts++;
}
}
for (i=0; i<ZIP_NUM; i++) {
for (i = 0; i < ZIP_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (zip_drives[i].bus_type != 0) {
edge += icon_width;
@@ -693,14 +667,11 @@ ui_sb_update_panes(void)
sb_parts++;
}
}
for (i=0; i<MO_NUM; i++) {
for (i = 0; i < MO_NUM; i++) {
/* Could be Internal or External IDE.. */
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) &&
!ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
if ((mo_drives[i].bus_type == MO_BUS_ATAPI) && !ide_int && memcmp(hdc_name, "xtide", 5) && memcmp(hdc_name, "ide", 3))
continue;
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int &&
(scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) &&
(scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
if ((mo_drives[i].bus_type == MO_BUS_SCSI) && !scsi_int && (scsi_card_current[0] == 0) && (scsi_card_current[1] == 0) && (scsi_card_current[2] == 0) && (scsi_card_current[3] == 0))
continue;
if (mo_drives[i].bus_type != 0) {
edge += icon_width;
@@ -738,8 +709,7 @@ ui_sb_update_panes(void)
sb_map[SB_HDD | HDD_BUS_IDE] = sb_parts;
sb_parts++;
}
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) ||
(scsi_card_current[2] != 0) || (scsi_card_current[3] != 0))) {
if (c_scsi && (scsi_int || (scsi_card_current[0] != 0) || (scsi_card_current[1] != 0) || (scsi_card_current[2] != 0) || (scsi_card_current[3] != 0))) {
edge += icon_width;
iStatusWidths[sb_parts] = edge;
sb_part_meanings[sb_parts] = SB_HDD | HDD_BUS_SCSI;
@@ -764,11 +734,11 @@ ui_sb_update_panes(void)
iStatusWidths[sb_parts] = -1;
sb_part_meanings[sb_parts] = SB_TEXT;
sb_map[SB_TEXT] = sb_parts;
sb_parts ++;
sb_parts++;
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths);
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM) sb_parts, (LPARAM) iStatusWidths);
for (i=0; i<sb_parts; i++) {
for (i = 0; i < sb_parts; i++) {
switch (sb_part_meanings[i] & 0xf0) {
case SB_CASSETTE: /* Cassette */
sb_part_icons[i] = (strlen(cassette_fname) == 0) ? 128 : 0;
@@ -826,17 +796,17 @@ ui_sb_update_panes(void)
break;
case SB_TEXT: /* Status text */
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L"");
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"");
sb_part_icons[i] = 255;
break;
}
if (sb_part_icons[i] != 255) {
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM)L"");
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)hIcon[sb_part_icons[i]]);
SendMessage(hwndSBAR, SB_SETTIPTEXT, i, (LPARAM)sbTips[i]);
SendMessage(hwndSBAR, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"");
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM) hIcon[sb_part_icons[i]]);
SendMessage(hwndSBAR, SB_SETTIPTEXT, i, (LPARAM) sbTips[i]);
} else
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)NULL);
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM) NULL);
}
sb_ready = 1;
@@ -844,19 +814,19 @@ ui_sb_update_panes(void)
reset_occurred |= 1;
}
static VOID APIENTRY
StatusBarPopupMenu(HWND hwnd, POINT pt, int id)
{
HMENU menu;
if (id >= (sb_parts - 1)) return;
if (id >= (sb_parts - 1))
return;
pt.x = id * icon_width; /* Justify to the left. */
pt.y = 0; /* Justify to the top. */
ClientToScreen(hwnd, (LPPOINT) &pt);
switch(sb_part_meanings[id] & 0xF0) {
switch (sb_part_meanings[id] & 0xF0) {
case SB_CASSETTE:
menu = media_menu_get_cassette();
break;
@@ -886,7 +856,8 @@ StatusBarPopupMenu(HWND hwnd, POINT pt, int id)
/* API: Load status bar icons */
void
StatusBarLoadIcon(HINSTANCE hInst) {
StatusBarLoadIcon(HINSTANCE hInst)
{
win_load_icon_set();
}
@@ -907,11 +878,11 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_COMMAND:
media_menu_proc(hwnd, message, wParam, lParam);
return(0);
return (0);
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
GetClientRect(hwnd, (LPRECT)& rc);
GetClientRect(hwnd, (LPRECT) &rc);
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (PtInRect((LPRECT) &rc, pt))
@@ -919,7 +890,7 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_LBUTTONDBLCLK:
GetClientRect(hwnd, (LPRECT)& rc);
GetClientRect(hwnd, (LPRECT) &rc);
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
item_id = (pt.x / icon_width);
@@ -931,31 +902,30 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_DPICHANGED_AFTERPARENT:
/* DPI changed, reload icons */
hInst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
hInst = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
dpi = win_get_dpi(hwnd);
icon_width = MulDiv(SB_ICON_WIDTH, dpi, 96);
StatusBarLoadIcon(hInst);
for (i=0; i<sb_parts; i++) {
for (i = 0; i < sb_parts; i++) {
if (sb_part_icons[i] != 255) {
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM)hIcon[sb_part_icons[i]]);
SendMessage(hwndSBAR, SB_SETICON, i, (LPARAM) hIcon[sb_part_icons[i]]);
}
iStatusWidths[i] = (i+1)*icon_width;
iStatusWidths[i] = (i + 1) * icon_width;
}
iStatusWidths[i-1] = -1;
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths);
iStatusWidths[i - 1] = -1;
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM) sb_parts, (LPARAM) iStatusWidths);
break;
default:
return(CallWindowProc((WNDPROC)OriginalProcedure,
return (CallWindowProc((WNDPROC) OriginalProcedure,
hwnd, message, wParam, lParam));
}
return(0);
return (0);
}
/* API: Create and set up the Status Bar window. */
void
StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst)
@@ -980,50 +950,49 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst)
/* Create the window, and make sure it's using the STATUS class. */
hwndSBAR = CreateWindowEx(0,
STATUSCLASSNAME,
(LPCTSTR)NULL,
SBARS_SIZEGRIP|WS_CHILD|WS_VISIBLE|SBT_TOOLTIPS,
0, dh-17, dw, 17,
(LPCTSTR) NULL,
SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE | SBT_TOOLTIPS,
0, dh - 17, dw, 17,
hwndParent,
(HMENU)idStatus, hInst, NULL);
(HMENU) idStatus, hInst, NULL);
/* Replace the original procedure with ours. */
OriginalProcedure = GetWindowLongPtr(hwndSBAR, GWLP_WNDPROC);
SetWindowLongPtr(hwndSBAR, GWLP_WNDPROC, (LONG_PTR)&StatusBarProcedure);
SetWindowLongPtr(hwndSBAR, GWLP_WNDPROC, (LONG_PTR) &StatusBarProcedure);
SendMessage(hwndSBAR, SB_SETMINHEIGHT, (WPARAM)17, (LPARAM)0);
SendMessage(hwndSBAR, SB_SETMINHEIGHT, (WPARAM) 17, (LPARAM) 0);
/* Align the window with the parent (main) window. */
GetWindowRect(hwndSBAR, &rectDialog);
SetWindowPos(hwndSBAR,
HWND_TOPMOST,
rectDialog.left, rectDialog.top,
rectDialog.right-rectDialog.left,
rectDialog.bottom-rectDialog.top,
rectDialog.right - rectDialog.left,
rectDialog.bottom - rectDialog.top,
SWP_SHOWWINDOW);
/* Initialize the status bar. This is clumsy. */
sb_parts = 1;
iStatusWidths = (int *)malloc(sb_parts * sizeof(int));
iStatusWidths = (int *) malloc(sb_parts * sizeof(int));
memset(iStatusWidths, 0, sb_parts * sizeof(int));
sb_part_meanings = (int *)malloc(sb_parts * sizeof(int));
sb_part_meanings = (int *) malloc(sb_parts * sizeof(int));
memset(sb_part_meanings, 0, sb_parts * sizeof(int));
sb_part_icons = (uint8_t *)malloc(sb_parts * sizeof(uint8_t));
sb_part_icons = (uint8_t *) malloc(sb_parts * sizeof(uint8_t));
memset(sb_part_icons, 0, sb_parts * sizeof(uint8_t));
sbTips = (WCHAR **)malloc(sb_parts * sizeof(WCHAR *));
sbTips = (WCHAR **) malloc(sb_parts * sizeof(WCHAR *));
memset(sbTips, 0, sb_parts * sizeof(WCHAR *));
sb_parts = 0;
iStatusWidths[sb_parts] = -1;
sb_part_meanings[sb_parts] = SB_TEXT;
sb_part_icons[sb_parts] = 255;
sb_parts++;
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths);
SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM) sb_parts, (LPARAM) iStatusWidths);
SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS,
(LPARAM)plat_get_string(IDS_2117));
(LPARAM) plat_get_string(IDS_2117));
sb_ready = 1;
}
void
ui_sb_update_text()
{
@@ -1035,10 +1004,9 @@ ui_sb_update_text()
part = sb_map[SB_TEXT];
if (part != 0xff)
SendMessage(hwndSBAR, SB_SETTEXT, part | SBT_NOBORDERS, (LPARAM)((sb_text[0] != L'\0') ? sb_text : sb_bugtext));
SendMessage(hwndSBAR, SB_SETTEXT, part | SBT_NOBORDERS, (LPARAM) ((sb_text[0] != L'\0') ? sb_text : sb_bugtext));
}
/* API */
void
ui_sb_set_text_w(wchar_t *wstr)
@@ -1050,7 +1018,6 @@ ui_sb_set_text_w(wchar_t *wstr)
ui_sb_update_text();
}
/* API */
void
ui_sb_set_text(char *str)
@@ -1062,7 +1029,6 @@ ui_sb_set_text(char *str)
ui_sb_update_text();
}
/* API */
void
ui_sb_bugui(char *str)
@@ -1076,6 +1042,6 @@ ui_sb_bugui(char *str)
/* API */
void
ui_sb_mt32lcd(char* str)
ui_sb_mt32lcd(char *str)
{
}

View File

@@ -31,41 +31,38 @@
#include <86box/plat.h>
#include <86box/thread.h>
typedef struct {
HANDLE handle;
} win_event_t;
thread_t *
thread_create(void (*func)(void *param), void *param)
{
uintptr_t bt = _beginthread(func, 0, param);
return((thread_t *)bt);
return ((thread_t *) bt);
}
int
thread_test_mutex(thread_t *arg)
{
if (arg == NULL) return(0);
if (arg == NULL)
return (0);
return (WaitForSingleObject(arg, 0) == WAIT_OBJECT_0) ? 1 : 0;
}
int
thread_wait(thread_t *arg)
{
if (arg == NULL) return(0);
if (arg == NULL)
return (0);
if (WaitForSingleObject(arg, INFINITE)) return(1);
if (WaitForSingleObject(arg, INFINITE))
return (1);
return(0);
return (0);
}
event_t *
thread_create_event(void)
{
@@ -73,63 +70,64 @@ thread_create_event(void)
ev->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
return((event_t *)ev);
return ((event_t *) ev);
}
void
thread_set_event(event_t *arg)
{
win_event_t *ev = (win_event_t *)arg;
win_event_t *ev = (win_event_t *) arg;
if (arg == NULL) return;
if (arg == NULL)
return;
SetEvent(ev->handle);
}
void
thread_reset_event(event_t *arg)
{
win_event_t *ev = (win_event_t *)arg;
win_event_t *ev = (win_event_t *) arg;
if (arg == NULL) return;
if (arg == NULL)
return;
ResetEvent(ev->handle);
}
int
thread_wait_event(event_t *arg, int timeout)
{
win_event_t *ev = (win_event_t *)arg;
win_event_t *ev = (win_event_t *) arg;
if (arg == NULL) return(0);
if (arg == NULL)
return (0);
if (ev->handle == NULL) return(0);
if (ev->handle == NULL)
return (0);
if (timeout == -1)
timeout = INFINITE;
if (WaitForSingleObject(ev->handle, timeout)) return(1);
if (WaitForSingleObject(ev->handle, timeout))
return (1);
return(0);
return (0);
}
void
thread_destroy_event(event_t *arg)
{
win_event_t *ev = (win_event_t *)arg;
win_event_t *ev = (win_event_t *) arg;
if (arg == NULL) return;
if (arg == NULL)
return;
CloseHandle(ev->handle);
free(ev);
}
mutex_t *
thread_create_mutex(void)
{
@@ -140,39 +138,39 @@ thread_create_mutex(void)
return mutex;
}
int
thread_wait_mutex(mutex_t *mutex)
{
if (mutex == NULL) return(0);
if (mutex == NULL)
return (0);
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION) mutex;
EnterCriticalSection(critsec);
return 1;
}
int
thread_release_mutex(mutex_t *mutex)
{
if (mutex == NULL) return(0);
if (mutex == NULL)
return (0);
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION) mutex;
LeaveCriticalSection(critsec);
return 1;
}
void
thread_close_mutex(mutex_t *mutex)
{
if (mutex == NULL) return;
if (mutex == NULL)
return;
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION)mutex;
LPCRITICAL_SECTION critsec = (LPCRITICAL_SECTION) mutex;
DeleteCriticalSection(critsec);

View File

@@ -17,7 +17,6 @@ static HIMAGELIST hImageList = NULL;
static wchar_t wTitle[512] = { 0 };
static WNDPROC pOriginalProcedure = NULL;
enum image_index {
RUN,
PAUSE,
@@ -28,7 +27,6 @@ enum image_index {
SETTINGS
};
void
ToolBarLoadIcons()
{
@@ -56,15 +54,15 @@ ToolBarLoadIcons()
SendMessage(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImageList);
}
int
ToolBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_NOTIFY:
switch (((LPNMHDR) lParam)->code) {
case TTN_GETDISPINFO: {
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT) lParam;
// Set the instance of the module that contains the resource.
lpttt->hinst = hinstance;
@@ -101,10 +99,9 @@ ToolBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
}
return(CallWindowProc(pOriginalProcedure, hwnd, message, wParam, lParam));
return (CallWindowProc(pOriginalProcedure, hwnd, message, wParam, lParam));
}
void
ToolBarUpdatePause(int pause)
{
@@ -117,19 +114,17 @@ ToolBarUpdatePause(int pause)
SendMessage(hwndToolbar, TB_SETBUTTONINFO, IDM_ACTION_PAUSE, (LPARAM) &tbbi);
}
static TBBUTTON buttons[] = {
{ PAUSE, IDM_ACTION_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 },
{ HARD_RESET, IDM_ACTION_HRESET, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 },
{ ACPI_SHUTDOWN, 0, TBSTATE_HIDDEN, BTNS_BUTTON, { 0 }, 0, 0 },
{ 0, 0, TBSTATE_INDETERMINATE, BTNS_SEP, { 0 }, 0, 0 },
{ CTRL_ALT_DEL, IDM_ACTION_RESET_CAD, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 },
{ CTRL_ALT_ESC, IDM_ACTION_CTRL_ALT_ESC, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 },
{ 0, 0, TBSTATE_INDETERMINATE, BTNS_SEP, { 0 }, 0, 0 },
{ SETTINGS, IDM_CONFIG, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0 }
{PAUSE, IDM_ACTION_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0},
{ HARD_RESET, IDM_ACTION_HRESET, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0},
{ ACPI_SHUTDOWN, 0, TBSTATE_HIDDEN, BTNS_BUTTON, { 0 }, 0, 0},
{ 0, 0, TBSTATE_INDETERMINATE, BTNS_SEP, { 0 }, 0, 0},
{ CTRL_ALT_DEL, IDM_ACTION_RESET_CAD, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0},
{ CTRL_ALT_ESC, IDM_ACTION_CTRL_ALT_ESC, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0},
{ 0, 0, TBSTATE_INDETERMINATE, BTNS_SEP, { 0 }, 0, 0},
{ SETTINGS, IDM_CONFIG, TBSTATE_ENABLED, BTNS_BUTTON, { 0 }, 0, 0}
};
void
ToolBarCreate(HWND hwndParent, HINSTANCE hInst)
{
@@ -139,11 +134,7 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst)
// Create the toolbar.
hwndToolbar = CreateWindowEx(WS_EX_PALETTEWINDOW, TOOLBARCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |
TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE |
CCS_NOPARENTALIGN | CCS_NORESIZE |
CCS_NODIVIDER,
WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER,
0, 0, 0, 0,
hwndParent, NULL, hInst, NULL);
@@ -154,26 +145,24 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst)
SendMessage(hwndToolbar, TB_ADDBUTTONS, sizeof(buttons) / sizeof(TBBUTTON), (LPARAM) &buttons);
// Autosize the toolbar and determine its size.
btnSize = LOWORD(SendMessage(hwndToolbar, TB_GETBUTTONSIZE, 0,0));
btnSize = LOWORD(SendMessage(hwndToolbar, TB_GETBUTTONSIZE, 0, 0));
// Replace the original procedure with ours.
pOriginalProcedure = (WNDPROC) GetWindowLongPtr(hwndToolbar, GWLP_WNDPROC);
SetWindowLongPtr(hwndToolbar, GWLP_WNDPROC, (LONG_PTR)&ToolBarProcedure);
SetWindowLongPtr(hwndToolbar, GWLP_WNDPROC, (LONG_PTR) &ToolBarProcedure);
// Make sure the Pause button is in the correct state.
ToolBarUpdatePause(dopause);
// Create the containing Rebar.
hwndRebar = CreateWindowEx(0, REBARCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN | RBS_VARHEIGHT |
CCS_NODIVIDER | CCS_NOPARENTALIGN,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | CCS_NOPARENTALIGN,
0, 0, scrnsz_x, 0,
hwndParent, NULL, hInst, NULL);
// Create and send the REBARINFO structure.
rbi.cbSize = sizeof(rbi);
SendMessage(hwndRebar, RB_SETBARINFO, 0, (LPARAM)&rbi);
SendMessage(hwndRebar, RB_SETBARINFO, 0, (LPARAM) &rbi);
// Add the toolbar to the rebar.
rbbi.cbSize = sizeof(rbbi);
@@ -182,13 +171,13 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst)
rbbi.cxMinChild = 0;
rbbi.cyMinChild = btnSize;
rbbi.fStyle = RBBS_NOGRIPPER;
SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM)&rbbi);
SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM) &rbbi);
// Add a label for machine information.
rbbi.fMask = RBBIM_TEXT | RBBIM_STYLE;
rbbi.lpText = TEXT("Test");
rbbi.fStyle = RBBS_NOGRIPPER;
SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM)&rbbi);
SendMessage(hwndRebar, RB_INSERTBAND, -1, (LPARAM) &rbbi);
SendMessage(hwndRebar, RB_MAXIMIZEBAND, 0, 0);
ShowWindow(hwndRebar, TRUE);
@@ -196,12 +185,11 @@ ToolBarCreate(HWND hwndParent, HINSTANCE hInst)
return;
}
wchar_t *
ui_window_title(wchar_t *s)
{
REBARBANDINFO rbbi = { 0 };
if (! video_fullscreen) {
if (!video_fullscreen) {
if (s != NULL) {
wcsncpy(wTitle, s, sizeof_w(wTitle) - 1);
} else
@@ -216,5 +204,5 @@ ui_window_title(wchar_t *s)
s = wTitle;
}
return(s);
return (s);
}

View File

@@ -47,12 +47,11 @@
#include <86box/discord.h>
#ifdef MTR_ENABLED
#include <minitrace/minitrace.h>
# include <minitrace/minitrace.h>
#endif
#define TIMER_1SEC 1 /* ID of the one-second timer */
/* Platform Public data, specific. */
HWND hwndMain = NULL, /* application main window */
hwndRender = NULL; /* machine render window */
@@ -73,7 +72,6 @@ int dpi = 96;
extern char openfilestring[512];
extern WCHAR wopenfilestring[512];
/* Local data. */
static int manager_wm = 0;
static int save_window_pos = 0, pause_state = 0;
@@ -81,29 +79,30 @@ static int padded_frame = 0;
static int vis = -1;
/* Per Monitor DPI Aware v2 APIs, Windows 10 v1703+ */
void* user32_handle = NULL;
static UINT (WINAPI *pGetDpiForWindow)(HWND);
static UINT (WINAPI *pGetSystemMetricsForDpi)(int i, UINT dpi);
static DPI_AWARENESS_CONTEXT (WINAPI *pGetWindowDpiAwarenessContext)(HWND);
static BOOL (WINAPI *pAreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT A, DPI_AWARENESS_CONTEXT B);
void *user32_handle = NULL;
static UINT(WINAPI *pGetDpiForWindow)(HWND);
static UINT(WINAPI *pGetSystemMetricsForDpi)(int i, UINT dpi);
static DPI_AWARENESS_CONTEXT(WINAPI *pGetWindowDpiAwarenessContext)(HWND);
static BOOL(WINAPI *pAreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT A, DPI_AWARENESS_CONTEXT B);
static dllimp_t user32_imports[] = {
{ "GetDpiForWindow", &pGetDpiForWindow },
{ "GetSystemMetricsForDpi", &pGetSystemMetricsForDpi },
{ "GetWindowDpiAwarenessContext", &pGetWindowDpiAwarenessContext },
{ "AreDpiAwarenessContextsEqual", &pAreDpiAwarenessContextsEqual },
{ NULL, NULL }
{"GetDpiForWindow", &pGetDpiForWindow },
{ "GetSystemMetricsForDpi", &pGetSystemMetricsForDpi },
{ "GetWindowDpiAwarenessContext", &pGetWindowDpiAwarenessContext},
{ "AreDpiAwarenessContextsEqual", &pAreDpiAwarenessContextsEqual},
{ NULL, NULL }
};
/* Taskbar application ID API, Windows 7+ */
void* shell32_handle = NULL;
static HRESULT (WINAPI *pSetCurrentProcessExplicitAppUserModelID)(PCWSTR AppID);
static dllimp_t shell32_imports[]= {
{ "SetCurrentProcessExplicitAppUserModelID", &pSetCurrentProcessExplicitAppUserModelID },
{ NULL, NULL }
void *shell32_handle = NULL;
static HRESULT(WINAPI *pSetCurrentProcessExplicitAppUserModelID)(PCWSTR AppID);
static dllimp_t shell32_imports[] = {
{"SetCurrentProcessExplicitAppUserModelID", &pSetCurrentProcessExplicitAppUserModelID},
{ NULL, NULL }
};
int
win_get_dpi(HWND hwnd) {
win_get_dpi(HWND hwnd)
{
if (user32_handle != NULL) {
return pGetDpiForWindow(hwnd);
} else {
@@ -114,7 +113,9 @@ win_get_dpi(HWND hwnd) {
}
}
int win_get_system_metrics(int index, int dpi) {
int
win_get_system_metrics(int index, int dpi)
{
if (user32_handle != NULL) {
/* Only call GetSystemMetricsForDpi when we are using PMv2 */
DPI_AWARENESS_CONTEXT c = pGetWindowDpiAwarenessContext(hwndMain);
@@ -152,7 +153,8 @@ show_cursor(int val)
if (val == 0) {
while (1)
if (ShowCursor(FALSE) < 0) break;
if (ShowCursor(FALSE) < 0)
break;
} else
ShowCursor(TRUE);
@@ -174,21 +176,16 @@ video_toggle_option(HMENU h, int *val, int id)
static int
delete_submenu(HMENU parent, HMENU target)
{
for (int i = 0; i < GetMenuItemCount(parent); i++)
{
for (int i = 0; i < GetMenuItemCount(parent); i++) {
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU;
if (GetMenuItemInfo(parent, i, TRUE, &mii) != 0)
{
if (mii.hSubMenu == target)
{
if (GetMenuItemInfo(parent, i, TRUE, &mii) != 0) {
if (mii.hSubMenu == target) {
DeleteMenu(parent, i, MF_BYPOSITION);
return 1;
}
else if (mii.hSubMenu != NULL)
{
} else if (mii.hSubMenu != NULL) {
if (delete_submenu(mii.hSubMenu, target))
return 1;
}
@@ -207,19 +204,16 @@ show_render_options_menu()
if (vid_api == menu_vidapi)
return;
if (cur_menu != NULL)
{
if (cur_menu != NULL) {
if (delete_submenu(menuMain, cur_menu))
cur_menu = NULL;
}
if (cur_menu == NULL)
{
switch (IDM_VID_SDL_SW + vid_api)
{
if (cur_menu == NULL) {
switch (IDM_VID_SDL_SW + vid_api) {
case IDM_VID_OPENGL_CORE:
cur_menu = LoadMenu(hinstance, VID_GL_SUBMENU);
InsertMenu(GetSubMenu(menuMain, 1), 6, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR)cur_menu, plat_get_string(IDS_2144));
InsertMenu(GetSubMenu(menuMain, 1), 6, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR) cur_menu, plat_get_string(IDS_2144));
CheckMenuItem(menuMain, IDM_VID_GL_FPS_BLITTER, video_framerate == -1 ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GL_FPS_25, video_framerate == 25 ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GL_FPS_30, video_framerate == 30 ? MF_CHECKED : MF_UNCHECKED);
@@ -270,27 +264,27 @@ ResetAllMenus(void)
#ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_VNC, MF_UNCHECKED);
#endif
CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+4, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + 0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + 1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + 2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + 3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + 4, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_REMEMBER, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + 0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + 1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + 2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + 3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_HIDPI, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_CGACON, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+4, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601 + 0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601 + 1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601 + 2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + 0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + 1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + 2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + 3, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + 4, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_ACTION_RCTRL_IS_LALT, rctrl_is_lalt ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_ACTION_KBD_REQ_CAPTURE, kbd_req_capture ? MF_CHECKED : MF_UNCHECKED);
@@ -299,21 +293,21 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_VID_HIDE_STATUS_BAR, hide_status_bar ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_HIDE_TOOLBAR, hide_tool_bar ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43 ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED);
if (vid_resize == 1)
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_SW+vid_api, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_HIDPI, dpi_scale?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_SW + vid_api, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X + scale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_HIDPI, dpi_scale ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAYCT_601 + video_graytype, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
video_set_filter_menu(menuMain);
@@ -340,7 +334,6 @@ ResetAllMenus(void)
}
}
void
win_notify_dlg_open(void)
{
@@ -351,7 +344,6 @@ win_notify_dlg_open(void)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDDLGSTATUS, (WPARAM) 1, (LPARAM) hwndMain);
}
void
win_notify_dlg_closed(void)
{
@@ -361,7 +353,6 @@ win_notify_dlg_closed(void)
manager_wm = 0;
}
void
plat_power_off(void)
{
@@ -388,8 +379,8 @@ plat_power_off(void)
static void
handle_trace(HMENU hmenu, int trace)
{
EnableMenuItem(hmenu, IDM_ACTION_BEGIN_TRACE, trace? MF_GRAYED : MF_ENABLED);
EnableMenuItem(hmenu, IDM_ACTION_END_TRACE, trace? MF_ENABLED : MF_GRAYED);
EnableMenuItem(hmenu, IDM_ACTION_BEGIN_TRACE, trace ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(hmenu, IDM_ACTION_END_TRACE, trace ? MF_ENABLED : MF_GRAYED);
if (trace) {
init_trace();
} else {
@@ -413,11 +404,10 @@ input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
PRAWINPUT raw = NULL;
/* Here we read the raw input data */
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
raw = (PRAWINPUT)malloc(size);
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)) == size) {
switch(raw->header.dwType)
{
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
raw = (PRAWINPUT) malloc(size);
if (GetRawInputData((HRAWINPUT) lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)) == size) {
switch (raw->header.dwType) {
case RIM_TYPEKEYBOARD:
keyboard_handle(raw);
break;
@@ -457,15 +447,14 @@ input_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
default:
return(1);
return (1);
/* return(CallWindowProc((WNDPROC)input_orig_proc,
hwnd, message, wParam, lParam)); */
}
return(0);
return (0);
}
static LRESULT CALLBACK
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -479,7 +468,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
int temp_x, temp_y;
if (input_proc(hwnd, message, wParam, lParam) == 0)
return(0);
return (0);
switch (message) {
case WM_CREATE:
@@ -690,7 +679,8 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static const int fps[] = { -1, 25, 30, 50, 60, 75 };
int idx = 0;
for (; fps[idx] != video_framerate; idx++);
for (; fps[idx] != video_framerate; idx++)
;
CheckMenuItem(hmenu, IDM_VID_GL_FPS_BLITTER + idx, MF_UNCHECKED);
video_framerate = fps[LOWORD(wParam) - IDM_VID_GL_FPS_BLITTER];
CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED);
@@ -706,8 +696,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDM_VID_GL_SHADER:
win_notify_dlg_open();
if (file_dlg_st(hwnd, IDS_2143, video_shader, NULL, 0) == 0)
{
if (file_dlg_st(hwnd, IDS_2143, video_shader, NULL, 0) == 0) {
strcpy_s(video_shader, sizeof(video_shader), openfilestring);
EnableMenuItem(menuMain, IDM_VID_GL_NOSHADER, strlen(video_shader) > 0 ? MF_ENABLED : MF_DISABLED);
}
@@ -729,9 +718,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_FS_43:
case IDM_VID_FS_KEEPRATIO:
case IDM_VID_FS_INT:
CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_UNCHECKED);
video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL;
CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED);
device_force_redraw();
config_save();
break;
@@ -740,9 +729,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_SCALE_2X:
case IDM_VID_SCALE_3X:
case IDM_VID_SCALE_4X:
CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED);
scale = LOWORD(wParam) - IDM_VID_SCALE_1X;
CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_CHECKED);
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_CHECKED);
reset_screen_size();
device_force_redraw();
video_force_resize_set(1);
@@ -800,9 +789,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_GRAYCT_601:
case IDM_VID_GRAYCT_709:
case IDM_VID_GRAYCT_AVE:
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601 + video_graytype, MF_UNCHECKED);
video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601;
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED);
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601 + video_graytype, MF_CHECKED);
device_force_redraw();
config_save();
break;
@@ -812,20 +801,21 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_GRAY_AMBER:
case IDM_VID_GRAY_GREEN:
case IDM_VID_GRAY_WHITE:
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_UNCHECKED);
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_UNCHECKED);
video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB;
video_copy = (video_grayscale || invert_display) ? video_transform_copy : memcpy;
plat_vidapi_reload();
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED);
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
device_force_redraw();
config_save();
break;
case IDM_DISCORD:
if (! discord_loaded) break;
if (!discord_loaded)
break;
enable_discord ^= 1;
CheckMenuItem(hmenu, IDM_DISCORD, enable_discord ? MF_CHECKED : MF_UNCHECKED);
if(enable_discord) {
if (enable_discord) {
discord_init();
discord_update_activity(dopause);
} else
@@ -836,7 +826,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
media_menu_proc(hwnd, message, wParam, lParam);
break;
}
return(0);
return (0);
case WM_ENTERMENULOOP:
break;
@@ -847,7 +837,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
sbar_height = rect.bottom - rect.top;
GetWindowRect(hwndRebar, &rect);
tbar_height = rect.bottom - rect.top;
rect_p = (RECT*)lParam;
rect_p = (RECT *) lParam;
if (vid_resize == 1)
MoveWindow(hwnd, rect_p->left, rect_p->top, rect_p->right - rect_p->left, rect_p->bottom - rect_p->top, TRUE);
else if (vid_resize >= 2) {
@@ -868,13 +858,13 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (video_fullscreen & 1)
PostMessage(hwndMain, WM_LEAVEFULLSCREEN, 0, 0);
pos = (WINDOWPOS*)lParam;
pos = (WINDOWPOS *) lParam;
GetClientRect(hwndMain, &rect);
if (IsIconic(hwndMain)) {
plat_vidapi_enable(0);
minimized = 1;
return(0);
return (0);
} else if (minimized) {
minimized = 0;
video_force_resize_set(1);
@@ -930,7 +920,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
plat_vidapi_enable(2);
}
return(0);
return (0);
case WM_TIMER:
if (wParam == TIMER_1SEC)
@@ -948,7 +938,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
return(0);
return (0);
case WM_CLOSE:
win_notify_dlg_open();
@@ -1057,7 +1047,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
default:
return(DefWindowProc(hwnd, message, wParam, lParam));
return (DefWindowProc(hwnd, message, wParam, lParam));
case WM_SETFOCUS:
infocus = 1;
@@ -1097,10 +1087,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
return(0);
return (0);
}
static LRESULT CALLBACK
SubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -1121,30 +1110,27 @@ SubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
default:
return(DefWindowProc(hwnd, message, wParam, lParam));
return (DefWindowProc(hwnd, message, wParam, lParam));
}
return(0);
return (0);
}
static LRESULT CALLBACK
SDLMainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (input_proc(hwnd, message, wParam, lParam) == 0)
return(0);
return (0);
return(DefWindowProc(hwnd, message, wParam, lParam));
return (DefWindowProc(hwnd, message, wParam, lParam));
}
static LRESULT CALLBACK
SDLSubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return(DefWindowProc(hwnd, message, wParam, lParam));
return (DefWindowProc(hwnd, message, wParam, lParam));
}
static HRESULT CALLBACK
TaskDialogProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData)
{
@@ -1158,20 +1144,21 @@ TaskDialogProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LONG_
return S_OK;
}
int
ui_init(int nCmdShow)
{
WCHAR title[200];
WNDCLASSEX wincl; /* buffer for main window's class */
RAWINPUTDEVICE ridev; /* RawInput device */
MSG messages = {0}; /* received-messages buffer */
MSG messages = { 0 }; /* received-messages buffer */
HWND hwnd = NULL; /* handle for our window */
HACCEL haccel; /* handle to accelerator table */
RECT rect;
int bRet;
TASKDIALOGCONFIG tdconfig = {0};
TASKDIALOG_BUTTON tdbuttons[] = {{IDCANCEL, MAKEINTRESOURCE(IDS_2119)}};
TASKDIALOGCONFIG tdconfig = { 0 };
TASKDIALOG_BUTTON tdbuttons[] = {
{IDCANCEL, MAKEINTRESOURCE(IDS_2119)}
};
uint32_t helper_lang;
/* Load DPI related Windows 10 APIs */
@@ -1198,25 +1185,24 @@ ui_init(int nCmdShow)
/* Start settings-only mode if requested. */
if (settings_only) {
if (! pc_init_modules()) {
if (!pc_init_modules()) {
/* Dang, no ROMs found at all! */
tdconfig.pszMainInstruction = MAKEINTRESOURCE(IDS_2120);
tdconfig.pszContent = MAKEINTRESOURCE(IDS_2056);
TaskDialogIndirect(&tdconfig, NULL, NULL, NULL);
return(6);
return (6);
}
/* Load the desired language */
helper_lang = lang_id;
lang_id = 0;
set_language(helper_lang);
win_settings_open(NULL);
return(0);
return (0);
}
if(! discord_load()) {
if (!discord_load()) {
enable_discord = 0;
} else if (enable_discord) {
/* Initialize the Discord API */
@@ -1238,39 +1224,39 @@ ui_init(int nCmdShow)
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = CreateSolidBrush(RGB(0,0,0));
wincl.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
/* Load proper icons */
wchar_t path[MAX_PATH + 1] = {0};
wchar_t path[MAX_PATH + 1] = { 0 };
GetModuleFileNameW(hinstance, path, MAX_PATH);
ExtractIconExW(path, 0, &wincl.hIcon, &wincl.hIconSm, 1);
if (! RegisterClassEx(&wincl))
return(2);
if (!RegisterClassEx(&wincl))
return (2);
wincl.lpszClassName = SUB_CLASS_NAME;
wincl.lpfnWndProc = SubWindowProcedure;
if (! RegisterClassEx(&wincl))
return(2);
if (!RegisterClassEx(&wincl))
return (2);
wincl.lpszClassName = SDL_CLASS_NAME;
wincl.lpfnWndProc = SDLMainWindowProcedure;
if (! RegisterClassEx(&wincl))
return(2);
if (!RegisterClassEx(&wincl))
return (2);
wincl.lpszClassName = SDL_SUB_CLASS_NAME;
wincl.lpfnWndProc = SDLSubWindowProcedure;
if (! RegisterClassEx(&wincl))
return(2);
if (!RegisterClassEx(&wincl))
return (2);
/* Now create our main window. */
swprintf_s(title, sizeof_w(title), L"%hs - %s %s", vm_name, EMU_NAME_W, EMU_VERSION_FULL_W);
hwnd = CreateWindowEx (
hwnd = CreateWindowEx(
0, /* no extended possibilites */
CLASS_NAME, /* class name */
title, /* Title Text */
(WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX) | DS_3DLOOK,
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where window ends up on the screen */
scrnsz_x+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* width */
scrnsz_y+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */
scrnsz_x + (GetSystemMetrics(SM_CXFIXEDFRAME) * 2), /* width */
scrnsz_y + (GetSystemMetrics(SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 1, /* and height in pixels */
HWND_DESKTOP, /* window is a child to desktop */
NULL, /* no menu (yet) */
hinstance, /* Program Instance handler */
@@ -1308,10 +1294,10 @@ ui_init(int nCmdShow)
(WS_OVERLAPPEDWINDOW));
else
SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX));
(WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX));
/* Create the Machine Rendering window. */
hwndRender = CreateWindow(/*L"STATIC"*/ SUB_CLASS_NAME, NULL, WS_CHILD|SS_BITMAP,
hwndRender = CreateWindow(/*L"STATIC"*/ SUB_CLASS_NAME, NULL, WS_CHILD | SS_BITMAP,
0, 0, 1, 1, hwnd, NULL, hinstance, NULL);
/* Initiate a resize in order to properly arrange all controls.
@@ -1336,10 +1322,9 @@ ui_init(int nCmdShow)
ShowWindow(hwnd, nCmdShow);
/* Warn the user about unsupported configs. */
if (cpu_override && ui_msgbox_ex(MBX_WARNING | MBX_QUESTION_OK, (void*)IDS_2145, (void*)IDS_2146, (void*)IDS_2147, (void*)IDS_2119, NULL))
{
if (cpu_override && ui_msgbox_ex(MBX_WARNING | MBX_QUESTION_OK, (void *) IDS_2145, (void *) IDS_2146, (void *) IDS_2147, (void *) IDS_2119, NULL)) {
DestroyWindow(hwnd);
return(0);
return (0);
}
GetClipCursor(&oldclip);
@@ -1350,10 +1335,10 @@ ui_init(int nCmdShow)
ridev.usUsage = 0x06;
ridev.dwFlags = RIDEV_NOHOTKEYS;
ridev.hwndTarget = NULL; /* current focus window */
if (! RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) {
if (!RegisterRawInputDevices(&ridev, 1, sizeof(ridev))) {
tdconfig.pszContent = MAKEINTRESOURCE(IDS_2105);
TaskDialogIndirect(&tdconfig, NULL, NULL, NULL);
return(4);
return (4);
}
keyboard_getkeymap();
@@ -1362,7 +1347,7 @@ ui_init(int nCmdShow)
if (haccel == NULL) {
tdconfig.pszContent = MAKEINTRESOURCE(IDS_2104);
TaskDialogIndirect(&tdconfig, NULL, NULL, NULL);
return(3);
return (3);
}
/* Initialize the mouse module. */
@@ -1376,19 +1361,19 @@ ui_init(int nCmdShow)
ghMutex = CreateMutex(NULL, FALSE, NULL);
/* All done, fire up the actual emulated machine. */
if (! pc_init_modules()) {
if (!pc_init_modules()) {
/* Dang, no ROMs found at all! */
tdconfig.pszMainInstruction = MAKEINTRESOURCE(IDS_2120);
tdconfig.pszContent = MAKEINTRESOURCE(IDS_2056);
TaskDialogIndirect(&tdconfig, NULL, NULL, NULL);
return(6);
return (6);
}
/* Initialize the configured Video API. */
if (! plat_setvid(vid_api)) {
if (!plat_setvid(vid_api)) {
tdconfig.pszContent = MAKEINTRESOURCE(IDS_2089);
TaskDialogIndirect(&tdconfig, NULL, NULL, NULL);
return(5);
return (5);
}
/* Set up the current window size. */
@@ -1423,9 +1408,10 @@ ui_init(int nCmdShow)
do_start();
/* Run the message loop. It will run until GetMessage() returns 0 */
while (! is_quit) {
while (!is_quit) {
bRet = GetMessage(&messages, NULL, 0, 0);
if ((bRet == 0) || is_quit) break;
if ((bRet == 0) || is_quit)
break;
if (bRet == -1) {
fatal("bRet is -1\n");
@@ -1436,13 +1422,9 @@ ui_init(int nCmdShow)
if (messages.message == WM_QUIT)
cpu_thread_run = 0;
if (! TranslateAccelerator(hwnd, haccel, &messages))
{
if (!TranslateAccelerator(hwnd, haccel, &messages)) {
/* Don't process other keypresses. */
if (messages.message == WM_SYSKEYDOWN ||
messages.message == WM_SYSKEYUP ||
messages.message == WM_KEYDOWN ||
messages.message == WM_KEYUP)
if (messages.message == WM_SYSKEYDOWN || messages.message == WM_SYSKEYUP || messages.message == WM_KEYDOWN || messages.message == WM_KEYUP)
continue;
TranslateMessage(&messages);
@@ -1485,10 +1467,9 @@ ui_init(int nCmdShow)
if (user32_handle != NULL)
dynld_close(user32_handle);
return(messages.wParam);
return (messages.wParam);
}
/* We should have the language ID as a parameter. */
void
plat_pause(int p)
@@ -1540,7 +1521,6 @@ plat_pause(int p)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDSTATUS, (WPARAM) !!dopause, (LPARAM) hwndMain);
}
/* Tell the UI about a new screen resolution. */
void
plat_resize(int x, int y)
@@ -1556,13 +1536,12 @@ plat_resize(int x, int y)
}
}
void plat_resize_request(int w, int h, int monitor_index)
void
plat_resize_request(int w, int h, int monitor_index)
{
atomic_store((&doresize_monitors[monitor_index]), 1);
}
void
plat_mouse_capture(int on)
{
@@ -1587,5 +1566,11 @@ plat_mouse_capture(int on)
}
}
void ui_init_monitor(int monitor_index) {}
void ui_deinit_monitor(int monitor_index) {}
void
ui_init_monitor(int monitor_index)
{
}
void
ui_deinit_monitor(int monitor_index)
{
}