[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>
|
---|
[2f9f352] | 30 | #include <SDL2/SDL_ttf.h>
|
---|
[ff8d800] | 31 |
|
---|
| 32 | #define inf(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 33 | #define err(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__);
|
---|
| 34 |
|
---|
[4c71d39] | 35 | #define _ver(_v, _t, ...) { \
|
---|
| 36 | if (_v > _t) { \
|
---|
| 37 | SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 38 | } \
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[ff8d800] | 41 | #define fail(...) { \
|
---|
| 42 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
|
---|
| 43 | exit(1); \
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[a06aa8b] | 46 | #define ARRAY_COUNT(_a) (int32_t)(sizeof (_a) / sizeof (_a)[0])
|
---|
| 47 |
|
---|
[bb4fd0c] | 48 | #define WIN_W (1520 * 2 / 3)
|
---|
| 49 | #define WIN_H (950 * 2 / 3)
|
---|
| 50 |
|
---|
[4c71d39] | 51 | extern int32_t sdl_verbose;
|
---|
| 52 | extern int32_t cpu_verbose;
|
---|
| 53 | extern int32_t fpu_verbose;
|
---|
| 54 | extern int32_t vid_verbose;
|
---|
| 55 | extern int32_t tim_verbose;
|
---|
| 56 | extern int32_t lcd_verbose;
|
---|
| 57 | extern int32_t ser_verbose;
|
---|
| 58 | extern int32_t mid_verbose;
|
---|
| 59 | extern int32_t fdd_verbose;
|
---|
| 60 | extern int32_t snd_verbose;
|
---|
| 61 | extern int32_t led_verbose;
|
---|
| 62 | extern int32_t kbd_verbose;
|
---|
[ff8d800] | 63 |
|
---|
[bb4fd0c] | 64 | extern SDL_Window *sdl_win;
|
---|
| 65 | extern SDL_Renderer *sdl_ren;
|
---|
| 66 |
|
---|
[ff8d800] | 67 | extern void sdl_init(void);
|
---|
| 68 | extern void sdl_quit(void);
|
---|
| 69 |
|
---|
[b909777] | 70 | extern void cpu_loop(const char *bios);
|
---|
[a06aa8b] | 71 |
|
---|
| 72 | extern void fpu_init(void);
|
---|
| 73 | extern void fpu_quit(void);
|
---|
[3c30832] | 74 | extern bool fpu_exec(void);
|
---|
[a06aa8b] | 75 | extern uint32_t fpu_read(uint32_t off, int32_t sz);
|
---|
| 76 | extern void fpu_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 77 |
|
---|
| 78 | extern void vid_init(void);
|
---|
| 79 | extern void vid_quit(void);
|
---|
[3c30832] | 80 | extern bool vid_exec(void);
|
---|
[a06aa8b] | 81 | extern uint32_t vid_read(uint32_t off, int32_t sz);
|
---|
| 82 | extern void vid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 83 |
|
---|
| 84 | extern void tim_init(void);
|
---|
| 85 | extern void tim_quit(void);
|
---|
[3c30832] | 86 | extern bool tim_exec(void);
|
---|
[a06aa8b] | 87 | extern uint32_t tim_read(uint32_t off, int32_t sz);
|
---|
| 88 | extern void tim_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 89 |
|
---|
| 90 | extern void lcd_init(void);
|
---|
| 91 | extern void lcd_quit(void);
|
---|
[3c30832] | 92 | extern bool lcd_exec(void);
|
---|
[a06aa8b] | 93 | extern uint32_t lcd_read(uint32_t off, int32_t sz);
|
---|
| 94 | extern void lcd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 95 |
|
---|
| 96 | extern void ser_init(void);
|
---|
| 97 | extern void ser_quit(void);
|
---|
[3c30832] | 98 | extern bool ser_exec(void);
|
---|
[a06aa8b] | 99 | extern uint32_t ser_read(uint32_t off, int32_t sz);
|
---|
| 100 | extern void ser_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 101 |
|
---|
[bb4fd0c] | 102 | extern void ser_text(SDL_TextInputEvent *ev);
|
---|
| 103 | extern void ser_key(SDL_KeyboardEvent *ev);
|
---|
| 104 |
|
---|
[a06aa8b] | 105 | extern void mid_init(void);
|
---|
| 106 | extern void mid_quit(void);
|
---|
[3c30832] | 107 | extern bool mid_exec(void);
|
---|
[a06aa8b] | 108 | extern uint32_t mid_read(uint32_t off, int32_t sz);
|
---|
| 109 | extern void mid_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 110 |
|
---|
| 111 | extern void fdd_init(void);
|
---|
| 112 | extern void fdd_quit(void);
|
---|
[3c30832] | 113 | extern bool fdd_exec(void);
|
---|
[a06aa8b] | 114 | extern uint32_t fdd_read(uint32_t off, int32_t sz);
|
---|
| 115 | extern void fdd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 116 |
|
---|
| 117 | extern void snd_init(void);
|
---|
| 118 | extern void snd_quit(void);
|
---|
[3c30832] | 119 | extern bool snd_exec(void);
|
---|
[a06aa8b] | 120 | extern uint32_t snd_read(uint32_t off, int32_t sz);
|
---|
| 121 | extern void snd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 122 |
|
---|
| 123 | extern void led_init(void);
|
---|
| 124 | extern void led_quit(void);
|
---|
[3c30832] | 125 | extern bool led_exec(void);
|
---|
[a06aa8b] | 126 | extern uint32_t led_read(uint32_t off, int32_t sz);
|
---|
| 127 | extern void led_write(uint32_t off, int32_t sz, uint32_t val);
|
---|
| 128 |
|
---|
| 129 | extern void kbd_init(void);
|
---|
| 130 | extern void kbd_quit(void);
|
---|
[3c30832] | 131 | extern bool kbd_exec(void);
|
---|
[a06aa8b] | 132 | extern uint32_t kbd_read(uint32_t off, int32_t sz);
|
---|
| 133 | extern void kbd_write(uint32_t off, int32_t sz, uint32_t val);
|
---|