Mostly cosmetic changes

Update headers year
Remove useless /// headers that eat lines for no reasons
Fixed build issues because of stupid me doing stupid stuff in prototypes.
Added color and mono GPU stub.
Also a tad of code cleaning.
This commit is contained in:
Godzil 2022-03-14 14:50:41 +00:00
parent 6f56a8efda
commit 2305ce975b
39 changed files with 140 additions and 1017 deletions

View File

@ -2,7 +2,7 @@
* NewOswan
* dumpinfo.c: Tool to dump the metadata info about a cart rom image.
*
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/

36
main.c
View File

@ -1,20 +1,12 @@
/******************************************************************************
* NewOswan
* main.c: Entry point
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
//
// 13.04.2002: Fixed a small bug causing crashes
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -31,17 +23,6 @@
#include <emulate.h>
#include <audio.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define LOG_PATH "oswan.log"
int sram_path_explicit = 0;
@ -103,18 +84,6 @@ int ws_mk_ieppath()
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
wssystem_t ws_system = WS_SYSTEM_AUTODETECT;
@ -191,4 +160,3 @@ int main(int argc, char *argv[])
return (0);
}

View File

@ -1,20 +1,12 @@
/*******************************************************************************
* NewOswan
* emulate.c:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -410,17 +402,6 @@ double getTicks()
return ticks;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate(void)
{
int32_t nCount = 0;

View File

@ -1,26 +1,12 @@
/*******************************************************************************
* NewOswan
* gpu.c:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// GPU
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// 7.04.2002: Fixed sprites order
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -35,17 +21,6 @@
#include <ws.h>
#include <memory.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
extern uint8_t *internalRam;
enum VideoModes
@ -53,17 +28,6 @@ enum VideoModes
DISPLAY_MODE_GRAY = 0, DISPLAY_MODE_2BPP = 4, DISPLAY_MODE_P_4BPP = 7, DISPLAY_MODE_L_4BPP = 6,
};
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define RGB555(R, G, B) ((((int)(R))<<10)|(((int)(G))<<5)|((int)(B)))
uint8_t ws_gpu_operatingInColor = 0;
@ -106,17 +70,6 @@ uint8_t *wsc_hflipped_tile_cache;
uint8_t *ws_modified_tile;
uint8_t *wsc_modified_tile;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_init(void)
{
ws_tile_cache = (uint8_t *)malloc(1024 * 8 * 8);
@ -138,17 +91,6 @@ void ws_gpu_init(void)
memset(wsc_modified_tile, 0x01, 1024);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_done(void)
{
free(ws_tile_cache);
@ -159,17 +101,6 @@ void ws_gpu_done(void)
free(wsc_modified_tile);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_changeVideoMode(uint8_t value)
{
if (ws_videoMode != (value >> 5))
@ -190,17 +121,6 @@ void ws_gpu_changeVideoMode(uint8_t value)
(value & 0x20)?"Packed":"Planar");
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_reset(void)
{
memset(ws_modified_tile, 0x01, 1024);
@ -208,33 +128,11 @@ void ws_gpu_reset(void)
ws_gpu_changeVideoMode(0x00);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_clearCache(void)
{
memset(ws_modified_tile, 0x01, 1024);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line, uint32_t vFlip, uint32_t hFlip, uint32_t bank)
{
if (ws_gpu_operatingInColor)
@ -447,17 +345,6 @@ uint8_t *ws_tileCache_getTileRow(uint32_t tileIndex, uint32_t line, uint32_t vFl
return (NULL);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
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)
@ -542,17 +429,6 @@ void ws_drawClippedSpriteLine(int16_t *framebuffer, uint16_t scanline, uint32_t
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_renderScanline(int16_t *framebuffer)
{
@ -1901,17 +1777,6 @@ void ws_gpu_renderScanline(int16_t *framebuffer)
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_gpu_write_byte(uint32_t offset, uint8_t value)
{
// ws 4 color tiles
@ -1968,17 +1833,6 @@ void ws_gpu_write_byte(uint32_t offset, uint8_t value)
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
unsigned int ws_gpu_unknownPort;
int ws_gpu_port_write(uint32_t port, uint8_t value)
@ -2038,17 +1892,6 @@ int ws_gpu_port_write(uint32_t port, uint8_t value)
return ws_gpu_unknownPort;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t ws_gpu_port_read(uint8_t port)
{
switch (port)

View File

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

View File

@ -1,11 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* device.h:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/
#ifndef NEWOSWAN_DEVICE_H
#define NEWOSWAN_DEVICE_H

View File

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

View File

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

View File

@ -1,8 +1,9 @@
/*******************************************************************************
* NewOswan
* io.h:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
@ -44,7 +45,7 @@ void io_writeport(uint8_t port, uint8_t value);
typedef uint8_t (*io_read)(void *pdata, uint8_t port);
typedef void (*io_write)(void *pdata, uint8_t port, uint8_t value);
void register_io_hook(uint8_t port, io_read *readHook, io_write writeHook, void *pdata);
void register_io_hook_array(uint8_t *portList, uint8_t listLen, io_read *readHook, io_write writeHook, void *pdata);
void register_io_hook(uint8_t port, io_read readHook, io_write writeHook, void *pdata);
void register_io_hook_array(uint8_t *portList, uint8_t listLen, io_read readHook, io_write writeHook, void *pdata);
#endif

View File

@ -1,9 +1,10 @@
/*******************************************************************************
* NewOswan
* log.h: C Fancy Logger
* Copyright (c) 2009-2021 986-Studio. All rights reserved.
*
* Created by Manoël Trapier on 20/01/2009.
* Copyright (c) 2009-2022 986-Studio. All rights reserved.
*
******************************************************************************/
#ifndef _LOG_H

