Skip to content

Commit

Permalink
Kickstart screen showing up (#7)
Browse files Browse the repository at this point in the history
* Kickstart screen showing up

* Linux fix

* Linux fix try 2

* Linux fix part 3

* Disabled older macOS due to lacking SDL support

* Disabled older macOS due to lacking SDL support
  • Loading branch information
emoon authored Feb 8, 2024
1 parent b5f0867 commit 0ca743f
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11, macos-12, macos-13, macos-14]
os: [macos-14]

steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ add_executable(quaesar
src/uaeserial.cpp
src/quaesar.cpp
src/blkdev.cpp
src/gfxutil.cpp
od-cross/gfx.cpp
od-cross/gui.cpp
od-cross/mman.cpp
Expand Down
162 changes: 147 additions & 15 deletions od-cross/dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include "rommgr.h"
#include "newcpu.h"
#include "fpp.h"
#include "xwin.h"
#include <SDL.h>

int avioutput_enabled = 0;
bool beamracer_debug = false;
Expand All @@ -60,6 +62,9 @@ bool is_dsp_installed = false;
int tablet_log = 0;
int log_scsi = 0;
int uaelib_debug;
int flashscreen;
bool gfx_hdr = false;
uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];

uae_u8* start_pc_p = nullptr;
uae_u32 start_pc = 0;
Expand Down Expand Up @@ -298,7 +303,7 @@ int input_get_default_joystick (struct uae_input_device *uid, int i, int port, i
}

bool get_plugin_path (TCHAR *out, int len, const TCHAR *path) {
UNIMPLEMENTED();
TRACE();
return false;
}

Expand All @@ -310,9 +315,6 @@ void fixtrailing(TCHAR* p) {
UNIMPLEMENTED();
}

void unlockscr(struct vidbuffer *vb, int y_start, int y_end) {
UNIMPLEMENTED();
}

