Add configuration file support

Also tweaked with the UseLargeScreen hack and factored out some more
stuff into src/HW/RAM.
This commit is contained in:
InvisibleUp 2020-07-10 21:51:05 -04:00
parent 98f4e216c0
commit 5c6bbec87a
24 changed files with 576 additions and 364 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "src/incbin"]
path = src/incbin
url = https://github.com/graphitemaster/incbin
[submodule "src/tomlc99"]
path = src/tomlc99
url = https://github.com/cktan/tomlc99

View File

@ -55,12 +55,12 @@
#define AutoKeyThresh 0x06
#define AutoKeyRate 0x03
#define CurEmMd kEmMd_II
#define CurEmMd kEmMd_Plus
//#if (CurEmMd == kEmMd_Plus)
//#include "MACPLUS.h"
#include "MACPLUS.h"
//#elif (CurEmMd == kEmMd_II)
#include "MACII.h"
//#include "MACII.h"
//#endif
#define WantDisasm 0

View File

@ -1,3 +1,4 @@
#pragma once
#define EmClassicKbrd 1
#define EmADB 0
#define EmRTC 1

View File

@ -152,9 +152,11 @@ UI_SRC = [
EMU_SRC = [
'src/PROGMAIN.c',
'src/GLOBGLUE.c',
'src/CFGMAN.c',
'src/PATCHES/ROMEMDEV.c',
'src/UTIL/DATE2SEC.c',
'src/LANG/INTLCHAR.c',
'src/tomlc99/toml.c'
]
EMU_INC = include_directories([
@ -166,7 +168,7 @@ EMU_INC = include_directories([
# Just gonna do an SDL2 Mac Plus for now
executable(
'microvmac',
sources: MAC_SRC['II'] + UI_SRC + EMU_SRC,
sources: MAC_SRC['Plus'] + UI_SRC + EMU_SRC,
dependencies: [lSDL2],
include_directories: EMU_INC,
)

156
src/CFGMAN.c Normal file
View File

@ -0,0 +1,156 @@
/*
* CFGMAN.c
*
* Configuration Management
*
*/
#include "tomlc99/toml.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "HW/SCREEN/SCRNEMDV.h"
toml_table_t* CONFIG;
const char CONFIG_PATH[] = "uvmac-cfg.toml";
/* Load existing config */
static bool Config_TryLoad()
{
FILE* fp;
char errbuf[200];
/* Open the file. */
fp = fopen("uvmac-cfg.toml", "r");
if (fp == NULL) {
return false;
}
/* Run the file through the parser. */
CONFIG = toml_parse_file(fp, errbuf, sizeof(errbuf));
if (CONFIG == NULL) {
fclose(fp);
return false;
}
fclose(fp);
return true;
}
/* Create new configuration */
static bool Config_TryCreate()
{
/* TODO: implement this. or really, TOML creation in general. */
char errbuf[200];
CONFIG = toml_parse("", errbuf, sizeof(errbuf));
return (CONFIG != NULL);
}
/* Load or create config and prepare for use */
bool Config_TryInit()
{
bool okay;
okay = Config_TryLoad();
if (!okay) { okay = Config_TryCreate(); }
if (!okay) { return false; }
// Initialize per-device configuration
okay = Screen_LoadCfg();
if (!okay) { return false; }
return true;
}
/* Locate a raw value given a table/key pair */
static bool Config_GetRawValue(const char table[], const char key[], toml_raw_t *value)
{
toml_table_t *table_raw;
/* Locate the table. */
table_raw = toml_table_in(CONFIG, table);
if (table_raw == NULL) { return false; }
/* Locate the key */
*value = toml_raw_in(table_raw, key);
if (*value == NULL) { return false; }
return true;
}
/* Check if key exists */
bool Config_KeyExists(const char table[], const char key[])
{
toml_raw_t value_raw;
return Config_GetRawValue(table, key, &value_raw);
}
/* Read a boolean */
bool Config_GetBool(const char table[], const char key[], bool *value, bool defaultValue)
{
toml_raw_t value_raw;
bool found, okay;
int result;
found = Config_GetRawValue(table, key, &value_raw);
if (!found) {
// TODO: write default to TOML file
*value = defaultValue;
return true;
}
okay = (toml_rtob(value_raw, &result) == 0);
*value = result;
return okay;
}
/* Read an integer */
bool Config_GetInt(const char table[], const char key[], int64_t *value, int64_t defaultValue)
{
toml_raw_t value_raw;
bool found;
found = Config_GetRawValue(table, key, &value_raw);
if (!found) {
// TODO: write default to TOML file
*value = defaultValue;
return true;
}
return (toml_rtoi(value_raw, value) == 0);
}
/* Read a double-precision floating point number */
bool Config_GetFloat(const char table[], const char key[], double *value, double defaultValue)
{
toml_raw_t value_raw;
bool found;
found = Config_GetRawValue(table, key, &value_raw);
if (!found) {
// TODO: write default to TOML file
*value = defaultValue;
return true;
}
return (toml_rtod(value_raw, value) == 0);
}
/* Read a string value */
bool Config_GetString(const char table[], const char key[], char **value, const char *defaultValue)
{
toml_raw_t value_raw;
bool found;
found = Config_GetRawValue(table, key, &value_raw);
if (!found) {
// TODO: write default to TOML file
int defaultLen = strlen(defaultValue)+1;
*value = malloc(defaultLen);
strncpy(*value, defaultValue, defaultLen);
return true;
}
return (toml_rtos(value_raw, value) == 0);
}

35
src/CFGMAN.h Normal file
View File

@ -0,0 +1,35 @@
/*
* CFGMAN.h
*
* Configuration Management
*
*/
/* Load or create config and prepare for use */
#pragma once
bool Config_TryInit();
/* Check if key exists */
bool Config_KeyExists(const char table[], const char key[]);
/* Read a boolean */
bool Config_GetBool(const char table[], const char key[], bool *value, bool defaultValue);
/* Read an integer */
bool Config_GetInt(const char table[], const char key[], int64_t *value, int64_t defaultValue);
/* Read a double-precision floating point number */
bool Config_GetFloat(const char table[], const char key[], double *value, double defaultValue);
/* Read a string value */
bool Config_GetString(const char table[], const char key[], char **value, const char *defaultValue);
/* List of known tables and keys */
#define CONFIG_SCC_REALPORT(MACPORT) "SCC_#MACPORT", "RealPort"
#define CONFIG_SCC_REALPORT(MACPORT) "SCC_#MACPORT", "RealPort"
#define CONFIG_VIDEO_BLACK "Video", "ColorBlack"
#define CONFIG_VIDEO_WHITE "Video", "ColorWhite"
#define CONFIG_VIDEO_WIDTH "Video", "Width"
#define CONFIG_VIDEO_HEIGHT "Video", "Height"
#define CONFIG_VIDEO_DEPTH "Video", "Depth"
#define CONFIG_VIDEO_USEHACK "Video", "UseLargeScreenHack"
#define DISK_PATH(NUM) "Disk", "Path#NUM"

View File

@ -33,6 +33,7 @@
#endif
#include "GLOBGLUE.h"
#include "HW/RAM/RAMADDR.h"
/*
ReportAbnormalID unused 0x111D - 0x11FF
@ -233,72 +234,6 @@ GLOBALPROC DoReportAbnormalID(uint16_t id
}
#endif
/* map of address space */
#define kRAM_Base 0x00000000 /* when overlay off */
#if (CurEmMd == kEmMd_PB100)
#define kRAM_ln2Spc 23
#elif (CurEmMd == kEmMd_II) || (CurEmMd == kEmMd_IIx)
#define kRAM_ln2Spc 23
#else
#define kRAM_ln2Spc 22
#endif
#if IncludeVidMem
#if CurEmMd == kEmMd_PB100
#define kVidMem_Base 0x00FA0000
#define kVidMem_ln2Spc 16
#else
#define kVidMem_Base 0x00540000
#define kVidMem_ln2Spc 18
#endif
#endif
#if CurEmMd == kEmMd_PB100
#define kSCSI_Block_Base 0x00F90000
#define kSCSI_ln2Spc 16
#else
#define kSCSI_Block_Base 0x00580000
#define kSCSI_ln2Spc 19
#endif
#define kRAM_Overlay_Base 0x00600000 /* when overlay on */
#define kRAM_Overlay_Top 0x00800000
#if CurEmMd == kEmMd_PB100
#define kSCCRd_Block_Base 0x00FD0000
#define kSCC_ln2Spc 16
#else
#define kSCCRd_Block_Base 0x00800000
#define kSCC_ln2Spc 22
#endif
#if CurEmMd != kEmMd_PB100
#define kSCCWr_Block_Base 0x00A00000
#define kSCCWr_Block_Top 0x00C00000
#endif
#if CurEmMd == kEmMd_PB100
#define kIWM_Block_Base 0x00F60000
#define kIWM_ln2Spc 16
#else
#define kIWM_Block_Base 0x00C00000
#define kIWM_ln2Spc 21
#endif
#if CurEmMd == kEmMd_PB100
#define kVIA1_Block_Base 0x00F70000
#define kVIA1_ln2Spc 16
#else
#define kVIA1_Block_Base 0x00E80000
#define kVIA1_ln2Spc 19
#endif
#if CurEmMd == kEmMd_PB100
#define kASC_Block_Base 0x00FB0000
#define kASC_ln2Spc 16
#endif
#define kASC_Mask 0x00000FFF
#if IncludeExtnPbufs
@ -622,49 +557,6 @@ GLOBALPROC Extn_Reset(void)
ParamAddrHi = (uint16_t) - 1;
}
/* implementation of read/write for everything but RAM and ROM */
#define kSCC_Mask 0x03
#define kVIA1_Mask 0x00000F
#if EmVIA2
#define kVIA2_Mask 0x00000F
#endif
#define kIWM_Mask 0x00000F /* Allocated Memory Bandwidth for IWM */
#if CurEmMd <= kEmMd_512Ke
#define ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_Plus
#if kROM_Size > 0x00020000
#define ROM_CmpZeroMask 0 /* For hacks like Mac ROM-inator */
#else
#define ROM_CmpZeroMask 0x00020000
#endif
#elif CurEmMd <= kEmMd_PB100
#define ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_IIx
#define ROM_CmpZeroMask 0
#else
#error "ROM_CmpZeroMask not defined"
#endif
#define kROM_cmpmask (0x00F00000 | ROM_CmpZeroMask)
#if CurEmMd <= kEmMd_512Ke
#define Overlay_ROM_CmpZeroMask 0x00100000
#elif CurEmMd <= kEmMd_Plus
#define Overlay_ROM_CmpZeroMask 0x00020000
#elif CurEmMd <= kEmMd_Classic
#define Overlay_ROM_CmpZeroMask 0x00300000
#elif CurEmMd <= kEmMd_PB100
#define Overlay_ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_IIx
#define Overlay_ROM_CmpZeroMask 0
#else
#error "Overlay_ROM_CmpZeroMask not defined"
#endif
enum {
kMMDV_VIA1,
#if EmVIA2

112
src/HW/RAM/RAMADDR.h Normal file
View File

@ -0,0 +1,112 @@
#pragma once
/* map of address space */
#define kRAM_Base 0x00000000 /* when overlay off */
#if (CurEmMd == kEmMd_PB100)
#define kRAM_ln2Spc 23
#elif (CurEmMd == kEmMd_II) || (CurEmMd == kEmMd_IIx)
#define kRAM_ln2Spc 23
#else
#define kRAM_ln2Spc 22
#endif
#if IncludeVidMem
#if CurEmMd == kEmMd_PB100
#define kVidMem_Base 0x00FA0000
#define kVidMem_ln2Spc 16
#else
#define kVidMem_Base 0x00540000
#define kVidMem_ln2Spc 18
#endif
#endif
#if CurEmMd == kEmMd_PB100
#define kSCSI_Block_Base 0x00F90000
#define kSCSI_ln2Spc 16
#else
#define kSCSI_Block_Base 0x00580000
#define kSCSI_ln2Spc 19
#endif
#define kRAM_Overlay_Base 0x00600000 /* when overlay on */
#define kRAM_Overlay_Top 0x00800000
#if CurEmMd == kEmMd_PB100
#define kSCCRd_Block_Base 0x00FD0000
#define kSCC_ln2Spc 16
#else
#define kSCCRd_Block_Base 0x00800000
#define kSCC_ln2Spc 22
#endif
#if CurEmMd != kEmMd_PB100
#define kSCCWr_Block_Base 0x00A00000
#define kSCCWr_Block_Top 0x00C00000
#endif
#if CurEmMd == kEmMd_PB100
#define kIWM_Block_Base 0x00F60000
#define kIWM_ln2Spc 16
#else
#define kIWM_Block_Base 0x00C00000
#define kIWM_ln2Spc 21
#endif
#if CurEmMd == kEmMd_PB100
#define kVIA1_Block_Base 0x00F70000
#define kVIA1_ln2Spc 16
#else
#define kVIA1_Block_Base 0x00E80000
#define kVIA1_ln2Spc 19
#endif
#if CurEmMd == kEmMd_PB100
#define kASC_Block_Base 0x00FB0000
#define kASC_ln2Spc 16
#endif
#define kASC_Mask 0x00000FFF
/* implementation of read/write for everything but RAM and ROM */
#define kSCC_Mask 0x03
#define kVIA1_Mask 0x00000F
#if EmVIA2
#define kVIA2_Mask 0x00000F
#endif
#define kIWM_Mask 0x00000F /* Allocated Memory Bandwidth for IWM */
#if CurEmMd <= kEmMd_512Ke
#define ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_Plus
#if kROM_Size > 0x00020000
#define ROM_CmpZeroMask 0 /* For hacks like Mac ROM-inator */
#else
#define ROM_CmpZeroMask 0x00020000
#endif
#elif CurEmMd <= kEmMd_PB100
#define ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_IIx
#define ROM_CmpZeroMask 0
#else
#error "ROM_CmpZeroMask not defined"
#endif
#define kROM_cmpmask (0x00F00000 | ROM_CmpZeroMask)
#if CurEmMd <= kEmMd_512Ke
#define Overlay_ROM_CmpZeroMask 0x00100000
#elif CurEmMd <= kEmMd_Plus
#define Overlay_ROM_CmpZeroMask 0x00020000
#elif CurEmMd <= kEmMd_Classic
#define Overlay_ROM_CmpZeroMask 0x00300000
#elif CurEmMd <= kEmMd_PB100
#define Overlay_ROM_CmpZeroMask 0
#elif CurEmMd <= kEmMd_IIx
#define Overlay_ROM_CmpZeroMask 0
#else
#error "Overlay_ROM_CmpZeroMask not defined"
#endif

View File

@ -24,15 +24,13 @@
Macintosh port of vMac, by Philip Cummins.
*/
#ifndef AllFiles
#include "SYSDEPNS.h"
#include "UI/MYOSGLUE.h"
#include "UTIL/ENDIANAC.h"
#include "EMCONFIG.h"
#include "GLOBGLUE.h"
#endif
#include "HW/SCREEN/SCRNEMDV.h"
#include "CFGMAN.h"
#if ! IncludeVidMem
#define kMain_Offset 0x5900
@ -41,7 +39,54 @@
#define kAlternate_Buffer (kRAM_Size - kAlternate_Offset)
#endif
GLOBALPROC Screen_EndTickNotify(void)
// Configuration variables
uint16_t vMacScreenHeight;
uint16_t vMacScreenWidth;
uint16_t vMacScreenDepth;
uint32_t vMacScreenNumPixels;
uint32_t vMacScreenNumBits;
uint32_t vMacScreenNumBytes;
uint32_t vMacScreenBitWidth;
uint32_t vMacScreenByteWidth;
uint32_t vMacScreenMonoNumBytes;
uint32_t vMacScreenMonoByteWidth;
bool UseLargeScreenHack;
bool Screen_Init(void)
{
return true;
}
bool Screen_LoadCfg()
{
// Load configuration
int64_t temp;
bool okay;
okay = Config_GetInt(CONFIG_VIDEO_HEIGHT, &temp, 342);
if (!okay) { return false; }
vMacScreenHeight = temp;
okay = Config_GetInt(CONFIG_VIDEO_WIDTH, &temp, 512);
if (!okay) { return false; }
vMacScreenWidth = temp;
okay = Config_GetInt(CONFIG_VIDEO_DEPTH, &temp, 0);
if (!okay) { return false; }
vMacScreenDepth = temp;
okay = Config_GetBool(CONFIG_VIDEO_USEHACK, &UseLargeScreenHack, false);
if (!okay) { return false; }
// Compute the other sorts of things
vMacScreenNumPixels = vMacScreenHeight * vMacScreenWidth;
vMacScreenNumBits = vMacScreenNumPixels << vMacScreenDepth;
vMacScreenNumBytes = vMacScreenNumBits / 8;
vMacScreenBitWidth = vMacScreenWidth << vMacScreenDepth;
vMacScreenByteWidth = vMacScreenBitWidth / 8;
vMacScreenMonoNumBytes = vMacScreenNumPixels / 8;
vMacScreenMonoByteWidth = (long)vMacScreenWidth / 8;
return true;
}
void Screen_EndTickNotify(void)
{
uint8_t * screencurrentbuff;

View File

@ -18,6 +18,20 @@
#ifndef SCRNEMDV_H
#define SCRNEMDV_H
EXPORTPROC Screen_EndTickNotify(void);
bool Screen_LoadCfg(void);
bool Screen_Init(void);
void Screen_EndTickNotify(void);
extern uint16_t vMacScreenHeight;
extern uint16_t vMacScreenWidth;
extern uint16_t vMacScreenDepth;
extern uint32_t vMacScreenNumPixels;
extern uint32_t vMacScreenNumBits;
extern uint32_t vMacScreenNumBytes;
extern uint32_t vMacScreenBitWidth;
extern uint32_t vMacScreenByteWidth;
extern uint32_t vMacScreenMonoNumBytes;
extern uint32_t vMacScreenMonoByteWidth;
bool UseLargeScreenHack;
#endif

View File

@ -1,53 +0,0 @@
/*
HW/SCREEN/SCRNMAPR.h
Copyright (C) 2012 Paul C. Pratt
You can redistribute this file and/or modify it under the terms
of version 2 of the GNU General Public License as published by
the Free Software Foundation. You should have received a copy
of the license along with this file; see the file COPYING.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
license for more details.
*/
/*
SCReeN MAPpeR
*/
#include "SCRNMAPR.h"
#include <assert.h>
void ScrnMapr_DoMap(
rect_t region, rect_t bounds,
const color_t *src, color_t *dst,
uint8_t src_depth, uint8_t dst_depth,
const color_t *map, uint8_t scale
) {
/* check of parameters */
assert(src_depth >= 0);
assert(src_depth <= 3);
assert(dst_depth >= src_depth);
/* define variables */
int x, y, sx, sy; // loop vars
uint16_t line_width = bounds.right - bounds.left;
for (y = region.top; y < region.bottom; y += 1)
{
for (sy = 0; sy < scale - 1; sy += 1)
{
for (x = region.left; x < region.right; x += 1)
{
color_t color = src[(y+sy)*line_width + x];
for (sx = 0; sx < scale - 1; sx += 1)
{
dst[(y+sy)*line_width + x*scale + sx] = map[color];
}
}
}
}
}

View File

@ -1,19 +0,0 @@
/* SCRNMAPR.h */
#include <stdint.h>
#pragma once
typedef struct {
uint16_t top;
uint16_t left;
uint16_t right;
uint16_t bottom;
} rect_t;
typedef uint32_t color_t;
// Copy a rectangular bitmap region, scaling and converting color depth as needed
void ScrnMapr_DoMap(
rect_t bounds,
const uint8_t *src, uint8_t *dst, uint8_t src_depth, uint8_t dst_depth,
const uint8_t *map, uint8_t scale
);

View File

@ -32,6 +32,7 @@
#include "UTIL/ENDIANAC.h"
#include "PATCHES/ROMEMDEV.h"
#include "PATCHES/SCRNHACK.h"
#include "PATCHES/SONYDRV.h"
#ifdef CurAltHappyMac
#include "HPMCHACK.h"
#endif

View File

@ -18,9 +18,6 @@
#define ROMEMDEV_H
#ifndef UseLargeScreenHack
#define UseLargeScreenHack 0
#endif
#ifndef DisableRomCheck
#define DisableRomCheck 1
#endif
@ -34,4 +31,4 @@
EXPORTFUNC bool ROM_Init(void);
#endif
#endif

View File

@ -28,13 +28,12 @@
#include "GLOBGLUE.h"
#include "incbin/incbin.h"
#include "PATCHES/ROMEMDEV.h"
#include "HW/SCREEN/SCRNEMDV.h"
void ScreenHack_Install(uint8_t *pto)
static void ScreenHack_Install_64K(uint8_t **pto)
{
uint8_t * patchp = pto;
if (!UseLargeScreenHack) {return; }
#if CurEmMd <= kEmMd_128K
uint8_t *patchp = *pto;
do_put_mem_long(112 + ROM, kVidMem_Base);
do_put_mem_long(260 + ROM, kVidMem_Base);
do_put_mem_long(292 + ROM, kVidMem_Base
@ -54,11 +53,11 @@ void ScreenHack_Install(uint8_t *pto)
/* screen setup, main */
{
pto = 862 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
*pto = 862 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x21FC); /* MOVE.L */
patchp += 2;
@ -99,58 +98,64 @@ void ScreenHack_Install(uint8_t *pto)
do_put_mem_word(2052 + ROM, vMacScreenWidth / 8 - 2);
/* cursor handling */
#if vMacScreenWidth >= 1024
pto = 3448 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 3448 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave),A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x,D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(3452 + ROM, 0x7000 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave),A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x,D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(3452 + ROM, 0x7000 + (vMacScreenWidth / 8));
}
do_put_mem_word(3572 + ROM, vMacScreenWidth - 32);
do_put_mem_word(3578 + ROM, vMacScreenWidth - 32);
do_put_mem_word(3610 + ROM, vMacScreenHeight - 16);
do_put_mem_word(3616 + ROM, vMacScreenHeight);
#if vMacScreenWidth >= 1024
pto = 3646 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 3646 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x,D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5,D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1,A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(3646 + ROM, 0x7A00 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x,D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5,D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1,A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(3646 + ROM, 0x7A00 + (vMacScreenWidth / 8));
}
/* set up screen bitmap */
do_put_mem_word(3832 + ROM, vMacScreenHeight);
do_put_mem_word(3838 + ROM, vMacScreenWidth);
/* do_put_mem_word(7810 + ROM, vMacScreenHeight); */
}
#elif CurEmMd <= kEmMd_Plus
// Currently not functional
static void ScreenHack_Install_128K(uint8_t **pto)
{
uint8_t *patchp = *pto;
do_put_mem_long(138 + ROM, kVidMem_Base);
do_put_mem_long(326 + ROM, kVidMem_Base);
do_put_mem_long(356 + ROM, kVidMem_Base
@ -173,11 +178,11 @@ void ScreenHack_Install(uint8_t *pto)
/* screen setup, main */
{
pto = 1132 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
*pto = 1132 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x21FC); /* MOVE.L */
patchp += 2;
@ -222,50 +227,50 @@ void ScreenHack_Install(uint8_t *pto)
do_put_mem_word(3894 + ROM, vMacScreenWidth / 8 - 2);
/* cursor handling */
#if vMacScreenWidth >= 1024
pto = 7372 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 7372 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave), A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x, D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(7376 + ROM, 0x7000 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave), A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x, D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(7376 + ROM, 0x7000 + (vMacScreenWidth / 8));
}
do_put_mem_word(7496 + ROM, vMacScreenWidth - 32);
do_put_mem_word(7502 + ROM, vMacScreenWidth - 32);
do_put_mem_word(7534 + ROM, vMacScreenHeight - 16);
do_put_mem_word(7540 + ROM, vMacScreenHeight);
#if vMacScreenWidth >= 1024
pto = 7570 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 7570 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x,D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5,D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1,A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(7570 + ROM, 0x7A00 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x,D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5,D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1,A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(7570 + ROM, 0x7A00 + (vMacScreenWidth / 8));
}
/* set up screen bitmap */
do_put_mem_word(7784 + ROM, vMacScreenHeight);
@ -297,16 +302,19 @@ void ScreenHack_Install(uint8_t *pto)
do_put_mem_word(5212 + ROM, vMacScreenHeight / 2 - 101);
do_put_mem_word(5214 + ROM, vMacScreenWidth / 2 - 218);
#endif
}
#elif CurEmMd <= kEmMd_Classic
void ScreenHack_Install_256K(uint8_t **pto)
{
uint8_t *patchp = *pto;
/* screen setup, main */
{
pto = 1482 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
*pto = 1482 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x21FC); /* MOVE.L */
patchp += 2;
@ -357,55 +365,79 @@ void ScreenHack_Install(uint8_t *pto)
do_put_mem_word(4586 + ROM, vMacScreenWidth / 8);
/* cursor handling */
#if vMacScreenWidth >= 1024
pto = 101886 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 101886 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave),A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x,D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(101890 + ROM, 0x7000 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x41F8); /* Lea.L (CrsrSave),A0 */
patchp += 2;
do_put_mem_word(patchp, 0x088C);
patchp += 2;
do_put_mem_word(patchp, 0x203C); /* MOVE.L #$x,D0 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(101890 + ROM, 0x7000 + (vMacScreenWidth / 8));
}
do_put_mem_word(102010 + ROM, vMacScreenWidth - 32);
do_put_mem_word(102016 + ROM, vMacScreenWidth - 32);
do_put_mem_word(102048 + ROM, vMacScreenHeight - 16);
do_put_mem_word(102054 + ROM, vMacScreenHeight);
#if vMacScreenWidth >= 1024
pto = 102084 + ROM;
do_put_mem_word(pto, 0x4EB9); /* JSR */
pto += 2;
do_put_mem_long(pto, kROM_Base + (patchp - ROM));
pto += 4;
if (vMacScreenWidth >= 1024) {
*pto = 102084 + ROM;
do_put_mem_word(*pto, 0x4EB9); /* JSR */
*pto += 2;
do_put_mem_long(*pto, kROM_Base + (patchp - ROM));
*pto += 4;
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x, D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5, D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1, A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
#else
do_put_mem_word(102084 + ROM, 0x7A00 + (vMacScreenWidth / 8));
#endif
do_put_mem_word(patchp, 0x2A3C); /* MOVE.L #$x, D5 */
patchp += 2;
do_put_mem_long(patchp, (vMacScreenWidth / 8));
patchp += 4;
do_put_mem_word(patchp, 0xC2C5); /* MulU D5, D1 */
patchp += 2;
do_put_mem_word(patchp, 0xD3C1); /* AddA.L D1, A1 */
patchp += 2;
do_put_mem_word(patchp, 0x4E75); /* RTS */
patchp += 2;
} else {
do_put_mem_word(102084 + ROM, 0x7A00 + (vMacScreenWidth / 8));
}
/* set up screen bitmap */
do_put_mem_word(102298 + ROM, vMacScreenHeight);
do_put_mem_word(102304 + ROM, vMacScreenWidth);
do_put_mem_word(102324 + ROM, vMacScreenHeight);
#endif
}
void ScreenHack_Install(uint8_t **pto)
{
if (!UseLargeScreenHack) { return; }
switch(CurEmMd) {
case kEmMd_Twiggy:
case kEmMd_Twig43:
case kEmMd_128K:
ScreenHack_Install_64K(pto);
break;
case kEmMd_512Ke:
case kEmMd_Plus:
ScreenHack_Install_128K(pto);
break;
case kEmMd_SE:
case kEmMd_SEFDHD:
case kEmMd_Classic:
ScreenHack_Install_256K(pto);
break;
default:
// unsupported
break;
}
}

View File

@ -1,3 +1,3 @@
#include <stdint.h>
void ScreenHack_Install(uint8_t *pto);
void ScreenHack_Install(uint8_t **pto);

View File

@ -12,7 +12,11 @@
#include "UTIL/ENDIANAC.h"
#include "UI/MYOSGLUE.h"
#include "PATCHES/SONYDRV.h"
#include "PATCHES/SCRNHACK.h"
#include "PATCHES/ROMEMDEV.h"
//#include "PATCHES/SCRNHACK.h"
// temporary screenhack stuff
#include "HW/SCREEN/SCRNEMDV.h"
// Include binaries
INCBIN(SonyDriver, "rsrc/SONYDRV.bin");
@ -66,6 +70,6 @@ void Sony_Install(void)
Sony_LoadIcon(pto, &icoSize);
pto += icoSize;
// yeah this sucks but it's so awful and intertwined that i have no choice
//ScreenHack_Install(pto);
// currently broken
//ScreenHack_Install(&pto);
}

View File

@ -46,11 +46,6 @@
#include "PROGMAIN.h"
// Temporary location for config variables
uint16_t vMacScreenHeight = 342;
uint16_t vMacScreenWidth = 512;
uint16_t vMacScreenDepth = 0;
// Let's define a bunch of function structure thingies
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
@ -257,7 +252,7 @@ const DevMethods_t DEVICES[] = {
},
// Screen
{
.init = NULL,
.init = Screen_Init,
.reset = NULL,
.starttick = Sixtieth_PulseNtfy, // VBlank interrupt
.endtick = Screen_EndTickNotify,

View File

@ -23,8 +23,8 @@
#include "GLOBGLUE.h"
#include "MYOSGLUE.h"
#include "CNFGRAPI.h"
#include "COMOSGLU.h"
#include "HW/SCREEN/SCRNEMDV.h"
GLOBALVAR uint8_t * ROM = nullpr;
GLOBALVAR bool ROM_loaded = false;

View File

@ -1,7 +1,7 @@
/*
* CONFIG Mode
*
* A replacement for Control Mode, with prettier grapgics and actual settings
* A replacement for Control Mode, with prettier graphics and actual settings
*
*/

View File

@ -122,16 +122,6 @@ EXPORTVAR(uint32_t, CurMacDelta)
#endif
#define vMacScreenNumPixels \
((long)vMacScreenHeight * (long)vMacScreenWidth)
#define vMacScreenNumBits (vMacScreenNumPixels << vMacScreenDepth)
#define vMacScreenNumBytes (vMacScreenNumBits / 8)
#define vMacScreenBitWidth ((long)vMacScreenWidth << vMacScreenDepth)
#define vMacScreenByteWidth (vMacScreenBitWidth / 8)
#define vMacScreenMonoNumBytes (vMacScreenNumPixels / 8)
#define vMacScreenMonoByteWidth ((long)vMacScreenWidth / 8)
EXPORTVAR(bool, UseColorMode)
EXPORTVAR(bool, ColorModeWorks)

View File

@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL2/SDL.h>
#include "CNFGRAPI.h"
#include "SYSDEPNS.h"
#include "UTIL/ENDIANAC.h"
@ -32,6 +32,8 @@
#include "STRCONST.h"
#include "OSGLUSD2.h"
#include "LANG/INTLCHAR.h"
#include "HW/SCREEN/SCRNEMDV.h"
#include "CFGMAN.h"
/* --- some simple utilities --- */
@ -206,7 +208,7 @@ LOCALPROC HandleTheEvent(SDL_Event *event)
LOCALVAR int argc;
LOCALVAR char **argv;
LOCALFUNC bool Screen_Init(void)
LOCALFUNC bool SDL_InitDisplay(void)
{
bool v = false;
@ -799,12 +801,12 @@ LOCALPROC CheckForSavedTasks(void)
if (RequestMacOff) {
RequestMacOff = false;
if (AnyDiskInserted()) {
/*if (AnyDiskInserted()) {
MacMsgOverride(kStrQuitWarningTitle,
kStrQuitWarningMessage);
} else {
} else {*/
ForceMacOff = true;
}
//}
}
if (ForceMacOff) {
@ -1043,6 +1045,7 @@ LOCALPROC UninitWhereAmI(void)
LOCALFUNC bool InitOSGLU(void)
{
if (Config_TryInit())
if (AllocMemory())
#if CanGetAppPath
if (InitWhereAmI())
@ -1057,7 +1060,7 @@ LOCALFUNC bool InitOSGLU(void)
#if SoundEnabled
if (Sound_Init())
#endif
if (Screen_Init())
if (SDL_InitDisplay())
if (CreateMainWindow())
if (WaitForRom())
{

View File

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL_pixels.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_pixels.h>
#include "CNFGRAPI.h"
#include "SYSDEPNS.h"
#include "UTIL/ENDIANAC.h"
@ -10,6 +10,7 @@
#include "UI/COMOSGLU.h"
#include "STRCONST.h"
#include "OSGLUSD2.h"
#include "HW/SCREEN/SCRNEMDV.h"
/* --- video out --- */

1
src/tomlc99 Submodule

@ -0,0 +1 @@
Subproject commit b539e3f20ec443d7046153ed4623da277da89170