View File

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

View File

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

View File

@ -1,10 +1,11 @@
/*
/******************************************************************************
* NewOswan
* nec_debugger.h:
* Created by Manoël Trapier on 14/04/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
* Created by Manoël Trapier on 14/04/2021.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
#ifndef NEWOSWAN_SOURCE_NEC_NEC_DEBUGGER_H
#define NEWOSWAN_SOURCE_NEC_NEC_DEBUGGER_H

View File

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

View File

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

View File

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

View File

@ -1,19 +1,12 @@
/*******************************************************************************
* NewOswan
* io.c: I/O ports implementaton
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -47,8 +40,6 @@ extern nec_Regs I;
extern uint64_t nec_monotonicCycles;
extern uint32_t sramSize;
uint8_t *ws_ioRam = NULL;
uint8_t ws_key_start;
uint8_t ws_key_x4;
uint8_t ws_key_x2;
@ -64,17 +55,6 @@ uint8_t ws_key_flipped;
FILE *ioLogFp = NULL;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void io_reset(void)
{
ws_key_start = 0;
@ -88,42 +68,10 @@ void io_reset(void)
ws_key_y3 = 0;
ws_key_button_a = 0;
ws_key_button_b = 0;
int i;
for (i = 0 ; i < 0x100 ; i++)
{
/*
* 0x90 should probably be a better value as for some reason
* the Swan seems to like to returh 0x90 for not connected memory/IO
* Keep 0x00 for now until the whole IO "default" value is solved.
*/
ws_ioRam[i] = 0x00;
}
ws_ioRam[0xC0] = 0xFF;
ws_ioRam[0xC1] = 0xFF;
ws_ioRam[0xC2] = 0xFF;
ws_ioRam[0xC3] = 0xFF;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void io_init(void)
{
if (ws_ioRam == NULL)
{
ws_ioRam = (uint8_t *)malloc(0x100);
}
io_reset();
ws_key_flipped = 0;
@ -132,33 +80,11 @@ void io_init(void)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void io_flipControls(void)
{
ws_key_flipped = !ws_key_flipped;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void io_done(void)
{
if (ws_ioRam == NULL)
@ -171,42 +97,14 @@ void io_done(void)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t io_readport_new(uint8_t port)
{
if (io_registry[port].read)
{
return io_registry[port].read(io_registry[port].private, port);
}
return 0x90;
}
void io_writeport_new(uint8_t port, uint8_t value)
{
if (io_registry[port].write)
{
return io_registry[port].write(io_registry[port].private, port, value);
}
}
void register_io_hook(uint8_t port, io_read *readHook, io_write writeHook, void *pdata)
void register_io_hook(uint8_t port, io_read readHook, io_write writeHook, void *pdata)
{
io_registry[port].read = readHook;
io_registry[port].write = writeHook;
io_registry[port].private = pdata;
}
void register_io_hook_array(uint8_t *portList, uint8_t listLen, io_read *readHook, io_write writeHook, void *pdata)
void register_io_hook_array(uint8_t *portList, uint8_t listLen, io_read readHook, io_write writeHook, void *pdata)
{
uint16_t i;
for(i = 0; i < listLen; i++)
@ -219,9 +117,21 @@ void register_io_hook_array(uint8_t *portList, uint8_t listLen, io_read *readHoo
uint8_t io_readport(uint8_t port)
{
int w1, w2;
uint8_t retVal = 0;
if (io_registry[port].read)
{
retVal = io_registry[port].read(io_registry[port].private, port);
}
if (ioLogFp)
{
fprintf(ioLogFp, "%llu, R, %02X, %02X\n", nec_monotonicCycles, port, retVal);
}
return retVal;
#if 0
switch (port)
{
case 0x4e:
@ -361,43 +271,27 @@ exit:
break;
}
}
if (ioLogFp)
{
fprintf(ioLogFp, "%llu, R, %02X, %02X\n", nec_monotonicCycles, port, retVal);
}
return retVal;
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void io_writeport(uint32_t port, uint8_t value)
void io_writeport(uint8_t port, uint8_t value)
{
int unknown_io_port = 0;
if (ioLogFp)
{
fprintf(ioLogFp, "%llu, W, %02X, %02X\n", nec_monotonicCycles, port, value);
}
if (port > 0x100)
if (io_registry[port].write)
{
port &= 0xFF;
if (port > 0x100)
{
return;
}
io_registry[port].write(io_registry[port].private, port, value);
}
#if 0
if ((port == 0xA0) && (ws_ioRam[port] & 0x01) && (~value & 0x01))
{
value |= 0x01;
@ -760,6 +654,5 @@ void io_writeport(uint32_t port, uint8_t value)
break;
}
}
#endif
}

View File

@ -1,9 +1,10 @@
/*******************************************************************************
* NewOswan
* log.c: C Fancy Logger
* Copyright (c) 2009-2021 986-Studio. All rights reserved.
*
* Created by Manoël Trapier on 20/01/2009.
* Copyright (c) 2009-2022 986-Studio. All rights reserved.
*
******************************************************************************/
#define __LOG_C_INTERNAL_

View File

@ -1,20 +1,12 @@
/*******************************************************************************
* NewOswan
* memory.c: Memory implementation
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// Notes: need to optimize mem_writemem20
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -37,17 +29,6 @@
#include <audio.h>
#include <memory.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define IO_ROM_BANK_BASE_SELECTOR 0xC0
uint8_t *ws_rom;
@ -125,17 +106,6 @@ void dump_memory()
}
#ifndef USE_PAGED_MEMORY_ACCESS
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void mem_writemem20(uint32_t addr, uint8_t value)
{
uint32_t offset = addr & 0xffff;
@ -156,17 +126,6 @@ void mem_writemem20(uint32_t addr, uint8_t value)
// other banks are read-only
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t mem_readmem20(uint32_t addr)
{
uint32_t offset = addr & 0xffff;
@ -372,17 +331,7 @@ void mem_dump_info()
}
}
#endif
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
char *load_file(char *filename)
{
int fd;
@ -407,17 +356,6 @@ char *load_file(char *filename)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
char *create_file(char *filename, uint32_t size)
{
int fd;
@ -454,17 +392,6 @@ char *create_file(char *filename, uint32_t size)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_init(uint8_t *rom, uint32_t wsRomSize)
{
ws_romHeaderStruct *ws_romHeader;
@ -570,81 +497,26 @@ void ws_memory_init(uint8_t *rom, uint32_t wsRomSize)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_reset(void)
{
memset(internalRam, 0, 0x10000);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_done(void)
{
free(internalRam);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t *memory_getRom(void)
{
return (ws_rom);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32_t memory_getRomSize(void)
{
return (romSize);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint16_t memory_getRomCrc(void)
{
return (ws_rom_checksum);

View File

@ -1,8 +1,9 @@
/******************************************************************************
* NewOswan
* nec.c:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/

View File

@ -1,10 +1,11 @@
/*
/******************************************************************************
* NewOswan
* nec_debugger.c:
* Created by Manoël Trapier on 14/04/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
* Created by Manoël Trapier on 14/04/2021.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
#include <stdio.h>
#include <stdint.h>
@ -17,7 +18,7 @@
#include <memory.h>
/***
* Note: the while code to decode instruction is not meant to be optimised, but to be easy to maintain.
* Note: the whole code to decode instruction is not meant to be optimised, but to be easy to maintain.
* It probably could be more concise, but this is code for the debugger, not runtime, so optimisation does
* not really matter here.
*/
@ -790,7 +791,7 @@ int nec_decode_instruction(uint16_t segment, uint16_t offset, char *buffer, unsi
/* Special case for C6 and C7, they are valid ONLY if reg == 0 */
param1 = mem_readmem20(MAKE_LINEAR(segment, offset + 1));
get_mod_reg_rm(param1, NULL, &reg, NULL, NULL);
if (reg > 0)
if (reg != 0)
{
strncat(buffer, "illegal", bufferSize);
opcodeParams = PR_NONE;
@ -800,6 +801,7 @@ int nec_decode_instruction(uint16_t segment, uint16_t offset, char *buffer, unsi
{
strncat(buffer, "mov", bufferSize);
}
break;
default:
strncat(buffer, opcodeName, bufferSize);

View File

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

View File

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

View File

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

View File

@ -1,22 +1,12 @@
/*******************************************************************************
* NewOswan
* audio.c:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
//
// Sound information thanks to toshi (wscamp wonderswan emulator)
// Note that sound is far from perfect for now.
//
// fixes by zalas 2002-08-21
//
//
//
////////////////////////////////////////////////////////////////////////////////
// alternate the commenting of the following defines to get audio port tracing
#define dbgprintf(...)
//#define dbgprintf(...) printf(...)
@ -108,17 +98,6 @@ const long TblMainVol[4]= // 1,1/2,1/4,1/8
};
*/
////////////////////////////////////////////////////////////////////////////////
// seal audio specific
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
//HAC ws_audio_pcm_voice[4];
//HAC ws_audio_noise_voice;
//HAC ws_audio_sweep_voice;
@ -131,17 +110,6 @@ uint32_t ws_audio_channel_isPlaying[6];
static unsigned int ws_audio_log;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_init(void)
{
Log(TLOG_NORMAL, "audio", "audio init");
@ -150,17 +118,6 @@ void ws_audio_init(void)
ws_audio_reset();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_reset(void)
{
WaveMap = -1;
@ -183,17 +140,6 @@ void ws_audio_reset(void)
ws_audio_set_channel_frequency(4, 1792);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_port_write(uint32_t port, uint8_t value)
{
uint32_t n, i, j, k, b;
@ -410,49 +356,16 @@ void ws_audio_port_write(uint32_t port, uint8_t value)
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t ws_audio_port_read(uint8_t port)
{
return (ws_ioRam[port]);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_done(void)
{
ws_audio_seal_done();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
unsigned int ws_audio_mrand(unsigned int Degree)
{
#define BIT(n) (1<<n)
@ -534,18 +447,6 @@ unsigned int ws_audio_mrand(unsigned int Degree)
return ShiftReg;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_audio_seal_init(void)
{
#if 0
@ -692,17 +593,6 @@ int ws_audio_seal_init(void)
return 1;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_seal_done(void)
{
#if 0
@ -747,17 +637,6 @@ void ws_audio_seal_done(void)
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_clear_channel(int Channel)
{
#if 0
@ -783,17 +662,6 @@ void ws_audio_clear_channel(int Channel)
#endif
}
////////////////////////////////////////////////////////////////////////////////
// start playing a channel
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_audio_play_channel(int Channel)
{
#if 0
@ -822,17 +690,6 @@ int ws_audio_play_channel(int Channel)
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// stop playing a channel
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_audio_stop_channel(int Channel)
{
#if 0
@ -859,17 +716,6 @@ int ws_audio_stop_channel(int Channel)
return (0);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_set_channel_frequency(int Channel, int Period)
{
#if 0
@ -915,17 +761,6 @@ void ws_audio_set_channel_frequency(int Channel, int Period)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_set_channel_volume(int Channel, int Vol)
{
#if 0
@ -955,17 +790,6 @@ void ws_audio_set_channel_volume(int Channel, int Vol)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_set_channel_pan(int Channel, int Left, int Right)
{
#if 0
@ -1031,17 +855,6 @@ void ws_audio_set_channel_pan(int Channel, int Left, int Right)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_set_channel_pdata(int Channel, int Index)
{
#if 0
@ -1069,17 +882,6 @@ void ws_audio_set_channel_pdata(int Channel, int Index)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_set_channels_pbuf(int Addr, int Data)
{
#if 0
@ -1100,17 +902,6 @@ void ws_audio_set_channels_pbuf(int Addr, int Data)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_rst_channel(int Channel)
{
#if 0
@ -1122,17 +913,6 @@ void ws_audio_rst_channel(int Channel)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_audio_int(void)
{
#if 0
@ -1176,17 +956,7 @@ int ws_audio_int(void)
#endif
return 1;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#if 0
static uint32_t PCMPos=0;
uint32_t TickZ=0,PcmCount;
@ -1221,17 +991,6 @@ void ws_audio_set_pcm(int Data)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_flash_pcm(void)
{
#if 0
@ -1263,17 +1022,6 @@ void ws_audio_flash_pcm(void)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_write_byte(uint32_t offset, uint8_t value)
{
if (!((offset - WaveMap) & 0xFFC0))
@ -1283,17 +1031,6 @@ void ws_audio_write_byte(uint32_t offset, uint8_t value)
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_process(void)
{
uint32_t i, j, b;
@ -1357,17 +1094,6 @@ void ws_audio_process(void)
ws_audio_set_pcm(b);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_readState(int fp)
{
#if 0
@ -1458,17 +1184,6 @@ void ws_audio_readState(int fp)
#endif
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_audio_writeState(int fp)
{
#if 0

View File

@ -1,9 +1,9 @@
/*
/*******************************************************************************
* NewOswan
* buttons.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/

View File

@ -0,0 +1,8 @@
/*******************************************************************************
* NewOswan
* color_gpu.c: Implementation of the color GPU (Wonderswan Color & SwanCrystal)
*
* Created by Manoël Trapier on 14/03/2022.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/

View File

@ -1,9 +1,9 @@
/*
/*******************************************************************************
* NewOswan
* color_system.c: IO specific to the WonderSwan Color systems.
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/

View File

@ -1,11 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* debug.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/
#include <stdio.h>
#include <stdint.h>

View File

@ -1,9 +1,9 @@
/*
/*******************************************************************************
* NewOswan
* dma.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/

View File

@ -1,11 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* eeprom.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>

View File

@ -0,0 +1,9 @@
/*******************************************************************************
* NewOswan
* mono_gpu.c: Implementation of the monochrome GPU
*
* Created by Manoël Trapier on 14/03/2022.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/

View File

@ -1,9 +1,9 @@
/*
/*******************************************************************************
* NewOswan
* mono_system.c: IOs specific to the original WonderSwan
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/

View File

@ -1,11 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* rs232.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/
#include <stdio.h>
#include <stdint.h>

View File

@ -1,11 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* rtc.c:
*
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
*/
******************************************************************************/
#include <stdint.h>

View File

@ -1,9 +1,11 @@
/*
/*******************************************************************************
* NewOswan
* universal_luxor.c: Implement a "universal" version of both known version of Luxor (Bandai 2001 and Bandai 2003)
* as there is no way from the ROM to really know which version is on the original cart.
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* universal_luxor.c: Implement a "universal" version of both known version
* of Luxor (Bandai 2001 and Bandai 2003) as there is no way from the ROM
* to really know which version is on the original cart.
*
*/
* Created by Manoël Trapier on 19/12/2021.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/

View File

@ -1,20 +1,12 @@
/*******************************************************************************
* NewOswan
* rom.c:
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -27,17 +19,6 @@
#include <log.h>
#include <rom.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8_t *ws_rom_load(char *path, uint32_t *romSize)
{
int fd;
@ -63,18 +44,6 @@ uint8_t *ws_rom_load(char *path, uint32_t *romSize)
return ret_ptr;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
const char *eepromSizeName[] =
{
[WS_EEPROM_SIZE_NONE] = "none",
@ -107,17 +76,6 @@ void ws_rom_dumpInfo(uint8_t *wsrom, uint32_t romSize)
Log(TLOG_NORMAL, "rom", "checksum 0x%.4x", romHeader->checksum);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
{
ws_romHeaderStruct *wsromHeader = (ws_romHeaderStruct *)(wsrom + wsromSize - sizeof(ws_romHeaderStruct));
@ -125,17 +83,6 @@ ws_romHeaderStruct *ws_rom_getHeader(uint8_t *wsrom, uint32_t wsromSize)
return (wsromHeader);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
{
ws_romHeaderStruct *romHeader = ws_rom_getHeader(wsrom, wsromSize);
@ -167,17 +114,6 @@ uint32_t ws_rom_sramSize(uint8_t *wsrom, uint32_t wsromSize)
return (0);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32_t ws_rom_eepromSize(uint8_t *wsrom, uint32_t wsromSize)
{
ws_romHeaderStruct *romHeader = ws_rom_getHeader(wsrom, wsromSize);

View File

@ -1,25 +1,12 @@
/*******************************************************************************
* NewOswan
* ws.c: Base wonderswan implementation
*
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// 07.04.2002: speed problems partially fixed
// 13.04.2002: Set cycles by line to 256 (according to toshi)
// this seems to work well in most situations with
// the new nec v30 cpu core
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@ -37,18 +24,6 @@
#include <audio.h>
#include <ws.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32_t ws_cycles;
uint32_t ws_skip;
uint32_t ws_cyclesByLine = 0;
@ -59,17 +34,6 @@ char *ws_ieep_path = NULL;
char *ws_rom_path = NULL;
wssystem_t systemType;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_patchRom(void)
{
@ -85,17 +49,6 @@ void ws_patchRom(void)
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_init(char *rompath)
{
uint8_t *rom;
@ -145,17 +98,6 @@ int ws_init(char *rompath)
return (1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_reset(void)
{
ws_memory_reset();
@ -166,17 +108,6 @@ void ws_reset(void)
nec_set_reg(NEC_SP, 0x2000);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_executeLine(int16_t *framebuffer, int renderLine)
{
int drawWholeScreen = 0;
@ -274,17 +205,6 @@ int ws_executeLine(int16_t *framebuffer, int renderLine)
return (drawWholeScreen);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_done(void)
{
ws_memory_done();
@ -293,17 +213,6 @@ void ws_done(void)
ws_gpu_done();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_set_system(wssystem_t system)
{
if (system == WS_SYSTEM_AUTODETECT)
@ -317,17 +226,7 @@ wssystem_t ws_get_system()
{
return systemType;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define MacroLoadNecRegisterFromFile(F, R) \
read(fp,&value,sizeof(value)); \
nec_set_reg(R,value);
@ -390,17 +289,7 @@ int ws_loadState(char *statepath)
ws_gpu_clearCache();
return (1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define MacroStoreNecRegisterToFile(F, R) \
value=nec_get_reg(R); \
write(fp,&value,sizeof(value));
@ -485,17 +374,6 @@ int ws_saveState(char *statepath)
return (1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_rotated(void)
{
uint8_t *rom = memory_getRom();

View File

@ -2,7 +2,7 @@
* NewOswan
* testserial.c: A simple tool to test serial in/out
*
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
* Copyright (c) 2014-2022 986-Studio. All rights reserved.
*
******************************************************************************/