int uae_slirp_redir(int is_udp, int host_port, struct in_addr guest_addr, int guest_port) {
UNIMPLEMENTED();
Expand All @@ -338,10 +340,6 @@ void refreshtitle() {
UNIMPLEMENTED();
}

bool render_screen(int, int, bool) {
TRACE();
return true;
}

bool my_utime(const TCHAR* name, struct mytimeval* tv) {
UNIMPLEMENTED();
Expand Down Expand Up @@ -517,7 +515,7 @@ bool ariadne2_init(autoconfig_info*) {
}

bool audio_is_pull_event() {
TRACE();
//TRACE();
return false;
}

Expand Down Expand Up @@ -592,9 +590,14 @@ int check_for_cache_miss() {
return 0;
}

static int s_has_changed_setting = 1;

int check_prefs_changed_gfx() {
// TODO: Fix
int has_changed = s_has_changed_setting;
s_has_changed_setting = 0;
TRACE();
return 0;
return has_changed;
}

void clipboard_unsafeperiod() {
Expand Down Expand Up @@ -844,8 +847,9 @@ void fpux_restore(int*) {
}

bool frame_drawn(int) {
UNIMPLEMENTED();
return false;
//UNIMPLEMENTED();
TRACE();
return true;
}

void free_ahi_v2() {
Expand Down Expand Up @@ -904,11 +908,124 @@ void golemfast_ncr9x_scsi_put(unsigned int, unsigned int, int) {
UNIMPLEMENTED();
}

SDL_Window* s_window;
SDL_Surface* s_window_surface;

int graphics_init(bool) {
int amiga_width = 754;
int amiga_height = 576;
int depth = 32;

struct vidbuf_description* avidinfo = &adisplays[0].gfxvidinfo;

avidinfo->drawbuffer.inwidth = avidinfo->drawbuffer.outwidth = amiga_width;
avidinfo->drawbuffer.inheight = avidinfo->drawbuffer.outheight = amiga_height;

int pitch = amiga_width * depth >> 3;

avidinfo->drawbuffer.pixbytes = depth >> 3;
avidinfo->drawbuffer.bufmem = NULL;
avidinfo->drawbuffer.linemem = NULL;
avidinfo->drawbuffer.rowbytes = pitch;

struct vidbuffer* buf = &avidinfo->drawbuffer;

int width = 1280;
int height = 720;

buf->monitor_id = 0;
buf->pixbytes = (depth + 7) / 8;
buf->width_allocated = (width + 7) & ~7;
buf->height_allocated = height;

int w = buf->width_allocated;
int h = buf->height_allocated;
int size = (w * 2) * (h * 2) * buf->pixbytes;
buf->rowbytes = w * 2 * buf->pixbytes;
buf->realbufmem = xcalloc(uae_u8, size);
buf->bufmem_allocated = buf->bufmem = buf->realbufmem + (h / 2) * buf->rowbytes + (w / 2) * buf->pixbytes;
buf->bufmemend = buf->realbufmem + size - buf->rowbytes;
buf->bufmem_lockable = true;

// Create a window
s_window = SDL_CreateWindow("QUAEsar",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height, 0);

if (!s_window) {
SDL_Log("Could not create window: %s", SDL_GetError());
SDL_Quit();
return 0;
}

int bits = 8;
int red_shift = 16;
int green_shift = 8;
int blue_shift = 0;

alloc_colors64k(0, bits, bits, bits, red_shift, green_shift, blue_shift, bits, 24, 0, 0, false);

// Get the window surface
s_window_surface = SDL_GetWindowSurface(s_window);

TRACE();
return 1;
}

bool render_screen(int monid, int, bool) {
return true;
}


void unlockscr(struct vidbuffer* vb_in, int y_start, int y_end) {
SDL_Event e;

if (!s_window)
return;

// TODO: Should likley move this somewhere else
// Handle events on queue
while (SDL_PollEvent(&e) != 0) {
// User requests quit
if (e.type == SDL_QUIT) {
exit(1);
}
}

// Lock surface if necessary
if (SDL_MUSTLOCK(s_window_surface)) SDL_LockSurface(s_window_surface);

// Pointer to the pixels
Uint32* pixels = (Uint32*)s_window_surface->pixels;

struct amigadisplay* ad = &adisplays[vb_in->monitor_id];
struct vidbuf_description* avidinfo = &adisplays[vb_in->monitor_id].gfxvidinfo;
struct vidbuffer* vb = avidinfo->outbuffer;

if (!vb || !vb->bufmem)
return;

uint8_t* sptr = vb->bufmem;
uint8_t* endsptr = vb->bufmemend;

int amiga_width = vb->outwidth;
int amiga_height = vb->outheight;

// Change pixels
for (int y = 0; y < amiga_height; y++) {
uint8_t* dest = (uint8_t*)&pixels[y * s_window_surface->w];
memcpy(dest, sptr, amiga_width * 4);
sptr += vb->rowbytes;
}

// Unlock surface if necessary
if (SDL_MUSTLOCK(s_window_surface)) SDL_UnlockSurface(s_window_surface);

// Update the surface
SDL_UpdateWindowSurface(s_window);
}


void graphics_leave() {
UNIMPLEMENTED();
}
Expand Down Expand Up @@ -1702,10 +1819,12 @@ uae_u32 getlocaltime() {
return 0;
}

/*
float getvsyncrate(int, float, int*) {
UNIMPLEMENTED();
return 50.0f;
}
*/

const TCHAR* gfxboard_get_configname(int) {
UNIMPLEMENTED();
Expand Down Expand Up @@ -1848,9 +1967,22 @@ void target_default_options(uae_prefs*, int) {
//UNIMPLEMENTED();
}

bool target_graphics_buffer_update(int) {
static int old_w = -1;
static int old_h = -1;

bool target_graphics_buffer_update(int monid) {
struct vidbuf_description* avidinfo = &adisplays[monid].gfxvidinfo;
struct vidbuffer* vb = avidinfo->drawbuffer.tempbufferinuse ? &avidinfo->tempbuffer : &avidinfo->drawbuffer;

if ((vb->outwidth != old_w) || (old_h != vb->outheight)) {
old_w = vb->outwidth;
old_h = vb->outheight;
return true;
}

TRACE();
return true;

return false;
}

int target_parse_option(uae_prefs*, char const*, char const*, int) {
Expand Down Expand Up @@ -1886,7 +2018,7 @@ int uaeser_write(void*, unsigned char*, unsigned int) {
}

int audio_is_pull() {
TRACE();
//TRACE();
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions od-cross/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ TCHAR* target_expand_environment(const TCHAR* path, TCHAR* out, int maxlen) {
}

bool my_stat (const TCHAR* name, struct mystat* ms) {
UNIMPLEMENTED();
return FALSE;
//UNIMPLEMENTED();
return true;
}

int my_readdir(struct my_opendir_s* mod, TCHAR* name) {
Expand Down
6 changes: 4 additions & 2 deletions od-cross/sysconfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef WINUAE_SYSCONFIG_H
#define WINUAE_SYSCONFIG_H

//#include <intrin.h>

#ifdef _WIN32
#define ftello64 _ftelli64
#define fseeko64 _fseeki64
Expand Down Expand Up @@ -618,8 +620,8 @@ typedef long uae_atomic;
} while (0)


#define TRACE() \
do { } while (0)
//#define TRACE() do { printf("%s\n", __func__); } while (0)
#define TRACE() do { } while (0)


#endif /* WINUAE_SYSCONFIG_H */
2 changes: 1 addition & 1 deletion src/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12180,7 +12180,7 @@ static void vsync_handler_render(void)
if (!vsync_rendered) {
frame_time_t start, end;
start = read_processor_time();
//vsync_handle_redraw(lof_store, lof_changed, bplcon0, bplcon3, isvsync_chipset() >= 0, initial_frame);
vsync_handle_redraw(lof_store, lof_changed, bplcon0, bplcon3, isvsync_chipset() >= 0, initial_frame);
initial_frame = false;
vsync_rendered = true;
end = read_processor_time();
Expand Down
34 changes: 17 additions & 17 deletions src/gfxutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static float video_gamma (float value, float gamma, float bri, float con)
return ret;
}

static uae_u32 gamma[256 * 3][3];
static uae_u32 gamma_table[256 * 3][3];
static int lf, hf;

static void video_calc_gammatable(int monid)
Expand Down Expand Up @@ -186,7 +186,7 @@ static void video_calc_gammatable(int monid)
if (v > max)
v = max;

gamma[i][j] = (uae_u32)(v + 0.5);
gamma_table[i][j] = (uae_u32)(v + 0.5);
}
}
}
Expand Down Expand Up @@ -359,9 +359,9 @@ void alloc_colors_rgb (int rw, int gw, int bw, int rs, int gs, int bs, int aw, i
}
j += 256;

rc[i] = doColor(gamma[j][0], rw, rs) | doAlpha(alpha, aw, as);
gc[i] = doColor(gamma[j][1], gw, gs) | doAlpha(alpha, aw, as);
bc[i] = doColor(gamma[j][2], bw, bs) | doAlpha(alpha, aw, as);
rc[i] = doColor(gamma_table[j][0], rw, rs) | doAlpha(alpha, aw, as);
gc[i] = doColor(gamma_table[j][1], gw, gs) | doAlpha(alpha, aw, as);
bc[i] = doColor(gamma_table[j][2], bw, bs) | doAlpha(alpha, aw, as);

if (byte_swap) {
if (bpp <= 16) {
Expand Down Expand Up @@ -401,9 +401,9 @@ void alloc_colors64k(int monid, int rw, int gw, int bw, int rs, int gs, int bs,
g = (g * (255 - 8) / 255) + 8;
b = (b * (255 - 8) / 255) + 8;
}
r = gamma[r + j][0];
g = gamma[g + j][1];
b = gamma[b + j][2];
r = gamma_table[r + j][0];
g = gamma_table[g + j][1];
b = gamma_table[b + j][2];
xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs) | doAlpha(alpha, aw, as);
if (byte_swap) {
if (bpp <= 16) {
Expand Down Expand Up @@ -442,9 +442,9 @@ void alloc_colors64k(int monid, int rw, int gw, int bw, int rs, int gs, int bs,
/* create internal 5:6:5 color tables */
for (i = 0; i < 256; i++) {
j = i + 256;
xredcolors[i] = doColor (gamma[j][0], 5, 11);
xgreencolors[i] = doColor (gamma[j][1], 6, 5);
xbluecolors[i] = doColor (gamma[j][2], 5, 0);
xredcolors[i] = doColor (gamma_table[j][0], 5, 11);
xgreencolors[i] = doColor (gamma_table[j][1], 6, 5);
xbluecolors[i] = doColor (gamma_table[j][2], 5, 0);
if (bpp <= 16) {
/* Fill upper 16 bits of each colour value with
* a copy of the colour. */
Expand All @@ -457,9 +457,9 @@ void alloc_colors64k(int monid, int rw, int gw, int bw, int rs, int gs, int bs,
int r = ((i >> 8) << 4) | (i >> 8);
int g = (((i >> 4) & 0xf) << 4) | ((i >> 4) & 0x0f);
int b = ((i & 0xf) << 4) | (i & 0x0f);
r = gamma[r + 256][0];
g = gamma[g + 256][1];
b = gamma[b + 256][2];
r = gamma_table[r + 256][0];
g = gamma_table[g + 256][1];
b = gamma_table[b + 256][2];

if (currprefs.gfx_blackerthanblack) {
r = (r * (255 - 8) / 255) + 8;
Expand All @@ -485,11 +485,11 @@ void alloc_colors64k(int monid, int rw, int gw, int bw, int rs, int gs, int bs,
for (i = 0; i < 65536; i++) {
uae_u32 r, g, b;
r = (((i >> 11) & 31) << 3) | lowbits (i, 11, 3);
r = gamma[r + 256][0];
r = gamma_table[r + 256][0];
g = (((i >> 5) & 63) << 2) | lowbits (i, 5, 2);
g = gamma[g + 256][1];
g = gamma_table[g + 256][1];
b = (((i >> 0) & 31) << 3) | lowbits (i, 0, 3);
b = gamma[b + 256][2];
b = gamma_table[b + 256][2];
tyhrgb[i] = get_yh(monid, r, g, b) * 256 * 256;
tylrgb[i] = get_yl(monid, r, g, b) * 256 * 256;
tcbrgb[i] = ((uae_s8)get_cb(monid, r, g, b)) * 256;
Expand Down
Loading

0 comments on commit 0ca743f

Please sign in to comment.