[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 |
|
---|
| 33 | #define inf(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 34 | #define err(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 35 |
|
---|
[4c71d39] | 36 | #define _ver(_v, _t, ...) { \
|
---|
| 37 | if (_v > _t) { \
|
---|
| 38 | SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 39 | } \
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[ff8d800] | 42 | #define fail(...) { \
|
---|
| 43 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 44 | exit(1); \
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[a06aa8b] | 47 | #define ARRAY_COUNT(_a) (int32_t)(sizeof (_a) / sizeof (_a)[0])
|
---|
| 48 |
|
---|
[4c71d39] | 49 | extern int32_t sdl_verbose;
|
---|
[7cc6ac0] | 50 | extern int32_t gdb_verbose;
|
---|
[4c71d39] | 51 | extern int32_t cpu_verbose;
|
---|
| 52 | extern int32_t fpu_verbose;
|
---|
| 53 | extern int32_t vid_verbose;
|
---|
| 54 | extern int32_t tim_verbose;
|
---|
| 55 | extern int32_t lcd_verbose;
|
---|
| 56 | extern int32_t ser_verbose;
|
---|
| 57 | extern int32_t mid_verbose;
|
---|
| 58 | extern int32_t fdd_verbose;
|
---|
| 59 | extern int32_t snd_verbose;
|
---|
| 60 | extern int32_t led_verbose;
|
---|
| 61 | extern int32_t kbd_verbose;
|
---|
[ff8d800] | 62 |
|
---|
[1efc42c] | 63 | extern const char *bios;
|
---|
| 64 | extern const char *disk;
|
---|
[0edef06] | 65 | extern const char *font;
|
---|
[1efc42c] | 66 |
|
---|
[bdd5a63] | 67 | extern SDL_atomic_t run;
|
---|
| 68 |
|
---|
[ff8d800] | 69 | extern void sdl_init(void);
|
---|
| 70 | extern void sdl_quit(void);
|
---|
[bdd5a63] | 71 | extern void sdl_loop(void);
|
---|
| 72 |
|
---|
[7cc6ac0] | 73 | extern void gdb_init(void);
|
---|
| 74 | extern void gdb_quit(void);
|
---|
| 75 | extern void gdb_loop(void);
|
---|
[149c3e0] | 76 | extern void gdb_inst(bool bp);
|
---|
[7cc6ac0] | 77 |
|
---|
[bdd5a63] | 78 | extern SDL_mutex *cpu_mutex;
|
---|
[ff8d800] | 79 |
|
---|
[bdd5a63] | 80 | extern void cpu_init(void);
|
---|
| 81 | extern void cpu_quit(void);
|
---|
[1efc42c] | 82 | extern void cpu_loop(void);
|
---|
[a06aa8b] | 83 |
|
---|
[5fa5369] | 84 | extern uint8_t cpu_peek(int32_t addr);
|
---|
| 85 | extern void cpu_poke(int32_t addr, uint8_t val);
|
---|
| 86 |
|
---|
[a06aa8b] | 87 | extern void fpu_init(void);
|
---|
| 88 | extern void fpu_quit(void);
|
---|
[3c30832] | 89 | extern bool fpu_exec(void);
|
---|
[a06aa8b] | 90 | extern uint32_t fpu_read(uint32_t off, int32_t sz);
|
---|
| 91 | extern void fpu_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 92 |
|
---|
| 93 | extern void vid_init(void);
|
---|
| 94 | extern void vid_quit(void);
|
---|
[3c30832] | 95 | extern bool vid_exec(void);
|
---|
[a06aa8b] | 96 | extern uint32_t vid_read(uint32_t off, int32_t sz);
|
---|
| 97 | extern void vid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 98 |
|
---|
[f285858] | 99 | extern void vid_sdl(void);
|
---|
| 100 |
|
---|
[a06aa8b] | 101 | extern void tim_init(void);
|
---|
| 102 | extern void tim_quit(void);
|
---|
[3c30832] | 103 | extern bool tim_exec(void);
|
---|
[a06aa8b] | 104 | extern uint32_t tim_read(uint32_t off, int32_t sz);
|
---|
| 105 | extern void tim_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 106 |
|
---|
| 107 | extern void lcd_init(void);
|
---|
| 108 | extern void lcd_quit(void);
|
---|
[3c30832] | 109 | extern bool lcd_exec(void);
|
---|
[a06aa8b] | 110 | extern uint32_t lcd_read(uint32_t off, int32_t sz);
|
---|
| 111 | extern void lcd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 112 |
|
---|
| 113 | extern void ser_init(void);
|
---|
| 114 | extern void ser_quit(void);
|
---|
[3c30832] | 115 | extern bool ser_exec(void);
|
---|
[a06aa8b] | 116 | extern uint32_t ser_read(uint32_t off, int32_t sz);
|
---|
| 117 | extern void ser_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 118 |
|
---|
[bdd5a63] | 119 | extern void ser_sdl(void);
|
---|
[bb4fd0c] | 120 | extern void ser_text(SDL_TextInputEvent *ev);
|
---|
| 121 | extern void ser_key(SDL_KeyboardEvent *ev);
|
---|
| 122 |
|
---|
[657abdf] | 123 | extern void ser_mou_res(void);
|
---|
| 124 | extern void ser_mou_mov(SDL_MouseMotionEvent *ev);
|
---|
| 125 | extern void ser_mou_dn(SDL_MouseButtonEvent *ev);
|
---|
| 126 | extern void ser_mou_up(SDL_MouseButtonEvent *ev);
|
---|
| 127 |
|
---|
[a06aa8b] | 128 | extern void mid_init(void);
|
---|
| 129 | extern void mid_quit(void);
|
---|
[3c30832] | 130 | extern bool mid_exec(void);
|
---|
[a06aa8b] | 131 | extern uint32_t mid_read(uint32_t off, int32_t sz);
|
---|
| 132 | extern void mid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 133 |
|
---|
| 134 | extern void fdd_init(void);
|
---|
| 135 | extern void fdd_quit(void);
|
---|
[3c30832] | 136 | extern bool fdd_exec(void);
|
---|
[a06aa8b] | 137 | extern uint32_t fdd_read(uint32_t off, int32_t sz);
|
---|
| 138 | extern void fdd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 139 |
|
---|
[c5b6c90] | 140 | extern void fdd_set_side(int32_t sid);
|
---|
| 141 | extern void fdd_set_sel(int32_t sel);
|
---|
| 142 |
|
---|
[a06aa8b] | 143 | extern void snd_init(void);
|
---|
| 144 | extern void snd_quit(void);
|
---|
[3c30832] | 145 | extern bool snd_exec(void);
|
---|
[a06aa8b] | 146 | extern uint32_t snd_read(uint32_t off, int32_t sz);
|
---|
| 147 | extern void snd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 148 |
|
---|
| 149 | extern void led_init(void);
|
---|
| 150 | extern void led_quit(void);
|
---|
[3c30832] | 151 | extern bool led_exec(void);
|
---|
[a06aa8b] | 152 | extern uint32_t led_read(uint32_t off, int32_t sz);
|
---|
| 153 | extern void led_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 154 |
|
---|
| 155 | extern void kbd_init(void);
|
---|
| 156 | extern void kbd_quit(void);
|
---|
[3c30832] | 157 | extern bool kbd_exec(void);
|
---|
[a06aa8b] | 158 | extern uint32_t kbd_read(uint32_t off, int32_t sz);
|
---|
| 159 | extern void kbd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|