Major code cleanup and code reformating
This commit is contained in:
parent
4e5f796d6a
commit
cc1060775c
38
dumpinfo.c
38
dumpinfo.c
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* dumpinfo.c: Tool to dump the metadata info about a cart rom image.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -17,7 +24,7 @@ char *load_file(char *filename, uint32_t *fileSize)
|
|||||||
|
|
||||||
fstat(fd, &FileStat);
|
fstat(fd, &FileStat);
|
||||||
|
|
||||||
ret_ptr = (char *)mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
ret_ptr = (char *)mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
*fileSize = FileStat.st_size;
|
*fileSize = FileStat.st_size;
|
||||||
|
|
||||||
@ -32,7 +39,7 @@ char *load_file(char *filename, uint32_t *fileSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct cart_metadata
|
struct cart_metadata
|
||||||
{
|
{
|
||||||
uint8_t farjump[5];
|
uint8_t farjump[5];
|
||||||
uint8_t flagExt;
|
uint8_t flagExt;
|
||||||
@ -64,29 +71,26 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (content != NULL)
|
if (content != NULL)
|
||||||
{
|
{
|
||||||
data = (struct cart_metadata*)&(content[size - sizeof(struct cart_metadata)]);
|
data = (struct cart_metadata *)&(content[size - sizeof(struct cart_metadata)]);
|
||||||
|
|
||||||
printf("%s:\n", argv[1]);
|
printf("%s:\n", argv[1]);
|
||||||
if (data->farjump[0] == 0xEA)
|
if (data->farjump[0] == 0xEA)
|
||||||
{
|
{
|
||||||
printf("[%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]",
|
printf("[%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]", data->publishId, data->gameId[0],
|
||||||
data->publishId, data->gameId[0], data->gameId[1], data->flags2, data->romInfo, data->saveInfo,
|
data->gameId[1], data->flags2, data->romInfo, data->saveInfo, data->flags & 0xFF,
|
||||||
data->flags & 0xFF, (data->flags>>8) & 0xFF, data->crc & 0xFF, (data->crc>>8) & 0xFF);
|
(data->flags >> 8) & 0xFF, data->crc & 0xFF, (data->crc >> 8) & 0xFF);
|
||||||
printf(" - Reset @ %02X%02X:%02X%02Xh\n",
|
printf(" - Reset @ %02X%02X:%02X%02Xh\n", data->farjump[4], data->farjump[3], data->farjump[2],
|
||||||
data->farjump[4], data->farjump[3],
|
data->farjump[1]);
|
||||||
data->farjump[2], data->farjump[1]);
|
|
||||||
|
|
||||||
printf(" - publisher: %02X, gameId: %01X%02X\n", data->publishId, data->gameId[0], data->gameId[1]);
|
printf(" - publisher: %02X, gameId: %01X%02X\n", data->publishId, data->gameId[0], data->gameId[1]);
|
||||||
printf(" - %s want to write to EEPROM\n", data->flags2&0x80?"Do":"Do not");
|
printf(" - %s want to write to EEPROM\n", data->flags2 & 0x80 ? "Do" : "Do not");
|
||||||
printf(" - %s user defined bootsplash\n", data->flagExt&0x80?"Dissallow":"Allow");
|
printf(" - %s user defined bootsplash\n", data->flagExt & 0x80 ? "Dissallow" : "Allow");
|
||||||
printf(" - Is %sbootable on a normal swan\n", data->flagExt&0x0F?"not ":"");
|
printf(" - Is %sbootable on a normal swan\n", data->flagExt & 0x0F ? "not " : "");
|
||||||
printf(" - ROM Size: %02Xh\n", data->romInfo);
|
printf(" - ROM Size: %02Xh\n", data->romInfo);
|
||||||
printf(" - Save type & Size: %02Xh\n", data->saveInfo);
|
printf(" - Save type & Size: %02Xh\n", data->saveInfo);
|
||||||
printf(" - Flags: %d cycles ROM, %d bit ROM bus, %sRTC, %s orientation\n",
|
printf(" - Flags: %d cycles ROM, %d bit ROM bus, %sRTC, %s orientation\n", data->flags & 0x004 ? 1 : 3,
|
||||||
data->flags & 0x004?1:3,
|
data->flags & 0x002 ? 8 : 16, data->flags & 0x100 ? "" : "No ",
|
||||||
data->flags & 0x002?8:16,
|
data->flags & 0x001 ? "Vertical" : "Horizontal");
|
||||||
data->flags & 0x100?"":"No ",
|
|
||||||
data->flags & 0x001?"Vertical":"Horizontal");
|
|
||||||
printf(" - CRC: %04Xh\n", data->crc);
|
printf(" - CRC: %04Xh\n", data->crc);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
224
main.c
224
main.c
@ -1,5 +1,10 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
// Wonderswan emulator
|
* NewOswan
|
||||||
|
* main.c: Entry point
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// 13.04.2002: Fixed a small bug causing crashes
|
// 13.04.2002: Fixed a small bug causing crashes
|
||||||
@ -7,7 +12,7 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -36,73 +41,65 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#define LOG_PATH "oswan.log"
|
#define LOG_PATH "oswan.log"
|
||||||
|
|
||||||
|
|
||||||
int gui_command=GUI_COMMAND_NONE;
|
|
||||||
int gui_mainDialogRunning;
|
|
||||||
int gui_controls_configuration_Running;
|
|
||||||
int gui_get_key_Running;
|
|
||||||
int gui_get_key_key;
|
|
||||||
|
|
||||||
int ws_videoEnhancementType=0;
|
|
||||||
int sram_path_explicit = 0;
|
int sram_path_explicit = 0;
|
||||||
int ieep_path_explicit = 0;
|
int ieep_path_explicit = 0;
|
||||||
|
|
||||||
int ws_mk_savpath()
|
int ws_mk_savpath()
|
||||||
{
|
{
|
||||||
char *w;
|
char *w;
|
||||||
|
|
||||||
if (sram_path_explicit)
|
if (sram_path_explicit)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws_sram_path != NULL)
|
if (ws_sram_path != NULL)
|
||||||
{
|
{
|
||||||
free(ws_sram_path);
|
free(ws_sram_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_sram_path = (char *)malloc(strlen(ws_rom_path) + 2);
|
ws_sram_path = (char *)malloc(strlen(ws_rom_path) + 2);
|
||||||
strcpy(ws_sram_path, ws_rom_path);
|
strcpy(ws_sram_path, ws_rom_path);
|
||||||
w = strrchr(ws_sram_path, '.');
|
w = strrchr(ws_sram_path, '.');
|
||||||
|
|
||||||
if (NULL == w)
|
if (NULL == w)
|
||||||
{
|
{
|
||||||
strcpy(ws_sram_path, "error.sav");
|
strcpy(ws_sram_path, "error.sav");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(w, ".sav");
|
strcpy(w, ".sav");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ws_mk_ieppath()
|
int ws_mk_ieppath()
|
||||||
{
|
{
|
||||||
char *w;
|
char *w;
|
||||||
|
|
||||||
if (ieep_path_explicit)
|
if (ieep_path_explicit)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws_ieep_path != NULL)
|
if (ws_ieep_path != NULL)
|
||||||
{
|
{
|
||||||
free(ws_ieep_path);
|
free(ws_ieep_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_ieep_path = (char *)malloc(strlen(ws_rom_path) + 2);
|
ws_ieep_path = (char *)malloc(strlen(ws_rom_path) + 2);
|
||||||
strcpy(ws_ieep_path, ws_rom_path);
|
strcpy(ws_ieep_path, ws_rom_path);
|
||||||
w = strrchr(ws_ieep_path, '.');
|
w = strrchr(ws_ieep_path, '.');
|
||||||
|
|
||||||
if (NULL == w)
|
if (NULL == w)
|
||||||
{
|
{
|
||||||
strcpy(ws_ieep_path, "error.iep");
|
strcpy(ws_ieep_path, "error.iep");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(w, ".iep");
|
strcpy(w, ".iep");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -130,81 +127,74 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fprintf(log_get(), "NewOswan %s (built at: %s %s)\n", VERSION, __DATE__, __TIME__);
|
fprintf(log_get(), "NewOswan %s (built at: %s %s)\n", VERSION, __DATE__, __TIME__);
|
||||||
|
|
||||||
ws_rom_path = NULL;
|
ws_rom_path = NULL;
|
||||||
|
|
||||||
for (int n = 1; n < argc; ++n)
|
for (int n = 1 ; n < argc ; ++n)
|
||||||
{
|
{
|
||||||
if (argv[n][0] == '-')
|
if (argv[n][0] == '-')
|
||||||
{
|
{
|
||||||
switch(argv[n][1])
|
switch (argv[n][1])
|
||||||
{
|
|
||||||
case 'C':
|
|
||||||
if (++n < argc)
|
|
||||||
{
|
{
|
||||||
ws_cyclesByLine = atoi(argv[n]);
|
case 'C':
|
||||||
|
if (++n < argc)
|
||||||
|
{
|
||||||
|
ws_cyclesByLine = atoi(argv[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(log_get(), "Cycles by line set to %d\n", ws_cyclesByLine);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
if (++n < argc)
|
||||||
|
{
|
||||||
|
ws_system = atoi(argv[n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(log_get(), "WonderSwan set to %d\n", ws_system);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
if (++n < argc)
|
||||||
|
{
|
||||||
|
ws_sram_path = argv[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
sram_path_explicit = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ws_rom_path = argv[n];
|
||||||
|
ws_mk_savpath();
|
||||||
|
ws_mk_ieppath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(log_get(), "Cycles by line set to %d\n", ws_cyclesByLine);
|
while (!app_terminate)
|
||||||
break;
|
{
|
||||||
|
if (!ws_rom_path)
|
||||||
|
{
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
case 'w':
|
if (ws_rom_path)
|
||||||
if (++n < argc)
|
{
|
||||||
|
ws_set_system(ws_system);
|
||||||
|
if (ws_init(ws_rom_path))
|
||||||
{
|
{
|
||||||
ws_system = atoi(argv[n]);
|
ws_reset();
|
||||||
|
|
||||||
|
ws_emulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(log_get(), "WonderSwan set to %d\n", ws_system);
|
ws_done();
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 's':
|
log_done();
|
||||||
if (++n < argc)
|
return (0);
|
||||||
{
|
|
||||||
ws_sram_path = argv[n];
|
|
||||||
}
|
|
||||||
|
|
||||||
sram_path_explicit = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ws_rom_path = argv[n];
|
|
||||||
ws_mk_savpath();
|
|
||||||
ws_mk_ieppath();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!app_terminate)
|
|
||||||
{
|
|
||||||
if (!ws_rom_path)
|
|
||||||
{
|
|
||||||
app_gameRunning=0;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ws_rom_path)
|
|
||||||
{
|
|
||||||
ws_set_system(ws_system);
|
|
||||||
if (ws_init(ws_rom_path))
|
|
||||||
{
|
|
||||||
app_rotated=ws_rotated();
|
|
||||||
app_gameRunning=1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ws_reset();
|
|
||||||
|
|
||||||
ws_emulate();
|
|
||||||
}
|
|
||||||
|
|
||||||
ws_done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log_done();
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
resource.h
50
resource.h
@ -1,50 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Developer Studio generated include file.
|
|
||||||
// Used by gui.rc
|
|
||||||
//
|
|
||||||
#define IDD_DIALOG_MAIN 101
|
|
||||||
#define IDB_BITMAP1 102
|
|
||||||
#define IDB_BITMAP2 103
|
|
||||||
#define IDC_BUTTON_LOAD 1000
|
|
||||||
#define IDC_BUTTON_RESET 1001
|
|
||||||
#define IDC_BUTTON_EXIT 1002
|
|
||||||
#define IDC_RADIO1 1003
|
|
||||||
#define IDC_RADIO_WINDOWED 1003
|
|
||||||
#define IDC_RADIO2 1004
|
|
||||||
#define IDC_RADIO_FULLSCREEN 1004
|
|
||||||
#define IDC_BUTTON_LOADSTATE 1005
|
|
||||||
#define IDC_BUTTON_SAVESTATE 1006
|
|
||||||
#define IDC_RADIO3 1007
|
|
||||||
#define IDC_BUTTON_CONTINUE 1007
|
|
||||||
#define IDC_RADIO4 1008
|
|
||||||
#define IDC_BUTTON_CONTROLS 1008
|
|
||||||
#define IDC_RADIO5 1009
|
|
||||||
#define IDC_RADIO_STANDARD_MODE 1009
|
|
||||||
#define IDC_RADIO6 1010
|
|
||||||
#define IDC_RADIO_DOUBLESIZE_MODE 1010
|
|
||||||
#define IDC_RADIO7 1011
|
|
||||||
#define IDC_RADIO_SCANLINES_MODE 1011
|
|
||||||
#define IDC_RADIO8 1012
|
|
||||||
#define IDC_RADIO_50PRCTSCANLINES_MODE 1012
|
|
||||||
#define IDC_RADIO9 1013
|
|
||||||
#define IDC_RADIO_SPECIAL_MODE 1013
|
|
||||||
#define IDC_RADIO_SYSTEM_AUTODETECT 1014
|
|
||||||
#define IDC_RADIO_SYSTEM_MONO 1015
|
|
||||||
#define IDC_RADIO_SYSTEM_COLOR 1016
|
|
||||||
#define IDC_RADIO_2XSAI 1017
|
|
||||||
#define IDC_RADIO_SUPER2XSAI 1018
|
|
||||||
#define IDC_COLOUR_DEFAULT 1019
|
|
||||||
#define IDC_COLOUR_AMBER 1020
|
|
||||||
#define IDC_COLOUR_GREEN 1021
|
|
||||||
#define IDC_RADIO_SUPEREAGLE 1022
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 108
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1021
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
set(SOURCES audio.c emulate.c gpu.c io.c log.c memory.c rom.c ws.c)
|
set(SOURCES audio.c emulate.c gpu.c io.c log.c memory.c rom.c ws.c)
|
||||||
set(HEADERS audio.h emulate.h gpu.h ieeprom.h io.h log.h memory.h rom.h ws.h)
|
set(HEADERS audio.h emulate.h gpu.h io.h log.h memory.h rom.h ws.h)
|
||||||
|
|
||||||
add_library(wswan ${SOURCES} ${HEADERS})
|
add_library(wswan ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
|
|||||||
1795
source/audio.c
1795
source/audio.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* audio.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|||||||
102
source/emulate.c
102
source/emulate.c
@ -1,6 +1,11 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
// Main emulation loop
|
* NewOswan
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
* emulate.c:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -23,6 +28,7 @@
|
|||||||
|
|
||||||
#define GLFW_INCLUDE_GLEXT
|
#define GLFW_INCLUDE_GLEXT
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
/* "Apple" fix */
|
/* "Apple" fix */
|
||||||
#ifndef GL_TEXTURE_RECTANGLE
|
#ifndef GL_TEXTURE_RECTANGLE
|
||||||
@ -39,12 +45,8 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
char app_window_title[256];
|
char app_window_title[256];
|
||||||
int app_gameRunning=0;
|
int app_terminate = 0;
|
||||||
int app_terminate=0;
|
|
||||||
int app_fullscreen=0;
|
|
||||||
int app_rotated=0;
|
|
||||||
|
|
||||||
|
|
||||||
int ws_key_esc = 0;
|
int ws_key_esc = 0;
|
||||||
|
|
||||||
@ -68,13 +70,13 @@ struct GLWindow_t
|
|||||||
};
|
};
|
||||||
static GLWindow mainWindow;
|
static GLWindow mainWindow;
|
||||||
static int window_num = 0;
|
static int window_num = 0;
|
||||||
|
|
||||||
static void ShowScreen(GLWindow *g, int w, int h)
|
static void ShowScreen(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
// glTexSubImage2D is faster when not using a texture range
|
// glTexSubImage2D is faster when not using a texture range
|
||||||
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h,
|
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, g->videoMemory);
|
||||||
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, g->videoMemory);
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glTexCoord2f(0.0f, 0.0f);
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
@ -92,12 +94,14 @@ static void ShowScreen(GLWindow *g, int w, int h)
|
|||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLWindowInitEx(GLWindow *g, int w, int h)
|
static void GLWindowInitEx(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
g->WIDTH = w;
|
g->WIDTH = w;
|
||||||
g->HEIGHT = h;
|
g->HEIGHT = h;
|
||||||
g->videoTexture = window_num++;
|
g->videoTexture = window_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupGL(GLWindow *g, int w, int h)
|
static void setupGL(GLWindow *g, int w, int h)
|
||||||
{
|
{
|
||||||
g->videoMemory = (uint8_t *)malloc(w * h * sizeof(uint16_t));
|
g->videoMemory = (uint8_t *)malloc(w * h * sizeof(uint16_t));
|
||||||
@ -120,10 +124,6 @@ static void setupGL(GLWindow *g, int w, int h)
|
|||||||
glEnable(GL_TEXTURE_RECTANGLE);
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
|
||||||
|
|
||||||
// glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
|
|
||||||
|
|
||||||
// glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
|
||||||
// glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
|
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
@ -134,6 +134,7 @@ static void setupGL(GLWindow *g, int w, int h)
|
|||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreGL(GLWindow *g)
|
void restoreGL(GLWindow *g)
|
||||||
{
|
{
|
||||||
//Tell OpenGL how to convert from coordinates to pixel values
|
//Tell OpenGL how to convert from coordinates to pixel values
|
||||||
@ -154,6 +155,7 @@ void restoreGL(GLWindow *g)
|
|||||||
glEnable(GL_TEXTURE_RECTANGLE);
|
glEnable(GL_TEXTURE_RECTANGLE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
|
static void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
|
||||||
{
|
{
|
||||||
struct KeyArray *keyArray;
|
struct KeyArray *keyArray;
|
||||||
@ -174,16 +176,19 @@ static void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod
|
|||||||
/*printf("key:%d, state:%d debounce:%d, laststate:%d\n", key, keyArray[key].curState,
|
/*printf("key:%d, state:%d debounce:%d, laststate:%d\n", key, keyArray[key].curState,
|
||||||
keyArray[key].debounced, keyArray[key].lastState);*/
|
keyArray[key].debounced, keyArray[key].lastState);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sizeHandler(GLFWwindow *window, int xs, int ys)
|
static void sizeHandler(GLFWwindow *window, int xs, int ys)
|
||||||
{
|
{
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glViewport(0, 0, xs, ys);
|
glViewport(0, 0, xs, ys);
|
||||||
ShowScreen(&mainWindow, 244, 144);
|
ShowScreen(&mainWindow, 244, 144);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char *description)
|
static void error_callback(int error, const char *description)
|
||||||
{
|
{
|
||||||
puts(description);
|
puts(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initDisplay(GLWindow *g)
|
static void initDisplay(GLWindow *g)
|
||||||
{
|
{
|
||||||
int h = g->HEIGHT;
|
int h = g->HEIGHT;
|
||||||
@ -216,10 +221,12 @@ static void initDisplay(GLWindow *g)
|
|||||||
glfwSetKeyCallback(g->windows, kbHandler);
|
glfwSetKeyCallback(g->windows, kbHandler);
|
||||||
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
glfwSetWindowSizeCallback(g->windows, sizeHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearScreen(GLWindow *g)
|
static void clearScreen(GLWindow *g)
|
||||||
{
|
{
|
||||||
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateScreen(GLWindow *g)
|
static void updateScreen(GLWindow *g)
|
||||||
{
|
{
|
||||||
/* Update windows code */
|
/* Update windows code */
|
||||||
@ -228,6 +235,7 @@ static void updateScreen(GLWindow *g)
|
|||||||
glfwSwapBuffers(g->windows);
|
glfwSwapBuffers(g->windows);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getTicks()
|
uint64_t getTicks()
|
||||||
{
|
{
|
||||||
struct timeval curTime;
|
struct timeval curTime;
|
||||||
@ -235,7 +243,7 @@ uint64_t getTicks()
|
|||||||
/* Get datetime */
|
/* Get datetime */
|
||||||
gettimeofday(&curTime, NULL);
|
gettimeofday(&curTime, NULL);
|
||||||
|
|
||||||
ticks = (curTime.tv_sec* 1000) + curTime.tv_usec / 1000;
|
ticks = (curTime.tv_sec * 1000) + curTime.tv_usec / 1000;
|
||||||
|
|
||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
@ -247,97 +255,97 @@ static inline int getKeyState(int key)
|
|||||||
|
|
||||||
static void read_keys()
|
static void read_keys()
|
||||||
{
|
{
|
||||||
ws_key_start=0;
|
ws_key_start = 0;
|
||||||
ws_key_x4=0;
|
ws_key_x4 = 0;
|
||||||
ws_key_x2=0;
|
ws_key_x2 = 0;
|
||||||
ws_key_x1=0;
|
ws_key_x1 = 0;
|
||||||
ws_key_x3=0;
|
ws_key_x3 = 0;
|
||||||
ws_key_y4=0;
|
ws_key_y4 = 0;
|
||||||
ws_key_y2=0;
|
ws_key_y2 = 0;
|
||||||
ws_key_y1=0;
|
ws_key_y1 = 0;
|
||||||
ws_key_y3=0;
|
ws_key_y3 = 0;
|
||||||
ws_key_button_a=0;
|
ws_key_button_a = 0;
|
||||||
ws_key_button_b=0;
|
ws_key_button_b = 0;
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_E))
|
if (getKeyState(GLFW_KEY_E))
|
||||||
{
|
{
|
||||||
dump_memory();
|
dump_memory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_R))
|
if (getKeyState(GLFW_KEY_R))
|
||||||
{
|
{
|
||||||
printf("Boop\n");
|
printf("Boop\n");
|
||||||
ws_reset();
|
ws_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_ESCAPE))
|
if (getKeyState(GLFW_KEY_ESCAPE))
|
||||||
{
|
{
|
||||||
ws_key_esc = 1;
|
ws_key_esc = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getKeyState(GLFW_KEY_UP))
|
if (getKeyState(GLFW_KEY_UP))
|
||||||
{
|
{
|
||||||
ws_key_x1=1;
|
ws_key_x1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getKeyState(GLFW_KEY_DOWN))
|
if (getKeyState(GLFW_KEY_DOWN))
|
||||||
{
|
{
|
||||||
ws_key_x3=1;
|
ws_key_x3 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_RIGHT))
|
if (getKeyState(GLFW_KEY_RIGHT))
|
||||||
{
|
{
|
||||||
ws_key_x2=1;
|
ws_key_x2 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_LEFT))
|
if (getKeyState(GLFW_KEY_LEFT))
|
||||||
{
|
{
|
||||||
ws_key_x4=1;
|
ws_key_x4 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_ENTER))
|
if (getKeyState(GLFW_KEY_ENTER))
|
||||||
{
|
{
|
||||||
ws_key_start=1;
|
ws_key_start = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_C))
|
if (getKeyState(GLFW_KEY_C))
|
||||||
{
|
{
|
||||||
ws_key_button_a=1;
|
ws_key_button_a = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_X))
|
if (getKeyState(GLFW_KEY_X))
|
||||||
{
|
{
|
||||||
ws_key_button_b=1;
|
ws_key_button_b = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_W))
|
if (getKeyState(GLFW_KEY_W))
|
||||||
{
|
{
|
||||||
ws_key_y1=1;
|
ws_key_y1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_A))
|
if (getKeyState(GLFW_KEY_A))
|
||||||
{
|
{
|
||||||
ws_key_y4=1;
|
ws_key_y4 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_S))
|
if (getKeyState(GLFW_KEY_S))
|
||||||
{
|
{
|
||||||
ws_key_y3=1;
|
ws_key_y3 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_D))
|
if (getKeyState(GLFW_KEY_D))
|
||||||
{
|
{
|
||||||
ws_key_y2=1;
|
ws_key_y2 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_O))
|
if (getKeyState(GLFW_KEY_O))
|
||||||
{
|
{
|
||||||
ws_cyclesByLine+=10;
|
ws_cyclesByLine += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getKeyState(GLFW_KEY_L))
|
if (getKeyState(GLFW_KEY_L))
|
||||||
{
|
{
|
||||||
ws_cyclesByLine-=10;
|
ws_cyclesByLine -= 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +373,7 @@ void ws_emulate(void)
|
|||||||
initDisplay(&mainWindow);
|
initDisplay(&mainWindow);
|
||||||
clearScreen(&mainWindow);
|
clearScreen(&mainWindow);
|
||||||
updateScreen(&mainWindow);
|
updateScreen(&mainWindow);
|
||||||
int16_t *backBuffer = (int16_t *)mainWindow.videoMemory;
|
int16_t *backBuffer = (int16_t *)mainWindow.videoMemory;
|
||||||
|
|
||||||
|
|
||||||
dNormalLast = (double)getTicks();
|
dNormalLast = (double)getTicks();
|
||||||
|
|||||||
@ -1,32 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* emulate.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
#ifndef EMULATE_H
|
#ifndef EMULATE_H
|
||||||
#define EMULATE_H
|
#define EMULATE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define KEY_ENTER 0x0D
|
extern char app_window_title[256];
|
||||||
#define KEY_SPACE 0x20
|
extern int app_terminate;
|
||||||
#define KEY_ESC 0x1b
|
|
||||||
#define KEY_UP 0x26
|
|
||||||
#define KEY_DOWN 0x28
|
|
||||||
#define KEY_LEFT 0x25
|
|
||||||
#define KEY_RIGHT 0x27
|
|
||||||
#define KEY_BUTTON1 0x57
|
|
||||||
#define KEY_BUTTON2 0x58
|
|
||||||
|
|
||||||
#define GUI_COMMAND_NONE 0
|
|
||||||
#define GUI_COMMAND_RESET 1
|
|
||||||
#define GUI_COMMAND_SCHEME_CHANGE 2
|
|
||||||
#define GUI_COMMAND_FILTER_CHANGE 3
|
|
||||||
|
|
||||||
|
|
||||||
extern char app_window_title[256];
|
|
||||||
extern int app_gameRunning;
|
|
||||||
extern int app_terminate;
|
|
||||||
extern int app_fullscreen;
|
|
||||||
extern int app_rotated;
|
|
||||||
|
|
||||||
|
|
||||||
void ws_emulate(void);
|
void ws_emulate(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* EMULATE_H */
|
#endif /* EMULATE_H */
|
||||||
2979
source/gpu.c
2979
source/gpu.c
File diff suppressed because it is too large
Load Diff
39
source/gpu.h
39
source/gpu.h
@ -1,33 +1,24 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
* gpu.h:
|
||||||
//
|
* Based on the original Oswan-unix
|
||||||
//
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
//
|
*
|
||||||
//
|
*/
|
||||||
//
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __GPU_H__
|
#ifndef __GPU_H__
|
||||||
#define __GPU_H__
|
#define __GPU_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define COLOUR_SCHEME_DEFAULT 0
|
extern uint8_t ws_gpu_scanline;
|
||||||
#define COLOUR_SCHEME_AMBER 1
|
extern uint8_t ws_gpu_operatingInColor;
|
||||||
#define COLOUR_SCHEME_GREEN 2
|
extern uint8_t ws_videoMode;
|
||||||
|
extern int16_t ws_palette[16 * 4];
|
||||||
extern uint8_t ws_gpu_scanline;
|
extern int8_t ws_paletteColors[8];
|
||||||
extern uint8_t ws_gpu_operatingInColor;
|
extern int16_t wsc_palette[16 * 16];
|
||||||
extern uint8_t ws_videoMode;
|
extern unsigned int ws_gpu_unknownPort;
|
||||||
extern int16_t ws_palette[16*4];
|
|
||||||
extern int8_t ws_paletteColors[8];
|
|
||||||
extern int16_t wsc_palette[16*16];
|
|
||||||
extern unsigned int ws_gpu_unknownPort;
|
|
||||||
|
|
||||||
extern uint32_t vblank_count;
|
|
||||||
|
|
||||||
|
extern uint32_t vblank_count;
|
||||||
|
|
||||||
void ws_gpu_init(void);
|
void ws_gpu_init(void);
|
||||||
void ws_gpu_done(void);
|
void ws_gpu_done(void);
|
||||||
|
|||||||
191
source/ieeprom.h
191
source/ieeprom.h
@ -1,191 +0,0 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
uint8_t DefaultBWEEprom[]=
|
|
||||||
{
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,192,0xff,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,127,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,252,0xff,1,0xff,253,0xff,253,0xff,253,0xff,253,
|
|
||||||
0xff,253,0xff,253,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,0x00,3,3,0x00,0x00,0x00,64,128,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
135,5,140,9,5,12,139,12,144,0x00,0x00,2,
|
|
||||||
0x00,76,165,0x00,128,0x00,0x00,0x00,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,0x00,6,6,6,6,6,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
1,128,15,0x00,1,1,1,15,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
'W'-54,'O'-54,'N'-54,'D'-54,'E'-54,'R'-54,'S'-54,'W'-54,'A'-54,'N'-54,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,32,1,1,33,1,4,0x00,1,
|
|
||||||
0x00,152,60,127,74,1,53,1,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t DefaultColorEEprom[]=
|
|
||||||
{
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,192,0xff,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,127,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,252,0xff,1,0xff,253,0xff,253,0xff,253,0xff,253,
|
|
||||||
0xff,253,0xff,253,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,0x00,3,3,0x00,0x00,0x00,64,128,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
135,5,140,9,5,12,139,12,144,0x00,0x00,2,
|
|
||||||
0x00,76,165,0x00,128,0x00,0x00,0x00,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
|
|
||||||
0xff,127,0xff,127,0xff,127,0xff,127,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0x00,0x00,6,6,6,6,6,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
1,128,15,0x00,1,1,1,15,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
'W'-54,'O'-54,'N'-54,'D'-54,'E'-54,'R'-54,'S'-54,'W'-54,'A'-54,'N'-54,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,32,1,1,33,1,4,0x00,1,
|
|
||||||
0x00,152,60,127,74,1,53,1,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
|
||||||
0xff,0xff,0xff,0xff
|
|
||||||
};
|
|
||||||
663
source/io.c
663
source/io.c
@ -1,6 +1,11 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
// I/O ports
|
* NewOswan
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
* io.c: I/O ports implementaton
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -8,7 +13,6 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -40,26 +44,18 @@ extern uint64_t nec_monotonicCycles;
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
EEPROM_SUBCOMMAND = 0, /* 00 00 */
|
EEPROM_SUBCOMMAND = 0, /* 00 00 */
|
||||||
EEPROM_WRITE, /* 01 xx */
|
EEPROM_WRITE, /* 01 xx */
|
||||||
EEPROM_READ, /* 10 xx */
|
EEPROM_READ, /* 10 xx */
|
||||||
EEPROM_ERASE, /* 11 xx */
|
EEPROM_ERASE, /* 11 xx */
|
||||||
EEPROM_WRITEDISABLE, /* 00 00 */
|
EEPROM_WRITEDISABLE, /* 00 00 */
|
||||||
EEPROM_WRITEALL, /* 00 01 */
|
EEPROM_WRITEALL, /* 00 01 */
|
||||||
EEPROM_ERASEALL, /* 00 10 */
|
EEPROM_ERASEALL, /* 00 10 */
|
||||||
EEPROM_WRITEENABLE /* 00 11 */
|
EEPROM_WRITEENABLE /* 00 11 */
|
||||||
};
|
};
|
||||||
|
|
||||||
char *eii_CommandName[] =
|
char *eii_CommandName[] = {
|
||||||
{
|
"SUB", "WRI", "RED", "ERA", "WRD", "WRA", "ERL", "WRE",
|
||||||
"SUB",
|
|
||||||
"WRI",
|
|
||||||
"RED",
|
|
||||||
"ERA",
|
|
||||||
"WRD",
|
|
||||||
"WRA",
|
|
||||||
"ERL",
|
|
||||||
"WRE",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t iee_WriteEnable = false;
|
uint8_t iee_WriteEnable = false;
|
||||||
@ -73,7 +69,7 @@ uint16_t cee_Databuffer = 0;
|
|||||||
uint8_t cee_Mode = EEPROM_READ;
|
uint8_t cee_Mode = EEPROM_READ;
|
||||||
|
|
||||||
|
|
||||||
uint8_t *ws_ioRam=NULL;
|
uint8_t *ws_ioRam = NULL;
|
||||||
|
|
||||||
uint8_t ws_key_start;
|
uint8_t ws_key_start;
|
||||||
uint8_t ws_key_x4;
|
uint8_t ws_key_x4;
|
||||||
@ -88,7 +84,7 @@ uint8_t ws_key_button_a;
|
|||||||
uint8_t ws_key_button_b;
|
uint8_t ws_key_button_b;
|
||||||
uint8_t ws_key_flipped;
|
uint8_t ws_key_flipped;
|
||||||
|
|
||||||
int rtcDataRegisterReadCount=0;
|
int rtcDataRegisterReadCount = 0;
|
||||||
|
|
||||||
FILE *ioLogFp = NULL;
|
FILE *ioLogFp = NULL;
|
||||||
|
|
||||||
@ -105,18 +101,18 @@ FILE *ioLogFp = NULL;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_io_reset(void)
|
void ws_io_reset(void)
|
||||||
{
|
{
|
||||||
ws_key_start=0;
|
ws_key_start = 0;
|
||||||
ws_key_x4=0;
|
ws_key_x4 = 0;
|
||||||
ws_key_x2=0;
|
ws_key_x2 = 0;
|
||||||
ws_key_x1=0;
|
ws_key_x1 = 0;
|
||||||
ws_key_x3=0;
|
ws_key_x3 = 0;
|
||||||
ws_key_y4=0;
|
ws_key_y4 = 0;
|
||||||
ws_key_y2=0;
|
ws_key_y2 = 0;
|
||||||
ws_key_y1=0;
|
ws_key_y1 = 0;
|
||||||
ws_key_y3=0;
|
ws_key_y3 = 0;
|
||||||
ws_key_button_a=0;
|
ws_key_button_a = 0;
|
||||||
ws_key_button_b=0;
|
ws_key_button_b = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0 ; i < 0x100 ; i++)
|
for (i = 0 ; i < 0x100 ; i++)
|
||||||
{
|
{
|
||||||
@ -133,8 +129,9 @@ void ws_io_reset(void)
|
|||||||
ws_ioRam[0xC2] = 0xFF;
|
ws_ioRam[0xC2] = 0xFF;
|
||||||
ws_ioRam[0xC3] = 0xFF;
|
ws_ioRam[0xC3] = 0xFF;
|
||||||
|
|
||||||
rtcDataRegisterReadCount=0;
|
rtcDataRegisterReadCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -148,18 +145,19 @@ void ws_io_reset(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_io_init(void)
|
void ws_io_init(void)
|
||||||
{
|
{
|
||||||
if (ws_ioRam==NULL)
|
if (ws_ioRam == NULL)
|
||||||
{
|
{
|
||||||
ws_ioRam=(uint8_t*)malloc(0x100);
|
ws_ioRam = (uint8_t *)malloc(0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_io_reset();
|
ws_io_reset();
|
||||||
ws_key_flipped=0;
|
ws_key_flipped = 0;
|
||||||
|
|
||||||
#ifdef IO_DUMP
|
#ifdef IO_DUMP
|
||||||
ioLogFp = fopen("iodump.csv", "wt");
|
ioLogFp = fopen("iodump.csv", "wt");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -173,8 +171,9 @@ void ws_io_init(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_io_flipControls(void)
|
void ws_io_flipControls(void)
|
||||||
{
|
{
|
||||||
ws_key_flipped=!ws_key_flipped;
|
ws_key_flipped = !ws_key_flipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -188,13 +187,13 @@ void ws_io_flipControls(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_io_done(void)
|
void ws_io_done(void)
|
||||||
{
|
{
|
||||||
if (ws_ioRam==NULL)
|
if (ws_ioRam == NULL)
|
||||||
{
|
{
|
||||||
free(ws_ioRam);
|
free(ws_ioRam);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IO_DUMP
|
#ifdef IO_DUMP
|
||||||
fclose(ioLogFp);
|
fclose(ioLogFp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,134 +205,135 @@ int serialfd = -1;
|
|||||||
int serial_have_data = 0;
|
int serial_have_data = 0;
|
||||||
unsigned char serial_data = 0;
|
unsigned char serial_data = 0;
|
||||||
int serial_speed = BDR_9600;
|
int serial_speed = BDR_9600;
|
||||||
|
|
||||||
void open_serial()
|
void open_serial()
|
||||||
{
|
{
|
||||||
if (serialfd < 0)
|
if (serialfd < 0)
|
||||||
{
|
{
|
||||||
serialfd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
serialfd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||||
|
|
||||||
//set_baudrate(serial_speed);
|
//set_baudrate(serial_speed);
|
||||||
serial_have_data = 0;
|
serial_have_data = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_baudrate(int speed)
|
void set_baudrate(int speed)
|
||||||
{
|
{
|
||||||
struct termios options;
|
struct termios options;
|
||||||
|
|
||||||
if (serialfd < 0)
|
if (serialfd < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcgetattr(serialfd, &options);
|
tcgetattr(serialfd, &options);
|
||||||
|
|
||||||
options.c_cflag &= ~PARENB;
|
options.c_cflag &= ~PARENB;
|
||||||
options.c_cflag &= ~CSTOPB;
|
options.c_cflag &= ~CSTOPB;
|
||||||
options.c_cflag &= ~CSIZE;
|
options.c_cflag &= ~CSIZE;
|
||||||
options.c_cflag |= CS8;
|
options.c_cflag |= CS8;
|
||||||
|
|
||||||
if (speed == BDR_9600)
|
if (speed == BDR_9600)
|
||||||
{
|
{
|
||||||
cfsetispeed(&options, B9600);
|
cfsetispeed(&options, B9600);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfsetospeed(&options, B38400);
|
cfsetospeed(&options, B38400);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
options.c_cflag &= ~CNEW_RTSCTS;
|
options.c_cflag &= ~CNEW_RTSCTS;
|
||||||
#else
|
#else
|
||||||
options.c_cflag &= ~CRTSCTS;
|
options.c_cflag &= ~CRTSCTS;
|
||||||
#endif
|
#endif
|
||||||
options.c_cflag |= (CLOCAL | CREAD);
|
options.c_cflag |= (CLOCAL | CREAD);
|
||||||
|
|
||||||
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||||
|
|
||||||
options.c_oflag &= ~OPOST;
|
options.c_oflag &= ~OPOST;
|
||||||
|
|
||||||
tcsetattr(serialfd, TCSANOW, &options);
|
tcsetattr(serialfd, TCSANOW, &options);
|
||||||
|
|
||||||
/* Make sure read is not blocking */
|
/* Make sure read is not blocking */
|
||||||
fcntl(serialfd, F_SETFL, FNDELAY);
|
fcntl(serialfd, F_SETFL, FNDELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_serial()
|
void close_serial()
|
||||||
{
|
{
|
||||||
close(serialfd);
|
close(serialfd);
|
||||||
serialfd = -1;
|
serialfd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_serial_data()
|
void check_serial_data()
|
||||||
{
|
{
|
||||||
unsigned char buf[10];
|
unsigned char buf[10];
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
if (serialfd < 0)
|
if (serialfd < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serial_have_data == 0)
|
if (serial_have_data == 0)
|
||||||
{
|
{
|
||||||
f = read(serialfd, buf, 1);
|
f = read(serialfd, buf, 1);
|
||||||
|
|
||||||
if (f > 0)
|
if (f > 0)
|
||||||
{
|
{
|
||||||
printf("Ho [%d]!\n", f);
|
printf("Ho [%d]!\n", f);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
serial_have_data = 0x01;
|
serial_have_data = 0x01;
|
||||||
serial_data = buf[0];
|
serial_data = buf[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serial_have_data > 0)
|
if (serial_have_data > 0)
|
||||||
{
|
{
|
||||||
/* Gen an int if enabled */
|
/* Gen an int if enabled */
|
||||||
if(ws_ioRam[0xB2] & 0x04)
|
if (ws_ioRam[0xB2] & 0x04)
|
||||||
{
|
{
|
||||||
ws_ioRam[0xb6] &= ~ 0x04;
|
ws_ioRam[0xb6] &= ~0x04;
|
||||||
printf("SERIAL INNNNNTTTT!!!!!!!");
|
printf("SERIAL INNNNNTTTT!!!!!!!");
|
||||||
nec_int((ws_ioRam[0xb0]+3)*4);
|
nec_int((ws_ioRam[0xb0] + 3) * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char read_serial()
|
unsigned char read_serial()
|
||||||
{
|
{
|
||||||
unsigned char buf[10];
|
unsigned char buf[10];
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
if (serialfd < 0)
|
if (serialfd < 0)
|
||||||
{
|
{
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serial_have_data > 0)
|
if (serial_have_data > 0)
|
||||||
{
|
{
|
||||||
serial_have_data = 0;
|
serial_have_data = 0;
|
||||||
return serial_data;
|
return serial_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = read(serialfd, buf, 1);
|
f = read(serialfd, buf, 1);
|
||||||
|
|
||||||
if (f == 1)
|
if (f == 1)
|
||||||
{
|
{
|
||||||
return buf[0];
|
return buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0x42;
|
return 0x42;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_serial(unsigned char value)
|
void write_serial(unsigned char value)
|
||||||
{
|
{
|
||||||
if (serialfd < 0)
|
if (serialfd < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
write(serialfd, &value, 1);
|
write(serialfd, &value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -390,10 +390,12 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
case 0x91:
|
case 0x91:
|
||||||
case 0x92:
|
case 0x92:
|
||||||
case 0x93:
|
case 0x93:
|
||||||
case 0x94:retVal = ws_audio_port_read(port);
|
case 0x94:
|
||||||
|
retVal = ws_audio_port_read(port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xb5:w1 = ws_ioRam[0xb5];
|
case 0xb5:
|
||||||
|
w1 = ws_ioRam[0xb5];
|
||||||
|
|
||||||
if (w1 & 0x40)
|
if (w1 & 0x40)
|
||||||
{
|
{
|
||||||
@ -445,10 +447,12 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
{
|
{
|
||||||
case WS_SYSTEM_AUTODETECT:
|
case WS_SYSTEM_AUTODETECT:
|
||||||
case WS_SYSTEM_MONO:
|
case WS_SYSTEM_MONO:
|
||||||
case WS_SYSTEM_COLOR:retVal = 0x00;
|
case WS_SYSTEM_COLOR:
|
||||||
|
retVal = 0x00;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_SYSTEM_CRYSTAL:retVal = 0x80;
|
case WS_SYSTEM_CRYSTAL:
|
||||||
|
retVal = 0x80;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -509,31 +513,38 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
|
|
||||||
switch (rtcDataRegisterReadCount)
|
switch (rtcDataRegisterReadCount)
|
||||||
{
|
{
|
||||||
case 0:rtcDataRegisterReadCount++;
|
case 0:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_year - 100);
|
retVal = BCD(newtime->tm_year - 100);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 1:rtcDataRegisterReadCount++;
|
case 1:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_mon);
|
retVal = BCD(newtime->tm_mon);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 2:rtcDataRegisterReadCount++;
|
case 2:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_mday);
|
retVal = BCD(newtime->tm_mday);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 3:rtcDataRegisterReadCount++;
|
case 3:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_wday);
|
retVal = BCD(newtime->tm_wday);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 4:rtcDataRegisterReadCount++;
|
case 4:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_hour);
|
retVal = BCD(newtime->tm_hour);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 5:rtcDataRegisterReadCount++;
|
case 5:
|
||||||
|
rtcDataRegisterReadCount++;
|
||||||
retVal = BCD(newtime->tm_min);
|
retVal = BCD(newtime->tm_min);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 6:rtcDataRegisterReadCount = 0;
|
case 6:
|
||||||
|
rtcDataRegisterReadCount = 0;
|
||||||
retVal = BCD(newtime->tm_sec);
|
retVal = BCD(newtime->tm_sec);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -547,15 +558,18 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD0:retVal = 0;
|
case 0xD0:
|
||||||
|
retVal = 0;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* Serial port link.. */
|
/* Serial port link.. */
|
||||||
case 0xB1:retVal = read_serial();
|
case 0xB1:
|
||||||
|
retVal = read_serial();
|
||||||
printf("RS232: Read %02X\n", retVal);
|
printf("RS232: Read %02X\n", retVal);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 0xB3:check_serial_data();
|
case 0xB3:
|
||||||
|
check_serial_data();
|
||||||
|
|
||||||
if (ws_ioRam[0xB3] & 0x80)
|
if (ws_ioRam[0xB3] & 0x80)
|
||||||
{
|
{
|
||||||
@ -572,10 +586,12 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
case 0xCC:
|
case 0xCC:
|
||||||
case 0xCD:retVal = 0;
|
case 0xCD:
|
||||||
|
retVal = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:retVal = ws_ioRam[port];
|
default:
|
||||||
|
retVal = ws_ioRam[port];
|
||||||
if (port > 0xD0)
|
if (port > 0xD0)
|
||||||
{
|
{
|
||||||
printf("ReadIO %02X <= %02X\n", port, retVal);
|
printf("ReadIO %02X <= %02X\n", port, retVal);
|
||||||
@ -586,7 +602,8 @@ uint8_t cpu_readport(uint8_t port)
|
|||||||
case 0xAA:
|
case 0xAA:
|
||||||
case 0xAB:
|
case 0xAB:
|
||||||
case 0xAC:
|
case 0xAC:
|
||||||
case 0xAD:retVal = ws_gpu_port_read(port);
|
case 0xAD:
|
||||||
|
retVal = ws_gpu_port_read(port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -645,7 +662,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
switch (port)
|
switch (port)
|
||||||
{
|
{
|
||||||
/* GPU IOs */
|
/* GPU IOs */
|
||||||
case 0x00:break;
|
case 0x00:
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x04:
|
case 0x04:
|
||||||
case 0x07:
|
case 0x07:
|
||||||
@ -666,7 +684,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0x11:
|
case 0x11:
|
||||||
case 0x12:
|
case 0x12:
|
||||||
case 0x13:
|
case 0x13:
|
||||||
case 0x14:break;
|
case 0x14:
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x15:
|
case 0x15:
|
||||||
printf("Icons %c %c %c %c %c %c %c %c\n", (value >> 7) & 1 ? '?' : ' ', (value >> 6) & 1 ? '?' : ' ',
|
printf("Icons %c %c %c %c %c %c %c %c\n", (value >> 7) & 1 ? '?' : ' ', (value >> 6) & 1 ? '?' : ' ',
|
||||||
@ -708,7 +727,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0x36:
|
case 0x36:
|
||||||
case 0x24:
|
case 0x24:
|
||||||
case 0x2E:
|
case 0x2E:
|
||||||
case 0x37:break;
|
case 0x37:
|
||||||
|
break;
|
||||||
|
|
||||||
/* DMAs */
|
/* DMAs */
|
||||||
case 0x40:
|
case 0x40:
|
||||||
@ -718,7 +738,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0x44:
|
case 0x44:
|
||||||
case 0x45:
|
case 0x45:
|
||||||
case 0x46:
|
case 0x46:
|
||||||
case 0x47:break;
|
case 0x47:
|
||||||
|
break;
|
||||||
|
|
||||||
case 0x48: // DMA
|
case 0x48: // DMA
|
||||||
|
|
||||||
@ -753,14 +774,17 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0x4c:
|
case 0x4c:
|
||||||
case 0x4d:
|
case 0x4d:
|
||||||
case 0x4e:
|
case 0x4e:
|
||||||
case 0x4f:ws_audio_port_write(port, value);
|
case 0x4f:
|
||||||
|
ws_audio_port_write(port, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* DMA Start! */
|
/* DMA Start! */
|
||||||
case 0x52:break;
|
case 0x52:
|
||||||
|
break;
|
||||||
|
|
||||||
/* GPU (again) */
|
/* GPU (again) */
|
||||||
case 0x60:break;
|
case 0x60:
|
||||||
|
break;
|
||||||
/* System */
|
/* System */
|
||||||
case 0x62:
|
case 0x62:
|
||||||
printf("HeyHo!");
|
printf("HeyHo!");
|
||||||
@ -797,7 +821,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0x9B:
|
case 0x9B:
|
||||||
case 0x9C:
|
case 0x9C:
|
||||||
case 0x9D:
|
case 0x9D:
|
||||||
case 0x9E:ws_audio_port_write(port, value);
|
case 0x9E:
|
||||||
|
ws_audio_port_write(port, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Hardware */
|
/* Hardware */
|
||||||
@ -815,17 +840,20 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
case 0xA8:
|
case 0xA8:
|
||||||
case 0xA9:
|
case 0xA9:
|
||||||
case 0xAA:
|
case 0xAA:
|
||||||
case 0xAB:break;
|
case 0xAB:
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
/* Intc */
|
/* Intc */
|
||||||
case 0xB0:
|
case 0xB0:
|
||||||
case 0xB2:
|
case 0xB2:
|
||||||
case 0xB4:
|
case 0xB4:
|
||||||
case 0xB6:break;
|
case 0xB6:
|
||||||
|
break;
|
||||||
|
|
||||||
/* Serial */
|
/* Serial */
|
||||||
case 0xB1:write_serial(value);
|
case 0xB1:
|
||||||
|
write_serial(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xB3:
|
case 0xB3:
|
||||||
@ -850,7 +878,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* buttons */
|
/* buttons */
|
||||||
case 0xB5:break;
|
case 0xB5:
|
||||||
|
break;
|
||||||
|
|
||||||
/* Internal EEPROM */
|
/* Internal EEPROM */
|
||||||
case 0xba: /* DATA Low */
|
case 0xba: /* DATA Low */
|
||||||
@ -885,216 +914,216 @@ void cpu_writeport(uint32_t port, uint8_t value)
|
|||||||
command = (iee_SelAddress >> 10) & 0x3;
|
command = (iee_SelAddress >> 10) & 0x3;
|
||||||
address = iee_SelAddress & 0x3FF;
|
address = iee_SelAddress & 0x3FF;
|
||||||
subcmd = (iee_SelAddress >> 8) & 0x03;
|
subcmd = (iee_SelAddress >> 8) & 0x03;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* S CC aaAAAA */
|
/* S CC aaAAAA */
|
||||||
command = (iee_SelAddress >> 6) & 0x3;
|
command = (iee_SelAddress >> 6) & 0x3;
|
||||||
address = iee_SelAddress & 0x3F;
|
address = iee_SelAddress & 0x3F;
|
||||||
subcmd = (iee_SelAddress >> 4) & 0x03;
|
subcmd = (iee_SelAddress >> 4) & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (command == EEPROM_SUBCOMMAND)
|
|
||||||
{
|
if (command == EEPROM_SUBCOMMAND)
|
||||||
|
{
|
||||||
command = EEPROM_WRITEDISABLE + subcmd;
|
command = EEPROM_WRITEDISABLE + subcmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("IEEP: RA:%04X RD:%04X A:%03X C:%s", iee_SelAddress, iee_Databuffer, address, eii_CommandName[command]);
|
printf("IEEP: RA:%04X RD:%04X A:%03X C:%s", iee_SelAddress, iee_Databuffer, address, eii_CommandName[command]);
|
||||||
|
|
||||||
if (value & 0x40)
|
if (value & 0x40)
|
||||||
{
|
{
|
||||||
/* Sub command */
|
/* Sub command */
|
||||||
printf(" - Sub");
|
printf(" - Sub");
|
||||||
if (command == EEPROM_WRITEENABLE)
|
if (command == EEPROM_WRITEENABLE)
|
||||||
{
|
{
|
||||||
printf(" Write Enable\n");
|
printf(" Write Enable\n");
|
||||||
iee_WriteEnable = true;
|
iee_WriteEnable = true;
|
||||||
}
|
}
|
||||||
else if (command == EEPROM_WRITEDISABLE)
|
else if (command == EEPROM_WRITEDISABLE)
|
||||||
{
|
{
|
||||||
printf(" Write Disable\n");
|
printf(" Write Disable\n");
|
||||||
iee_WriteEnable = false;
|
iee_WriteEnable = false;
|
||||||
}
|
}
|
||||||
else if (command == EEPROM_ERASEALL)
|
else if (command == EEPROM_ERASEALL)
|
||||||
{
|
{
|
||||||
printf(" Erase All\n");
|
printf(" Erase All\n");
|
||||||
if (ws_gpu_operatingInColor)
|
if (ws_gpu_operatingInColor)
|
||||||
{
|
{
|
||||||
memset(internalEeprom, 0, COLOR_IEEPROM_SIZE);
|
memset(internalEeprom, 0, COLOR_IEEPROM_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(internalEeprom, 0, BW_IEEPROM_SIZE);
|
memset(internalEeprom, 0, BW_IEEPROM_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" Write All?\n");
|
printf(" Write All?\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value & 0x20)
|
else if (value & 0x20)
|
||||||
{
|
{
|
||||||
/* Write */
|
/* Write */
|
||||||
printf(" - Write?");
|
printf(" - Write?");
|
||||||
if (iee_WriteEnable)
|
if (iee_WriteEnable)
|
||||||
{
|
{
|
||||||
printf(" Yes : %04X\n", iee_Databuffer);
|
printf(" Yes : %04X\n", iee_Databuffer);
|
||||||
internalEeprom[address] = iee_Databuffer;
|
internalEeprom[address] = iee_Databuffer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" No\n");
|
printf(" No\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value & 0x10)
|
else if (value & 0x10)
|
||||||
{
|
{
|
||||||
/* Read */
|
/* Read */
|
||||||
printf(" - Read");
|
printf(" - Read");
|
||||||
iee_Databuffer = internalEeprom[address];
|
iee_Databuffer = internalEeprom[address];
|
||||||
printf(" Data : %04X\n", iee_Databuffer);
|
printf(" Data : %04X\n", iee_Databuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" Unknown value: %02X\n", value);
|
printf(" Unknown value: %02X\n", value);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/* MBC */
|
/* MBC */
|
||||||
case 0xC0:
|
case 0xC0:
|
||||||
case 0xC1:
|
case 0xC1:
|
||||||
case 0xC2:
|
case 0xC2:
|
||||||
case 0xC3:
|
case 0xC3:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Cart EEPROM */
|
/* Cart EEPROM */
|
||||||
case 0xC4: /* Data High */
|
case 0xC4: /* Data High */
|
||||||
cee_Databuffer = cee_Databuffer & 0xFF00;
|
cee_Databuffer = cee_Databuffer & 0xFF00;
|
||||||
cee_Databuffer = cee_Databuffer | (value);
|
cee_Databuffer = cee_Databuffer | (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xC5: /* Data High */
|
case 0xC5: /* Data High */
|
||||||
cee_Databuffer = cee_Databuffer & 0x00FF;
|
cee_Databuffer = cee_Databuffer & 0x00FF;
|
||||||
cee_Databuffer = cee_Databuffer | (value << 8);
|
cee_Databuffer = cee_Databuffer | (value << 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xC6: /* Address Low */
|
case 0xC6: /* Address Low */
|
||||||
case 0xC7: /* Address High */
|
case 0xC7: /* Address High */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xC8: /* Command / Status */
|
case 0xC8: /* Command / Status */
|
||||||
{
|
{
|
||||||
uint16_t address, command, subcmd; /*, start;*/
|
uint16_t address, command, subcmd; /*, start;*/
|
||||||
|
|
||||||
cee_SelAddress = (ws_ioRam[0xBD] << 8) | ws_ioRam[0xBC];
|
cee_SelAddress = (ws_ioRam[0xBD] << 8) | ws_ioRam[0xBC];
|
||||||
|
|
||||||
/* S CC aaAAAA */
|
/* S CC aaAAAA */
|
||||||
command = (cee_SelAddress >> 6) & 0x3;
|
command = (cee_SelAddress >> 6) & 0x3;
|
||||||
address = cee_SelAddress & 0x3F;
|
address = cee_SelAddress & 0x3F;
|
||||||
subcmd = (cee_SelAddress >> 4) & 0x03;
|
subcmd = (cee_SelAddress >> 4) & 0x03;
|
||||||
|
|
||||||
|
|
||||||
if (command == EEPROM_SUBCOMMAND)
|
if (command == EEPROM_SUBCOMMAND)
|
||||||
{
|
{
|
||||||
command = EEPROM_WRITEDISABLE + subcmd;
|
command = EEPROM_WRITEDISABLE + subcmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("CEEP: RA:%04X RD:%04X A:%03X C:%s", cee_SelAddress, cee_Databuffer, address, eii_CommandName[command]);
|
printf("CEEP: RA:%04X RD:%04X A:%03X C:%s", cee_SelAddress, cee_Databuffer, address, eii_CommandName[command]);
|
||||||
|
|
||||||
if (value & 0x40)
|
if (value & 0x40)
|
||||||
{
|
{
|
||||||
/* Sub command */
|
/* Sub command */
|
||||||
printf(" - Sub");
|
printf(" - Sub");
|
||||||
if (command == EEPROM_WRITEENABLE)
|
if (command == EEPROM_WRITEENABLE)
|
||||||
{
|
{
|
||||||
printf(" Write Enable\n");
|
printf(" Write Enable\n");
|
||||||
cee_WriteEnable = true;
|
cee_WriteEnable = true;
|
||||||
}
|
}
|
||||||
else if (command == EEPROM_WRITEDISABLE)
|
else if (command == EEPROM_WRITEDISABLE)
|
||||||
{
|
{
|
||||||
printf(" Write Disable\n");
|
printf(" Write Disable\n");
|
||||||
cee_WriteEnable = false;
|
cee_WriteEnable = false;
|
||||||
}
|
}
|
||||||
else if (command == EEPROM_ERASEALL)
|
else if (command == EEPROM_ERASEALL)
|
||||||
{
|
{
|
||||||
printf(" Erase All\n");
|
printf(" Erase All\n");
|
||||||
/* Nothing here at the moment */
|
/* Nothing here at the moment */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" Write All?\n");
|
printf(" Write All?\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value & 0x20)
|
else if (value & 0x20)
|
||||||
{
|
{
|
||||||
/* Write */
|
/* Write */
|
||||||
printf(" - Write?");
|
printf(" - Write?");
|
||||||
if (cee_WriteEnable)
|
if (cee_WriteEnable)
|
||||||
{
|
{
|
||||||
printf(" Yes : %04X\n", cee_Databuffer);
|
printf(" Yes : %04X\n", cee_Databuffer);
|
||||||
externalEeprom[address] = cee_Databuffer;
|
externalEeprom[address] = cee_Databuffer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" No\n");
|
printf(" No\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value & 0x10)
|
else if (value & 0x10)
|
||||||
{
|
{
|
||||||
/* Read */
|
/* Read */
|
||||||
printf(" - Read");
|
printf(" - Read");
|
||||||
cee_Databuffer = externalEeprom[address];
|
cee_Databuffer = externalEeprom[address];
|
||||||
printf(" Data : %04X\n", cee_Databuffer);
|
printf(" Data : %04X\n", cee_Databuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf(" Unknown value: %02X\n", value);
|
printf(" Unknown value: %02X\n", value);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xca:
|
case 0xca:
|
||||||
if(value==0x15)
|
if (value == 0x15)
|
||||||
{
|
{
|
||||||
rtcDataRegisterReadCount=0;
|
rtcDataRegisterReadCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xCB:
|
case 0xCB:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xF0:
|
case 0xF0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xF1:
|
case 0xF1:
|
||||||
printf("%d\n", (signed short)((value << 8) | ws_ioRam[0xF0]));
|
printf("%d\n", (signed short)((value << 8) | ws_ioRam[0xF0]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xF2:
|
case 0xF2:
|
||||||
printf("%c", value);
|
printf("%c", value);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xB7:
|
case 0xB7:
|
||||||
break; /* Somwthing to write there, but what? */
|
break; /* Somwthing to write there, but what? */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
unknown_io_port=1;
|
unknown_io_port = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ws_gpu_port_write(port,value) == 1) && (unknown_io_port == 1))
|
if ((ws_gpu_port_write(port, value) == 1) && (unknown_io_port == 1))
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"WriteIO(%02X, %02X) [%04X:%04Xh];\n",port, value, I.sregs[CS], I.ip);
|
fprintf(log_get(), "WriteIO(%02X, %02X) [%04X:%04Xh];\n", port, value, I.sregs[CS], I.ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port >= 0xC4)
|
if (port >= 0xC4)
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"WriteMBCIO(%02X, %02X);\n",port, value);
|
fprintf(log_get(), "WriteMBCIO(%02X, %02X);\n", port, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
source/io.h
11
source/io.h
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* io.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -14,7 +19,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern uint8_t *ws_ioRam;
|
extern uint8_t *ws_ioRam;
|
||||||
extern uint8_t ws_key_start;
|
extern uint8_t ws_key_start;
|
||||||
extern uint8_t ws_key_x4;
|
extern uint8_t ws_key_x4;
|
||||||
extern uint8_t ws_key_x2;
|
extern uint8_t ws_key_x2;
|
||||||
|
|||||||
31
source/log.c
31
source/log.c
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* log.c:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -13,7 +18,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
FILE *log_stream=NULL;
|
FILE *log_stream = NULL;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -27,16 +32,17 @@ FILE *log_stream=NULL;
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
int log_init(char *path)
|
int log_init(char *path)
|
||||||
{
|
{
|
||||||
//log_stream=fopen(path,"wrt");
|
//log_stream=fopen(path,"wrt");
|
||||||
log_stream = stdout;
|
log_stream = stdout;
|
||||||
|
|
||||||
if (log_stream==NULL)
|
if (log_stream == NULL)
|
||||||
{
|
{
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -49,8 +55,9 @@ int log_init(char *path)
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
FILE *log_get(void)
|
FILE *log_get(void)
|
||||||
{
|
{
|
||||||
return(log_stream);
|
return (log_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -63,5 +70,5 @@ FILE *log_get(void)
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
void log_done(void)
|
void log_done(void)
|
||||||
{
|
{
|
||||||
fclose(log_stream);
|
fclose(log_stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* log.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|||||||
167
source/memory.c
167
source/memory.c
@ -1,5 +1,10 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
// Memory
|
* NewOswan
|
||||||
|
* memory.c: Memory implementatoion
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Notes: need to optimize cpu_writemem20
|
// Notes: need to optimize cpu_writemem20
|
||||||
//
|
//
|
||||||
@ -16,6 +21,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -29,7 +35,6 @@
|
|||||||
#include "gpu.h"
|
#include "gpu.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -42,7 +47,7 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#define IO_ROM_BANK_BASE_SELECTOR 0xC0
|
#define IO_ROM_BANK_BASE_SELECTOR 0xC0
|
||||||
|
|
||||||
uint8_t *ws_rom;
|
uint8_t *ws_rom;
|
||||||
uint8_t *ws_staticRam;
|
uint8_t *ws_staticRam;
|
||||||
@ -60,15 +65,16 @@ uint16_t *internalEeprom;
|
|||||||
|
|
||||||
extern uint8_t *ws_ioRam;
|
extern uint8_t *ws_ioRam;
|
||||||
|
|
||||||
uint16_t ws_rom_checksum;
|
uint16_t ws_rom_checksum;
|
||||||
|
|
||||||
uint8_t ws_haveColorIRom;
|
uint8_t ws_haveCrystalIRom;
|
||||||
uint8_t ws_haveBWIRom;
|
uint8_t ws_haveColorIRom;
|
||||||
|
uint8_t ws_haveBWIRom;
|
||||||
|
|
||||||
uint32_t sramAddressMask;
|
uint32_t sramAddressMask;
|
||||||
uint32_t externalEepromAddressMask;
|
uint32_t externalEepromAddressMask;
|
||||||
uint32_t romAddressMask;
|
uint32_t romAddressMask;
|
||||||
uint32_t romSize;
|
uint32_t romSize;
|
||||||
|
|
||||||
int ws_sram_dirty = 0;
|
int ws_sram_dirty = 0;
|
||||||
|
|
||||||
@ -76,46 +82,46 @@ extern nec_Regs I;
|
|||||||
|
|
||||||
void dump_memory()
|
void dump_memory()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
printf("Dumping memory....\n");
|
printf("Dumping memory....\n");
|
||||||
fp = fopen("iram.bin", "wb");
|
fp = fopen("iram.bin", "wb");
|
||||||
fwrite(internalRam, 1, 0x10000, fp);
|
fwrite(internalRam, 1, 0x10000, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
fp = fopen("sram.bin", "wb");
|
fp = fopen("sram.bin", "wb");
|
||||||
fwrite(ws_staticRam, 1, 0x10000, fp);
|
fwrite(ws_staticRam, 1, 0x10000, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
fp = fopen("rom.bin", "wb");
|
fp = fopen("rom.bin", "wb");
|
||||||
fwrite(ws_rom, 1, romSize, fp);
|
fwrite(ws_rom, 1, romSize, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
fp = fopen("memorydump.bin", "wb");
|
fp = fopen("memorydump.bin", "wb");
|
||||||
fwrite(internalRam, 1, 0x10000, fp);
|
fwrite(internalRam, 1, 0x10000, fp);
|
||||||
/* page 1 */
|
/* page 1 */
|
||||||
fwrite(&(ws_staticRam[0 & sramAddressMask]), 1, 0x10000, fp);
|
fwrite(&(ws_staticRam[0 & sramAddressMask]), 1, 0x10000, fp);
|
||||||
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+2]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp);
|
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR + 2] & ((romSize >> 16) - 1)) << 16)]), 1, 0x10000, fp);
|
||||||
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+3]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp);
|
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR + 3] & ((romSize >> 16) - 1)) << 16)]), 1, 0x10000, fp);
|
||||||
|
|
||||||
for(i = 4; i < 0x10; i++)
|
for (i = 4 ; i < 0x10 ; i++)
|
||||||
{
|
{
|
||||||
int romBank=(256-(((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR]&0xf)<<4)|(i&0xf)));
|
int romBank = (256 - (((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR] & 0xf) << 4) | (i & 0xf)));
|
||||||
fwrite(&(ws_rom[(unsigned)(romSize-(romBank<<16))]), 1, 0x10000, fp);
|
fwrite(&(ws_rom[(unsigned)(romSize - (romBank << 16))]), 1, 0x10000, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
fp = fopen("registers.bin", "wb");
|
fp = fopen("registers.bin", "wb");
|
||||||
fwrite(ws_ioRam, 1, 256, fp);
|
fwrite(ws_ioRam, 1, 256, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
fp = fopen("cpuregs.bin", "wb");
|
fp = fopen("cpuregs.bin", "wb");
|
||||||
/* CS */
|
/* CS */
|
||||||
fwrite(&I.sregs[CS], 1, 2, fp);
|
fwrite(&I.sregs[CS], 1, 2, fp);
|
||||||
/* IP */
|
/* IP */
|
||||||
fwrite(&I.ip, 1, 2, fp);
|
fwrite(&I.ip, 1, 2, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -131,24 +137,25 @@ void dump_memory()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void cpu_writemem20(uint32_t addr, uint8_t value)
|
void cpu_writemem20(uint32_t addr, uint8_t value)
|
||||||
{
|
{
|
||||||
uint32_t offset=addr&0xffff;
|
uint32_t offset = addr & 0xffff;
|
||||||
uint32_t bank=addr>>16;
|
uint32_t bank = addr >> 16;
|
||||||
|
|
||||||
if (!bank)
|
if (!bank)
|
||||||
{
|
{
|
||||||
// 0 - RAM - 16 KB (WS) / 64 KB (WSC) internal RAM
|
// 0 - RAM - 16 KB (WS) / 64 KB (WSC) internal RAM
|
||||||
ws_gpu_write_byte(offset,value);
|
ws_gpu_write_byte(offset, value);
|
||||||
ws_audio_write_byte(offset,value);
|
ws_audio_write_byte(offset, value);
|
||||||
}
|
}
|
||||||
else if (bank==1)
|
else if (bank == 1)
|
||||||
{
|
{
|
||||||
// 1 - SRAM (cart)
|
// 1 - SRAM (cart)
|
||||||
ws_staticRam[offset&sramAddressMask]=value;
|
ws_staticRam[offset & sramAddressMask] = value;
|
||||||
ws_sram_dirty = 1;
|
ws_sram_dirty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// other banks are read-only
|
// other banks are read-only
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -206,7 +213,8 @@ uint8_t cpu_readmem20(uint32_t addr)
|
|||||||
temp &= (romSize - 1);
|
temp &= (romSize - 1);
|
||||||
return ws_rom[temp];
|
return ws_rom[temp];
|
||||||
|
|
||||||
case 0xF:hwReg = ws_ioRam[0xA0];
|
case 0xF:
|
||||||
|
hwReg = ws_ioRam[0xA0];
|
||||||
|
|
||||||
if (!(hwReg & 1))
|
if (!(hwReg & 1))
|
||||||
{
|
{
|
||||||
@ -237,7 +245,8 @@ uint8_t cpu_readmem20(uint32_t addr)
|
|||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
default:hwReg = ws_ioRam[0xC0];
|
default:
|
||||||
|
hwReg = ws_ioRam[0xC0];
|
||||||
temp = hwReg << 20;
|
temp = hwReg << 20;
|
||||||
temp += addr & 0xFFFFF;
|
temp += addr & 0xFFFFF;
|
||||||
temp &= (romSize - 1);
|
temp &= (romSize - 1);
|
||||||
@ -246,6 +255,7 @@ uint8_t cpu_readmem20(uint32_t addr)
|
|||||||
|
|
||||||
return (0x90);
|
return (0x90);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -267,9 +277,9 @@ char *load_file(char *filename)
|
|||||||
|
|
||||||
fstat(fd, &FileStat);
|
fstat(fd, &FileStat);
|
||||||
|
|
||||||
printf("Trying to load %s, size = %lu...\n",filename, (unsigned long)FileStat.st_size);
|
printf("Trying to load %s, size = %lu...\n", filename, (unsigned long)FileStat.st_size);
|
||||||
|
|
||||||
ret_ptr = (char *)mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
ret_ptr = (char *)mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -280,6 +290,7 @@ char *load_file(char *filename)
|
|||||||
|
|
||||||
return ret_ptr;
|
return ret_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -296,9 +307,9 @@ char *create_file(char *filename, uint32_t size)
|
|||||||
int fd;
|
int fd;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
char *ret_ptr;
|
char *ret_ptr;
|
||||||
char buf[] = { 0 };
|
char buf[] = {0};
|
||||||
|
|
||||||
printf("Trying to create %s, size = %u...\n",filename, size);
|
printf("Trying to create %s, size = %u...\n", filename, size);
|
||||||
fd = open(filename, O_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_TRUNC, 0644);
|
fd = open(filename, O_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_TRUNC, 0644);
|
||||||
fchmod(fd, 0644);
|
fchmod(fd, 0644);
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -306,16 +317,16 @@ char *create_file(char *filename, uint32_t size)
|
|||||||
|
|
||||||
fd = open(filename, O_RDWR);
|
fd = open(filename, O_RDWR);
|
||||||
|
|
||||||
for(i = 0; i < size; i++)
|
for (i = 0 ; i < size ; i++)
|
||||||
{
|
{
|
||||||
write(fd, buf, 1);
|
write(fd, buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
fd = open(filename, O_RDWR);
|
fd = open(filename, O_RDWR);
|
||||||
ret_ptr = (char *)mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
ret_ptr = (char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -326,6 +337,7 @@ char *create_file(char *filename, uint32_t size)
|
|||||||
|
|
||||||
return ret_ptr;
|
return ret_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -403,6 +415,7 @@ void ws_memory_init(uint8_t *rom, uint32_t wsRomSize)
|
|||||||
|
|
||||||
romAddressMask = romSize - 1;
|
romAddressMask = romSize - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -416,8 +429,9 @@ void ws_memory_init(uint8_t *rom, uint32_t wsRomSize)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_memory_reset(void)
|
void ws_memory_reset(void)
|
||||||
{
|
{
|
||||||
memset(internalRam,0,0x10000);
|
memset(internalRam, 0, 0x10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -431,8 +445,9 @@ void ws_memory_reset(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_memory_done(void)
|
void ws_memory_done(void)
|
||||||
{
|
{
|
||||||
free(internalRam);
|
free(internalRam);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -446,8 +461,9 @@ void ws_memory_done(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint8_t *memory_getRom(void)
|
uint8_t *memory_getRom(void)
|
||||||
{
|
{
|
||||||
return(ws_rom);
|
return (ws_rom);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -459,10 +475,11 @@ uint8_t *memory_getRom(void)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint32_t memory_getRomSize(void)
|
uint32_t memory_getRomSize(void)
|
||||||
{
|
{
|
||||||
return(romSize);
|
return (romSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -474,7 +491,7 @@ uint32_t memory_getRomSize(void)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint16_t memory_getRomCrc(void)
|
uint16_t memory_getRomCrc(void)
|
||||||
{
|
{
|
||||||
return(ws_rom_checksum);
|
return (ws_rom_checksum);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* memory.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -14,16 +19,16 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
extern uint8_t *ws_staticRam;
|
extern uint8_t *ws_staticRam;
|
||||||
extern uint8_t *internalRam;
|
extern uint8_t *internalRam;
|
||||||
extern uint8_t *externalEeprom;
|
extern uint8_t *externalEeprom;
|
||||||
|
|
||||||
void ws_memory_init(uint8_t *rom, uint32_t romSize);
|
void ws_memory_init(uint8_t *rom, uint32_t romSize);
|
||||||
void ws_memory_reset(void);
|
void ws_memory_reset(void);
|
||||||
uint8_t *memory_getRom(void);
|
uint8_t *memory_getRom(void);
|
||||||
uint32_t memory_getRomSize(void);
|
uint32_t memory_getRomSize(void);
|
||||||
uint16_t memory_getRomCrc(void);
|
uint16_t memory_getRomCrc(void);
|
||||||
void ws_memory_done(void);
|
void ws_memory_done(void);
|
||||||
void memory_load(int fp);
|
void memory_load(int fp);
|
||||||
void memory_save(int fp);
|
void memory_save(int fp);
|
||||||
|
|
||||||
|
|||||||
7204
source/nec/nec.c
7204
source/nec/nec.c
File diff suppressed because it is too large
Load Diff
517
source/nec/nec.h
517
source/nec/nec.h
@ -1,37 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* nec.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
#ifndef __NEC_H_
|
#ifndef __NEC_H_
|
||||||
#define __NEC_H_
|
#define __NEC_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "necintrf.h"
|
#include "necintrf.h"
|
||||||
|
|
||||||
typedef enum { ES, CS, SS, DS } SREGS;
|
typedef enum
|
||||||
typedef enum { AW, CW, DW, BW, SP, BP, IX, IY } WREGS;
|
{
|
||||||
typedef enum { AL,AH,CL,CH,DL,DH,BL,BH,SPL,SPH,BPL,BPH,IXL,IXH,IYL,IYH } BREGS;
|
ES, CS, SS, DS
|
||||||
|
} SREGS;
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AW, CW, DW, BW, SP, BP, IX, IY
|
||||||
|
} WREGS;
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AL, AH, CL, CH, DL, DH, BL, BH, SPL, SPH, BPL, BPH, IXL, IXH, IYL, IYH
|
||||||
|
} BREGS;
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
/* eight general registers */
|
/* eight general registers */
|
||||||
uint16_t w[8]; /* viewed as 16 bits registers */
|
uint16_t w[8]; /* viewed as 16 bits registers */
|
||||||
uint8_t b[16]; /* or as 8 bit registers */
|
uint8_t b[16]; /* or as 8 bit registers */
|
||||||
} necbasicregs;
|
} necbasicregs;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
necbasicregs regs;
|
necbasicregs regs;
|
||||||
uint16_t sregs[4];
|
uint16_t sregs[4];
|
||||||
|
|
||||||
uint16_t ip;
|
uint16_t ip;
|
||||||
|
|
||||||
int32_t SignVal;
|
int32_t SignVal;
|
||||||
int32_t AuxVal, OverVal, ZeroVal, CarryVal, ParityVal; /* 0 or non-0 valued flags */
|
int32_t AuxVal, OverVal, ZeroVal, CarryVal, ParityVal; /* 0 or non-0 valued flags */
|
||||||
|
|
||||||
uint32_t TF, IF, DF, MF; /* 0 or 1 valued flags */ /* OB[19.07.99] added Mode Flag V30 */
|
uint32_t TF, IF, DF, MF; /* 0 or 1 valued flags */ /* OB[19.07.99] added Mode Flag V30 */
|
||||||
|
|
||||||
uint32_t int_vector;
|
uint32_t int_vector;
|
||||||
uint32_t pending_irq;
|
uint32_t pending_irq;
|
||||||
uint32_t nmi_state;
|
uint32_t nmi_state;
|
||||||
uint32_t irq_state;
|
uint32_t irq_state;
|
||||||
int (*irq_callback)(int irqline);
|
int (*irq_callback)(int irqline);
|
||||||
} nec_Regs;
|
} nec_Regs;
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
@ -49,30 +66,28 @@ typedef struct
|
|||||||
|
|
||||||
/* parameter x = result, y = source 1, z = source 2 */
|
/* parameter x = result, y = source 1, z = source 2 */
|
||||||
|
|
||||||
#define SetTF(x) (I.TF = (x))
|
#define SetTF(x) (I.TF = (x))
|
||||||
#define SetIF(x) (I.IF = (x))
|
#define SetIF(x) (I.IF = (x))
|
||||||
#define SetDF(x) (I.DF = (x))
|
#define SetDF(x) (I.DF = (x))
|
||||||
#define SetMD(x) (I.MF = (x)) /* OB [19.07.99] Mode Flag V30 */
|
#define SetMD(x) (I.MF = (x)) /* OB [19.07.99] Mode Flag V30 */
|
||||||
|
|
||||||
#define SetCFB(x) (I.CarryVal = (x) & 0x100)
|
#define SetCFB(x) (I.CarryVal = (x) & 0x100)
|
||||||
#define SetCFW(x) (I.CarryVal = (x) & 0x10000)
|
#define SetCFW(x) (I.CarryVal = (x) & 0x10000)
|
||||||
|
|
||||||
#define SetAF(x,y,z) (I.AuxVal = ((x) ^ ((y) ^ (z))) & 0x10)
|
#define SetAF(x, y, z) (I.AuxVal = ((x) ^ ((y) ^ (z))) & 0x10)
|
||||||
|
|
||||||
|
|
||||||
|
#define SetSF(x) (I.SignVal = (x))
|
||||||
|
#define SetZF(x) (I.ZeroVal = (x))
|
||||||
#define SetSF(x) (I.SignVal = (x))
|
#define SetPF(x) (I.ParityVal = (x))
|
||||||
#define SetZF(x) (I.ZeroVal = (x))
|
|
||||||
#define SetPF(x) (I.ParityVal = (x))
|
|
||||||
|
|
||||||
#define SetSZPF_Byte(x) (I.SignVal=I.ZeroVal=I.ParityVal=(int8_t)(x))
|
#define SetSZPF_Byte(x) (I.SignVal=I.ZeroVal=I.ParityVal=(int8_t)(x))
|
||||||
#define SetSZPF_Word(x) (I.SignVal=I.ZeroVal=I.ParityVal=(int16_t)(x))
|
#define SetSZPF_Word(x) (I.SignVal=I.ZeroVal=I.ParityVal=(int16_t)(x))
|
||||||
|
|
||||||
#define SetOFW_Add(x,y,z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x8000)
|
#define SetOFW_Add(x, y, z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x8000)
|
||||||
#define SetOFB_Add(x,y,z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x80)
|
#define SetOFB_Add(x, y, z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x80)
|
||||||
#define SetOFW_Sub(x,y,z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x8000)
|
#define SetOFW_Sub(x, y, z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x8000)
|
||||||
#define SetOFB_Sub(x,y,z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x80)
|
#define SetOFB_Sub(x, y, z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x80)
|
||||||
|
|
||||||
#define ADDB { uint32_t res=dst+src; SetCFB(res); SetOFB_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Byte(res); dst=(uint8_t)res; }
|
#define ADDB { uint32_t res=dst+src; SetCFB(res); SetOFB_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Byte(res); dst=(uint8_t)res; }
|
||||||
#define ADDW { uint32_t res=dst+src; SetCFW(res); SetOFW_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Word(res); dst=(uint16_t)res; }
|
#define ADDW { uint32_t res=dst+src; SetCFW(res); SetOFW_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Word(res); dst=(uint16_t)res; }
|
||||||
@ -89,13 +104,13 @@ typedef struct
|
|||||||
#define XORB dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Byte(dst)
|
#define XORB dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Byte(dst)
|
||||||
#define XORW dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Word(dst)
|
#define XORW dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Word(dst)
|
||||||
|
|
||||||
#define CF (I.CarryVal!=0)
|
#define CF (I.CarryVal!=0)
|
||||||
#define SF (I.SignVal<0)
|
#define SF (I.SignVal<0)
|
||||||
#define ZF (I.ZeroVal==0)
|
#define ZF (I.ZeroVal==0)
|
||||||
#define PF parity_table[(uint8_t)I.ParityVal]
|
#define PF parity_table[(uint8_t)I.ParityVal]
|
||||||
#define AF (I.AuxVal!=0)
|
#define AF (I.AuxVal!=0)
|
||||||
#define OF (I.OverVal!=0)
|
#define OF (I.OverVal!=0)
|
||||||
#define MD (I.MF!=0)
|
#define MD (I.MF!=0)
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
@ -103,20 +118,20 @@ typedef struct
|
|||||||
|
|
||||||
#define DefaultBase(Seg) ((seg_prefix && (Seg==DS || Seg==SS)) ? prefix_base : I.sregs[Seg] << 4)
|
#define DefaultBase(Seg) ((seg_prefix && (Seg==DS || Seg==SS)) ? prefix_base : I.sregs[Seg] << 4)
|
||||||
|
|
||||||
#define GetMemB(Seg,Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (uint8_t)cpu_readmem20((DefaultBase(Seg)+(Off))))
|
#define GetMemB(Seg, Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (uint8_t)cpu_readmem20((DefaultBase(Seg)+(Off))))
|
||||||
#define GetMemW(Seg,Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (uint16_t) cpu_readmem20((DefaultBase(Seg)+(Off))) + (cpu_readmem20((DefaultBase(Seg)+((Off)+1)))<<8) )
|
#define GetMemW(Seg, Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (uint16_t) cpu_readmem20((DefaultBase(Seg)+(Off))) + (cpu_readmem20((DefaultBase(Seg)+((Off)+1)))<<8) )
|
||||||
|
|
||||||
#define PutMemB(Seg,Off,x) { /*nec_ICount-=((Off)&1)?1:0*/; cpu_writemem20((DefaultBase(Seg)+(Off)),(x)); }
|
#define PutMemB(Seg, Off, x) { /*nec_ICount-=((Off)&1)?1:0*/; cpu_writemem20((DefaultBase(Seg)+(Off)),(x)); }
|
||||||
#define PutMemW(Seg,Off,x) { /*nec_ICount-=((Off)&1)?1:0*/; PutMemB(Seg,Off,(x)&0xff); PutMemB(Seg,(Off)+1,(uint8_t)((x)>>8)); }
|
#define PutMemW(Seg, Off, x) { /*nec_ICount-=((Off)&1)?1:0*/; PutMemB(Seg,Off,(x)&0xff); PutMemB(Seg,(Off)+1,(uint8_t)((x)>>8)); }
|
||||||
|
|
||||||
/* Todo: Remove these later - plus readword could overflow */
|
/* Todo: Remove these later - plus readword could overflow */
|
||||||
#define ReadByte(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ (uint8_t)cpu_readmem20((ea)))
|
#define ReadByte(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ (uint8_t)cpu_readmem20((ea)))
|
||||||
#define ReadWord(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ cpu_readmem20((ea))+(cpu_readmem20(((ea)+1))<<8))
|
#define ReadWord(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ cpu_readmem20((ea))+(cpu_readmem20(((ea)+1))<<8))
|
||||||
#define WriteByte(ea,val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),val); }
|
#define WriteByte(ea, val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),val); }
|
||||||
#define WriteWord(ea,val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),(uint8_t)(val)); cpu_writemem20(((ea)+1),(val)>>8); }
|
#define WriteWord(ea, val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),(uint8_t)(val)); cpu_writemem20(((ea)+1),(val)>>8); }
|
||||||
|
|
||||||
#define read_port(port) cpu_readport(port)
|
#define read_port(port) cpu_readport(port)
|
||||||
#define write_port(port,val) cpu_writeport(port,val)
|
#define write_port(port, val) cpu_writeport(port,val)
|
||||||
|
|
||||||
#define FETCH (cpu_readop_arg((I.sregs[CS]<<4)+I.ip++))
|
#define FETCH (cpu_readop_arg((I.sregs[CS]<<4)+I.ip++))
|
||||||
#define FETCHOP (cpu_readop((I.sregs[CS]<<4)+I.ip++))
|
#define FETCHOP (cpu_readop((I.sregs[CS]<<4)+I.ip++))
|
||||||
@ -145,121 +160,119 @@ typedef struct
|
|||||||
#define CLKM(v20,v30,v33,v20m,v30m,v33m) { const uint32_t ccount=(v20<<16)|(v30<<8)|v33, mcount=(v20m<<16)|(v30m<<8)|v33m; nec_ICount-=( ModRM >=0xc0 )?((ccount>>cpu_type)&0x7f):((mcount>>cpu_type)&0x7f); }
|
#define CLKM(v20,v30,v33,v20m,v30m,v33m) { const uint32_t ccount=(v20<<16)|(v30<<8)|v33, mcount=(v20m<<16)|(v30m<<8)|v33m; nec_ICount-=( ModRM >=0xc0 )?((ccount>>cpu_type)&0x7f):((mcount>>cpu_type)&0x7f); }
|
||||||
#define CLKR(v20o,v30o,v33o,v20e,v30e,v33e,vall) { const uint32_t ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?((ocount>>cpu_type)&0x7f):((ecount>>cpu_type)&0x7f); }
|
#define CLKR(v20o,v30o,v33o,v20e,v30e,v33e,vall) { const uint32_t ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?((ocount>>cpu_type)&0x7f):((ecount>>cpu_type)&0x7f); }
|
||||||
*/
|
*/
|
||||||
#define CLKS(v20,v30,v33) { const uint32_t ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>cpu_type)&0x7f; }
|
#define CLKS(v20, v30, v33) { const uint32_t ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>cpu_type)&0x7f; }
|
||||||
|
|
||||||
#define CLK(all) nec_ICount-=all
|
#define CLK(all) nec_ICount-=all
|
||||||
#define CLKW(v30MZo,v30MZe) { nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
|
#define CLKW(v30MZo, v30MZe) { nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
|
||||||
#define CLKM(v30MZm,v30MZ) { nec_ICount-=( ModRM >=0xc0 )?v30MZ:v30MZm; }
|
#define CLKM(v30MZm, v30MZ) { nec_ICount-=( ModRM >=0xc0 )?v30MZ:v30MZm; }
|
||||||
#define CLKR(v30MZo,v30MZe,vall) { if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
|
#define CLKR(v30MZo, v30MZe, vall) { if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
|
||||||
|
|
||||||
#define CompressFlags() (uint16_t)(CF | (PF << 2) | (AF << 4) | (ZF << 6) \
|
#define CompressFlags() (uint16_t)(CF | (PF << 2) | (AF << 4) | (ZF << 6) \
|
||||||
| (SF << 7) | (I.TF << 8) | (I.IF << 9) \
|
| (SF << 7) | (I.TF << 8) | (I.IF << 9) \
|
||||||
| (I.DF << 10) | (OF << 11))
|
| (I.DF << 10) | (OF << 11))
|
||||||
|
|
||||||
|
|
||||||
#define ExpandFlags(f) \
|
#define ExpandFlags(f) \
|
||||||
{ \
|
{ \
|
||||||
I.CarryVal = (f) & 1; \
|
I.CarryVal = (f) & 1; \
|
||||||
I.ParityVal = !((f) & 4); \
|
I.ParityVal = !((f) & 4); \
|
||||||
I.AuxVal = (f) & 16; \
|
I.AuxVal = (f) & 16; \
|
||||||
I.ZeroVal = !((f) & 64); \
|
I.ZeroVal = !((f) & 64); \
|
||||||
I.SignVal = (f) & 128 ? -1 : 0; \
|
I.SignVal = (f) & 128 ? -1 : 0; \
|
||||||
I.TF = ((f) & 256) == 256; \
|
I.TF = ((f) & 256) == 256; \
|
||||||
I.IF = ((f) & 512) == 512; \
|
I.IF = ((f) & 512) == 512; \
|
||||||
I.DF = ((f) & 1024) == 1024; \
|
I.DF = ((f) & 1024) == 1024; \
|
||||||
I.OverVal = (f) & 2048; \
|
I.OverVal = (f) & 2048; \
|
||||||
I.MF = ((f) & 0x8000) == 0x8000; \
|
I.MF = ((f) & 0x8000) == 0x8000; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define IncWordReg(Reg) \
|
||||||
#define IncWordReg(Reg) \
|
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
|
||||||
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
|
uint16_t tmp1 = tmp+1; \
|
||||||
uint16_t tmp1 = tmp+1; \
|
I.OverVal = (tmp == 0x7fff); \
|
||||||
I.OverVal = (tmp == 0x7fff); \
|
SetAF(tmp1,tmp,1); \
|
||||||
SetAF(tmp1,tmp,1); \
|
SetSZPF_Word(tmp1); \
|
||||||
SetSZPF_Word(tmp1); \
|
I.regs.w[Reg]=tmp1
|
||||||
I.regs.w[Reg]=tmp1
|
|
||||||
|
|
||||||
|
|
||||||
|
#define DecWordReg(Reg) \
|
||||||
|
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
|
||||||
|
uint16_t tmp1 = tmp-1; \
|
||||||
|
I.OverVal = (tmp == 0x8000); \
|
||||||
|
SetAF(tmp1,tmp,1); \
|
||||||
|
SetSZPF_Word(tmp1); \
|
||||||
|
I.regs.w[Reg]=tmp1
|
||||||
|
|
||||||
#define DecWordReg(Reg) \
|
#define JMP(flag) \
|
||||||
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
|
int tmp = (int)((int8_t)FETCH); \
|
||||||
uint16_t tmp1 = tmp-1; \
|
if (flag) \
|
||||||
I.OverVal = (tmp == 0x8000); \
|
{ \
|
||||||
SetAF(tmp1,tmp,1); \
|
I.ip = (uint16_t)(I.ip+tmp); \
|
||||||
SetSZPF_Word(tmp1); \
|
nec_ICount-=3; \
|
||||||
I.regs.w[Reg]=tmp1
|
return; \
|
||||||
|
|
||||||
#define JMP(flag) \
|
|
||||||
int tmp = (int)((int8_t)FETCH); \
|
|
||||||
if (flag) \
|
|
||||||
{ \
|
|
||||||
I.ip = (uint16_t)(I.ip+tmp); \
|
|
||||||
nec_ICount-=3; \
|
|
||||||
return; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ADJ4(param1,param2) \
|
|
||||||
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
|
|
||||||
{ \
|
|
||||||
int tmp; \
|
|
||||||
I.regs.b[AL] = tmp = I.regs.b[AL] + param1; \
|
|
||||||
I.AuxVal = 1; \
|
|
||||||
} \
|
|
||||||
if (CF || (I.regs.b[AL] > 0x9f)) \
|
|
||||||
{ \
|
|
||||||
I.regs.b[AL] += param2; \
|
|
||||||
I.CarryVal = 1; \
|
|
||||||
} \
|
|
||||||
SetSZPF_Byte(I.regs.b[AL])
|
|
||||||
|
|
||||||
#define ADJB(param1,param2) \
|
|
||||||
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
|
|
||||||
{ \
|
|
||||||
I.regs.b[AL] += param1; \
|
|
||||||
I.regs.b[AH] += param2; \
|
|
||||||
I.AuxVal = 1; \
|
|
||||||
I.CarryVal = 1; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
I.AuxVal = 0; \
|
|
||||||
I.CarryVal = 0; \
|
|
||||||
} \
|
|
||||||
I.regs.b[AL] &= 0x0F
|
|
||||||
|
|
||||||
#define BITOP_BYTE \
|
|
||||||
ModRM = FETCH; \
|
|
||||||
if (ModRM >= 0xc0) { \
|
|
||||||
tmp=I.regs.b[Mod_RM.RM.b[ModRM]]; \
|
|
||||||
} \
|
|
||||||
else { \
|
|
||||||
(*GetEA[ModRM])(); \
|
|
||||||
tmp=ReadByte(EA); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BITOP_WORD \
|
#define ADJ4(param1, param2) \
|
||||||
ModRM = FETCH; \
|
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
|
||||||
if (ModRM >= 0xc0) { \
|
{ \
|
||||||
tmp=I.regs.w[Mod_RM.RM.w[ModRM]]; \
|
int tmp; \
|
||||||
} \
|
I.regs.b[AL] = tmp = I.regs.b[AL] + param1; \
|
||||||
else { \
|
I.AuxVal = 1; \
|
||||||
(*GetEA[ModRM])(); \
|
} \
|
||||||
tmp=ReadWord(EA); \
|
if (CF || (I.regs.b[AL] > 0x9f)) \
|
||||||
|
{ \
|
||||||
|
I.regs.b[AL] += param2; \
|
||||||
|
I.CarryVal = 1; \
|
||||||
|
} \
|
||||||
|
SetSZPF_Byte(I.regs.b[AL])
|
||||||
|
|
||||||
|
#define ADJB(param1, param2) \
|
||||||
|
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
|
||||||
|
{ \
|
||||||
|
I.regs.b[AL] += param1; \
|
||||||
|
I.regs.b[AH] += param2; \
|
||||||
|
I.AuxVal = 1; \
|
||||||
|
I.CarryVal = 1; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
I.AuxVal = 0; \
|
||||||
|
I.CarryVal = 0; \
|
||||||
|
} \
|
||||||
|
I.regs.b[AL] &= 0x0F
|
||||||
|
|
||||||
|
#define BITOP_BYTE \
|
||||||
|
ModRM = FETCH; \
|
||||||
|
if (ModRM >= 0xc0) { \
|
||||||
|
tmp=I.regs.b[Mod_RM.RM.b[ModRM]]; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
(*GetEA[ModRM])(); \
|
||||||
|
tmp=ReadByte(EA); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BIT_NOT \
|
#define BITOP_WORD \
|
||||||
if (tmp & (1<<tmp2)) \
|
ModRM = FETCH; \
|
||||||
tmp &= ~(1<<tmp2); \
|
if (ModRM >= 0xc0) { \
|
||||||
else \
|
tmp=I.regs.w[Mod_RM.RM.w[ModRM]]; \
|
||||||
tmp |= (1<<tmp2)
|
} \
|
||||||
|
else { \
|
||||||
|
(*GetEA[ModRM])(); \
|
||||||
|
tmp=ReadWord(EA); \
|
||||||
|
}
|
||||||
|
|
||||||
#define XchgAWReg(Reg) \
|
#define BIT_NOT \
|
||||||
uint16_t tmp; \
|
if (tmp & (1<<tmp2)) \
|
||||||
tmp = I.regs.w[Reg]; \
|
tmp &= ~(1<<tmp2); \
|
||||||
I.regs.w[Reg] = I.regs.w[AW]; \
|
else \
|
||||||
I.regs.w[AW] = tmp
|
tmp |= (1<<tmp2)
|
||||||
|
|
||||||
|
#define XchgAWReg(Reg) \
|
||||||
|
uint16_t tmp; \
|
||||||
|
tmp = I.regs.w[Reg]; \
|
||||||
|
I.regs.w[Reg] = I.regs.w[AW]; \
|
||||||
|
I.regs.w[AW] = tmp
|
||||||
|
|
||||||
#define ROL_BYTE I.CarryVal = dst & 0x80; dst = (dst << 1)+CF
|
#define ROL_BYTE I.CarryVal = dst & 0x80; dst = (dst << 1)+CF
|
||||||
#define ROL_WORD I.CarryVal = dst & 0x8000; dst = (dst << 1)+CF
|
#define ROL_WORD I.CarryVal = dst & 0x8000; dst = (dst << 1)+CF
|
||||||
@ -269,126 +282,126 @@ typedef struct
|
|||||||
#define ROLC_WORD dst = (dst << 1) + CF; SetCFW(dst)
|
#define ROLC_WORD dst = (dst << 1) + CF; SetCFW(dst)
|
||||||
#define RORC_BYTE dst = (CF<<8)+dst; I.CarryVal = dst & 0x01; dst >>= 1
|
#define RORC_BYTE dst = (CF<<8)+dst; I.CarryVal = dst & 0x01; dst >>= 1
|
||||||
#define RORC_WORD dst = (CF<<16)+dst; I.CarryVal = dst & 0x01; dst >>= 1
|
#define RORC_WORD dst = (CF<<16)+dst; I.CarryVal = dst & 0x01; dst >>= 1
|
||||||
#define SHL_BYTE(c) dst <<= c; SetCFB(dst); SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
#define SHL_BYTE(c) dst <<= c; SetCFB(dst); SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
||||||
#define SHL_WORD(c) dst <<= c; SetCFW(dst); SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
#define SHL_WORD(c) dst <<= c; SetCFW(dst); SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
||||||
#define SHR_BYTE(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
#define SHR_BYTE(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
||||||
#define SHR_WORD(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
#define SHR_WORD(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
||||||
#define SHRA_BYTE(c) dst = ((int8_t)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((int8_t)((uint8_t)dst)) >> 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
#define SHRA_BYTE(c) dst = ((int8_t)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((int8_t)((uint8_t)dst)) >> 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(uint8_t)dst)
|
||||||
#define SHRA_WORD(c) dst = ((int16_t)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((int16_t)((uint16_t)dst)) >> 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
#define SHRA_WORD(c) dst = ((int16_t)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((int16_t)((uint16_t)dst)) >> 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(uint16_t)dst)
|
||||||
|
|
||||||
#define DIVUB \
|
#define DIVUB \
|
||||||
uresult = I.regs.w[AW]; \
|
uresult = I.regs.w[AW]; \
|
||||||
uresult2 = uresult % tmp; \
|
uresult2 = uresult % tmp; \
|
||||||
if ((uresult /= tmp) > 0xff) { \
|
if ((uresult /= tmp) > 0xff) { \
|
||||||
nec_interrupt(0,0); break; \
|
nec_interrupt(0,0); break; \
|
||||||
} else { \
|
} else { \
|
||||||
I.regs.b[AL] = uresult; \
|
I.regs.b[AL] = uresult; \
|
||||||
I.regs.b[AH] = uresult2; \
|
I.regs.b[AH] = uresult2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DIVB \
|
#define DIVB \
|
||||||
result = (int16_t)I.regs.w[AW]; \
|
result = (int16_t)I.regs.w[AW]; \
|
||||||
result2 = result % (int16_t)((int8_t)tmp); \
|
result2 = result % (int16_t)((int8_t)tmp); \
|
||||||
if ((result /= (int16_t)((int8_t)tmp)) > 0xff) { \
|
if ((result /= (int16_t)((int8_t)tmp)) > 0xff) { \
|
||||||
nec_interrupt(0,0); break; \
|
nec_interrupt(0,0); break; \
|
||||||
} else { \
|
} else { \
|
||||||
I.regs.b[AL] = result; \
|
I.regs.b[AL] = result; \
|
||||||
I.regs.b[AH] = result2; \
|
I.regs.b[AH] = result2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DIVUW \
|
#define DIVUW \
|
||||||
uresult = (((uint32_t)I.regs.w[DW]) << 16) | I.regs.w[AW];\
|
uresult = (((uint32_t)I.regs.w[DW]) << 16) | I.regs.w[AW];\
|
||||||
uresult2 = uresult % tmp; \
|
uresult2 = uresult % tmp; \
|
||||||
if ((uresult /= tmp) > 0xffff) { \
|
if ((uresult /= tmp) > 0xffff) { \
|
||||||
nec_interrupt(0,0); break; \
|
nec_interrupt(0,0); break; \
|
||||||
} else { \
|
} else { \
|
||||||
I.regs.w[AW]=uresult; \
|
I.regs.w[AW]=uresult; \
|
||||||
I.regs.w[DW]=uresult2; \
|
I.regs.w[DW]=uresult2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DIVW \
|
#define DIVW \
|
||||||
result = ((uint32_t)I.regs.w[DW] << 16) + I.regs.w[AW]; \
|
result = ((uint32_t)I.regs.w[DW] << 16) + I.regs.w[AW]; \
|
||||||
result2 = result % (int32_t)((int16_t)tmp); \
|
result2 = result % (int32_t)((int16_t)tmp); \
|
||||||
if ((result /= (int32_t)((int16_t)tmp)) > 0xffff) { \
|
if ((result /= (int32_t)((int16_t)tmp)) > 0xffff) { \
|
||||||
nec_interrupt(0,0); break; \
|
nec_interrupt(0,0); break; \
|
||||||
} else { \
|
} else { \
|
||||||
I.regs.w[AW]=result; \
|
I.regs.w[AW]=result; \
|
||||||
I.regs.w[DW]=result2; \
|
I.regs.w[DW]=result2; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADD4S { \
|
#define ADD4S { \
|
||||||
int i,v1,v2,result; \
|
int i,v1,v2,result; \
|
||||||
int count = (I.regs.b[CL]+1)/2; \
|
int count = (I.regs.b[CL]+1)/2; \
|
||||||
uint16_t di = I.regs.w[IY]; \
|
uint16_t di = I.regs.w[IY]; \
|
||||||
uint16_t si = I.regs.w[IX]; \
|
uint16_t si = I.regs.w[IX]; \
|
||||||
I.ZeroVal = I.CarryVal = 0; \
|
I.ZeroVal = I.CarryVal = 0; \
|
||||||
for (i=0;i<count;i++) { \
|
for (i=0;i<count;i++) { \
|
||||||
tmp = GetMemB(DS, si); \
|
tmp = GetMemB(DS, si); \
|
||||||
tmp2 = GetMemB(ES, di); \
|
tmp2 = GetMemB(ES, di); \
|
||||||
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
||||||
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
||||||
result = v1+v2+I.CarryVal; \
|
result = v1+v2+I.CarryVal; \
|
||||||
I.CarryVal = result > 99 ? 1 : 0; \
|
I.CarryVal = result > 99 ? 1 : 0; \
|
||||||
result = result % 100; \
|
result = result % 100; \
|
||||||
v1 = ((result/10)<<4) | (result % 10); \
|
v1 = ((result/10)<<4) | (result % 10); \
|
||||||
PutMemB(ES, di,v1); \
|
PutMemB(ES, di,v1); \
|
||||||
if (v1) I.ZeroVal = 1; \
|
if (v1) I.ZeroVal = 1; \
|
||||||
si++; \
|
si++; \
|
||||||
di++; \
|
di++; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SUB4S { \
|
#define SUB4S { \
|
||||||
int count = (I.regs.b[CL]+1)/2; \
|
int count = (I.regs.b[CL]+1)/2; \
|
||||||
int i,v1,v2,result; \
|
int i,v1,v2,result; \
|
||||||
uint16_t di = I.regs.w[IY]; \
|
uint16_t di = I.regs.w[IY]; \
|
||||||
uint16_t si = I.regs.w[IX]; \
|
uint16_t si = I.regs.w[IX]; \
|
||||||
I.ZeroVal = I.CarryVal = 0; \
|
I.ZeroVal = I.CarryVal = 0; \
|
||||||
for (i=0;i<count;i++) { \
|
for (i=0;i<count;i++) { \
|
||||||
tmp = GetMemB(ES, di); \
|
tmp = GetMemB(ES, di); \
|
||||||
tmp2 = GetMemB(DS, si); \
|
tmp2 = GetMemB(DS, si); \
|
||||||
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
||||||
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
||||||
if (v1 < (v2+I.CarryVal)) { \
|
if (v1 < (v2+I.CarryVal)) { \
|
||||||
v1+=100; \
|
v1+=100; \
|
||||||
result = v1-(v2+I.CarryVal); \
|
result = v1-(v2+I.CarryVal); \
|
||||||
I.CarryVal = 1; \
|
I.CarryVal = 1; \
|
||||||
} else { \
|
} else { \
|
||||||
result = v1-(v2+I.CarryVal); \
|
result = v1-(v2+I.CarryVal); \
|
||||||
I.CarryVal = 0; \
|
I.CarryVal = 0; \
|
||||||
} \
|
} \
|
||||||
v1 = ((result/10)<<4) | (result % 10); \
|
v1 = ((result/10)<<4) | (result % 10); \
|
||||||
PutMemB(ES, di,v1); \
|
PutMemB(ES, di,v1); \
|
||||||
if (v1) I.ZeroVal = 1; \
|
if (v1) I.ZeroVal = 1; \
|
||||||
si++; \
|
si++; \
|
||||||
di++; \
|
di++; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CMP4S { \
|
#define CMP4S { \
|
||||||
int count = (I.regs.b[CL]+1)/2; \
|
int count = (I.regs.b[CL]+1)/2; \
|
||||||
int i,v1,v2,result; \
|
int i,v1,v2,result; \
|
||||||
uint16_t di = I.regs.w[IY]; \
|
uint16_t di = I.regs.w[IY]; \
|
||||||
uint16_t si = I.regs.w[IX]; \
|
uint16_t si = I.regs.w[IX]; \
|
||||||
I.ZeroVal = I.CarryVal = 0; \
|
I.ZeroVal = I.CarryVal = 0; \
|
||||||
for (i=0;i<count;i++) { \
|
for (i=0;i<count;i++) { \
|
||||||
tmp = GetMemB(ES, di); \
|
tmp = GetMemB(ES, di); \
|
||||||
tmp2 = GetMemB(DS, si); \
|
tmp2 = GetMemB(DS, si); \
|
||||||
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
v1 = (tmp>>4)*10 + (tmp&0xf); \
|
||||||
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
|
||||||
if (v1 < (v2+I.CarryVal)) { \
|
if (v1 < (v2+I.CarryVal)) { \
|
||||||
v1+=100; \
|
v1+=100; \
|
||||||
result = v1-(v2+I.CarryVal); \
|
result = v1-(v2+I.CarryVal); \
|
||||||
I.CarryVal = 1; \
|
I.CarryVal = 1; \
|
||||||
} else { \
|
} else { \
|
||||||
result = v1-(v2+I.CarryVal); \
|
result = v1-(v2+I.CarryVal); \
|
||||||
I.CarryVal = 0; \
|
I.CarryVal = 0; \
|
||||||
} \
|
} \
|
||||||
v1 = ((result/10)<<4) | (result % 10); \
|
v1 = ((result/10)<<4) | (result % 10); \
|
||||||
if (v1) I.ZeroVal = 1; \
|
if (v1) I.ZeroVal = 1; \
|
||||||
si++; \
|
si++; \
|
||||||
di++; \
|
di++; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __NEC_H_ */
|
#endif /* __NEC_H_ */
|
||||||
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* necea.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
static uint32_t EA;
|
static uint32_t EA;
|
||||||
static uint16_t EO;
|
static uint16_t EO;
|
||||||
@ -5,194 +12,206 @@ static uint16_t E16;
|
|||||||
|
|
||||||
static unsigned EA_000(void)
|
static unsigned EA_000(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[BW]+I.regs.w[IX];
|
EO = I.regs.w[BW] + I.regs.w[IX];
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_001(void)
|
static unsigned EA_001(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[BW]+I.regs.w[IY];
|
EO = I.regs.w[BW] + I.regs.w[IY];
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_002(void)
|
static unsigned EA_002(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[BP]+I.regs.w[IX];
|
EO = I.regs.w[BP] + I.regs.w[IX];
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_003(void)
|
static unsigned EA_003(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[BP]+I.regs.w[IY];
|
EO = I.regs.w[BP] + I.regs.w[IY];
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_004(void)
|
static unsigned EA_004(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[IX];
|
EO = I.regs.w[IX];
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_005(void)
|
static unsigned EA_005(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[IY];
|
EO = I.regs.w[IY];
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_006(void)
|
static unsigned EA_006(void)
|
||||||
{
|
{
|
||||||
EO=FETCH;
|
EO = FETCH;
|
||||||
EO+=FETCH<<8;
|
EO += FETCH << 8;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_007(void)
|
static unsigned EA_007(void)
|
||||||
{
|
{
|
||||||
EO=I.regs.w[BW];
|
EO = I.regs.w[BW];
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_100(void)
|
static unsigned EA_100(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BW]+I.regs.w[IX]+(int8_t)FETCH);
|
EO = (I.regs.w[BW] + I.regs.w[IX] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_101(void)
|
static unsigned EA_101(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BW]+I.regs.w[IY]+(int8_t)FETCH);
|
EO = (I.regs.w[BW] + I.regs.w[IY] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_102(void)
|
static unsigned EA_102(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BP]+I.regs.w[IX]+(int8_t)FETCH);
|
EO = (I.regs.w[BP] + I.regs.w[IX] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_103(void)
|
static unsigned EA_103(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BP]+I.regs.w[IY]+(int8_t)FETCH);
|
EO = (I.regs.w[BP] + I.regs.w[IY] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_104(void)
|
static unsigned EA_104(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[IX]+(int8_t)FETCH);
|
EO = (I.regs.w[IX] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_105(void)
|
static unsigned EA_105(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[IY]+(int8_t)FETCH);
|
EO = (I.regs.w[IY] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_106(void)
|
static unsigned EA_106(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BP]+(int8_t)FETCH);
|
EO = (I.regs.w[BP] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_107(void)
|
static unsigned EA_107(void)
|
||||||
{
|
{
|
||||||
EO=(I.regs.w[BW]+(int8_t)FETCH);
|
EO = (I.regs.w[BW] + (int8_t)FETCH);
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_200(void)
|
static unsigned EA_200(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BW]+I.regs.w[IX]+(int16_t)E16;
|
EO = I.regs.w[BW] + I.regs.w[IX] + (int16_t)E16;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_201(void)
|
static unsigned EA_201(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BW]+I.regs.w[IY]+(int16_t)E16;
|
EO = I.regs.w[BW] + I.regs.w[IY] + (int16_t)E16;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_202(void)
|
static unsigned EA_202(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BP]+I.regs.w[IX]+(int16_t)E16;
|
EO = I.regs.w[BP] + I.regs.w[IX] + (int16_t)E16;
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_203(void)
|
static unsigned EA_203(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BP]+I.regs.w[IY]+(int16_t)E16;
|
EO = I.regs.w[BP] + I.regs.w[IY] + (int16_t)E16;
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_204(void)
|
static unsigned EA_204(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[IX]+(int16_t)E16;
|
EO = I.regs.w[IX] + (int16_t)E16;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_205(void)
|
static unsigned EA_205(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[IY]+(int16_t)E16;
|
EO = I.regs.w[IY] + (int16_t)E16;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_206(void)
|
static unsigned EA_206(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BP]+(int16_t)E16;
|
EO = I.regs.w[BP] + (int16_t)E16;
|
||||||
EA=DefaultBase(SS)+EO;
|
EA = DefaultBase(SS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned EA_207(void)
|
static unsigned EA_207(void)
|
||||||
{
|
{
|
||||||
E16=FETCH;
|
E16 = FETCH;
|
||||||
E16+=FETCH<<8;
|
E16 += FETCH << 8;
|
||||||
EO=I.regs.w[BW]+(int16_t)E16;
|
EO = I.regs.w[BW] + (int16_t)E16;
|
||||||
EA=DefaultBase(DS)+EO;
|
EA = DefaultBase(DS) + EO;
|
||||||
return EA;
|
return EA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned (*GetEA[192])(void)=
|
static unsigned (*GetEA[192])(void) =
|
||||||
{
|
{
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005,
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003,
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001,
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
|
||||||
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
|
|
||||||
|
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107, EA_100, EA_101, EA_102, EA_103, EA_104, EA_105,
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
EA_106, EA_107, EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107, EA_100, EA_101, EA_102, EA_103,
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
EA_104, EA_105, EA_106, EA_107, EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107, EA_100, EA_101,
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
EA_102, EA_103, EA_104, EA_105, EA_106, EA_107, EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
|
||||||
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
|
|
||||||
|
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205,
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203,
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201,
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
};
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
|
|
||||||
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207
|
|
||||||
};
|
|
||||||
|
|||||||
@ -1,3 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* necinstr.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
static void i_add_br8(void);
|
static void i_add_br8(void);
|
||||||
static void i_add_wr16(void);
|
static void i_add_wr16(void);
|
||||||
static void i_add_r8b(void);
|
static void i_add_r8b(void);
|
||||||
@ -247,261 +255,261 @@ static void i_ffpre(void);
|
|||||||
static void i_wait(void);
|
static void i_wait(void);
|
||||||
|
|
||||||
void (*nec_instruction[256])(void) =
|
void (*nec_instruction[256])(void) =
|
||||||
{
|
{
|
||||||
i_add_br8, /* 0x00 */
|
i_add_br8, /* 0x00 */
|
||||||
i_add_wr16, /* 0x01 */
|
i_add_wr16, /* 0x01 */
|
||||||
i_add_r8b, /* 0x02 */
|
i_add_r8b, /* 0x02 */
|
||||||
i_add_r16w, /* 0x03 */
|
i_add_r16w, /* 0x03 */
|
||||||
i_add_ald8, /* 0x04 */
|
i_add_ald8, /* 0x04 */
|
||||||
i_add_axd16, /* 0x05 */
|
i_add_axd16, /* 0x05 */
|
||||||
i_push_es, /* 0x06 */
|
i_push_es, /* 0x06 */
|
||||||
i_pop_es, /* 0x07 */
|
i_pop_es, /* 0x07 */
|
||||||
i_or_br8, /* 0x08 */
|
i_or_br8, /* 0x08 */
|
||||||
i_or_wr16, /* 0x09 */
|
i_or_wr16, /* 0x09 */
|
||||||
i_or_r8b, /* 0x0a */
|
i_or_r8b, /* 0x0a */
|
||||||
i_or_r16w, /* 0x0b */
|
i_or_r16w, /* 0x0b */
|
||||||
i_or_ald8, /* 0x0c */
|
i_or_ald8, /* 0x0c */
|
||||||
i_or_axd16, /* 0x0d */
|
i_or_axd16, /* 0x0d */
|
||||||
i_push_cs, /* 0x0e */
|
i_push_cs, /* 0x0e */
|
||||||
i_pre_nec /* 0x0f */,
|
i_pre_nec, /* 0x0f */
|
||||||
i_adc_br8, /* 0x10 */
|
i_adc_br8, /* 0x10 */
|
||||||
i_adc_wr16, /* 0x11 */
|
i_adc_wr16, /* 0x11 */
|
||||||
i_adc_r8b, /* 0x12 */
|
i_adc_r8b, /* 0x12 */
|
||||||
i_adc_r16w, /* 0x13 */
|
i_adc_r16w, /* 0x13 */
|
||||||
i_adc_ald8, /* 0x14 */
|
i_adc_ald8, /* 0x14 */
|
||||||
i_adc_axd16, /* 0x15 */
|
i_adc_axd16, /* 0x15 */
|
||||||
i_push_ss, /* 0x16 */
|
i_push_ss, /* 0x16 */
|
||||||
i_pop_ss, /* 0x17 */
|
i_pop_ss, /* 0x17 */
|
||||||
i_sbb_br8, /* 0x18 */
|
i_sbb_br8, /* 0x18 */
|
||||||
i_sbb_wr16, /* 0x19 */
|
i_sbb_wr16, /* 0x19 */
|
||||||
i_sbb_r8b, /* 0x1a */
|
i_sbb_r8b, /* 0x1a */
|
||||||
i_sbb_r16w, /* 0x1b */
|
i_sbb_r16w, /* 0x1b */
|
||||||
i_sbb_ald8, /* 0x1c */
|
i_sbb_ald8, /* 0x1c */
|
||||||
i_sbb_axd16, /* 0x1d */
|
i_sbb_axd16, /* 0x1d */
|
||||||
i_push_ds, /* 0x1e */
|
i_push_ds, /* 0x1e */
|
||||||
i_pop_ds, /* 0x1f */
|
i_pop_ds, /* 0x1f */
|
||||||
i_and_br8, /* 0x20 */
|
i_and_br8, /* 0x20 */
|
||||||
i_and_wr16, /* 0x21 */
|
i_and_wr16, /* 0x21 */
|
||||||
i_and_r8b, /* 0x22 */
|
i_and_r8b, /* 0x22 */
|
||||||
i_and_r16w, /* 0x23 */
|
i_and_r16w, /* 0x23 */
|
||||||
i_and_ald8, /* 0x24 */
|
i_and_ald8, /* 0x24 */
|
||||||
i_and_axd16, /* 0x25 */
|
i_and_axd16, /* 0x25 */
|
||||||
i_es, /* 0x26 */
|
i_es, /* 0x26 */
|
||||||
i_daa, /* 0x27 */
|
i_daa, /* 0x27 */
|
||||||
i_sub_br8, /* 0x28 */
|
i_sub_br8, /* 0x28 */
|
||||||
i_sub_wr16, /* 0x29 */
|
i_sub_wr16, /* 0x29 */
|
||||||
i_sub_r8b, /* 0x2a */
|
i_sub_r8b, /* 0x2a */
|
||||||
i_sub_r16w, /* 0x2b */
|
i_sub_r16w, /* 0x2b */
|
||||||
i_sub_ald8, /* 0x2c */
|
i_sub_ald8, /* 0x2c */
|
||||||
i_sub_axd16, /* 0x2d */
|
i_sub_axd16, /* 0x2d */
|
||||||
i_cs, /* 0x2e */
|
i_cs, /* 0x2e */
|
||||||
i_das, /* 0x2f */
|
i_das, /* 0x2f */
|
||||||
i_xor_br8, /* 0x30 */
|
i_xor_br8, /* 0x30 */
|
||||||
i_xor_wr16, /* 0x31 */
|
i_xor_wr16, /* 0x31 */
|
||||||
i_xor_r8b, /* 0x32 */
|
i_xor_r8b, /* 0x32 */
|
||||||
i_xor_r16w, /* 0x33 */
|
i_xor_r16w, /* 0x33 */
|
||||||
i_xor_ald8, /* 0x34 */
|
i_xor_ald8, /* 0x34 */
|
||||||
i_xor_axd16, /* 0x35 */
|
i_xor_axd16, /* 0x35 */
|
||||||
i_ss, /* 0x36 */
|
i_ss, /* 0x36 */
|
||||||
i_aaa, /* 0x37 */
|
i_aaa, /* 0x37 */
|
||||||
i_cmp_br8, /* 0x38 */
|
i_cmp_br8, /* 0x38 */
|
||||||
i_cmp_wr16, /* 0x39 */
|
i_cmp_wr16, /* 0x39 */
|
||||||
i_cmp_r8b, /* 0x3a */
|
i_cmp_r8b, /* 0x3a */
|
||||||
i_cmp_r16w, /* 0x3b */
|
i_cmp_r16w, /* 0x3b */
|
||||||
i_cmp_ald8, /* 0x3c */
|
i_cmp_ald8, /* 0x3c */
|
||||||
i_cmp_axd16, /* 0x3d */
|
i_cmp_axd16, /* 0x3d */
|
||||||
i_ds, /* 0x3e */
|
i_ds, /* 0x3e */
|
||||||
i_aas, /* 0x3f */
|
i_aas, /* 0x3f */
|
||||||
i_inc_ax, /* 0x40 */
|
i_inc_ax, /* 0x40 */
|
||||||
i_inc_cx, /* 0x41 */
|
i_inc_cx, /* 0x41 */
|
||||||
i_inc_dx, /* 0x42 */
|
i_inc_dx, /* 0x42 */
|
||||||
i_inc_bx, /* 0x43 */
|
i_inc_bx, /* 0x43 */
|
||||||
i_inc_sp, /* 0x44 */
|
i_inc_sp, /* 0x44 */
|
||||||
i_inc_bp, /* 0x45 */
|
i_inc_bp, /* 0x45 */
|
||||||
i_inc_si, /* 0x46 */
|
i_inc_si, /* 0x46 */
|
||||||
i_inc_di, /* 0x47 */
|
i_inc_di, /* 0x47 */
|
||||||
i_dec_ax, /* 0x48 */
|
i_dec_ax, /* 0x48 */
|
||||||
i_dec_cx, /* 0x49 */
|
i_dec_cx, /* 0x49 */
|
||||||
i_dec_dx, /* 0x4a */
|
i_dec_dx, /* 0x4a */
|
||||||
i_dec_bx, /* 0x4b */
|
i_dec_bx, /* 0x4b */
|
||||||
i_dec_sp, /* 0x4c */
|
i_dec_sp, /* 0x4c */
|
||||||
i_dec_bp, /* 0x4d */
|
i_dec_bp, /* 0x4d */
|
||||||
i_dec_si, /* 0x4e */
|
i_dec_si, /* 0x4e */
|
||||||
i_dec_di, /* 0x4f */
|
i_dec_di, /* 0x4f */
|
||||||
i_push_ax, /* 0x50 */
|
i_push_ax, /* 0x50 */
|
||||||
i_push_cx, /* 0x51 */
|
i_push_cx, /* 0x51 */
|
||||||
i_push_dx, /* 0x52 */
|
i_push_dx, /* 0x52 */
|
||||||
i_push_bx, /* 0x53 */
|
i_push_bx, /* 0x53 */
|
||||||
i_push_sp, /* 0x54 */
|
i_push_sp, /* 0x54 */
|
||||||
i_push_bp, /* 0x55 */
|
i_push_bp, /* 0x55 */
|
||||||
i_push_si, /* 0x56 */
|
i_push_si, /* 0x56 */
|
||||||
i_push_di, /* 0x57 */
|
i_push_di, /* 0x57 */
|
||||||
i_pop_ax, /* 0x58 */
|
i_pop_ax, /* 0x58 */
|
||||||
i_pop_cx, /* 0x59 */
|
i_pop_cx, /* 0x59 */
|
||||||
i_pop_dx, /* 0x5a */
|
i_pop_dx, /* 0x5a */
|
||||||
i_pop_bx, /* 0x5b */
|
i_pop_bx, /* 0x5b */
|
||||||
i_pop_sp, /* 0x5c */
|
i_pop_sp, /* 0x5c */
|
||||||
i_pop_bp, /* 0x5d */
|
i_pop_bp, /* 0x5d */
|
||||||
i_pop_si, /* 0x5e */
|
i_pop_si, /* 0x5e */
|
||||||
i_pop_di, /* 0x5f */
|
i_pop_di, /* 0x5f */
|
||||||
i_pusha, /* 0x60 */
|
i_pusha, /* 0x60 */
|
||||||
i_popa, /* 0x61 */
|
i_popa, /* 0x61 */
|
||||||
i_chkind, /* 0x62 */
|
i_chkind, /* 0x62 */
|
||||||
i_invalid, /* 0x63 */
|
i_invalid, /* 0x63 */
|
||||||
i_repnc, /* 0x64 */
|
i_repnc, /* 0x64 */
|
||||||
i_repc, /* 0x65 */
|
i_repc, /* 0x65 */
|
||||||
i_invalid, /* 0x66 */
|
i_invalid, /* 0x66 */
|
||||||
i_invalid, /* 0x67 */
|
i_invalid, /* 0x67 */
|
||||||
i_push_d16, /* 0x68 */
|
i_push_d16, /* 0x68 */
|
||||||
i_imul_d16, /* 0x69 */
|
i_imul_d16, /* 0x69 */
|
||||||
i_push_d8, /* 0x6a */
|
i_push_d8, /* 0x6a */
|
||||||
i_imul_d8, /* 0x6b */
|
i_imul_d8, /* 0x6b */
|
||||||
i_insb, /* 0x6c */
|
i_insb, /* 0x6c */
|
||||||
i_insw, /* 0x6d */
|
i_insw, /* 0x6d */
|
||||||
i_outsb, /* 0x6e */
|
i_outsb, /* 0x6e */
|
||||||
i_outsw, /* 0x6f */
|
i_outsw, /* 0x6f */
|
||||||
i_jo, /* 0x70 */
|
i_jo, /* 0x70 */
|
||||||
i_jno, /* 0x71 */
|
i_jno, /* 0x71 */
|
||||||
i_jc, /* 0x72 */
|
i_jc, /* 0x72 */
|
||||||
i_jnc, /* 0x73 */
|
i_jnc, /* 0x73 */
|
||||||
i_jz, /* 0x74 */
|
i_jz, /* 0x74 */
|
||||||
i_jnz, /* 0x75 */
|
i_jnz, /* 0x75 */
|
||||||
i_jce, /* 0x76 */
|
i_jce, /* 0x76 */
|
||||||
i_jnce, /* 0x77 */
|
i_jnce, /* 0x77 */
|
||||||
i_js, /* 0x78 */
|
i_js, /* 0x78 */
|
||||||
i_jns, /* 0x79 */
|
i_jns, /* 0x79 */
|
||||||
i_jp, /* 0x7a */
|
i_jp, /* 0x7a */
|
||||||
i_jnp, /* 0x7b */
|
i_jnp, /* 0x7b */
|
||||||
i_jl, /* 0x7c */
|
i_jl, /* 0x7c */
|
||||||
i_jnl, /* 0x7d */
|
i_jnl, /* 0x7d */
|
||||||
i_jle, /* 0x7e */
|
i_jle, /* 0x7e */
|
||||||
i_jnle, /* 0x7f */
|
i_jnle, /* 0x7f */
|
||||||
i_80pre, /* 0x80 */
|
i_80pre, /* 0x80 */
|
||||||
i_81pre, /* 0x81 */
|
i_81pre, /* 0x81 */
|
||||||
i_82pre, /* 0x82 */
|
i_82pre, /* 0x82 */
|
||||||
i_83pre, /* 0x83 */
|
i_83pre, /* 0x83 */
|
||||||
i_test_br8, /* 0x84 */
|
i_test_br8, /* 0x84 */
|
||||||
i_test_wr16, /* 0x85 */
|
i_test_wr16, /* 0x85 */
|
||||||
i_xchg_br8, /* 0x86 */
|
i_xchg_br8, /* 0x86 */
|
||||||
i_xchg_wr16, /* 0x87 */
|
i_xchg_wr16, /* 0x87 */
|
||||||
i_mov_br8, /* 0x88 */
|
i_mov_br8, /* 0x88 */
|
||||||
i_mov_wr16, /* 0x89 */
|
i_mov_wr16, /* 0x89 */
|
||||||
i_mov_r8b, /* 0x8a */
|
i_mov_r8b, /* 0x8a */
|
||||||
i_mov_r16w, /* 0x8b */
|
i_mov_r16w, /* 0x8b */
|
||||||
i_mov_wsreg, /* 0x8c */
|
i_mov_wsreg, /* 0x8c */
|
||||||
i_lea, /* 0x8d */
|
i_lea, /* 0x8d */
|
||||||
i_mov_sregw, /* 0x8e */
|
i_mov_sregw, /* 0x8e */
|
||||||
i_popw, /* 0x8f */
|
i_popw, /* 0x8f */
|
||||||
i_nop, /* 0x90 */
|
i_nop, /* 0x90 */
|
||||||
i_xchg_axcx, /* 0x91 */
|
i_xchg_axcx, /* 0x91 */
|
||||||
i_xchg_axdx, /* 0x92 */
|
i_xchg_axdx, /* 0x92 */
|
||||||
i_xchg_axbx, /* 0x93 */
|
i_xchg_axbx, /* 0x93 */
|
||||||
i_xchg_axsp, /* 0x94 */
|
i_xchg_axsp, /* 0x94 */
|
||||||
i_xchg_axbp, /* 0x95 */
|
i_xchg_axbp, /* 0x95 */
|
||||||
i_xchg_axsi, /* 0x97 */
|
i_xchg_axsi, /* 0x97 */
|
||||||
i_xchg_axdi, /* 0x97 */
|
i_xchg_axdi, /* 0x97 */
|
||||||
i_cbw, /* 0x98 */
|
i_cbw, /* 0x98 */
|
||||||
i_cwd, /* 0x99 */
|
i_cwd, /* 0x99 */
|
||||||
i_call_far, /* 0x9a */
|
i_call_far, /* 0x9a */
|
||||||
i_wait, /* 0x9b */
|
i_wait, /* 0x9b */
|
||||||
i_pushf, /* 0x9c */
|
i_pushf, /* 0x9c */
|
||||||
i_popf, /* 0x9d */
|
i_popf, /* 0x9d */
|
||||||
i_sahf, /* 0x9e */
|
i_sahf, /* 0x9e */
|
||||||
i_lahf, /* 0x9f */
|
i_lahf, /* 0x9f */
|
||||||
i_mov_aldisp, /* 0xa0 */
|
i_mov_aldisp, /* 0xa0 */
|
||||||
i_mov_axdisp, /* 0xa1 */
|
i_mov_axdisp, /* 0xa1 */
|
||||||
i_mov_dispal, /* 0xa2 */
|
i_mov_dispal, /* 0xa2 */
|
||||||
i_mov_dispax, /* 0xa3 */
|
i_mov_dispax, /* 0xa3 */
|
||||||
i_movsb, /* 0xa4 */
|
i_movsb, /* 0xa4 */
|
||||||
i_movsw, /* 0xa5 */
|
i_movsw, /* 0xa5 */
|
||||||
i_cmpsb, /* 0xa6 */
|
i_cmpsb, /* 0xa6 */
|
||||||
i_cmpsw, /* 0xa7 */
|
i_cmpsw, /* 0xa7 */
|
||||||
i_test_ald8, /* 0xa8 */
|
i_test_ald8, /* 0xa8 */
|
||||||
i_test_axd16, /* 0xa9 */
|
i_test_axd16, /* 0xa9 */
|
||||||
i_stosb, /* 0xaa */
|
i_stosb, /* 0xaa */
|
||||||
i_stosw, /* 0xab */
|
i_stosw, /* 0xab */
|
||||||
i_lodsb, /* 0xac */
|
i_lodsb, /* 0xac */
|
||||||
i_lodsw, /* 0xad */
|
i_lodsw, /* 0xad */
|
||||||
i_scasb, /* 0xae */
|
i_scasb, /* 0xae */
|
||||||
i_scasw, /* 0xaf */
|
i_scasw, /* 0xaf */
|
||||||
i_mov_ald8, /* 0xb0 */
|
i_mov_ald8, /* 0xb0 */
|
||||||
i_mov_cld8, /* 0xb1 */
|
i_mov_cld8, /* 0xb1 */
|
||||||
i_mov_dld8, /* 0xb2 */
|
i_mov_dld8, /* 0xb2 */
|
||||||
i_mov_bld8, /* 0xb3 */
|
i_mov_bld8, /* 0xb3 */
|
||||||
i_mov_ahd8, /* 0xb4 */
|
i_mov_ahd8, /* 0xb4 */
|
||||||
i_mov_chd8, /* 0xb5 */
|
i_mov_chd8, /* 0xb5 */
|
||||||
i_mov_dhd8, /* 0xb6 */
|
i_mov_dhd8, /* 0xb6 */
|
||||||
i_mov_bhd8, /* 0xb7 */
|
i_mov_bhd8, /* 0xb7 */
|
||||||
i_mov_axd16, /* 0xb8 */
|
i_mov_axd16, /* 0xb8 */
|
||||||
i_mov_cxd16, /* 0xb9 */
|
i_mov_cxd16, /* 0xb9 */
|
||||||
i_mov_dxd16, /* 0xba */
|
i_mov_dxd16, /* 0xba */
|
||||||
i_mov_bxd16, /* 0xbb */
|
i_mov_bxd16, /* 0xbb */
|
||||||
i_mov_spd16, /* 0xbc */
|
i_mov_spd16, /* 0xbc */
|
||||||
i_mov_bpd16, /* 0xbd */
|
i_mov_bpd16, /* 0xbd */
|
||||||
i_mov_sid16, /* 0xbe */
|
i_mov_sid16, /* 0xbe */
|
||||||
i_mov_did16, /* 0xbf */
|
i_mov_did16, /* 0xbf */
|
||||||
i_rotshft_bd8, /* 0xc0 */
|
i_rotshft_bd8, /* 0xc0 */
|
||||||
i_rotshft_wd8, /* 0xc1 */
|
i_rotshft_wd8, /* 0xc1 */
|
||||||
i_ret_d16, /* 0xc2 */
|
i_ret_d16, /* 0xc2 */
|
||||||
i_ret, /* 0xc3 */
|
i_ret, /* 0xc3 */
|
||||||
i_les_dw, /* 0xc4 */
|
i_les_dw, /* 0xc4 */
|
||||||
i_lds_dw, /* 0xc5 */
|
i_lds_dw, /* 0xc5 */
|
||||||
i_mov_bd8, /* 0xc6 */
|
i_mov_bd8, /* 0xc6 */
|
||||||
i_mov_wd16, /* 0xc7 */
|
i_mov_wd16, /* 0xc7 */
|
||||||
i_enter, /* 0xc8 */
|
i_enter, /* 0xc8 */
|
||||||
i_leave, /* 0xc9 */
|
i_leave, /* 0xc9 */
|
||||||
i_retf_d16, /* 0xca */
|
i_retf_d16, /* 0xca */
|
||||||
i_retf, /* 0xcb */
|
i_retf, /* 0xcb */
|
||||||
i_int3, /* 0xcc */
|
i_int3, /* 0xcc */
|
||||||
i_int, /* 0xcd */
|
i_int, /* 0xcd */
|
||||||
i_into, /* 0xce */
|
i_into, /* 0xce */
|
||||||
i_iret, /* 0xcf */
|
i_iret, /* 0xcf */
|
||||||
i_rotshft_b, /* 0xd0 */
|
i_rotshft_b, /* 0xd0 */
|
||||||
i_rotshft_w, /* 0xd1 */
|
i_rotshft_w, /* 0xd1 */
|
||||||
i_rotshft_bcl, /* 0xd2 */
|
i_rotshft_bcl, /* 0xd2 */
|
||||||
i_rotshft_wcl, /* 0xd3 */
|
i_rotshft_wcl, /* 0xd3 */
|
||||||
i_aam, /* 0xd4 */
|
i_aam, /* 0xd4 */
|
||||||
i_aad, /* 0xd5 */
|
i_aad, /* 0xd5 */
|
||||||
i_setalc,
|
i_setalc, /* 0xd6 */
|
||||||
i_trans, /* 0xd7 */
|
i_trans, /* 0xd7 */
|
||||||
i_fpo, /* 0xd8 */
|
i_fpo, /* 0xd8 */
|
||||||
i_fpo, /* 0xd9 */
|
i_fpo, /* 0xd9 */
|
||||||
i_fpo, /* 0xda */
|
i_fpo, /* 0xda */
|
||||||
i_fpo, /* 0xdb */
|
i_fpo, /* 0xdb */
|
||||||
i_fpo, /* 0xdc */
|
i_fpo, /* 0xdc */
|
||||||
i_fpo, /* 0xdd */
|
i_fpo, /* 0xdd */
|
||||||
i_fpo, /* 0xde */
|
i_fpo, /* 0xde */
|
||||||
i_fpo, /* 0xdf */
|
i_fpo, /* 0xdf */
|
||||||
i_loopne, /* 0xe0 */
|
i_loopne, /* 0xe0 */
|
||||||
i_loope, /* 0xe1 */
|
i_loope, /* 0xe1 */
|
||||||
i_loop, /* 0xe2 */
|
i_loop, /* 0xe2 */
|
||||||
i_jcxz, /* 0xe3 */
|
i_jcxz, /* 0xe3 */
|
||||||
i_inal, /* 0xe4 */
|
i_inal, /* 0xe4 */
|
||||||
i_inax, /* 0xe5 */
|
i_inax, /* 0xe5 */
|
||||||
i_outal, /* 0xe6 */
|
i_outal, /* 0xe6 */
|
||||||
i_outax, /* 0xe7 */
|
i_outax, /* 0xe7 */
|
||||||
i_call_d16, /* 0xe8 */
|
i_call_d16, /* 0xe8 */
|
||||||
i_jmp_d16, /* 0xe9 */
|
i_jmp_d16, /* 0xe9 */
|
||||||
i_jmp_far, /* 0xea */
|
i_jmp_far, /* 0xea */
|
||||||
i_jmp_d8, /* 0xeb */
|
i_jmp_d8, /* 0xeb */
|
||||||
i_inaldx, /* 0xec */
|
i_inaldx, /* 0xec */
|
||||||
i_inaxdx, /* 0xed */
|
i_inaxdx, /* 0xed */
|
||||||
i_outdxal, /* 0xee */
|
i_outdxal, /* 0xee */
|
||||||
i_outdxax, /* 0xef */
|
i_outdxax, /* 0xef */
|
||||||
i_lock, /* 0xf0 */
|
i_lock, /* 0xf0 */
|
||||||
i_invalid, /* 0xf1 */
|
i_invalid, /* 0xf1 */
|
||||||
i_repne, /* 0xf2 */
|
i_repne, /* 0xf2 */
|
||||||
i_repe, /* 0xf3 */
|
i_repe, /* 0xf3 */
|
||||||
i_hlt, /* 0xf4 */
|
i_hlt, /* 0xf4 */
|
||||||
i_cmc, /* 0xf5 */
|
i_cmc, /* 0xf5 */
|
||||||
i_f6pre, /* 0xf6 */
|
i_f6pre, /* 0xf6 */
|
||||||
i_f7pre, /* 0xf7 */
|
i_f7pre, /* 0xf7 */
|
||||||
i_clc, /* 0xf8 */
|
i_clc, /* 0xf8 */
|
||||||
i_stc, /* 0xf9 */
|
i_stc, /* 0xf9 */
|
||||||
i_di, /* 0xfa */
|
i_di, /* 0xfa */
|
||||||
i_ei, /* 0xfb */
|
i_ei, /* 0xfb */
|
||||||
i_cld, /* 0xfc */
|
i_cld, /* 0xfc */
|
||||||
i_std, /* 0xfd */
|
i_std, /* 0xfd */
|
||||||
i_fepre, /* 0xfe */
|
i_fepre, /* 0xfe */
|
||||||
i_ffpre /* 0xff */
|
i_ffpre /* 0xff */
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* necintrf.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
/* ASG 971222 -- rewrote this interface */
|
/* ASG 971222 -- rewrote this interface */
|
||||||
#ifndef __NECITRF_H_
|
#ifndef __NECITRF_H_
|
||||||
#define __NECITRF_H_
|
#define __NECITRF_H_
|
||||||
@ -6,65 +13,35 @@
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NEC_IP=1, NEC_AW, NEC_CW, NEC_DW, NEC_BW, NEC_SP, NEC_BP, NEC_IX, NEC_IY,
|
NEC_IP = 1,
|
||||||
NEC_FLAGS, NEC_ES, NEC_CS, NEC_SS, NEC_DS,
|
NEC_AW,
|
||||||
NEC_VECTOR, NEC_PENDING, NEC_NMI_STATE, NEC_IRQ_STATE
|
NEC_CW,
|
||||||
|
NEC_DW,
|
||||||
|
NEC_BW,
|
||||||
|
NEC_SP,
|
||||||
|
NEC_BP,
|
||||||
|
NEC_IX,
|
||||||
|
NEC_IY,
|
||||||
|
NEC_FLAGS,
|
||||||
|
NEC_ES,
|
||||||
|
NEC_CS,
|
||||||
|
NEC_SS,
|
||||||
|
NEC_DS,
|
||||||
|
NEC_VECTOR,
|
||||||
|
NEC_PENDING,
|
||||||
|
NEC_NMI_STATE,
|
||||||
|
NEC_IRQ_STATE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Public variables */
|
/* Public variables */
|
||||||
extern int nec_ICount;
|
extern int nec_ICount;
|
||||||
|
|
||||||
/* Public functions */
|
/* Public functions */
|
||||||
|
|
||||||
/*
|
|
||||||
#define v20_ICount nec_ICount
|
|
||||||
extern void v20_init(void);
|
|
||||||
extern void v20_reset(void *param);
|
|
||||||
extern void v20_exit(void);
|
|
||||||
extern int v20_execute(int cycles);
|
|
||||||
extern unsigned v20_get_context(void *dst);
|
|
||||||
extern void v20_set_context(void *src);
|
|
||||||
extern unsigned v20_get_reg(int regnum);
|
|
||||||
extern void v20_set_reg(int regnum, unsigned val);
|
|
||||||
extern void v20_set_irq_line(int irqline, int state);
|
|
||||||
extern void v20_set_irq_callback(int (*callback)(int irqline));
|
|
||||||
extern const char *v20_info(void *context, int regnum);
|
|
||||||
extern unsigned v20_dasm(char *buffer, unsigned pc);
|
|
||||||
|
|
||||||
#define v30_ICount nec_ICount
|
|
||||||
extern void v30_init(void);
|
|
||||||
extern void v30_reset(void *param);
|
|
||||||
extern void v30_exit(void);
|
|
||||||
extern int v30_execute(int cycles);
|
|
||||||
extern unsigned v30_get_context(void *dst);
|
|
||||||
extern void v30_set_context(void *src);
|
|
||||||
extern unsigned v30_get_reg(int regnum);
|
|
||||||
extern void v30_set_reg(int regnum, unsigned val);
|
|
||||||
extern void v30_set_irq_line(int irqline, int state);
|
|
||||||
extern void v30_set_irq_callback(int (*callback)(int irqline));
|
|
||||||
extern const char *v30_info(void *context, int regnum);
|
|
||||||
extern unsigned v30_dasm(char *buffer, unsigned pc);
|
|
||||||
|
|
||||||
#define v33_ICount nec_ICount
|
|
||||||
extern void v33_init(void);
|
|
||||||
extern void v33_reset(void *param);
|
|
||||||
extern void v33_exit(void);
|
|
||||||
extern int v33_execute(int cycles);
|
|
||||||
extern unsigned v33_get_context(void *dst);
|
|
||||||
extern void v33_set_context(void *src);
|
|
||||||
extern unsigned v33_get_reg(int regnum);
|
|
||||||
extern void v33_set_reg(int regnum, unsigned val);
|
|
||||||
extern void v33_set_irq_line(int irqline, int state);
|
|
||||||
extern void v33_set_irq_callback(int (*callback)(int irqline));
|
|
||||||
extern const char *v33_info(void *context, int regnum);
|
|
||||||
extern unsigned v33_dasm(char *buffer, unsigned pc);
|
|
||||||
*/
|
|
||||||
|
|
||||||
void nec_set_irq_line(int irqline, int state);
|
void nec_set_irq_line(int irqline, int state);
|
||||||
void nec_set_reg(int regnum, uint32_t val);
|
void nec_set_reg(int regnum, uint32_t val);
|
||||||
int nec_execute(int cycles);
|
int nec_execute(int cycles);
|
||||||
unsigned nec_get_reg(int regnum);
|
unsigned nec_get_reg(int regnum);
|
||||||
void nec_reset (void *param);
|
void nec_reset(void *param);
|
||||||
void nec_int(uint16_t vector);
|
void nec_int(uint16_t vector);
|
||||||
|
|
||||||
uint8_t cpu_readport(uint8_t);
|
uint8_t cpu_readport(uint8_t);
|
||||||
|
|||||||
@ -1,107 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* necmodrm.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
WREGS w[256];
|
WREGS w[256];
|
||||||
BREGS b[256];
|
BREGS b[256];
|
||||||
} reg;
|
} reg;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
WREGS w[256];
|
WREGS w[256];
|
||||||
BREGS b[256];
|
BREGS b[256];
|
||||||
} RM;
|
} RM;
|
||||||
} Mod_RM;
|
} Mod_RM;
|
||||||
|
|
||||||
#define RegWord(ModRM) I.regs.w[Mod_RM.reg.w[ModRM]]
|
#define RegWord(ModRM) I.regs.w[Mod_RM.reg.w[ModRM]]
|
||||||
#define RegByte(ModRM) I.regs.b[Mod_RM.reg.b[ModRM]]
|
#define RegByte(ModRM) I.regs.b[Mod_RM.reg.b[ModRM]]
|
||||||
|
|
||||||
#define GetRMWord(ModRM) \
|
#define GetRMWord(ModRM) \
|
||||||
((ModRM) >= 0xc0 ? I.regs.w[Mod_RM.RM.w[ModRM]] : ( (*GetEA[ModRM])(), ReadWord( EA ) ))
|
((ModRM) >= 0xc0 ? I.regs.w[Mod_RM.RM.w[ModRM]] : ( (*GetEA[ModRM])(), ReadWord( EA ) ))
|
||||||
|
|
||||||
#define PutbackRMWord(ModRM,val) \
|
#define PutbackRMWord(ModRM, val) \
|
||||||
{ \
|
{ \
|
||||||
if (ModRM >= 0xc0) I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
|
if (ModRM >= 0xc0) I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
|
||||||
else WriteWord(EA,val); \
|
else WriteWord(EA,val); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GetnextRMWord ReadWord((EA&0xf0000)|((EA+2)&0xffff))
|
#define GetnextRMWord ReadWord((EA&0xf0000)|((EA+2)&0xffff))
|
||||||
|
|
||||||
#define PutRMWord(ModRM,val) \
|
#define PutRMWord(ModRM, val) \
|
||||||
{ \
|
{ \
|
||||||
if (ModRM >= 0xc0) \
|
if (ModRM >= 0xc0) \
|
||||||
I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
|
I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
|
||||||
else { \
|
else { \
|
||||||
(*GetEA[ModRM])(); \
|
(*GetEA[ModRM])(); \
|
||||||
WriteWord( EA ,val); \
|
WriteWord( EA ,val); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PutImmRMWord(ModRM) \
|
#define PutImmRMWord(ModRM) \
|
||||||
{ \
|
{ \
|
||||||
int16_t val; \
|
int16_t val; \
|
||||||
if (ModRM >= 0xc0) \
|
if (ModRM >= 0xc0) \
|
||||||
FETCHWORD(I.regs.w[Mod_RM.RM.w[ModRM]]) \
|
FETCHWORD(I.regs.w[Mod_RM.RM.w[ModRM]]) \
|
||||||
else { \
|
else { \
|
||||||
(*GetEA[ModRM])(); \
|
(*GetEA[ModRM])(); \
|
||||||
FETCHWORD(val) \
|
FETCHWORD(val) \
|
||||||
WriteWord( EA , val); \
|
WriteWord( EA , val); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GetRMByte(ModRM) \
|
#define GetRMByte(ModRM) \
|
||||||
((ModRM) >= 0xc0 ? I.regs.b[Mod_RM.RM.b[ModRM]] : ReadByte( (*GetEA[ModRM])() ))
|
((ModRM) >= 0xc0 ? I.regs.b[Mod_RM.RM.b[ModRM]] : ReadByte( (*GetEA[ModRM])() ))
|
||||||
|
|
||||||
#define PutRMByte(ModRM,val) \
|
#define PutRMByte(ModRM, val) \
|
||||||
{ \
|
{ \
|
||||||
if (ModRM >= 0xc0) \
|
if (ModRM >= 0xc0) \
|
||||||
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
|
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
|
||||||
else \
|
else \
|
||||||
WriteByte( (*GetEA[ModRM])() ,val); \
|
WriteByte( (*GetEA[ModRM])() ,val); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PutImmRMByte(ModRM) \
|
#define PutImmRMByte(ModRM) \
|
||||||
{ \
|
{ \
|
||||||
if (ModRM >= 0xc0) \
|
if (ModRM >= 0xc0) \
|
||||||
I.regs.b[Mod_RM.RM.b[ModRM]]=FETCH; \
|
I.regs.b[Mod_RM.RM.b[ModRM]]=FETCH; \
|
||||||
else { \
|
else { \
|
||||||
(*GetEA[ModRM])(); \
|
(*GetEA[ModRM])(); \
|
||||||
WriteByte( EA , FETCH ); \
|
WriteByte( EA , FETCH ); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PutbackRMByte(ModRM,val) \
|
#define PutbackRMByte(ModRM, val) \
|
||||||
{ \
|
{ \
|
||||||
if (ModRM >= 0xc0) \
|
if (ModRM >= 0xc0) \
|
||||||
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
|
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
|
||||||
else \
|
else \
|
||||||
WriteByte(EA,val); \
|
WriteByte(EA,val); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEF_br8 \
|
#define DEF_br8 \
|
||||||
uint32_t ModRM = FETCH,src,dst; \
|
uint32_t ModRM = FETCH,src,dst; \
|
||||||
src = RegByte(ModRM); \
|
src = RegByte(ModRM); \
|
||||||
dst = GetRMByte(ModRM)
|
dst = GetRMByte(ModRM)
|
||||||
|
|
||||||
#define DEF_wr16 \
|
#define DEF_wr16 \
|
||||||
uint32_t ModRM = FETCH,src,dst; \
|
uint32_t ModRM = FETCH,src,dst; \
|
||||||
src = RegWord(ModRM); \
|
src = RegWord(ModRM); \
|
||||||
dst = GetRMWord(ModRM)
|
dst = GetRMWord(ModRM)
|
||||||
|
|
||||||
#define DEF_r8b \
|
#define DEF_r8b \
|
||||||
uint32_t ModRM = FETCH,src,dst; \
|
uint32_t ModRM = FETCH,src,dst; \
|
||||||
dst = RegByte(ModRM); \
|
dst = RegByte(ModRM); \
|
||||||
src = GetRMByte(ModRM)
|
src = GetRMByte(ModRM)
|
||||||
|
|
||||||
#define DEF_r16w \
|
#define DEF_r16w \
|
||||||
uint32_t ModRM = FETCH,src,dst; \
|
uint32_t ModRM = FETCH,src,dst; \
|
||||||
dst = RegWord(ModRM); \
|
dst = RegWord(ModRM); \
|
||||||
src = GetRMWord(ModRM)
|
src = GetRMWord(ModRM)
|
||||||
|
|
||||||
#define DEF_ald8 \
|
#define DEF_ald8 \
|
||||||
uint32_t src = FETCH; \
|
uint32_t src = FETCH; \
|
||||||
uint32_t dst = I.regs.b[AL]
|
uint32_t dst = I.regs.b[AL]
|
||||||
|
|
||||||
#define DEF_axd16 \
|
#define DEF_axd16 \
|
||||||
uint32_t src = FETCH; \
|
uint32_t src = FETCH; \
|
||||||
uint32_t dst = I.regs.w[AW]; \
|
uint32_t dst = I.regs.w[AW]; \
|
||||||
src += (FETCH << 8)
|
src += (FETCH << 8)
|
||||||
|
|||||||
176
source/rom.c
176
source/rom.c
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* tom.c:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -21,7 +26,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "rom.h"
|
#include "rom.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -33,7 +37,7 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint8_t *ws_rom_load(char *path, uint32_t *romSize)
|
uint8_t *ws_rom_load(char *path, uint32_t *romSize)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint8_t *ret_ptr;
|
uint8_t *ret_ptr;
|
||||||
@ -45,7 +49,7 @@ uint8_t *ws_rom_load(char *path, uint32_t *romSize)
|
|||||||
|
|
||||||
*romSize = FileStat.st_size;
|
*romSize = FileStat.st_size;
|
||||||
|
|
||||||
ret_ptr = (uint8_t *)mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
ret_ptr = (uint8_t *)mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -57,6 +61,7 @@ uint8_t *ws_rom_load(char *path, uint32_t *romSize)
|
|||||||
|
|
||||||
return ret_ptr;
|
return ret_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -68,68 +73,69 @@ uint8_t *ws_rom_load(char *path, uint32_t *romSize)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t romSize)
|
void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t romSize)
|
||||||
{
|
{
|
||||||
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,romSize);
|
ws_romHeaderStruct *romHeader = ws_rom_getHeader(wsrom, romSize);
|
||||||
|
|
||||||
fprintf(log_get(),"rom: developper Id 0x%.2x\n",romHeader->developperId);
|
fprintf(log_get(), "rom: developper Id 0x%.2x\n", romHeader->developperId);
|
||||||
fprintf(log_get(),"rom: cart Id 0x%.2x\n",romHeader->cartId);
|
fprintf(log_get(), "rom: cart Id 0x%.2x\n", romHeader->cartId);
|
||||||
fprintf(log_get(),"rom: minimum system %s\n",(romHeader->minimumSupportSystem==0)?"Wonderswan mono":"Wonderswan color");
|
fprintf(log_get(), "rom: minimum system %s\n",
|
||||||
fprintf(log_get(),"rom: size %i Mbits\n",(romSize>>20)<<3);
|
(romHeader->minimumSupportSystem == 0) ? "Wonderswan mono" : "Wonderswan color");
|
||||||
fprintf(log_get(),"rom: eeprom ");
|
fprintf(log_get(), "rom: size %i Mbits\n", (romSize >> 20) << 3);
|
||||||
|
fprintf(log_get(), "rom: eeprom ");
|
||||||
|
|
||||||
switch (romHeader->eepromSize&0xf)
|
switch (romHeader->eepromSize & 0xf)
|
||||||
{
|
{
|
||||||
case WS_EEPROM_SIZE_NONE:
|
case WS_EEPROM_SIZE_NONE:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"none\n");
|
fprintf(log_get(), "none\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WS_EEPROM_SIZE_64k:
|
case WS_EEPROM_SIZE_64k:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"64 kb\n");
|
fprintf(log_get(), "64 kb\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WS_EEPROM_SIZE_256k:
|
case WS_EEPROM_SIZE_256k:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"256 kb\n");
|
fprintf(log_get(), "256 kb\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(log_get(),"rom: sram ");
|
fprintf(log_get(), "rom: sram ");
|
||||||
|
|
||||||
switch (romHeader->eepromSize&0xf0)
|
switch (romHeader->eepromSize & 0xf0)
|
||||||
{
|
{
|
||||||
case WS_SRAM_SIZE_NONE:
|
case WS_SRAM_SIZE_NONE:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"none\n");
|
fprintf(log_get(), "none\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WS_SRAM_SIZE_1k:
|
case WS_SRAM_SIZE_1k:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"1 kb\n");
|
fprintf(log_get(), "1 kb\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WS_SRAM_SIZE_16k:
|
case WS_SRAM_SIZE_16k:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"16 kb\n");
|
fprintf(log_get(), "16 kb\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WS_SRAM_SIZE_8k:
|
case WS_SRAM_SIZE_8k:
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"8 kn\n");
|
fprintf(log_get(), "8 kn\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(log_get(),"rom: rtc %s\n",(romHeader->realtimeClock)?"Yes":"None");
|
fprintf(log_get(), "rom: rtc %s\n", (romHeader->realtimeClock) ? "Yes" : "None");
|
||||||
fprintf(log_get(),"checksum 0x%.4x\n",romHeader->checksum);
|
fprintf(log_get(), "checksum 0x%.4x\n", romHeader->checksum);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,12 +150,13 @@ void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t romSize)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
|
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
|
||||||
{
|
{
|
||||||
ws_romHeaderStruct *wsromHeader = (ws_romHeaderStruct *)(wsrom + wsromSize - 10);
|
ws_romHeaderStruct *wsromHeader = (ws_romHeaderStruct *)(wsrom + wsromSize - 10);
|
||||||
|
|
||||||
return(wsromHeader);
|
return (wsromHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -161,27 +168,28 @@ ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
|
uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
|
||||||
{
|
{
|
||||||
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,wsromSize);
|
ws_romHeaderStruct *romHeader = ws_rom_getHeader(wsrom, wsromSize);
|
||||||
|
|
||||||
switch (romHeader->eepromSize&0xf0)
|
switch (romHeader->eepromSize & 0xf0)
|
||||||
{
|
{
|
||||||
case WS_SRAM_SIZE_NONE:
|
case WS_SRAM_SIZE_NONE:
|
||||||
return(0);
|
return (0);
|
||||||
|
|
||||||
case WS_SRAM_SIZE_1k:
|
case WS_SRAM_SIZE_1k:
|
||||||
return(0x400);
|
return (0x400);
|
||||||
|
|
||||||
case WS_SRAM_SIZE_16k:
|
case WS_SRAM_SIZE_16k:
|
||||||
return(0x4000);
|
return (0x4000);
|
||||||
|
|
||||||
case WS_SRAM_SIZE_8k:
|
case WS_SRAM_SIZE_8k:
|
||||||
return(0x2000);
|
return (0x2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -193,22 +201,22 @@ uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize)
|
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize)
|
||||||
{
|
{
|
||||||
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,wsromSize);
|
ws_romHeaderStruct *romHeader = ws_rom_getHeader(wsrom, wsromSize);
|
||||||
|
|
||||||
switch (romHeader->eepromSize&0xf)
|
switch (romHeader->eepromSize & 0xf)
|
||||||
{
|
{
|
||||||
case WS_EEPROM_SIZE_NONE:
|
case WS_EEPROM_SIZE_NONE:
|
||||||
return(0);
|
return (0);
|
||||||
|
|
||||||
case WS_EEPROM_SIZE_64k:
|
case WS_EEPROM_SIZE_64k:
|
||||||
return(0x10000);
|
return (0x10000);
|
||||||
|
|
||||||
case WS_EEPROM_SIZE_256k:
|
case WS_EEPROM_SIZE_256k:
|
||||||
return(0x40000);
|
return (0x40000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
70
source/rom.h
70
source/rom.h
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* rom.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -14,43 +19,40 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define WS_ROM_SIZE_2MBIT 1
|
#define WS_ROM_SIZE_2MBIT 1
|
||||||
#define WS_ROM_SIZE_4MBIT 2
|
#define WS_ROM_SIZE_4MBIT 2
|
||||||
#define WS_ROM_SIZE_8MBIT 3
|
#define WS_ROM_SIZE_8MBIT 3
|
||||||
#define WS_ROM_SIZE_16MBIT 4
|
#define WS_ROM_SIZE_16MBIT 4
|
||||||
#define WS_ROM_SIZE_24MBIT 5
|
#define WS_ROM_SIZE_24MBIT 5
|
||||||
#define WS_ROM_SIZE_32MBIT 6
|
#define WS_ROM_SIZE_32MBIT 6
|
||||||
#define WS_ROM_SIZE_48MBIT 7
|
#define WS_ROM_SIZE_48MBIT 7
|
||||||
#define WS_ROM_SIZE_64MBIT 8
|
#define WS_ROM_SIZE_64MBIT 8
|
||||||
#define WS_ROM_SIZE_128MBIT 9
|
#define WS_ROM_SIZE_128MBIT 9
|
||||||
|
|
||||||
#define WS_EEPROM_SIZE_NONE 0
|
|
||||||
#define WS_SRAM_SIZE_NONE 0
|
|
||||||
#define WS_EEPROM_SIZE_64k 1
|
|
||||||
#define WS_EEPROM_SIZE_256k 2
|
|
||||||
#define WS_SRAM_SIZE_1k 10
|
|
||||||
#define WS_SRAM_SIZE_16k 20
|
|
||||||
#define WS_SRAM_SIZE_8k 50
|
|
||||||
|
|
||||||
|
#define WS_EEPROM_SIZE_NONE 0
|
||||||
|
#define WS_SRAM_SIZE_NONE 0
|
||||||
|
#define WS_EEPROM_SIZE_64k 1
|
||||||
|
#define WS_EEPROM_SIZE_256k 2
|
||||||
|
#define WS_SRAM_SIZE_1k 10
|
||||||
|
#define WS_SRAM_SIZE_16k 20
|
||||||
|
#define WS_SRAM_SIZE_8k 50
|
||||||
|
|
||||||
typedef struct ws_romHeaderStruct
|
typedef struct ws_romHeaderStruct
|
||||||
{
|
{
|
||||||
uint8_t developperId;
|
uint8_t developperId;
|
||||||
uint8_t minimumSupportSystem;
|
uint8_t minimumSupportSystem;
|
||||||
uint8_t cartId;
|
uint8_t cartId;
|
||||||
uint8_t romSize;
|
uint8_t romSize;
|
||||||
uint8_t eepromSize;
|
uint8_t eepromSize;
|
||||||
uint8_t additionnalCapabilities;
|
uint8_t additionnalCapabilities;
|
||||||
uint8_t realtimeClock;
|
uint8_t realtimeClock;
|
||||||
uint16_t checksum;
|
uint16_t checksum;
|
||||||
} ws_romHeaderStruct;
|
} ws_romHeaderStruct;
|
||||||
|
|
||||||
|
uint8_t *ws_rom_load(char *path, uint32_t *romSize);
|
||||||
uint8_t *ws_rom_load(char *path, uint32_t *romSize);
|
void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t wsromSize);
|
||||||
void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t wsromSize);
|
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize);
|
||||||
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize);
|
uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize);
|
||||||
uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize);
|
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize);
|
||||||
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
531
source/ws.c
531
source/ws.c
@ -1,5 +1,10 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
// Wonderswan emulator
|
* NewOswan
|
||||||
|
* ws.c: Base wonderswan implementation
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -43,14 +48,14 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
uint32_t ws_cycles;
|
uint32_t ws_cycles;
|
||||||
uint32_t ws_skip;
|
uint32_t ws_skip;
|
||||||
uint32_t ws_cyclesByLine=0;
|
uint32_t ws_cyclesByLine = 0;
|
||||||
uint32_t vblank_count=0;
|
uint32_t vblank_count = 0;
|
||||||
|
|
||||||
char *ws_sram_path = NULL;
|
char *ws_sram_path = NULL;
|
||||||
char *ws_ieep_path = NULL;
|
char *ws_ieep_path = NULL;
|
||||||
char *ws_rom_path = NULL;
|
char *ws_rom_path = NULL;
|
||||||
wssystem_t systemType;
|
wssystem_t systemType;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -67,15 +72,15 @@ wssystem_t systemType;
|
|||||||
void ws_patchRom(void)
|
void ws_patchRom(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t *rom=memory_getRom();
|
uint8_t *rom = memory_getRom();
|
||||||
uint32_t romSize=memory_getRomSize();
|
uint32_t romSize = memory_getRomSize();
|
||||||
|
|
||||||
fprintf(log_get(),"developper Id: 0x%.2x\nGame Id: 0x%.2x\n",rom[romSize-10],rom[romSize-8]);
|
fprintf(log_get(), "developper Id: 0x%.2x\nGame Id: 0x%.2x\n", rom[romSize - 10], rom[romSize - 8]);
|
||||||
|
|
||||||
if (!ws_cyclesByLine)
|
if (!ws_cyclesByLine)
|
||||||
{
|
{
|
||||||
ws_cyclesByLine=256;
|
ws_cyclesByLine = 256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -91,53 +96,53 @@ void ws_patchRom(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int ws_init(char *rompath)
|
int ws_init(char *rompath)
|
||||||
{
|
{
|
||||||
uint8_t *rom;
|
uint8_t *rom;
|
||||||
uint32_t romSize;
|
uint32_t romSize;
|
||||||
|
|
||||||
if ((rom=ws_rom_load(rompath,&romSize))==NULL)
|
if ((rom = ws_rom_load(rompath, &romSize)) == NULL)
|
||||||
{
|
{
|
||||||
printf("Error: cannot load %s\n",rompath);
|
printf("Error: cannot load %s\n", rompath);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws_memory_init(rom, romSize);
|
||||||
|
ws_patchRom();
|
||||||
|
|
||||||
ws_memory_init(rom, romSize);
|
ws_staticRam = (uint8_t *)load_file(ws_ieep_path);
|
||||||
ws_patchRom();
|
if (ws_staticRam == NULL)
|
||||||
|
{
|
||||||
|
ws_staticRam = (uint8_t *)create_file(ws_sram_path, 0x10000);
|
||||||
|
}
|
||||||
|
|
||||||
ws_staticRam = (uint8_t *)load_file(ws_ieep_path);
|
if (ws_staticRam == NULL)
|
||||||
if (ws_staticRam == NULL)
|
{
|
||||||
{
|
printf("Card SRAM load error!\n");
|
||||||
ws_staticRam = (uint8_t *)create_file(ws_sram_path, 0x10000);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws_staticRam == NULL)
|
externalEeprom = (uint8_t *)load_file(ws_ieep_path);
|
||||||
{
|
if (externalEeprom == NULL)
|
||||||
printf("Card SRAM load error!\n");
|
{
|
||||||
return 0;
|
externalEeprom = (uint8_t *)create_file(ws_ieep_path, 0x100000);
|
||||||
}
|
}
|
||||||
|
if (externalEeprom == NULL)
|
||||||
|
{
|
||||||
|
printf("Card EEPROM load error!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
externalEeprom = (uint8_t *)load_file(ws_ieep_path);
|
ws_io_init();
|
||||||
if (externalEeprom == NULL)
|
ws_audio_init();
|
||||||
{
|
ws_gpu_init();
|
||||||
externalEeprom = (uint8_t *)create_file(ws_ieep_path, 0x100000);
|
|
||||||
}
|
|
||||||
if (externalEeprom == NULL)
|
|
||||||
{
|
|
||||||
printf("Card EEPROM load error!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ws_io_init();
|
if (ws_rotated())
|
||||||
ws_audio_init();
|
{
|
||||||
ws_gpu_init();
|
ws_io_flipControls();
|
||||||
|
}
|
||||||
|
|
||||||
if (ws_rotated())
|
return (1);
|
||||||
{
|
|
||||||
ws_io_flipControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
return(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -151,13 +156,14 @@ int ws_init(char *rompath)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_reset(void)
|
void ws_reset(void)
|
||||||
{
|
{
|
||||||
ws_memory_reset();
|
ws_memory_reset();
|
||||||
ws_io_reset();
|
ws_io_reset();
|
||||||
ws_audio_reset();
|
ws_audio_reset();
|
||||||
ws_gpu_reset();
|
ws_gpu_reset();
|
||||||
nec_reset(NULL);
|
nec_reset(NULL);
|
||||||
nec_set_reg(NEC_SP,0x2000);
|
nec_set_reg(NEC_SP, 0x2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -171,100 +177,101 @@ void ws_reset(void)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int ws_executeLine(int16_t *framebuffer, int renderLine)
|
int ws_executeLine(int16_t *framebuffer, int renderLine)
|
||||||
{
|
{
|
||||||
int drawWholeScreen=0;
|
int drawWholeScreen = 0;
|
||||||
|
|
||||||
ws_audio_process();
|
ws_audio_process();
|
||||||
|
|
||||||
// update scanline register
|
// update scanline register
|
||||||
ws_ioRam[2]=ws_gpu_scanline;
|
ws_ioRam[2] = ws_gpu_scanline;
|
||||||
|
|
||||||
/* Why twice like that and random cycle count???? */
|
/* Why twice like that and random cycle count???? */
|
||||||
ws_cycles=nec_execute((ws_cyclesByLine>>1)+(rand()&7));
|
ws_cycles = nec_execute((ws_cyclesByLine >> 1) + (rand() & 7));
|
||||||
ws_cycles+=nec_execute((ws_cyclesByLine>>1)+(rand()&7));
|
ws_cycles += nec_execute((ws_cyclesByLine >> 1) + (rand() & 7));
|
||||||
|
|
||||||
if(ws_cycles>=ws_cyclesByLine+ws_cyclesByLine)
|
if (ws_cycles >= ws_cyclesByLine + ws_cyclesByLine)
|
||||||
{
|
{
|
||||||
ws_skip=ws_cycles/ws_cyclesByLine;
|
ws_skip = ws_cycles / ws_cyclesByLine;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ws_skip=1;
|
ws_skip = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_cycles%=ws_cyclesByLine;
|
ws_cycles %= ws_cyclesByLine;
|
||||||
|
|
||||||
for(uint32_t uI=0; uI<ws_skip; uI++)
|
for (uint32_t uI = 0 ; uI < ws_skip ; uI++)
|
||||||
{
|
{
|
||||||
if (renderLine)
|
if (renderLine)
|
||||||
{
|
{
|
||||||
ws_gpu_renderScanline(framebuffer);
|
ws_gpu_renderScanline(framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_gpu_scanline++;
|
ws_gpu_scanline++;
|
||||||
|
|
||||||
if(ws_gpu_scanline==144)
|
if (ws_gpu_scanline == 144)
|
||||||
{
|
{
|
||||||
drawWholeScreen=1;
|
drawWholeScreen = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ws_gpu_scanline>158)
|
if (ws_gpu_scanline > 158)
|
||||||
{
|
{
|
||||||
ws_gpu_scanline=0;
|
ws_gpu_scanline = 0;
|
||||||
{
|
{
|
||||||
if((ws_ioRam[0xb2]&32)) /* VBLANK Timer */
|
if ((ws_ioRam[0xb2] & 32)) /* VBLANK Timer */
|
||||||
{
|
{
|
||||||
/* TODO: REPAIR THAT SHIT */
|
/* TODO: REPAIR THAT SHIT */
|
||||||
ws_ioRam[0xb6]&=~32;
|
ws_ioRam[0xb6] &= ~32;
|
||||||
nec_int((ws_ioRam[0xb0]+5)*4);
|
nec_int((ws_ioRam[0xb0] + 5) * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_ioRam[2]=ws_gpu_scanline;
|
ws_ioRam[2] = ws_gpu_scanline;
|
||||||
|
|
||||||
if(drawWholeScreen)
|
if (drawWholeScreen)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(ws_ioRam[0xb2]&64) /* VBLANK INT */
|
if (ws_ioRam[0xb2] & 64) /* VBLANK INT */
|
||||||
{
|
{
|
||||||
ws_ioRam[0xb6]&=~64;
|
ws_ioRam[0xb6] &= ~64;
|
||||||
nec_int((ws_ioRam[0xb0]+6)*4);
|
nec_int((ws_ioRam[0xb0] + 6) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
vblank_count++;
|
vblank_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ws_ioRam[0xa4]&&(ws_ioRam[0xb2]&128)) /*HBLANK TMR*/
|
if (ws_ioRam[0xa4] && (ws_ioRam[0xb2] & 128)) /*HBLANK TMR*/
|
||||||
{
|
{
|
||||||
/* TODO: Check that shit */
|
/* TODO: Check that shit */
|
||||||
if(!ws_ioRam[0xa5])
|
if (!ws_ioRam[0xa5])
|
||||||
{
|
{
|
||||||
ws_ioRam[0xa5]=ws_ioRam[0xa4];
|
ws_ioRam[0xa5] = ws_ioRam[0xa4];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ws_ioRam[0xa5])
|
if (ws_ioRam[0xa5])
|
||||||
{
|
{
|
||||||
ws_ioRam[0xa5]--;
|
ws_ioRam[0xa5]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((!ws_ioRam[0xa5])&&(ws_ioRam[0xb2]&128))
|
if ((!ws_ioRam[0xa5]) && (ws_ioRam[0xb2] & 128))
|
||||||
{
|
{
|
||||||
|
|
||||||
ws_ioRam[0xb6]&=~128;
|
ws_ioRam[0xb6] &= ~128;
|
||||||
nec_int((ws_ioRam[0xb0]+7)*4);
|
nec_int((ws_ioRam[0xb0] + 7) * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ws_ioRam[0x2]==ws_ioRam[0x3])&&(ws_ioRam[0xb2]&16)) /*SCANLINE INT*/
|
if ((ws_ioRam[0x2] == ws_ioRam[0x3]) && (ws_ioRam[0xb2] & 16)) /*SCANLINE INT*/
|
||||||
{
|
{
|
||||||
ws_ioRam[0xb6]&=~16;
|
ws_ioRam[0xb6] &= ~16;
|
||||||
nec_int((ws_ioRam[0xb0]+4)*4);
|
nec_int((ws_ioRam[0xb0] + 4) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(drawWholeScreen);
|
return (drawWholeScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -278,11 +285,12 @@ int ws_executeLine(int16_t *framebuffer, int renderLine)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void ws_done(void)
|
void ws_done(void)
|
||||||
{
|
{
|
||||||
ws_memory_done();
|
ws_memory_done();
|
||||||
ws_io_done();
|
ws_io_done();
|
||||||
ws_audio_done();
|
ws_audio_done();
|
||||||
ws_gpu_done();
|
ws_gpu_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -318,67 +326,67 @@ wssystem_t ws_get_system()
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#define MacroLoadNecRegisterFromFile(F,R) \
|
#define MacroLoadNecRegisterFromFile(F, R) \
|
||||||
read(fp,&value,sizeof(value)); \
|
read(fp,&value,sizeof(value)); \
|
||||||
nec_set_reg(R,value);
|
nec_set_reg(R,value);
|
||||||
|
|
||||||
int ws_loadState(char *statepath)
|
int ws_loadState(char *statepath)
|
||||||
{
|
{
|
||||||
fprintf(log_get(),"loading %s\n",statepath);
|
fprintf(log_get(), "loading %s\n", statepath);
|
||||||
uint16_t crc=memory_getRomCrc();
|
uint16_t crc = memory_getRomCrc();
|
||||||
uint16_t newCrc;
|
uint16_t newCrc;
|
||||||
unsigned value;
|
unsigned value;
|
||||||
uint8_t ws_newVideoMode;
|
uint8_t ws_newVideoMode;
|
||||||
|
|
||||||
int fp = open(statepath, O_RDONLY);
|
int fp = open(statepath, O_RDONLY);
|
||||||
|
|
||||||
if (fp == -1)
|
if (fp == -1)
|
||||||
{
|
{
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
read(fp, &newCrc, 2);
|
read(fp, &newCrc, 2);
|
||||||
|
|
||||||
if (newCrc!=crc)
|
if (newCrc != crc)
|
||||||
{
|
{
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_IP);
|
MacroLoadNecRegisterFromFile(fp, NEC_IP);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_AW);
|
MacroLoadNecRegisterFromFile(fp, NEC_AW);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_BW);
|
MacroLoadNecRegisterFromFile(fp, NEC_BW);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_CW);
|
MacroLoadNecRegisterFromFile(fp, NEC_CW);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_DW);
|
MacroLoadNecRegisterFromFile(fp, NEC_DW);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_CS);
|
MacroLoadNecRegisterFromFile(fp, NEC_CS);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_DS);
|
MacroLoadNecRegisterFromFile(fp, NEC_DS);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_ES);
|
MacroLoadNecRegisterFromFile(fp, NEC_ES);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_SS);
|
MacroLoadNecRegisterFromFile(fp, NEC_SS);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_IX);
|
MacroLoadNecRegisterFromFile(fp, NEC_IX);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_IY);
|
MacroLoadNecRegisterFromFile(fp, NEC_IY);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_BP);
|
MacroLoadNecRegisterFromFile(fp, NEC_BP);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_SP);
|
MacroLoadNecRegisterFromFile(fp, NEC_SP);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_FLAGS);
|
MacroLoadNecRegisterFromFile(fp, NEC_FLAGS);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_VECTOR);
|
MacroLoadNecRegisterFromFile(fp, NEC_VECTOR);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_PENDING);
|
MacroLoadNecRegisterFromFile(fp, NEC_PENDING);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_NMI_STATE);
|
MacroLoadNecRegisterFromFile(fp, NEC_NMI_STATE);
|
||||||
MacroLoadNecRegisterFromFile(fp,NEC_IRQ_STATE);
|
MacroLoadNecRegisterFromFile(fp, NEC_IRQ_STATE);
|
||||||
|
|
||||||
read(fp,internalRam,65536);
|
read(fp, internalRam, 65536);
|
||||||
read(fp,ws_staticRam,65536);
|
read(fp, ws_staticRam, 65536);
|
||||||
read(fp,ws_ioRam,256);
|
read(fp, ws_ioRam, 256);
|
||||||
read(fp,ws_paletteColors,8);
|
read(fp, ws_paletteColors, 8);
|
||||||
read(fp,ws_palette,16*4*2);
|
read(fp, ws_palette, 16 * 4 * 2);
|
||||||
read(fp,wsc_palette,16*16*2);
|
read(fp, wsc_palette, 16 * 16 * 2);
|
||||||
read(fp,&ws_newVideoMode,1);
|
read(fp, &ws_newVideoMode, 1);
|
||||||
read(fp,&ws_gpu_scanline,1);
|
read(fp, &ws_gpu_scanline, 1);
|
||||||
read(fp,externalEeprom,131072);
|
read(fp, externalEeprom, 131072);
|
||||||
|
|
||||||
ws_audio_readState(fp);
|
ws_audio_readState(fp);
|
||||||
close(fp);
|
close(fp);
|
||||||
|
|
||||||
// force a video mode change to make all tiles dirty
|
// force a video mode change to make all tiles dirty
|
||||||
ws_gpu_clearCache();
|
ws_gpu_clearCache();
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -391,89 +399,90 @@ int ws_loadState(char *statepath)
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#define MacroStoreNecRegisterToFile(F,R) \
|
#define MacroStoreNecRegisterToFile(F, R) \
|
||||||
value=nec_get_reg(R); \
|
value=nec_get_reg(R); \
|
||||||
write(fp,&value,sizeof(value));
|
write(fp,&value,sizeof(value));
|
||||||
|
|
||||||
int ws_saveState(char *statepath)
|
int ws_saveState(char *statepath)
|
||||||
{
|
{
|
||||||
uint16_t crc=memory_getRomCrc();
|
uint16_t crc = memory_getRomCrc();
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
char newPath[1024];
|
char newPath[1024];
|
||||||
fprintf(log_get(),"saving %s\n",statepath);
|
fprintf(log_get(), "saving %s\n", statepath);
|
||||||
|
|
||||||
if (strlen(statepath)<4)
|
if (strlen(statepath) < 4)
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s.wss",statepath);
|
sprintf(newPath, "%s.wss", statepath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len=strlen(statepath);
|
int len = strlen(statepath);
|
||||||
|
|
||||||
if ((statepath[len-1]!='s')&&(statepath[len-1]!='S'))
|
if ((statepath[len - 1] != 's') && (statepath[len - 1] != 'S'))
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s.wss",statepath);
|
sprintf(newPath, "%s.wss", statepath);
|
||||||
}
|
}
|
||||||
else if ((statepath[len-2]!='s')&&(statepath[len-2]!='S'))
|
else if ((statepath[len - 2] != 's') && (statepath[len - 2] != 'S'))
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s.wss",statepath);
|
sprintf(newPath, "%s.wss", statepath);
|
||||||
}
|
}
|
||||||
else if ((statepath[len-3]!='w')&&(statepath[len-3]!='w'))
|
else if ((statepath[len - 3] != 'w') && (statepath[len - 3] != 'w'))
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s.wss",statepath);
|
sprintf(newPath, "%s.wss", statepath);
|
||||||
}
|
}
|
||||||
else if (statepath[len-4]!='.')
|
else if (statepath[len - 4] != '.')
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s.wss",statepath);
|
sprintf(newPath, "%s.wss", statepath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(newPath,"%s",statepath);
|
sprintf(newPath, "%s", statepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fp=open(newPath, O_RDWR|O_CREAT, 0644);
|
int fp = open(newPath, O_RDWR | O_CREAT, 0644);
|
||||||
|
|
||||||
if (fp==-1)
|
if (fp == -1)
|
||||||
{
|
{
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
write(fp,&crc,2);
|
write(fp, &crc, 2);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_IP);
|
MacroStoreNecRegisterToFile(fp, NEC_IP);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_AW);
|
MacroStoreNecRegisterToFile(fp, NEC_AW);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_BW);
|
MacroStoreNecRegisterToFile(fp, NEC_BW);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_CW);
|
MacroStoreNecRegisterToFile(fp, NEC_CW);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_DW);
|
MacroStoreNecRegisterToFile(fp, NEC_DW);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_CS);
|
MacroStoreNecRegisterToFile(fp, NEC_CS);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_DS);
|
MacroStoreNecRegisterToFile(fp, NEC_DS);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_ES);
|
MacroStoreNecRegisterToFile(fp, NEC_ES);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_SS);
|
MacroStoreNecRegisterToFile(fp, NEC_SS);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_IX);
|
MacroStoreNecRegisterToFile(fp, NEC_IX);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_IY);
|
MacroStoreNecRegisterToFile(fp, NEC_IY);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_BP);
|
MacroStoreNecRegisterToFile(fp, NEC_BP);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_SP);
|
MacroStoreNecRegisterToFile(fp, NEC_SP);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_FLAGS);
|
MacroStoreNecRegisterToFile(fp, NEC_FLAGS);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_VECTOR);
|
MacroStoreNecRegisterToFile(fp, NEC_VECTOR);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_PENDING);
|
MacroStoreNecRegisterToFile(fp, NEC_PENDING);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_NMI_STATE);
|
MacroStoreNecRegisterToFile(fp, NEC_NMI_STATE);
|
||||||
MacroStoreNecRegisterToFile(fp,NEC_IRQ_STATE);
|
MacroStoreNecRegisterToFile(fp, NEC_IRQ_STATE);
|
||||||
|
|
||||||
write(fp,internalRam,65536);
|
write(fp, internalRam, 65536);
|
||||||
write(fp,ws_staticRam,65536);
|
write(fp, ws_staticRam, 65536);
|
||||||
write(fp,ws_ioRam,256);
|
write(fp, ws_ioRam, 256);
|
||||||
write(fp,ws_paletteColors,8);
|
write(fp, ws_paletteColors, 8);
|
||||||
write(fp,ws_palette,16*4*2);
|
write(fp, ws_palette, 16 * 4 * 2);
|
||||||
write(fp,wsc_palette,16*16*2);
|
write(fp, wsc_palette, 16 * 16 * 2);
|
||||||
write(fp,&ws_videoMode,1);
|
write(fp, &ws_videoMode, 1);
|
||||||
write(fp,&ws_gpu_scanline,1);
|
write(fp, &ws_gpu_scanline, 1);
|
||||||
write(fp,externalEeprom,131072);
|
write(fp, externalEeprom, 131072);
|
||||||
|
|
||||||
ws_audio_writeState(fp);
|
ws_audio_writeState(fp);
|
||||||
close(fp);
|
close(fp);
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -487,8 +496,8 @@ int ws_saveState(char *statepath)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int ws_rotated(void)
|
int ws_rotated(void)
|
||||||
{
|
{
|
||||||
uint8_t *rom=memory_getRom();
|
uint8_t *rom = memory_getRom();
|
||||||
uint32_t romSize=memory_getRomSize();
|
uint32_t romSize = memory_getRomSize();
|
||||||
|
|
||||||
return(rom[romSize-4]&1);
|
return (rom[romSize - 4] & 1);
|
||||||
}
|
}
|
||||||
|
|||||||
39
source/ws.h
39
source/ws.h
@ -1,5 +1,10 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
/*
|
||||||
//
|
* NewOswan
|
||||||
|
* ws.h:
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -14,25 +19,23 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum wssystem_t {
|
typedef enum wssystem_t
|
||||||
WS_SYSTEM_AUTODETECT = 0,
|
{
|
||||||
WS_SYSTEM_MONO,
|
WS_SYSTEM_AUTODETECT = 0, WS_SYSTEM_MONO, WS_SYSTEM_COLOR, WS_SYSTEM_CRYSTAL,
|
||||||
WS_SYSTEM_COLOR,
|
|
||||||
WS_SYSTEM_CRYSTAL,
|
|
||||||
} wssystem_t;
|
} wssystem_t;
|
||||||
|
|
||||||
extern uint32_t ws_cyclesByLine;
|
extern uint32_t ws_cyclesByLine;
|
||||||
|
|
||||||
int ws_init(char *rompath);
|
int ws_init(char *rompath);
|
||||||
int ws_rotated(void);
|
int ws_rotated(void);
|
||||||
void ws_set_system(wssystem_t system);
|
void ws_set_system(wssystem_t system);
|
||||||
wssystem_t ws_get_system();
|
wssystem_t ws_get_system();
|
||||||
void ws_reset(void);
|
void ws_reset(void);
|
||||||
int ws_executeLine(int16_t *framebuffer, int renderLine);
|
int ws_executeLine(int16_t *framebuffer, int renderLine);
|
||||||
void ws_patchRom(void);
|
void ws_patchRom(void);
|
||||||
int ws_loadState(char *statepath);
|
int ws_loadState(char *statepath);
|
||||||
int ws_saveState(char *statepath);
|
int ws_saveState(char *statepath);
|
||||||
void ws_done(void);
|
void ws_done(void);
|
||||||
|
|
||||||
extern char *ws_sram_path;
|
extern char *ws_sram_path;
|
||||||
extern char *ws_ieep_path;
|
extern char *ws_ieep_path;
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* NewOswan
|
||||||
|
* testserial.c: A simple tool to test serial in/out
|
||||||
|
* Based on the original Oswan-unix
|
||||||
|
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user