Major code cleanup and code reformating

This commit is contained in:
Godzil 2021-04-05 14:19:35 +01:00
parent 4e5f796d6a
commit cc1060775c
28 changed files with 8068 additions and 7853 deletions

View File

@ -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 <stdint.h>
#include <stdlib.h>
@ -69,12 +76,11 @@ int main(int argc, char *argv[])
printf("%s:\n", argv[1]);
if (data->farjump[0] == 0xEA)
{
printf("[%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]",
data->publishId, data->gameId[0], data->gameId[1], data->flags2, data->romInfo, data->saveInfo,
data->flags & 0xFF, (data->flags>>8) & 0xFF, data->crc & 0xFF, (data->crc>>8) & 0xFF);
printf(" - Reset @ %02X%02X:%02X%02Xh\n",
data->farjump[4], data->farjump[3],
data->farjump[2], data->farjump[1]);
printf("[%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]", data->publishId, data->gameId[0],
data->gameId[1], data->flags2, data->romInfo, data->saveInfo, data->flags & 0xFF,
(data->flags >> 8) & 0xFF, data->crc & 0xFF, (data->crc >> 8) & 0xFF);
printf(" - Reset @ %02X%02X:%02X%02Xh\n", data->farjump[4], data->farjump[3], data->farjump[2],
data->farjump[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");
@ -82,10 +88,8 @@ int main(int argc, char *argv[])
printf(" - Is %sbootable on a normal swan\n", data->flagExt & 0x0F ? "not " : "");
printf(" - ROM Size: %02Xh\n", data->romInfo);
printf(" - Save type & Size: %02Xh\n", data->saveInfo);
printf(" - Flags: %d cycles ROM, %d bit ROM bus, %sRTC, %s orientation\n",
data->flags & 0x004?1:3,
data->flags & 0x002?8:16,
data->flags & 0x100?"":"No ",
printf(" - Flags: %d cycles ROM, %d bit ROM bus, %sRTC, %s orientation\n", data->flags & 0x004 ? 1 : 3,
data->flags & 0x002 ? 8 : 16, data->flags & 0x100 ? "" : "No ",
data->flags & 0x001 ? "Vertical" : "Horizontal");
printf(" - CRC: %04Xh\n", data->crc);
ret = 0;

28
main.c
View File

@ -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
@ -7,7 +12,7 @@
//
//
//
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
@ -38,14 +43,6 @@
////////////////////////////////////////////////////////////////////////////////
#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 ieep_path_explicit = 0;
@ -165,8 +162,7 @@ int main(int argc, char *argv[])
sram_path_explicit = 1;
break;
default:
break;
default:break;
}
}
else
@ -181,7 +177,6 @@ int main(int argc, char *argv[])
{
if (!ws_rom_path)
{
app_gameRunning=0;
exit(0);
}
@ -190,11 +185,6 @@ int main(int argc, char *argv[])
ws_set_system(ws_system);
if (ws_init(ws_rom_path))
{
app_rotated=ws_rotated();
app_gameRunning=1;
}
ws_reset();
ws_emulate();

View File

@ -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

View File

@ -1,5 +1,5 @@
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})

View File

@ -1,5 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
// Audio
/*
* NewOswan
* audio.c:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
////////////////////////////////////////////////////////////////////////////////
//
// Sound information thanks to toshi (wscamp wonderswan emulator)
@ -124,6 +129,7 @@ const long TblMainVol[4]= // 1,1/2,1/4,1/8
uint32_t ws_audio_channel_isPlaying[6];
static unsigned int ws_audio_log;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -143,6 +149,7 @@ void ws_audio_init(void)
//ws_audio_seal_init();
ws_audio_reset();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -175,6 +182,7 @@ void ws_audio_reset(void)
ws_audio_set_channel_frequency(4, 0);
ws_audio_set_channel_frequency(4, 1792);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -401,6 +409,7 @@ void ws_audio_port_write(uint32_t port, uint8_t value)
break;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -416,6 +425,7 @@ uint8_t ws_audio_port_read(uint8_t port)
{
return (ws_ioRam[port]);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -431,6 +441,7 @@ void ws_audio_done(void)
{
ws_audio_seal_done();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -452,9 +463,7 @@ unsigned int ws_audio_mrand(unsigned int Degree)
int Mask;
} POLYNOMIAL;
static POLYNOMIAL TblMask[]=
{
{ 2,BIT(2),BIT(0)|BIT(1)},
static POLYNOMIAL TblMask[] = {{2, BIT(2), BIT(0) | BIT(1)},
{3, BIT(3), BIT(0) | BIT(1)},
{4, BIT(4), BIT(0) | BIT(1)},
{5, BIT(5), BIT(0) | BIT(2)},
@ -682,6 +691,7 @@ int ws_audio_seal_init(void)
#endif
return 1;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -736,6 +746,7 @@ void ws_audio_seal_done(void)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -771,6 +782,7 @@ void ws_audio_clear_channel(int Channel)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
// start playing a channel
////////////////////////////////////////////////////////////////////////////////
@ -809,6 +821,7 @@ int ws_audio_play_channel(int Channel)
#endif
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// stop playing a channel
////////////////////////////////////////////////////////////////////////////////
@ -845,6 +858,7 @@ int ws_audio_stop_channel(int Channel)
#endif
return (0);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -900,6 +914,7 @@ void ws_audio_set_channel_frequency(int Channel,int Period)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -939,6 +954,7 @@ void ws_audio_set_channel_volume(int Channel,int Vol)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1014,6 +1030,7 @@ void ws_audio_set_channel_pan(int Channel,int Left,int Right)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1051,6 +1068,7 @@ void ws_audio_set_channel_pdata(int Channel,int Index)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1081,6 +1099,7 @@ void ws_audio_set_channels_pbuf(int Addr,int Data)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1102,6 +1121,7 @@ void ws_audio_rst_channel(int Channel)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1200,6 +1220,7 @@ void ws_audio_set_pcm(int Data)
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1241,6 +1262,7 @@ void ws_audio_flash_pcm(void)
PCMPos=0;
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1260,6 +1282,7 @@ void ws_audio_write_byte(uint32_t offset, uint8_t value)
internalRam[offset] = value;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1333,6 +1356,7 @@ void ws_audio_process(void)
ws_audio_set_pcm(b);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1433,6 +1457,7 @@ void ws_audio_readState(int fp)
read(fp,&lpnStatus,sizeof(int));
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* audio.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//

View File

@ -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 GL_SILENCE_DEPRECATION
#include <GLFW/glfw3.h>
/* "Apple" fix */
#ifndef GL_TEXTURE_RECTANGLE
@ -40,11 +46,7 @@
#include "memory.h"
char app_window_title[256];
int app_gameRunning=0;
int app_terminate = 0;
int app_fullscreen=0;
int app_rotated=0;
int ws_key_esc = 0;
@ -68,13 +70,13 @@ struct GLWindow_t
};
static GLWindow mainWindow;
static int window_num = 0;
static void ShowScreen(GLWindow *g, int w, int h)
{
glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
// glTexSubImage2D is faster when not using a texture range
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, g->videoMemory);
glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, g->videoMemory);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
@ -92,12 +94,14 @@ static void ShowScreen(GLWindow *g, int w, int h)
glFlush();
}
static void GLWindowInitEx(GLWindow *g, int w, int h)
{
g->WIDTH = w;
g->HEIGHT = h;
g->videoTexture = window_num++;
}
static void setupGL(GLWindow *g, int w, int h)
{
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);
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_MAG_FILTER, GL_NEAREST);
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);
}
void restoreGL(GLWindow *g)
{
//Tell OpenGL how to convert from coordinates to pixel values
@ -154,6 +155,7 @@ void restoreGL(GLWindow *g)
glEnable(GL_TEXTURE_RECTANGLE);
glDisable(GL_DEPTH_TEST);
}
static void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
{
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,
keyArray[key].debounced, keyArray[key].lastState);*/
}
static void sizeHandler(GLFWwindow *window, int xs, int ys)
{
glfwMakeContextCurrent(window);
glViewport(0, 0, xs, ys);
ShowScreen(&mainWindow, 244, 144);
}
static void error_callback(int error, const char *description)
{
puts(description);
}
static void initDisplay(GLWindow *g)
{
int h = g->HEIGHT;
@ -216,10 +221,12 @@ static void initDisplay(GLWindow *g)
glfwSetKeyCallback(g->windows, kbHandler);
glfwSetWindowSizeCallback(g->windows, sizeHandler);
}
static void clearScreen(GLWindow *g)
{
memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
}
static void updateScreen(GLWindow *g)
{
/* Update windows code */
@ -228,6 +235,7 @@ static void updateScreen(GLWindow *g)
glfwSwapBuffers(g->windows);
glfwPollEvents();
}
uint64_t getTicks()
{
struct timeval curTime;

View File

@ -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
#define EMULATE_H
#include <stdint.h>
#define KEY_ENTER 0x0D
#define KEY_SPACE 0x20
#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);
#endif /* EMULATE_H */

View File

@ -41,10 +41,7 @@ extern uint8_t *internalRam;
enum VideoModes
{
DISPLAY_MODE_GRAY = 0,
DISPLAY_MODE_2BPP = 4,
DISPLAY_MODE_P_4BPP = 7,
DISPLAY_MODE_L_4BPP = 6,
DISPLAY_MODE_GRAY = 0, DISPLAY_MODE_2BPP = 4, DISPLAY_MODE_P_4BPP = 7, DISPLAY_MODE_L_4BPP = 6,
};
////////////////////////////////////////////////////////////////////////////////
@ -60,14 +57,13 @@ enum VideoModes
////////////////////////////////////////////////////////////////////////////////
#define RGB555(R, G, B) ((((int)(R))<<10)|(((int)(G))<<5)|((int)(B)))
uint8_t ws_gpu_operatingInColor;
uint8_t ws_videoMode;
uint8_t ws_gpu_operatingInColor = 0;
uint8_t ws_videoMode = DISPLAY_MODE_GRAY;
uint8_t ws_gpu_scanline = 0;
int16_t ws_palette[16 * 4];
int8_t ws_paletteColors[8];
int16_t wsc_palette[16 * 16];
// white
#define SHADE_COLOR_RED 1.00
#define SHADE_COLOR_GREEN 1.00
@ -131,8 +127,8 @@ void ws_gpu_init(void)
memset(ws_modified_tile, 0x01, 1024);
memset(wsc_modified_tile, 0x01, 1024);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -153,6 +149,7 @@ void ws_gpu_done(void)
free(ws_modified_tile);
free(wsc_modified_tile);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -195,6 +192,7 @@ void ws_gpu_reset(void)
ws_gpu_scanline = 0;
ws_gpu_changeVideoMode(0x00);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -210,6 +208,7 @@ void ws_gpu_clearCache(void)
{
memset(ws_modified_tile, 0x01, 1024);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -221,8 +220,7 @@ void ws_gpu_clearCache(void)
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line,
uint32_t vFlip, uint32_t hFlip, uint32_t bank)
uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line, uint32_t vFlip, uint32_t hFlip, uint32_t bank)
{
if (ws_gpu_operatingInColor)
{
@ -316,7 +314,6 @@ uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line,
tileInCachePtr += 8;
hflippedTileInCachePtr += 8;
}
}
else
@ -353,7 +350,6 @@ uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line,
hflippedTileInCachePtr += 8;
}
}
else
{
@ -435,6 +431,7 @@ uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line,
return (NULL);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -446,10 +443,9 @@ uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line,
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_drawClippedSpriteLine(int16_t *framebuffer, uint16_t scanline,
uint32_t x, uint32_t y, uint32_t tileIndex, uint32_t paletteIndex,
uint32_t vFlip, uint32_t hFlip,
uint32_t clip_x0, uint32_t clip_y0, uint32_t clip_x1, uint32_t clip_y1)
void ws_drawClippedSpriteLine(int16_t *framebuffer, uint16_t scanline, uint32_t x, uint32_t y, uint32_t tileIndex,
uint32_t paletteIndex, uint32_t vFlip, uint32_t hFlip, uint32_t clip_x0, uint32_t clip_y0,
uint32_t clip_x1, uint32_t clip_y1)
{
if ((scanline < y) || (scanline > (y + 7)))
@ -530,6 +526,7 @@ void ws_drawClippedSpriteLine(int16_t *framebuffer, uint16_t scanline,
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -548,7 +545,6 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
return;
}
framebuffer += (224 * ws_gpu_scanline);
// fill with background color
@ -560,7 +556,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
}
else
{
backgroundColor=ws_shades[ws_paletteColors[ws_palette[((ws_ioRam[0x01]&0xf0)>>2)+(ws_ioRam[0x01]&0x03)]]];
backgroundColor = ws_shades[ws_paletteColors[ws_palette[((ws_ioRam[0x01] & 0xf0) >> 2) +
(ws_ioRam[0x01] & 0x03)]]];
}
for (int i = 0 ; i < 224 ; i++)
@ -568,7 +565,6 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
framebuffer[i] = backgroundColor;
}
// render background layer
if (ws_ioRam[0x00] & 0x01)
{
@ -595,7 +591,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
ws_tileRow += columnInTile;
@ -623,7 +620,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
if (*ws_tileRow)
@ -696,8 +694,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -720,8 +718,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
ws_tileRow += columnInTile;
@ -761,8 +759,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
if ((tileInfo >> 9) & 0x04)
@ -866,8 +864,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_bgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
@ -897,7 +895,6 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
}
}
// render sprites which are between both layers
if (ws_ioRam[0x00] & 0x04)
{
@ -919,14 +916,16 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
// sprite window on ?
if ((ws_ioRam[0x00] & 0x08) && (spr & 0x1000) && (ws_sprWindow_x0 != ws_sprWindow_x1))
{
ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16,
spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000,
ws_sprWindow_x0,ws_sprWindow_y0,ws_sprWindow_x1,ws_sprWindow_y1);
ws_drawClippedSpriteLine(framebuffer, ws_gpu_scanline, (spr & 0xff000000) >> 24,
(spr & 0x00ff0000) >> 16, spr & 0x1ff, 8 + ((spr & 0xe00) >> 9),
spr & 0x4000, spr & 0x8000, ws_sprWindow_x0, ws_sprWindow_y0,
ws_sprWindow_x1, ws_sprWindow_y1);
}
else
{
ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16,
spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000,
ws_drawClippedSpriteLine(framebuffer, ws_gpu_scanline, (spr & 0xff000000) >> 24,
(spr & 0x00ff0000) >> 16, spr & 0x1ff, 8 + ((spr & 0xe00) >> 9),
spr & 0x4000, spr & 0x8000,
//0,0,224,144);
0, 0, 224, 0);
}
@ -968,11 +967,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow(
tileInfo&0x1ff, lineInTile,
tileInfo&0x8000,
tileInfo&0x4000,
tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -1002,8 +998,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -1077,8 +1073,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -1101,8 +1097,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
ws_tileRow += columnInTile;
@ -1142,8 +1138,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
if ((tileInfo >> 9) & 0x04)
@ -1246,8 +1242,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
@ -1290,8 +1286,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
ws_tileRow += columnInTile;
@ -1321,12 +1317,11 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
if ((*ws_tileRow) && (column >= ws_fgWindow_x0) && (column <= ws_fgWindow_x1))
{
*scanlinePtr = wsc_paletteAlias[*ws_tileRow];
@ -1405,8 +1400,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -1430,8 +1425,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
ws_tileRow += columnInTile;
@ -1460,8 +1455,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
@ -1543,8 +1538,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
@ -1576,8 +1571,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
ws_tileRow += columnInTile;
@ -1607,12 +1602,11 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
if ((*ws_tileRow) && ((column < ws_fgWindow_x0) || (column > ws_fgWindow_x1)))
{
*scanlinePtr = wsc_paletteAlias[*ws_tileRow];
@ -1691,8 +1685,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *wsc_paletteAlias = &wsc_palette[((tileInfo >> 9) & 0x0f) << 4];
@ -1716,8 +1710,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
ws_tileRow += columnInTile;
@ -1746,7 +1740,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
if ((*ws_tileRow) && ((column < ws_fgWindow_x0) || (column > ws_fgWindow_x1)))
@ -1827,8 +1822,8 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
{
uint16_t tileInfo = ws_fgScrollRamBase[ws_currentTile & 0x1f];
ws_currentTile++;
uint8_t *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile,
tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000);
uint8_t *ws_tileRow = ws_tileCache_getTileRow(tileInfo & 0x1ff, lineInTile, tileInfo & 0x8000,
tileInfo & 0x4000, tileInfo & 0x2000);
int16_t *ws_paletteAlias = &ws_palette[((tileInfo >> 9) & 0x0f) << 2];
@ -1852,7 +1847,6 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
}
}
// render sprites
if (ws_ioRam[0x00] & 0x04)
{
@ -1874,14 +1868,16 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
// sprite window on ?
if ((ws_ioRam[0x00] & 0x08) && (spr & 0x1000) && (ws_sprWindow_x0 != ws_sprWindow_x1))
{
ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16,
spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000,
ws_sprWindow_x0,ws_sprWindow_y0,ws_sprWindow_x1,ws_sprWindow_y1);
ws_drawClippedSpriteLine(framebuffer, ws_gpu_scanline, (spr & 0xff000000) >> 24,
(spr & 0x00ff0000) >> 16, spr & 0x1ff, 8 + ((spr & 0xe00) >> 9),
spr & 0x4000, spr & 0x8000, ws_sprWindow_x0, ws_sprWindow_y0,
ws_sprWindow_x1, ws_sprWindow_y1);
}
else
{
ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16,
spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000,
ws_drawClippedSpriteLine(framebuffer, ws_gpu_scanline, (spr & 0xff000000) >> 24,
(spr & 0x00ff0000) >> 16, spr & 0x1ff, 8 + ((spr & 0xe00) >> 9),
spr & 0x4000, spr & 0x8000,
// 0,0,224,144);
0, 0, 224, 0);
}
@ -1889,6 +1885,7 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -1946,7 +1943,8 @@ void ws_gpu_write_byte(uint32_t offset, uint8_t value)
color <<= 8;
color |= (internalRam[(offset & 0xfffe)]);
wsc_palette[(offset&0x1ff)>>1]=RGB555(((color>>8)&0x0f)<<1,((color>>4)&0x0f)<<1,(color&0x0f)<<1);
wsc_palette[(offset & 0x1ff) >> 1] = RGB555(((color >> 8) & 0x0f) << 1, ((color >> 4) & 0x0f) << 1,
(color & 0x0f) << 1);
}
}
else if (offset < 0x4000)
@ -1954,6 +1952,7 @@ void ws_gpu_write_byte(uint32_t offset, uint8_t value)
internalRam[offset] = value;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,23 +1,15 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
/*
* NewOswan
* gpu.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
#ifndef __GPU_H__
#define __GPU_H__
#include <stdint.h>
#define COLOUR_SCHEME_DEFAULT 0
#define COLOUR_SCHEME_AMBER 1
#define COLOUR_SCHEME_GREEN 2
extern uint8_t ws_gpu_scanline;
extern uint8_t ws_gpu_operatingInColor;
extern uint8_t ws_videoMode;
@ -28,7 +20,6 @@ extern unsigned int ws_gpu_unknownPort;
extern uint32_t vblank_count;
void ws_gpu_init(void);
void ws_gpu_done(void);
void ws_gpu_reset(void);

View File

@ -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
};

View File

@ -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 <stdlib.h>
#include <stdint.h>
@ -50,16 +54,8 @@ enum
EEPROM_WRITEENABLE /* 00 11 */
};
char *eii_CommandName[] =
{
"SUB",
"WRI",
"RED",
"ERA",
"WRD",
"WRA",
"ERL",
"WRE",
char *eii_CommandName[] = {
"SUB", "WRI", "RED", "ERA", "WRD", "WRA", "ERL", "WRE",
};
uint8_t iee_WriteEnable = false;
@ -135,6 +131,7 @@ void ws_io_reset(void)
rtcDataRegisterReadCount = 0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -160,6 +157,7 @@ void ws_io_init(void)
ioLogFp = fopen("iodump.csv", "wt");
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -175,6 +173,7 @@ void ws_io_flipControls(void)
{
ws_key_flipped = !ws_key_flipped;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -206,6 +205,7 @@ int serialfd = -1;
int serial_have_data = 0;
unsigned char serial_data = 0;
int serial_speed = BDR_9600;
void open_serial()
{
if (serialfd < 0)
@ -390,10 +390,12 @@ uint8_t cpu_readport(uint8_t port)
case 0x91:
case 0x92:
case 0x93:
case 0x94:retVal = ws_audio_port_read(port);
case 0x94:
retVal = ws_audio_port_read(port);
break;
case 0xb5:w1 = ws_ioRam[0xb5];
case 0xb5:
w1 = ws_ioRam[0xb5];
if (w1 & 0x40)
{
@ -445,10 +447,12 @@ uint8_t cpu_readport(uint8_t port)
{
case WS_SYSTEM_AUTODETECT:
case WS_SYSTEM_MONO:
case WS_SYSTEM_COLOR:retVal = 0x00;
case WS_SYSTEM_COLOR:
retVal = 0x00;
break;
case WS_SYSTEM_CRYSTAL:retVal = 0x80;
case WS_SYSTEM_CRYSTAL:
retVal = 0x80;
break;
}
break;
@ -509,31 +513,38 @@ uint8_t cpu_readport(uint8_t port)
switch (rtcDataRegisterReadCount)
{
case 0:rtcDataRegisterReadCount++;
case 0:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_year - 100);
goto exit;
case 1:rtcDataRegisterReadCount++;
case 1:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_mon);
goto exit;
case 2:rtcDataRegisterReadCount++;
case 2:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_mday);
goto exit;
case 3:rtcDataRegisterReadCount++;
case 3:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_wday);
goto exit;
case 4:rtcDataRegisterReadCount++;
case 4:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_hour);
goto exit;
case 5:rtcDataRegisterReadCount++;
case 5:
rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_min);
goto exit;
case 6:rtcDataRegisterReadCount = 0;
case 6:
rtcDataRegisterReadCount = 0;
retVal = BCD(newtime->tm_sec);
goto exit;
}
@ -547,15 +558,18 @@ uint8_t cpu_readport(uint8_t port)
goto exit;
}
case 0xD0:retVal = 0;
case 0xD0:
retVal = 0;
goto exit;
/* Serial port link.. */
case 0xB1:retVal = read_serial();
case 0xB1:
retVal = read_serial();
printf("RS232: Read %02X\n", retVal);
goto exit;
case 0xB3:check_serial_data();
case 0xB3:
check_serial_data();
if (ws_ioRam[0xB3] & 0x80)
{
@ -572,10 +586,12 @@ uint8_t cpu_readport(uint8_t port)
goto exit;
case 0xCC:
case 0xCD:retVal = 0;
case 0xCD:
retVal = 0;
break;
default:retVal = ws_ioRam[port];
default:
retVal = ws_ioRam[port];
if (port > 0xD0)
{
printf("ReadIO %02X <= %02X\n", port, retVal);
@ -586,7 +602,8 @@ uint8_t cpu_readport(uint8_t port)
case 0xAA:
case 0xAB:
case 0xAC:
case 0xAD:retVal = ws_gpu_port_read(port);
case 0xAD:
retVal = ws_gpu_port_read(port);
break;
}
@ -645,7 +662,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
switch (port)
{
/* GPU IOs */
case 0x00:break;
case 0x00:
break;
case 0x04:
case 0x07:
@ -666,7 +684,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
case 0x11:
case 0x12:
case 0x13:
case 0x14:break;
case 0x14:
break;
case 0x15:
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 0x24:
case 0x2E:
case 0x37:break;
case 0x37:
break;
/* DMAs */
case 0x40:
@ -718,7 +738,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
case 0x44:
case 0x45:
case 0x46:
case 0x47:break;
case 0x47:
break;
case 0x48: // DMA
@ -753,14 +774,17 @@ void cpu_writeport(uint32_t port, uint8_t value)
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:ws_audio_port_write(port, value);
case 0x4f:
ws_audio_port_write(port, value);
break;
/* DMA Start! */
case 0x52:break;
case 0x52:
break;
/* GPU (again) */
case 0x60:break;
case 0x60:
break;
/* System */
case 0x62:
printf("HeyHo!");
@ -797,7 +821,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
case 0x9B:
case 0x9C:
case 0x9D:
case 0x9E:ws_audio_port_write(port, value);
case 0x9E:
ws_audio_port_write(port, value);
break;
/* Hardware */
@ -815,17 +840,20 @@ void cpu_writeport(uint32_t port, uint8_t value)
case 0xA8:
case 0xA9:
case 0xAA:
case 0xAB:break;
case 0xAB:
break;
/* Intc */
case 0xB0:
case 0xB2:
case 0xB4:
case 0xB6:break;
case 0xB6:
break;
/* Serial */
case 0xB1:write_serial(value);
case 0xB1:
write_serial(value);
break;
case 0xB3:
@ -850,7 +878,8 @@ void cpu_writeport(uint32_t port, uint8_t value)
break;
/* buttons */
case 0xB5:break;
case 0xB5:
break;
/* Internal EEPROM */
case 0xba: /* DATA Low */

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* io.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* log.c:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//
@ -37,6 +42,7 @@ int log_init(char *path)
return (1);
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
@ -51,6 +57,7 @@ FILE *log_get(void)
{
return (log_stream);
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* log.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//

View File

@ -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
//
@ -16,6 +21,7 @@
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -29,7 +35,6 @@
#include "gpu.h"
#include "audio.h"
#include "memory.h"
#include <stdbool.h>
////////////////////////////////////////////////////////////////////////////////
//
@ -62,6 +67,7 @@ extern uint8_t *ws_ioRam;
uint16_t ws_rom_checksum;
uint8_t ws_haveCrystalIRom;
uint8_t ws_haveColorIRom;
uint8_t ws_haveBWIRom;
@ -149,6 +155,7 @@ void cpu_writemem20(uint32_t addr, uint8_t value)
// other banks are read-only
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -206,7 +213,8 @@ uint8_t cpu_readmem20(uint32_t addr)
temp &= (romSize - 1);
return ws_rom[temp];
case 0xF:hwReg = ws_ioRam[0xA0];
case 0xF:
hwReg = ws_ioRam[0xA0];
if (!(hwReg & 1))
{
@ -237,7 +245,8 @@ uint8_t cpu_readmem20(uint32_t addr)
}
// fall through
default:hwReg = ws_ioRam[0xC0];
default:
hwReg = ws_ioRam[0xC0];
temp = hwReg << 20;
temp += addr & 0xFFFFF;
temp &= (romSize - 1);
@ -246,6 +255,7 @@ uint8_t cpu_readmem20(uint32_t addr)
return (0x90);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -280,6 +290,7 @@ char *load_file(char *filename)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -326,6 +337,7 @@ char *create_file(char *filename, uint32_t size)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -403,6 +415,7 @@ void ws_memory_init(uint8_t *rom, uint32_t wsRomSize)
romAddressMask = romSize - 1;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -418,6 +431,7 @@ void ws_memory_reset(void)
{
memset(internalRam, 0, 0x10000);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -433,6 +447,7 @@ void ws_memory_done(void)
{
free(internalRam);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -448,6 +463,7 @@ uint8_t *memory_getRom(void)
{
return (ws_rom);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -463,6 +479,7 @@ uint32_t memory_getRomSize(void)
{
return (romSize);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* memory.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,28 @@
/*
* NewOswan
* nec.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
#ifndef __NEC_H_
#define __NEC_H_
#include <stdint.h>
#include "necintrf.h"
typedef enum { 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;
typedef enum
{
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)
typedef union
@ -15,6 +31,7 @@ typedef union
uint16_t w[8]; /* viewed as 16 bits registers */
uint8_t b[16]; /* or as 8 bit registers */
} necbasicregs;
typedef struct
{
necbasicregs regs;
@ -60,8 +77,6 @@ typedef struct
#define SetAF(x, y, z) (I.AuxVal = ((x) ^ ((y) ^ (z))) & 0x10)
#define SetSF(x) (I.SignVal = (x))
#define SetZF(x) (I.ZeroVal = (x))
#define SetPF(x) (I.ParityVal = (x))
@ -172,7 +187,6 @@ typedef struct
}
#define IncWordReg(Reg) \
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
uint16_t tmp1 = tmp+1; \
@ -182,7 +196,6 @@ typedef struct
I.regs.w[Reg]=tmp1
#define DecWordReg(Reg) \
uint16_t tmp = (uint16_t)I.regs.w[Reg]; \
uint16_t tmp1 = tmp-1; \

View File

@ -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 uint16_t EO;
@ -9,36 +16,42 @@ static unsigned EA_000(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_001(void)
{
EO = I.regs.w[BW] + I.regs.w[IY];
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_002(void)
{
EO = I.regs.w[BP] + I.regs.w[IX];
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_003(void)
{
EO = I.regs.w[BP] + I.regs.w[IY];
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_004(void)
{
EO = I.regs.w[IX];
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_005(void)
{
EO = I.regs.w[IY];
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_006(void)
{
EO = FETCH;
@ -46,6 +59,7 @@ static unsigned EA_006(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_007(void)
{
EO = I.regs.w[BW];
@ -59,42 +73,49 @@ static unsigned EA_100(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_101(void)
{
EO = (I.regs.w[BW] + I.regs.w[IY] + (int8_t)FETCH);
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_102(void)
{
EO = (I.regs.w[BP] + I.regs.w[IX] + (int8_t)FETCH);
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_103(void)
{
EO = (I.regs.w[BP] + I.regs.w[IY] + (int8_t)FETCH);
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_104(void)
{
EO = (I.regs.w[IX] + (int8_t)FETCH);
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_105(void)
{
EO = (I.regs.w[IY] + (int8_t)FETCH);
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_106(void)
{
EO = (I.regs.w[BP] + (int8_t)FETCH);
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_107(void)
{
EO = (I.regs.w[BW] + (int8_t)FETCH);
@ -110,6 +131,7 @@ static unsigned EA_200(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_201(void)
{
E16 = FETCH;
@ -118,6 +140,7 @@ static unsigned EA_201(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_202(void)
{
E16 = FETCH;
@ -126,6 +149,7 @@ static unsigned EA_202(void)
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_203(void)
{
E16 = FETCH;
@ -134,6 +158,7 @@ static unsigned EA_203(void)
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_204(void)
{
E16 = FETCH;
@ -142,6 +167,7 @@ static unsigned EA_204(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_205(void)
{
E16 = FETCH;
@ -150,6 +176,7 @@ static unsigned EA_205(void)
EA = DefaultBase(DS) + EO;
return EA;
}
static unsigned EA_206(void)
{
E16 = FETCH;
@ -158,6 +185,7 @@ static unsigned EA_206(void)
EA = DefaultBase(SS) + EO;
return EA;
}
static unsigned EA_207(void)
{
E16 = FETCH;
@ -169,30 +197,21 @@ static unsigned EA_207(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_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_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_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_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_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, 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
};

View File

@ -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_wr16(void);
static void i_add_r8b(void);
@ -263,7 +271,7 @@ void (*nec_instruction[256])(void) =
i_or_ald8, /* 0x0c */
i_or_axd16, /* 0x0d */
i_push_cs, /* 0x0e */
i_pre_nec /* 0x0f */,
i_pre_nec, /* 0x0f */
i_adc_br8, /* 0x10 */
i_adc_wr16, /* 0x11 */
i_adc_r8b, /* 0x12 */
@ -462,7 +470,7 @@ void (*nec_instruction[256])(void) =
i_rotshft_wcl, /* 0xd3 */
i_aam, /* 0xd4 */
i_aad, /* 0xd5 */
i_setalc,
i_setalc, /* 0xd6 */
i_trans, /* 0xd7 */
i_fpo, /* 0xd8 */
i_fpo, /* 0xd9 */

View File

@ -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 */
#ifndef __NECITRF_H_
#define __NECITRF_H_
@ -6,60 +13,30 @@
enum
{
NEC_IP=1, NEC_AW, 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
NEC_IP = 1,
NEC_AW,
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 */
extern int nec_ICount;
/* 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_reg(int regnum, uint32_t val);
int nec_execute(int cycles);

View File

@ -1,3 +1,11 @@
/*
* NewOswan
* necmodrm.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
static struct
{
struct

View File

@ -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 "rom.h"
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -57,6 +61,7 @@ uint8_t *ws_rom_load(char *path, uint32_t *romSize)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -74,7 +79,8 @@ void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t romSize)
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: minimum system %s\n",(romHeader->minimumSupportSystem==0)?"Wonderswan mono":"Wonderswan color");
fprintf(log_get(), "rom: minimum system %s\n",
(romHeader->minimumSupportSystem == 0) ? "Wonderswan mono" : "Wonderswan color");
fprintf(log_get(), "rom: size %i Mbits\n", (romSize >> 20) << 3);
fprintf(log_get(), "rom: eeprom ");
@ -150,6 +156,7 @@ ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
return (wsromHeader);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -182,6 +189,7 @@ uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
return (0);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* rom.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//
@ -32,7 +37,6 @@
#define WS_SRAM_SIZE_16k 20
#define WS_SRAM_SIZE_8k 50
typedef struct ws_romHeaderStruct
{
uint8_t developperId;
@ -45,7 +49,6 @@ typedef struct ws_romHeaderStruct
uint16_t checksum;
} ws_romHeaderStruct;
uint8_t *ws_rom_load(char *path, uint32_t *romSize);
void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t wsromSize);
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize);
@ -53,4 +56,3 @@ uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize);
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize);
#endif

View File

@ -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.
*
*/
////////////////////////////////////////////////////////////////////////////////
//
//
@ -100,7 +105,6 @@ int ws_init(char *rompath)
return (0);
}
ws_memory_init(rom, romSize);
ws_patchRom();
@ -138,6 +142,7 @@ int ws_init(char *rompath)
return (1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -158,6 +163,7 @@ void ws_reset(void)
nec_reset(NULL);
nec_set_reg(NEC_SP, 0x2000);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -265,6 +271,7 @@ int ws_executeLine(int16_t *framebuffer, int renderLine)
return (drawWholeScreen);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -283,6 +290,7 @@ void ws_done(void)
ws_audio_done();
ws_gpu_done();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
@ -474,6 +482,7 @@ int ws_saveState(char *statepath)
return (1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,10 @@
//////////////////////////////////////////////////////////////////////////////
//
/*
* NewOswan
* ws.h:
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
//////////////////////////////////////////////////////////////////////////////
//
//
@ -14,11 +19,9 @@
#include <stdint.h>
typedef enum wssystem_t {
WS_SYSTEM_AUTODETECT = 0,
WS_SYSTEM_MONO,
WS_SYSTEM_COLOR,
WS_SYSTEM_CRYSTAL,
typedef enum wssystem_t
{
WS_SYSTEM_AUTODETECT = 0, WS_SYSTEM_MONO, WS_SYSTEM_COLOR, WS_SYSTEM_CRYSTAL,
} wssystem_t;
extern uint32_t ws_cyclesByLine;

View File

@ -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 <stdlib.h>
#include <string.h>