[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>
|
---|
[bb4fd0c] | 22 | #include <string.h>
|
---|
[ff8d800] | 23 | #include <unistd.h>
|
---|
| 24 |
|
---|
[ebc8f69] | 25 | #include <xmmintrin.h>
|
---|
| 26 |
|
---|
[ff8d800] | 27 | #include <m68k.h>
|
---|
| 28 |
|
---|
| 29 | #include <SDL2/SDL.h>
|
---|
[ea878ba] | 30 | #include <SDL2/SDL_net.h>
|
---|
[2f9f352] | 31 | #include <SDL2/SDL_ttf.h>
|
---|
[ff8d800] | 32 |
|
---|
[9ddbf3e] | 33 | // work around RtMidi's C++-isms
|
---|
| 34 |
|
---|
| 35 | #pragma GCC diagnostic push
|
---|
| 36 | #pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
---|
| 37 |
|
---|
| 38 | typedef struct RtMidiWrapper RtMidiWrapper;
|
---|
| 39 |
|
---|
| 40 | #include <rtmidi/rtmidi_c.h>
|
---|
| 41 |
|
---|
| 42 | #pragma GCC diagnostic pop
|
---|
| 43 |
|
---|
[ff8d800] | 44 | #define inf(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 45 | #define err(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 46 |
|
---|
[4c71d39] | 47 | #define _ver(_v, _t, ...) { \
|
---|
| 48 | if (_v > _t) { \
|
---|
| 49 | SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 50 | } \
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[ff8d800] | 53 | #define fail(...) { \
|
---|
| 54 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 55 | exit(1); \
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[a06aa8b] | 58 | #define ARRAY_COUNT(_a) (int32_t)(sizeof (_a) / sizeof (_a)[0])
|
---|
| 59 |
|
---|
[4c71d39] | 60 | extern int32_t sdl_verbose;
|
---|
[7cc6ac0] | 61 | extern int32_t gdb_verbose;
|
---|
[4c71d39] | 62 | extern int32_t cpu_verbose;
|
---|
| 63 | extern int32_t fpu_verbose;
|
---|
| 64 | extern int32_t vid_verbose;
|
---|
| 65 | extern int32_t tim_verbose;
|
---|
| 66 | extern int32_t lcd_verbose;
|
---|
| 67 | extern int32_t ser_verbose;
|
---|
| 68 | extern int32_t mid_verbose;
|
---|
| 69 | extern int32_t fdd_verbose;
|
---|
| 70 | extern int32_t snd_verbose;
|
---|
| 71 | extern int32_t led_verbose;
|
---|
| 72 | extern int32_t kbd_verbose;
|
---|
[ff8d800] | 73 |
|
---|
[1efc42c] | 74 | extern const char *bios;
|
---|
| 75 | extern const char *disk;
|
---|
[0edef06] | 76 | extern const char *font;
|
---|
[1efc42c] | 77 |
|
---|
[9ddbf3e] | 78 | extern int32_t mid_port;
|
---|
| 79 |
|
---|
[bdd5a63] | 80 | extern SDL_atomic_t run;
|
---|
| 81 |
|
---|
[4ed9bfe] | 82 | extern uint32_t vid_win;
|
---|
| 83 | extern uint32_t ser_win;
|
---|
[81d7cdc] | 84 | extern uint32_t lcd_win;
|
---|
[4ed9bfe] | 85 |
|
---|
[ff8d800] | 86 | extern void sdl_init(void);
|
---|
| 87 | extern void sdl_quit(void);
|
---|
[bdd5a63] | 88 | extern void sdl_loop(void);
|
---|
| 89 |
|
---|
[7cc6ac0] | 90 | extern void gdb_init(void);
|
---|
| 91 | extern void gdb_quit(void);
|
---|
| 92 | extern void gdb_loop(void);
|
---|
[149c3e0] | 93 | extern void gdb_inst(bool bp);
|
---|
[7cc6ac0] | 94 |
|
---|
[bdd5a63] | 95 | extern SDL_mutex *cpu_mutex;
|
---|
[ff8d800] | 96 |
|
---|
[bdd5a63] | 97 | extern void cpu_init(void);
|
---|
| 98 | extern void cpu_quit(void);
|
---|
[1efc42c] | 99 | extern void cpu_loop(void);
|
---|
[a06aa8b] | 100 |
|
---|
[5fa5369] | 101 | extern uint8_t cpu_peek(int32_t addr);
|
---|
| 102 | extern void cpu_poke(int32_t addr, uint8_t val);
|
---|
| 103 |
|
---|
[a06aa8b] | 104 | extern void fpu_init(void);
|
---|
| 105 | extern void fpu_quit(void);
|
---|
[3c30832] | 106 | extern bool fpu_exec(void);
|
---|
[a06aa8b] | 107 | extern uint32_t fpu_read(uint32_t off, int32_t sz);
|
---|
| 108 | extern void fpu_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 109 |
|
---|
| 110 | extern void vid_init(void);
|
---|
| 111 | extern void vid_quit(void);
|
---|
[3c30832] | 112 | extern bool vid_exec(void);
|
---|
[a06aa8b] | 113 | extern uint32_t vid_read(uint32_t off, int32_t sz);
|
---|
| 114 | extern void vid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 115 |
|
---|
[f285858] | 116 | extern void vid_sdl(void);
|
---|
| 117 |
|
---|
[a06aa8b] | 118 | extern void tim_init(void);
|
---|
| 119 | extern void tim_quit(void);
|
---|
[3c30832] | 120 | extern bool tim_exec(void);
|
---|
[a06aa8b] | 121 | extern uint32_t tim_read(uint32_t off, int32_t sz);
|
---|
| 122 | extern void tim_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 123 |
|
---|
| 124 | extern void lcd_init(void);
|
---|
| 125 | extern void lcd_quit(void);
|
---|
[3c30832] | 126 | extern bool lcd_exec(void);
|
---|
[a06aa8b] | 127 | extern uint32_t lcd_read(uint32_t off, int32_t sz);
|
---|
| 128 | extern void lcd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 129 |
|
---|
[7ba68aa] | 130 | extern void lcd_sdl(void);
|
---|
| 131 |
|
---|
[a06aa8b] | 132 | extern void ser_init(void);
|
---|
| 133 | extern void ser_quit(void);
|
---|
[3c30832] | 134 | extern bool ser_exec(void);
|
---|
[a06aa8b] | 135 | extern uint32_t ser_read(uint32_t off, int32_t sz);
|
---|
| 136 | extern void ser_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 137 |
|
---|
[bdd5a63] | 138 | extern void ser_sdl(void);
|
---|
[bb4fd0c] | 139 | extern void ser_text(SDL_TextInputEvent *ev);
|
---|
| 140 | extern void ser_key(SDL_KeyboardEvent *ev);
|
---|
| 141 |
|
---|
[657abdf] | 142 | extern void ser_mou_res(void);
|
---|
| 143 | extern void ser_mou_mov(SDL_MouseMotionEvent *ev);
|
---|
| 144 | extern void ser_mou_dn(SDL_MouseButtonEvent *ev);
|
---|
| 145 | extern void ser_mou_up(SDL_MouseButtonEvent *ev);
|
---|
| 146 |
|
---|
[a06aa8b] | 147 | extern void mid_init(void);
|
---|
| 148 | extern void mid_quit(void);
|
---|
[3c30832] | 149 | extern bool mid_exec(void);
|
---|
[a06aa8b] | 150 | extern uint32_t mid_read(uint32_t off, int32_t sz);
|
---|
| 151 | extern void mid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
[77d8df8] | 152 | extern void mid_list(void);
|
---|
[a06aa8b] | 153 |
|
---|
| 154 | extern void fdd_init(void);
|
---|
| 155 | extern void fdd_quit(void);
|
---|
[3c30832] | 156 | extern bool fdd_exec(void);
|
---|
[a06aa8b] | 157 | extern uint32_t fdd_read(uint32_t off, int32_t sz);
|
---|
| 158 | extern void fdd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 159 |
|
---|
[c5b6c90] | 160 | extern void fdd_set_side(int32_t sid);
|
---|
| 161 | extern void fdd_set_sel(int32_t sel);
|
---|
| 162 |
|
---|
[a06aa8b] | 163 | extern void snd_init(void);
|
---|
| 164 | extern void snd_quit(void);
|
---|
[3c30832] | 165 | extern bool snd_exec(void);
|
---|
[a06aa8b] | 166 | extern uint32_t snd_read(uint32_t off, int32_t sz);
|
---|
| 167 | extern void snd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 168 |
|
---|
| 169 | extern void led_init(void);
|
---|
| 170 | extern void led_quit(void);
|
---|
[3c30832] | 171 | extern bool led_exec(void);
|
---|
[a06aa8b] | 172 | extern uint32_t led_read(uint32_t off, int32_t sz);
|
---|
| 173 | extern void led_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 174 |
|
---|
| 175 | extern void kbd_init(void);
|
---|
| 176 | extern void kbd_quit(void);
|
---|
[3c30832] | 177 | extern bool kbd_exec(void);
|
---|
[a06aa8b] | 178 | extern uint32_t kbd_read(uint32_t off, int32_t sz);
|
---|
| 179 | extern void kbd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
[4ed9bfe] | 180 |
|
---|
[81d7cdc] | 181 | extern void kbd_key(SDL_KeyboardEvent *ev, bool vid, bool dn);
|
---|