[a06aa8b] | 1 | /*
|
---|
| 2 | * Copyright (C) 2017 The Contributors
|
---|
| 3 | *
|
---|
| 4 | * This program is free software: you can redistribute it and/or modify
|
---|
| 5 | * it under the terms of the GNU General Public License as published by
|
---|
| 6 | * the Free Software Foundation, either version 3 of the License, or (at
|
---|
| 7 | * your option) any later version.
|
---|
| 8 | *
|
---|
| 9 | * This program is distributed in the hope that it will be useful, but
|
---|
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 12 | * General Public License for more details.
|
---|
| 13 | *
|
---|
| 14 | * A copy of the GNU General Public License can be found in the file
|
---|
| 15 | * "gpl-v3.txt" in the top directory of this repository.
|
---|
| 16 | */
|
---|
| 17 |
|
---|
[ff8d800] | 18 | #include <stdbool.h>
|
---|
| 19 | #include <stddef.h>
|
---|
| 20 | #include <stdint.h>
|
---|
| 21 | #include <stdio.h>
|
---|
[25c3737] | 22 | #include <stdlib.h>
|
---|
[bb4fd0c] | 23 | #include <string.h>
|
---|
[ff8d800] | 24 | #include <unistd.h>
|
---|
| 25 |
|
---|
[ebc8f69] | 26 | #include <xmmintrin.h>
|
---|
| 27 |
|
---|
[ff8d800] | 28 | #include <m68k.h>
|
---|
| 29 |
|
---|
| 30 | #include <SDL2/SDL.h>
|
---|
[ea878ba] | 31 | #include <SDL2/SDL_net.h>
|
---|
[2f9f352] | 32 | #include <SDL2/SDL_ttf.h>
|
---|
[ff8d800] | 33 |
|
---|
[2cd18e3] | 34 | // XXX - work around RtMidi's C++-isms; remove when fixed in RtMidi
|
---|
[9ddbf3e] | 35 |
|
---|
| 36 | #pragma GCC diagnostic push
|
---|
| 37 | #pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
---|
| 38 |
|
---|
| 39 | typedef struct RtMidiWrapper RtMidiWrapper;
|
---|
| 40 |
|
---|
| 41 | #include <rtmidi/rtmidi_c.h>
|
---|
| 42 |
|
---|
| 43 | #pragma GCC diagnostic pop
|
---|
| 44 |
|
---|
[ff8d800] | 45 | #define inf(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 46 | #define err(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 47 |
|
---|
[4c71d39] | 48 | #define _ver(_v, _t, ...) { \
|
---|
| 49 | if (_v > _t) { \
|
---|
| 50 | SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 51 | } \
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[ff8d800] | 54 | #define fail(...) { \
|
---|
| 55 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 56 | exit(1); \
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[a06aa8b] | 59 | #define ARRAY_COUNT(_a) (int32_t)(sizeof (_a) / sizeof (_a)[0])
|
---|
| 60 |
|
---|
[4c71d39] | 61 | extern int32_t sdl_verbose;
|
---|
[7cc6ac0] | 62 | extern int32_t gdb_verbose;
|
---|
[4c71d39] | 63 | extern int32_t cpu_verbose;
|
---|
| 64 | extern int32_t fpu_verbose;
|
---|
| 65 | extern int32_t vid_verbose;
|
---|
| 66 | extern int32_t tim_verbose;
|
---|
| 67 | extern int32_t lcd_verbose;
|
---|
| 68 | extern int32_t ser_verbose;
|
---|
| 69 | extern int32_t mid_verbose;
|
---|
| 70 | extern int32_t fdd_verbose;
|
---|
| 71 | extern int32_t snd_verbose;
|
---|
| 72 | extern int32_t led_verbose;
|
---|
| 73 | extern int32_t kbd_verbose;
|
---|
[ff8d800] | 74 |
|
---|
[1efc42c] | 75 | extern const char *bios;
|
---|
| 76 | extern const char *disk;
|
---|
[0edef06] | 77 | extern const char *font;
|
---|
[1efc42c] | 78 |
|
---|
[2cd18e3] | 79 | extern uint32_t mid_port;
|
---|
[9ddbf3e] | 80 |
|
---|
[bdd5a63] | 81 | extern SDL_atomic_t run;
|
---|
| 82 |
|
---|
[4ed9bfe] | 83 | extern uint32_t vid_win;
|
---|
| 84 | extern uint32_t ser_win;
|
---|
[81d7cdc] | 85 | extern uint32_t lcd_win;
|
---|
[4ed9bfe] | 86 |
|
---|
[ff8d800] | 87 | extern void sdl_init(void);
|
---|
| 88 | extern void sdl_quit(void);
|
---|
[bdd5a63] | 89 | extern void sdl_loop(void);
|
---|
| 90 |
|
---|
[7cc6ac0] | 91 | extern void gdb_init(void);
|
---|
| 92 | extern void gdb_quit(void);
|
---|
| 93 | extern void gdb_loop(void);
|
---|
[149c3e0] | 94 | extern void gdb_inst(bool bp);
|
---|
[7cc6ac0] | 95 |
|
---|
[bdd5a63] | 96 | extern SDL_mutex *cpu_mutex;
|
---|
[ff8d800] | 97 |
|
---|
[bdd5a63] | 98 | extern void cpu_init(void);
|
---|
| 99 | extern void cpu_quit(void);
|
---|
[1efc42c] | 100 | extern void cpu_loop(void);
|
---|
[a06aa8b] | 101 |
|
---|
[5fa5369] | 102 | extern uint8_t cpu_peek(int32_t addr);
|
---|
| 103 | extern void cpu_poke(int32_t addr, uint8_t val);
|
---|
| 104 |
|
---|
[a06aa8b] | 105 | extern void fpu_init(void);
|
---|
| 106 | extern void fpu_quit(void);
|
---|
[3c30832] | 107 | extern bool fpu_exec(void);
|
---|
[a06aa8b] | 108 | extern uint32_t fpu_read(uint32_t off, int32_t sz);
|
---|
| 109 | extern void fpu_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 110 |
|
---|
| 111 | extern void vid_init(void);
|
---|
| 112 | extern void vid_quit(void);
|
---|
[3c30832] | 113 | extern bool vid_exec(void);
|
---|
[a06aa8b] | 114 | extern uint32_t vid_read(uint32_t off, int32_t sz);
|
---|
| 115 | extern void vid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 116 |
|
---|
[f285858] | 117 | extern void vid_sdl(void);
|
---|
| 118 |
|
---|
[a06aa8b] | 119 | extern void tim_init(void);
|
---|
| 120 | extern void tim_quit(void);
|
---|
[3c30832] | 121 | extern bool tim_exec(void);
|
---|
[a06aa8b] | 122 | extern uint32_t tim_read(uint32_t off, int32_t sz);
|
---|
| 123 | extern void tim_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 124 |
|
---|
| 125 | extern void lcd_init(void);
|
---|
| 126 | extern void lcd_quit(void);
|
---|
[3c30832] | 127 | extern bool lcd_exec(void);
|
---|
[a06aa8b] | 128 | extern uint32_t lcd_read(uint32_t off, int32_t sz);
|
---|
| 129 | extern void lcd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 130 |
|
---|
[7ba68aa] | 131 | extern void lcd_sdl(void);
|
---|
| 132 |
|
---|
[a06aa8b] | 133 | extern void ser_init(void);
|
---|
| 134 | extern void ser_quit(void);
|
---|
[3c30832] | 135 | extern bool ser_exec(void);
|
---|
[a06aa8b] | 136 | extern uint32_t ser_read(uint32_t off, int32_t sz);
|
---|
| 137 | extern void ser_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 138 |
|
---|
[bdd5a63] | 139 | extern void ser_sdl(void);
|
---|
[bb4fd0c] | 140 | extern void ser_text(SDL_TextInputEvent *ev);
|
---|
| 141 | extern void ser_key(SDL_KeyboardEvent *ev);
|
---|
| 142 |
|
---|
[657abdf] | 143 | extern void ser_mou_res(void);
|
---|
| 144 | extern void ser_mou_mov(SDL_MouseMotionEvent *ev);
|
---|
| 145 | extern void ser_mou_dn(SDL_MouseButtonEvent *ev);
|
---|
| 146 | extern void ser_mou_up(SDL_MouseButtonEvent *ev);
|
---|
| 147 |
|
---|
[a06aa8b] | 148 | extern void mid_init(void);
|
---|
| 149 | extern void mid_quit(void);
|
---|
[3c30832] | 150 | extern bool mid_exec(void);
|
---|
[a06aa8b] | 151 | extern uint32_t mid_read(uint32_t off, int32_t sz);
|
---|
| 152 | extern void mid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
[77d8df8] | 153 | extern void mid_list(void);
|
---|
[a06aa8b] | 154 |
|
---|
| 155 | extern void fdd_init(void);
|
---|
| 156 | extern void fdd_quit(void);
|
---|
[3c30832] | 157 | extern bool fdd_exec(void);
|
---|
[a06aa8b] | 158 | extern uint32_t fdd_read(uint32_t off, int32_t sz);
|
---|
| 159 | extern void fdd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 160 |
|
---|
[c5b6c90] | 161 | extern void fdd_set_side(int32_t sid);
|
---|
| 162 | extern void fdd_set_sel(int32_t sel);
|
---|
| 163 |
|
---|
[a06aa8b] | 164 | extern void snd_init(void);
|
---|
| 165 | extern void snd_quit(void);
|
---|
[3c30832] | 166 | extern bool snd_exec(void);
|
---|
[a06aa8b] | 167 | extern uint32_t snd_read(uint32_t off, int32_t sz);
|
---|
| 168 | extern void snd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 169 |
|
---|
| 170 | extern void led_init(void);
|
---|
| 171 | extern void led_quit(void);
|
---|
[3c30832] | 172 | extern bool led_exec(void);
|
---|
[a06aa8b] | 173 | extern uint32_t led_read(uint32_t off, int32_t sz);
|
---|
| 174 | extern void led_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 175 |
|
---|
| 176 | extern void kbd_init(void);
|
---|
| 177 | extern void kbd_quit(void);
|
---|
[3c30832] | 178 | extern bool kbd_exec(void);
|
---|
[a06aa8b] | 179 | extern uint32_t kbd_read(uint32_t off, int32_t sz);
|
---|
| 180 | extern void kbd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
[4ed9bfe] | 181 |
|
---|
[81d7cdc] | 182 | extern void kbd_key(SDL_KeyboardEvent *ev, bool vid, bool dn);
|
---|