From 2305ce975bb6b622319e67ea28918b34dc4c35e1 Mon Sep 17 00:00:00 2001 From: Godzil Date: Mon, 14 Mar 2022 14:50:41 +0000 Subject: [PATCH] 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. --- dumpinfo.c | 2 +- main.c | 36 +--- source/emulate.c | 23 +-- source/gpu.c | 161 +-------------- source/includes/audio.h | 3 +- source/includes/device.h | 6 +- source/includes/emulate.h | 3 +- source/includes/gpu.h | 3 +- source/includes/io.h | 7 +- source/includes/log.h | 3 +- source/includes/memory.h | 3 +- source/includes/nec.h | 3 +- source/includes/nec_debugger.h | 9 +- source/includes/necintrf.h | 3 +- source/includes/rom.h | 3 +- source/includes/ws.h | 3 +- source/io.c | 153 +++----------- source/log.c | 3 +- source/memory.c | 134 +----------- source/nec/nec.c | 3 +- source/nec/nec_debugger.c | 14 +- source/nec/necea.h | 3 +- source/nec/necinstr.h | 3 +- source/nec/necmodrm.h | 3 +- source/{ => peripherals}/audio.c | 291 +-------------------------- source/peripherals/buttons.c | 6 +- source/peripherals/color_gpu.c | 8 + source/peripherals/color_system.c | 6 +- source/peripherals/debug.c | 6 +- source/peripherals/dma.c | 6 +- source/peripherals/eeprom.c | 6 +- source/peripherals/mono_gpu.c | 9 + source/peripherals/mono_system.c | 6 +- source/peripherals/rs232.c | 6 +- source/peripherals/rtc.c | 6 +- source/peripherals/universal_luxor.c | 14 +- source/rom.c | 68 +------ source/ws.c | 130 +----------- testserial.c | 2 +- 39 files changed, 140 insertions(+), 1017 deletions(-) rename source/{ => peripherals}/audio.c (81%) create mode 100644 source/peripherals/color_gpu.c create mode 100644 source/peripherals/mono_gpu.c diff --git a/dumpinfo.c b/dumpinfo.c index 5e46f77..ed3cb28 100644 --- a/dumpinfo.c +++ b/dumpinfo.c @@ -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. * ******************************************************************************/ diff --git a/main.c b/main.c index 5f357a3..8fcccc8 100644 --- a/main.c +++ b/main.c @@ -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 #include #include @@ -31,17 +23,6 @@ #include #include -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// #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); } - diff --git a/source/emulate.c b/source/emulate.c index 845ad25..75ed44f 100644 --- a/source/emulate.c +++ b/source/emulate.c @@ -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 #include #include @@ -410,17 +402,6 @@ double getTicks() return ticks; } -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// void ws_emulate(void) { int32_t nCount = 0; diff --git a/source/gpu.c b/source/gpu.c index 3e27f03..602aa0f 100644 --- a/source/gpu.c +++ b/source/gpu.c @@ -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 #include #include @@ -35,17 +21,6 @@ #include #include -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// 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) diff --git a/source/includes/audio.h b/source/includes/audio.h index 095b085..ee93d13 100644 --- a/source/includes/audio.h +++ b/source/includes/audio.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/device.h b/source/includes/device.h index b60f3da..a2210bd 100644 --- a/source/includes/device.h +++ b/source/includes/device.h @@ -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 diff --git a/source/includes/emulate.h b/source/includes/emulate.h index 100557a..f44a10e 100644 --- a/source/includes/emulate.h +++ b/source/includes/emulate.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/gpu.h b/source/includes/gpu.h index 27bf745..a1c0260 100644 --- a/source/includes/gpu.h +++ b/source/includes/gpu.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/io.h b/source/includes/io.h index 1c08463..89f2e05 100644 --- a/source/includes/io.h +++ b/source/includes/io.h @@ -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 diff --git a/source/includes/log.h b/source/includes/log.h index 23cfa57..833b4fe 100644 --- a/source/includes/log.h +++ b/source/includes/log.h @@ -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 diff --git a/source/includes/memory.h b/source/includes/memory.h index e7fb0e2..cbbaa12 100644 --- a/source/includes/memory.h +++ b/source/includes/memory.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/nec.h b/source/includes/nec.h index 6f07f54..974f936 100644 --- a/source/includes/nec.h +++ b/source/includes/nec.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/nec_debugger.h b/source/includes/nec_debugger.h index 0b25cc4..c2b2fef 100644 --- a/source/includes/nec_debugger.h +++ b/source/includes/nec_debugger.h @@ -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 diff --git a/source/includes/necintrf.h b/source/includes/necintrf.h index 24ceaba..4b4c6ae 100644 --- a/source/includes/necintrf.h +++ b/source/includes/necintrf.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/rom.h b/source/includes/rom.h index ae01973..f704055 100644 --- a/source/includes/rom.h +++ b/source/includes/rom.h @@ -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. * ******************************************************************************/ diff --git a/source/includes/ws.h b/source/includes/ws.h index cd6b257..f57fc39 100644 --- a/source/includes/ws.h +++ b/source/includes/ws.h @@ -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. * ******************************************************************************/ diff --git a/source/io.c b/source/io.c index 3440989..d21ae29 100644 --- a/source/io.c +++ b/source/io.c @@ -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 #include #include @@ -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 } diff --git a/source/log.c b/source/log.c index 719198b..e90de9b 100644 --- a/source/log.c +++ b/source/log.c @@ -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_ diff --git a/source/memory.c b/source/memory.c index d23c0c4..1a0b4d1 100644 --- a/source/memory.c +++ b/source/memory.c @@ -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 #include #include @@ -37,17 +29,6 @@ #include #include -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// #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); diff --git a/source/nec/nec.c b/source/nec/nec.c index 69efe87..88b15ff 100644 --- a/source/nec/nec.c +++ b/source/nec/nec.c @@ -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. * ******************************************************************************/ diff --git a/source/nec/nec_debugger.c b/source/nec/nec_debugger.c index 0e81529..f319680 100644 --- a/source/nec/nec_debugger.c +++ b/source/nec/nec_debugger.c @@ -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 #include @@ -17,7 +18,7 @@ #include /*** - * 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, ®, 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); diff --git a/source/nec/necea.h b/source/nec/necea.h index ada0a79..8216069 100644 --- a/source/nec/necea.h +++ b/source/nec/necea.h @@ -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. * ******************************************************************************/ diff --git a/source/nec/necinstr.h b/source/nec/necinstr.h index 40706a1..1b9b2eb 100644 --- a/source/nec/necinstr.h +++ b/source/nec/necinstr.h @@ -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. * ******************************************************************************/ diff --git a/source/nec/necmodrm.h b/source/nec/necmodrm.h index 62cddd5..837051c 100644 --- a/source/nec/necmodrm.h +++ b/source/nec/necmodrm.h @@ -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. * ******************************************************************************/ diff --git a/source/audio.c b/source/peripherals/audio.c similarity index 81% rename from source/audio.c rename to source/peripherals/audio.c index 86d5af7..4eedee0 100644 --- a/source/audio.c +++ b/source/peripherals/audio.c @@ -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< #include diff --git a/source/peripherals/dma.c b/source/peripherals/dma.c index a44f32b..a0815f1 100644 --- a/source/peripherals/dma.c +++ b/source/peripherals/dma.c @@ -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. * - */ + ******************************************************************************/ diff --git a/source/peripherals/eeprom.c b/source/peripherals/eeprom.c index 7fa9790..928dbc3 100644 --- a/source/peripherals/eeprom.c +++ b/source/peripherals/eeprom.c @@ -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 #include diff --git a/source/peripherals/mono_gpu.c b/source/peripherals/mono_gpu.c new file mode 100644 index 0000000..3e70030 --- /dev/null +++ b/source/peripherals/mono_gpu.c @@ -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. + * + ******************************************************************************/ + diff --git a/source/peripherals/mono_system.c b/source/peripherals/mono_system.c index 042d622..3d024a9 100644 --- a/source/peripherals/mono_system.c +++ b/source/peripherals/mono_system.c @@ -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. * - */ + ******************************************************************************/ diff --git a/source/peripherals/rs232.c b/source/peripherals/rs232.c index fc9408c..9838ac4 100644 --- a/source/peripherals/rs232.c +++ b/source/peripherals/rs232.c @@ -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 #include diff --git a/source/peripherals/rtc.c b/source/peripherals/rtc.c index f490f31..1f4e261 100644 --- a/source/peripherals/rtc.c +++ b/source/peripherals/rtc.c @@ -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 diff --git a/source/peripherals/universal_luxor.c b/source/peripherals/universal_luxor.c index 97c3a42..af8fc40 100644 --- a/source/peripherals/universal_luxor.c +++ b/source/peripherals/universal_luxor.c @@ -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. + * + ******************************************************************************/ diff --git a/source/rom.c b/source/rom.c index 087fbbd..2b8c220 100644 --- a/source/rom.c +++ b/source/rom.c @@ -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 #include #include @@ -27,17 +19,6 @@ #include #include -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// 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); diff --git a/source/ws.c b/source/ws.c index a58381b..76b7a44 100644 --- a/source/ws.c +++ b/source/ws.c @@ -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 #include #include @@ -37,18 +24,6 @@ #include #include -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// - 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(); diff --git a/testserial.c b/testserial.c index 5110007..9096a08 100644 --- a/testserial.c +++ b/testserial.c @@ -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. * ******************************************************************************/