Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved emulation of ST7789 LCD controller #478

Merged
merged 35 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c91e30c
Genericize LCD command parameters, latch LCD modes and partial/scroll…
calc84maniac Mar 20, 2023
dbc5d54
Change API to scan multiple pixels at once, refactor scanning to emul…
calc84maniac Mar 21, 2023
5090046
Implement MCU and VSYNC display modes (scanning on internal LCD clock)
calc84maniac Mar 28, 2023
d467173
Implement digital gamma, 16bpp endianness, and 16/12bpp data translation
calc84maniac Apr 6, 2023
9bfe5dc
Add option to emulate LCD gamma, avoid unnecessary gamma recalculation
calc84maniac Apr 13, 2023
9b4ea46
Add support for G2.2 and G1.0 gamma presets
calc84maniac Apr 14, 2023
8318dc9
Ignore vsync signal until the frame finishes in RGB interface scan. F…
calc84maniac Apr 14, 2023
58e0453
Add support for G1.8 and G2.5 gamma presets, use a monotonic grayscal…
calc84maniac Oct 20, 2023
ecee6e8
Use a monotonic cubic spline for gamma approximation
calc84maniac Oct 20, 2023
1cc4761
Add basic support for LCD response time simulation
calc84maniac Jan 11, 2024
dc27f96
Miscellaneous LCD improvements/fixes
calc84maniac Feb 23, 2024
58099a4
Use configurable color for blank lines in partial mode
calc84maniac Feb 23, 2024
b57d7b7
Replace direct usage of scheduler internals with functions
calc84maniac Feb 23, 2024
343de36
Refactor and optimize scheduler to use 64-bit timestamps and magic di…
calc84maniac Feb 23, 2024
498c519
Fix display RAM address mirroring and various other mirrors.
calc84maniac Mar 2, 2024
031ae87
More accurately emulate Frame Memory Pointer behavior
calc84maniac Mar 4, 2024
6efe57b
Add support for undocumented display RAM wrapping mode settings
calc84maniac Mar 9, 2024
a0d9b39
Add support for panel internal clock rate divisor
calc84maniac Mar 9, 2024
49a0166
Add support for undocumented source scan direction bit
calc84maniac Mar 10, 2024
3a5341e
Implement accurate LCD RAM read timing, fix other timing errors, impr…
calc84maniac Mar 17, 2024
1ff08b3
Work around missing __has_builtin macro before GCC 10
calc84maniac May 14, 2024
daa352f
Update emscripten for new LCD code arrangement
calc84maniac May 14, 2024
ab2d432
Implement RAM bypass and RGB HV modes, use function pointer to clock …
calc84maniac May 22, 2024
68d5cd3
Handle reserved display mode correctly
calc84maniac May 22, 2024
296981a
Fold backlight effect into gamma LUTs when accurate rendering is enabled
calc84maniac May 30, 2024
d9bd0b6
Add LCD clock frequency field to misc debug panel
calc84maniac May 31, 2024
8d047cc
Change LCD SPI setting to LCD DMA setting, default enable in all builds
calc84maniac Jun 1, 2024
bd3db31
Fix endianness of 16-bit and 32-bit pixels in LCD FIFO, optimize pixe…
calc84maniac Jun 1, 2024
bfda3e7
Optimize DMA pixel processing further
calc84maniac Jun 1, 2024
e9368ac
Use BGR565 format for RGB interface, replace EPF LUTs with functions
calc84maniac Jun 2, 2024
a214692
Streamline LCD RAM writes by caching a function pointer and the X add…
calc84maniac Jun 3, 2024
bb48d23
Consolidate SPI memory-related bools into bitflags, use separate func…
calc84maniac Jun 3, 2024
e807444
Cache all LCD RAM write window params, cache base pixel pointer for Y…
calc84maniac Jun 5, 2024
4f14d89
Disable LCD vertical compare interrupts for zero-length porches
calc84maniac Jun 7, 2024
711e229
Disable scroll wrapping behavior when bottom fixed area is 320 or higher
calc84maniac Jun 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/asic.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static void plug_devices(void) {
port_map[0xD] = init_spi();
port_map[0xE] = init_uart();
port_map[0xF] = init_fxxx();
init_panel();

reset_proc_count = 0;

Expand Down
2 changes: 2 additions & 0 deletions core/backlight.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "backlight.h"
#include "emu.h"
#include "panel.h"

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -58,6 +59,7 @@ static void backlight_write(const uint16_t pio, const uint8_t byte, bool poke) {
}

backlight.factor = (310u - backlight.brightness) / 160.0f;
panel.gammaDirty = true;
}

static const eZ80portrange_t device = {
Expand Down
2 changes: 1 addition & 1 deletion core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void control_write(const uint16_t pio, const uint8_t byte, bool poke) {
}
break;
case 0x05:
if (control.ports[index] & (1 << 6) && !(byte & (1 << 6))) {
if ((control.ports[index] & ~byte) & (1 << 6)) {
cpu_crash("resetting bit 6 of port 5");
}
control.ports[index] = byte & 0x1F;
Expand Down
16 changes: 11 additions & 5 deletions core/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
# endif
#endif

#if __has_builtin(__builtin_expect)
#if __has_builtin(__builtin_expect) || (__GNUC__ >= 3)
# define unlikely(x) __builtin_expect(x, 0)
#else
# define unlikely(x) (x)
#endif
#define likely(x) !unlikely(!(x))

#if __has_builtin(__builtin_unreachable)
# define unreachable __builtin_unreachable
#else
# define unreachable abort
#include <stddef.h>
#ifndef unreachable
# if __has_builtin(__builtin_unreachable) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define unreachable() __builtin_unreachable()
# elif defined(_MSC_VER)
# define unreachable() __assume(0)
# else
# include <stdlib.h>
# define unreachable() abort()
# endif
#endif

#ifdef _MSC_VER
Expand Down
4 changes: 2 additions & 2 deletions core/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ void emu_run(uint64_t ticks) {
}
}

void emu_set_run_rate(uint32_t rate) {
sched_set_clock(CLOCK_RUN, rate);
bool emu_set_run_rate(uint32_t rate) {
return sched_set_clock(CLOCK_RUN, rate);
}

uint32_t emu_get_run_rate() {
Expand Down
2 changes: 1 addition & 1 deletion core/emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef enum {
emu_state_t emu_load(emu_data_t type, const char *path); /* load an emulator state */
bool emu_save(emu_data_t type, const char *path); /* save an emulator state */
void emu_run(uint64_t ticks); /* core emulation function, call after emu_load */
void emu_set_run_rate(uint32_t rate); /* how many ticks per second for emu_run */
bool emu_set_run_rate(uint32_t rate); /* how many ticks per second for emu_run */
uint32_t emu_get_run_rate(void); /* getter for the above */
void emu_reset(void); /* reset emulation as if the reset button was pressed */
void emu_exit(void); /* exit emulation */
Expand Down
4 changes: 1 addition & 3 deletions core/keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ static void keypad_write(const uint16_t pio, const uint8_t byte, bool poke) {
void keypad_reset(void) {
keypad.row = 0;

sched.items[SCHED_KEYPAD].callback.event = keypad_scan_event;
sched.items[SCHED_KEYPAD].clock = CLOCK_6M;
sched_clear(SCHED_KEYPAD);
sched_init_event(SCHED_KEYPAD, CLOCK_6M, keypad_scan_event);

gui_console_printf("[CEmu] Keypad reset.\n");
}
Expand Down
Loading
Loading