Skip to content

Commit

Permalink
Fix for 'black window' on some hardware
Browse files Browse the repository at this point in the history
Plus a few other minor bits...

Signed-off-by: Michel Pollet <[email protected]>
  • Loading branch information
buserror committed Jan 22, 2024
1 parent 352a7f0 commit bd0cda4
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 78 deletions.
1 change: 1 addition & 0 deletions libmui/mui/mui.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mui_dispose(
mui_t *ui)
{
pixman_region32_fini(&ui->inval);
pixman_region32_fini(&ui->redraw);
mui_font_dispose(ui);
mui_window_t *w;
while ((w = TAILQ_FIRST(&ui->windows))) {
Expand Down
21 changes: 12 additions & 9 deletions libmui/mui/mui.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ enum mui_modifier_e {
#define MUI_ICON_SBAR_UP ""
#define MUI_ICON_SBAR_DOWN ""

/* These are specific the Charcoal System font */
/* These are specific to our custom version of the Charcoal System font */
#define MUI_GLYPH_APPLE "" // solid apple
#define MUI_GLYPH_OAPPLE "" // open apple
#define MUI_GLYPH_COMMAND ""
Expand All @@ -138,7 +138,7 @@ enum mui_modifier_e {
typedef uint64_t mui_time_t;

/*
* Even description. pretty standard stuff here -- the 'when' field is
* Event description. pretty standard stuff here -- the 'when' field is
* only used really to detect double clicks so far.
*
* Even handlers should return true if the event was handled, (in which case
Expand Down Expand Up @@ -204,7 +204,7 @@ struct mui_listbox_elem_t;

/*
* Window DEFinition -- Handle all related to a window, from drawing to
* even handling.
* event handling.
*/
enum {
MUI_WDEF_INIT = 0,
Expand Down Expand Up @@ -288,7 +288,7 @@ struct cg_ctx_t;

/*
* Describes a pixmap. Currently only used for the screen destination pixels.
* And really, only bpp:43 for ARGB is supported.
* And really, only bpp:32 for ARGB is supported.
*/
typedef struct mui_pixmap_t {
uint8_t * pixels;
Expand Down Expand Up @@ -447,6 +447,7 @@ mui_font_textbox(
unsigned int text_len,
mui_color_t color,
uint16_t flags );

DECLARE_C_ARRAY(stb_ttc_g*, mui_glyph_array, 8, int x, y, w; );
DECLARE_C_ARRAY(mui_glyph_array_t, mui_glyph_line_array, 8);

Expand Down Expand Up @@ -519,7 +520,7 @@ mui_window_create(
uint8_t layer,
const char * title,
uint32_t instance_size);
// Dispose a window and it's content (controls).
// Dispose of a window and it's content (controls).
/*
* Note: if an action is in progress the window is not freed immediately
* but added to the zombie list, and freed when the action is done.
Expand Down Expand Up @@ -574,8 +575,9 @@ struct mui_menu_items_t;

/*
* This is a menu item descriptor (also used for the titles, bar a few bits).
* This does not a *control* in the window, instead this is used to describe
* the menus and menu item controls that are created when the menu becomes visible.
* This is not a *control* in the window, instead this is used to describe
* the menus and menu item controls that are created when the menu becomes
* visible.
*/
typedef struct mui_menu_item_t {
uint32_t disabled : 1, hilited : 1;
Expand Down Expand Up @@ -777,10 +779,11 @@ mui_button_new(
const char * title,
uint32_t uid );
/*
* Create a static text box. Font is optional, flags correponds to the MUI_TEXT_ALIGN_*
* PLUS the extrast listed below.
* Create a static text box. Font is optional (default to the system main font),
* flags corresponds to the MUI_TEXT_ALIGN_* * PLUS the extra(s) listed below.
*/
enum mui_textbox_e {
// draw the frame around the text box
MUI_CONTROL_TEXTBOX_FRAME = (1 << 8),
};
mui_control_t *
Expand Down
77 changes: 76 additions & 1 deletion src/mii_mish.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,30 @@ _mii_mish_cmd(
char buf[32];
sprintf(buf, "%s:%d", mii_sw_names[i],
!!(mii->sw_state & (1 << i)));
printf("%-13.13s%s", buf, !(i % 6) ? "\n" : " ");
printf("%-13.13s%s", buf, !((i+1) % 6) ? "\n" : " ");
}
printf("\n");
printf("RGB Video Mode: %d\n", mii->video.color_mode);
return;
}
if (!strcmp(argv[1], "reset")) {
mii_reset(mii, 0);
return;
}
if (!strcmp(argv[1], "rgb")) {
if (argc < 3) {
printf("rgb: missing argument\n");
return;
}
uint8_t val = strtol(argv[2], NULL, 16);
if (val > MII_VIDEO_MODE_COUNT) {
printf("rgb: invalid mode %d\n", val);
return;
}
mii->video.color_mode = val;
return;
}

if (!strcmp(argv[1], "mem")) {
printf("mii: memory map: ");
for (int i = 0; i < MII_BANK_COUNT; i++)
Expand Down Expand Up @@ -241,6 +256,54 @@ _mii_mish_il(
}
}


static void
_mii_mish_mm(
void * param,
int argc,
const char * argv[])
{
static uint32_t addr = 0x800;
if (argv[1]) {
addr = strtol(argv[1], NULL, 16);
if (addr > 0x00100000)
addr = 0x00fff0;
}
mii_t * mii = param;
int bi = (addr >> 16) & 0xf;
if (bi > MII_BANK_COUNT) {
printf("mii: invalid bank index %d (0:7)\n", bi);
return;
}
addr &= 0xffff;
mii_bank_t * bank = &mii->bank[bi];
// addr -= bank->base;
if (!strcmp(argv[0], "mm")) {
printf("%s %04x\n", bank->name, addr);
for (int i = 0; i < 8; i++) {
printf("%06x: ", addr);
for (int j = 0; j < 16; j++)
printf("%02x ", mii_bank_peek(bank, addr++));
printf("\n");
}
return;
}
if (!strcmp(argv[0], "mb")) {
printf("%s: %04x: ", bank->name, addr);
printf("%02x ", mii_bank_peek(bank, addr++));
printf("\n");
return;
}
if (!strcmp(argv[0], "mw") || !strcmp(argv[0], "ma")) {
printf("%s: %04x: ", bank->name, addr);
uint8_t l = mii_bank_peek(bank, addr++);
uint8_t h = mii_bank_peek(bank, addr++);
printf("%02x%02x", h, l);
printf("\n");
return;
}
}

static void
_mii_mish_dm(
void * param,
Expand Down Expand Up @@ -403,6 +466,7 @@ MISH_CMD_NAMES(mii, "mii");
MISH_CMD_HELP(mii,
"mii: access internals, trace, reset, speed, etc",
" <default> : dump current state",
" rgb <val>: Set RGB mode to <val>(0:color,1:green,2:amber)"
" reset : reset the cpu",
" t|trace : toggle trace_cpu (WARNING HUGE traces!))",
" mem : dump memory and bank map",
Expand Down Expand Up @@ -442,6 +506,17 @@ MISH_CMD_HELP(dm,
);
MII_MISH(dm, _mii_mish_dm);

MISH_CMD_NAMES(mm, "mm","mb","mw","ma");
MISH_CMD_HELP(mm,
"mii: dump memory, byte, word, [raw address]",
" <default>|mm <addr>: dump 64 bytes.",
" mb [<addr>]: dump one byte.",
" mw [<addr>]: dump one word.",
" ma [<addr>]: dump one address.",
" [addr]: 24 bits address addr 00 main, 01 aux"
);
MII_MISH(mm, _mii_mish_mm);

MISH_CMD_NAMES(step, "s","step","n","next","cont","h","halt");
MISH_CMD_HELP(step,
"mii: step instructions",
Expand Down
96 changes: 45 additions & 51 deletions src/mii_sw.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,54 @@
#pragma once

enum {
SW80STORE = 0xc018,
SWVBL = 0xc019,
SWALTCHARSET = 0xc01e,
SW80COL = 0xc01f,
SWTEXT = 0xc01a,
SWMIXED = 0xc01b,
SWPAGE2 = 0xc01c,
SWHIRES = 0xc01d,

SW80STOREOFF = 0xc000,
SW80STOREON = 0xc001,
SWKBD = 0xc000,
SW80STOREOFF = 0xc000,
SW80STOREON = 0xc001,
SWRAMRDOFF = 0xc002,
SWRAMRDON = 0xc003,
SWRAMWRTOFF = 0xc004,
SWRAMWRTON = 0xc005,
SWINTCXROMOFF = 0xc006,
SWINTCXROMON = 0xc007,
SWALTPZOFF = 0xc008,
SWALTPZON = 0xc009,
SWSLOTC3ROMOFF = 0xc00a,
SWSLOTC3ROMON = 0xc00b,
SW80COLOFF = 0xc00c,
SW80COLON = 0xc00d,
SWALTCHARSETOFF = 0xc00e,
SWALTCHARSETON = 0xc00f,
SW80COLOFF = 0xc00c,
SW80COLON = 0xc00d,
SWTEXTOFF = 0xc050, // (AKA LORES ON)
SWTEXTON = 0xc051,
SWMIXEDOFF = 0xc052,
SWMIXEDON = 0xc053,
SWPAGE2OFF = 0xc054,
SWPAGE2ON = 0xc055,
SWHIRESOFF = 0xc056,
SWHIRESON = 0xc057,

SWAKD = 0xc010,
SWBSRBANK2 = 0xc011,
SWBSRREADRAM = 0xc012,
SWRAMRD = 0xc013,
SWRAMWRT = 0xc014,
SWINTCXROM = 0xc015,
SWALTPZ = 0xc016,
SWSLOTC3ROM = 0xc017,
SW80STORE = 0xc018,
SWVBL = 0xc019,
SWALTCHARSET = 0xc01e,
SW80COL = 0xc01f,
SWTEXT = 0xc01a,
SWMIXED = 0xc01b,
SWPAGE2 = 0xc01c,
SWHIRES = 0xc01d,
SWSPEAKER = 0xc030,
SWTEXTOFF = 0xc050, // (AKA LORES ON)
SWTEXTON = 0xc051,
SWMIXEDOFF = 0xc052,
SWMIXEDON = 0xc053,
SWPAGE2OFF = 0xc054,
SWPAGE2ON = 0xc055,
SWHIRESOFF = 0xc056,
SWHIRESON = 0xc057,
// this one is inverted, the ON is the even address
SWDHIRESOFF = 0xc05f, // AN3_ON
SWDHIRESON = 0xc05e, // AN3_OFF
SWAN3 = 0xc05e, // AN3 status
SWAN3_REGISTER = 0xc05f, // AN3 register for video mode
SWRDDHIRES = 0xc07f,

SWRAMRDOFF = 0xc002,
SWRAMRDON = 0xc003,
SWRAMWRTOFF = 0xc004,
SWRAMWRTON = 0xc005,
SWALTPZOFF = 0xc008,
SWALTPZON = 0xc009,
SWINTCXROMOFF = 0xc006,
SWINTCXROMON = 0xc007,
SWSLOTC3ROMOFF = 0xc00a,
SWSLOTC3ROMON = 0xc00b,
SWBSRBANK2 = 0xc011,
SWBSRREADRAM = 0xc012,

SWRAMRD = 0xc013,
SWRAMWRT = 0xc014,
SWINTCXROM = 0xc015,
SWALTPZ = 0xc016,
SWSLOTC3ROM = 0xc017,

SWSPEAKER = 0xc030,
SWKBD = 0xc000,
SWAKD = 0xc010,

SWDHIRESON = 0xc05e, // AN3_OFF
SWDHIRESOFF = 0xc05f, // AN3_ON
SWAN3 = 0xc05e, // AN3 status
SWAN3_REGISTER = 0xc05f, // AN3 register for video mode
SWRDDHIRES = 0xc07f,
};

/*
Expand Down
7 changes: 7 additions & 0 deletions src/mii_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
#define MII_VIDEO_WIDTH (280 * 2)
#define MII_VIDEO_HEIGHT (192 * 2)
// in case padding is needed, these can be changed

#if 0 // Loads of padding to align to power of 2 sizes
#define MII_VRAM_WIDTH (1024 * 4)
#define MII_VRAM_HEIGHT 512
#else
#define MII_VRAM_WIDTH (MII_VIDEO_WIDTH * 4)
#define MII_VRAM_HEIGHT MII_VIDEO_HEIGHT
#endif

enum {
MII_VIDEO_COLOR = 0,
MII_VIDEO_GREEN,
MII_VIDEO_AMBER,
MII_VIDEO_MODE_COUNT
};

struct mii_t;
Expand Down
Loading

0 comments on commit bd0cda4

Please sign in to comment.