109 Commits
v0.7 ... v0.9

Author SHA1 Message Date
Godzil
146e2b2c1d Fix some headers (code is original here) and some cosmetics 2021-04-15 23:17:38 +01:00
Godzil
698d960bed Add some useful GPU debug logs 2021-04-15 23:17:01 +01:00
Godzil
62c5812b34 Add #ifdef around EEPROM debug prints 2021-04-15 23:08:03 +01:00
Godzil
7f7410c8f8 First step to get a debugger:
Decode instructions.


I now have an headache.
A couple of instruction are still not properly decoded.
I need to find proper documentation on them.
2021-04-15 23:07:13 +01:00
Godzil
0e02ee829f I'm constantly amazed by how poorly coded this emulator was.
SRAM and EEPROM were inverted and not all known value was in there.
Also fixed the rom metadata header that was missing one byte.
2021-04-09 23:55:58 +01:00
Godzil
4512def23a Change how SRAM/EEPROM mask are calculated 2021-04-09 23:19:23 +01:00
Godzil
46e90dcca1 Remove useless variable 2021-04-09 23:18:53 +01:00
Godzil
2e9685215b Starting work on making memory access more straigforward with less branching code. 2021-04-09 23:18:31 +01:00
Godzil
bddcaddf1f Fix a signed/unsigned warning 2021-04-09 23:11:25 +01:00
Godzil
5559269387 Use stdbool instead of non standard ifdefs 2021-04-09 23:11:10 +01:00
Godzil
b3c0a39d00 Init the memory after everything is loaded 2021-04-09 23:09:55 +01:00
Godzil
8ab6b20815 Fix a mistake in loading SRAM/EEP file name 2021-04-09 23:09:22 +01:00
Godzil
dd53d5bfd9 Update the stub boot rom to "enable" the 16bit cart access mode.
(the emulator do not care about that but it is just to be more accurate)
2021-04-09 23:08:29 +01:00
Godzil
5ba3560378 Let's use double instead of integer to the ticks. 2021-04-09 23:07:46 +01:00
Godzil
ac3779e640 Add a way to pretend displaying while actualy not displayint
to go around some weirdness with Valgrind that crashwhen using OpenGL.
2021-04-06 23:11:30 +01:00
Godzil
da26704390 Oops. Stupid memset..
(always blame the tools)
2021-04-06 23:10:30 +01:00
Godzil
2ced18d151 Change the log to my good old trusty log framework. 2021-04-06 23:08:22 +01:00
Godzil
359b05a518 Add a link to Mesen 2021-04-05 15:16:17 +01:00
Godzil
3771c65f2c Add a nifty travis badge to show how great the build it! 2021-04-05 15:01:48 +01:00
Godzil
4f4e4d148a Add a fancy README.
(ok not so fancy, but there are images!)
2021-04-05 14:59:38 +01:00
Godzil
cc1060775c Major code cleanup and code reformating 2021-04-05 14:19:35 +01:00
Godzil
4e5f796d6a Remove the "color schemes". 2021-04-05 13:40:29 +01:00
Godzil
3818e03e55 Now that we have system, let's also load the Swan Crystal irom. 2021-04-05 13:37:31 +01:00
Godzil
94dc2fc463 Missed some changes for the color/b&w logic changes 2021-04-05 13:36:02 +01:00
Godzil
d45d838378 Remove all the unused "statistics" code. 2021-04-05 13:33:13 +01:00
Godzil
18d9038639 Update .gitignore 2021-04-05 13:23:59 +01:00
Godzil
925bfd3b65 Change the way the system type is managed
and changed the logic on how the GPU use "color". 
Now IO register tell properly the selected system, and B&W swan does not allow to switch to color. Also the Swan do not start in color mode as it should.
2021-04-05 13:23:44 +01:00
Godzil
330262b55c Remove the "initial IO" table as most values are wrong anyway.
If there are some initial value that need to be set, it is per system, not globally like that.
2021-04-05 12:24:12 +01:00
Godzil
357d4e4ede Deleted the makefile as it is no longer supported 2021-04-05 00:20:22 +01:00
Godzil
d45822951f As this is C project, rename all source file to .c 2021-04-05 00:18:55 +01:00
Godzil
864fda651d Update travis file. 2021-04-04 23:35:13 +01:00
Godzil
065849cf68 Add stdint.h into headers that (may) need it. 2021-04-04 23:28:36 +01:00
Godzil
dbc7d6e940 Update splash string to show "NewOswan" 2021-04-04 23:19:04 +01:00
Godzil
432844304e Add a simple boot rom stub
so we can start the emulated console without need for special case in the code, and not adding any copyrighted material in the project.
Also automatically copy the stub rom in the build folder.
2021-04-04 23:18:51 +01:00
Godzil
e28317d29e Disable the IO Dump by default. 2021-04-04 21:17:34 +01:00
Godzil
f32928b0c3 Remove -Werror by default and add a cmake option to enable them. 2021-04-04 21:14:53 +01:00
Godzil
e4cf98bfe1 Add a debug function to log all access to IO regs. 2021-04-04 21:05:48 +01:00
Godzil
a89e253d9c Now use glfw/OpenGL for displaying.
Code is a bit crude, but the whole emulator would need a proper refactor at some point anyway.
2021-04-04 20:55:40 +01:00
Godzil
88468d6028 Now build without SDL
But of course, display nothing.
2020-12-12 19:28:21 +00:00
Godzil
875f0edb46 printf can be a pain at time. 2020-11-14 20:30:09 +00:00
Godzil
8bd2170f44 Remove some of the Rotation code.
And add a call placeholder for read_key for now to make the compiler happy.
2020-11-14 20:28:31 +00:00
Godzil
564e0ea2e6 Remove more SDL references 2020-11-14 20:27:58 +00:00
Godzil
8976d4363f Remove SDLptc.h, the "Console" class and related code. 2020-11-14 20:27:25 +00:00
Godzil
f3aca9a3c7 Start working on implementing the video interface.
First disabling/removing all the SDL related function call/variables

Also removing some nonsensical dunction (line doubling and rotation are useless in GL mode)
2020-11-14 20:16:46 +00:00
Godzil
ece8a07dcf Remove SDL refenrence in the non working audio emulation. 2020-11-14 20:15:50 +00:00
Godzil
9035a922c3 Add GLFW in the CMakeLists, and remove all SDL references. 2020-11-14 20:14:57 +00:00
Godzil
02c16b7987 Add glfw as an external module 2020-11-14 19:36:54 +00:00
Godzil
8c79f6f417 Clang should be happy now? 2020-02-11 00:53:32 +00:00
Godzil
2802e64697 clang don't like these unused tables. 2020-02-11 00:42:33 +00:00
Godzil
e8d7d8473e GCC quirkness makes no sense sometimes. 2020-02-11 00:38:17 +00:00
Godzil
ed93d90c51 Make sure we are not forcing to GCC and add a bit of debug.
CMake find the proper lib but not the makefile? WTF
2020-02-11 00:29:34 +00:00
Godzil
6e857bf630 Stupid names ubuntu; "libsdl1.2debian", seriously? 2020-02-11 00:24:04 +00:00
Godzil
62c43f311c Trying to add SDL lib package (seems -dev don't install it) 2020-02-11 00:21:17 +00:00
Godzil
3552bb8bf9 Silly me... 2020-02-11 00:20:36 +00:00
Godzil
466f910c9a Try to also build cmake build. 2020-02-11 00:18:06 +00:00
Godzil
a5ce89d14f Hmmm it was lurking in other places! 2020-02-11 00:17:38 +00:00
Godzil
c26f935072 Interesting that not all GCC versions complain here. 2020-02-11 00:14:36 +00:00
Godzil
4967dcab21 I honestly don't care about the return value of write. 2020-02-11 00:07:16 +00:00
Godzil
a0e5006a18 Add dumpinfo to cmake, and set the CXX standard to C++98 as it should on that project. 2020-02-11 00:05:22 +00:00
Godzil
6d78199031 Update .gitignore 2020-02-11 00:04:42 +00:00
Godzil
6d5658eb68 Make gcc happy (and fix a potential issue) 2020-02-11 00:00:23 +00:00
Godzil
667f655d22 Add preliminary CMake build. Not replacing the makefile for now, will in the future. 2020-02-10 23:59:01 +00:00
Godzil
3e6f096191 Add CMake module to get Git version. 2020-02-10 23:58:18 +00:00
Godzil
0fadff165b Update travis to use latest ubuntu instead of the old 14.04 2020-02-07 18:00:54 +00:00
Godzil
cf80c9624c Add tentative travis build script 2020-02-07 17:58:12 +00:00
Godzil
b5488bacba Add portaudio for futur audio work. 2020-02-07 17:57:59 +00:00
Godzil
f592057e48 Move everything in the root folder 2020-01-15 19:06:45 +00:00
Godzil
ec2a2f937f Update .gitignore 2020-01-15 19:02:30 +00:00
Godzil
ce85101e38 Remove root makefile. 2020-01-15 18:59:47 +00:00
Godzil
4b8495d443 Remove seal 2020-01-15 18:59:25 +00:00
Godzil
25cb419093 Disable all audio code to remove dependency to Seal. 2020-01-15 18:58:20 +00:00
Godzil
b7eb12dedc Remove more useless things 2020-01-15 18:48:29 +00:00
Godzil
8af626c143 Remove more useless files 2020-01-15 18:47:13 +00:00
Godzil
23088d723a Types cleanup. 2020-01-15 18:44:10 +00:00
Godzil
001cb1c080 Remove non standard flag. 2020-01-15 18:11:39 +00:00
Godzil
dfa4709069 Remove useless files. 2020-01-15 18:10:27 +00:00
Godzil
7583701b79 Don't do stupid things with memory allocation...
Seriously who wrote that code :(
That malloc was never freed.
2020-01-15 18:09:38 +00:00
Godzil
406d3253ba Some more cleanup 2020-01-15 18:08:24 +00:00
Godzil
9f49ce0de4 Add missing new emulate.cpp and emulate.h files
It contain the emulation loop that was in "filter" header files.
2020-01-15 17:53:21 +00:00
Godzil
fa498d40e5 Correct cart EEPROM handling to be more correct and cleaner. 2020-01-15 17:52:33 +00:00
Godzil
1130abeb9c Using mmap for cart sram/eeprom files. 2020-01-15 17:51:25 +00:00
Godzil
ee50803d33 Remove all useless filter and some dead code.
That streamline greatly the emulation code and remove all of that non-sense of code in headers included here and there.
Still lot to be done on that point.
Also update some times to use C99 instead of random from wherever it come from.
2020-01-15 17:49:52 +00:00
Godzil
d264ef17d8 Remove the segfault while exiting (was not really critical, but it's more clean)
For that: stop trying to free memory that was not malloc-ed.
2019-10-28 14:08:43 +00:00
Godzil
384525c9ad Change some **** in seal, and I'm pretty sure there are more of these things around. 2019-10-28 12:05:11 +00:00
Godzil
8b19769069 And change all of that **** of tabs into space here. 2019-10-28 12:04:35 +00:00
Godzil
1f8f6330e5 Remove useless files 2019-10-08 18:44:10 +01:00
Godzil
e73e5e28ae Version is no longer hardcoded and now depends on git tags 2019-10-08 18:41:15 +01:00
Godzil
c6b2b5437c This emulator is really terrible.. 2019-09-27 16:22:13 +01:00
Godzil
7bc1fb8888 Change some commment about HW INTs and TODO tasks
Bad language in there? yeah I know.
2019-09-20 16:36:06 +01:00
Godzil
f6f45a4b5e Adding some temporary log for IO access for exploring around 2019-09-20 16:34:31 +01:00
Godzil
d392f18ae5 Let's make sure that once the IROM is locked out it can't be enabled again 2019-09-20 16:33:18 +01:00
Godzil
8193c19ba9 Add some code for IO register higher than 0xFF 2019-09-20 16:32:56 +01:00
Godzil
e22d345598 More cleaning 2019-09-20 16:31:50 +01:00
Godzil
92ee27e57e Make memory read return 0x90 instead of 0xFF in the impossible(?) case where something read from an impossible location 2019-09-20 16:30:15 +01:00
Godzil
348d3774fc Code beautify 2019-09-20 16:29:30 +01:00
Godzil
c8f731c9f9 Rework for a cleaner code for ROM Bank 0, 1 and 2 address calculation 2019-09-20 16:29:21 +01:00
Godzil
b662fc05a1 Adding the main code for instruction trace 2019-09-20 16:27:50 +01:00
Godzil
a06c04dfaf A bit more cleaning 2019-09-20 16:27:07 +01:00
Godzil
bed670082e Add a temporary crude instruction tracer 2019-09-20 16:26:53 +01:00
Godzil
f71f131dcc Add proper report if something is trying to call a non initialized interrupt
aka CS=0000h, IP=0000h which is more than likely to crash the whole thing.
2019-09-20 16:26:07 +01:00
Godzil
43292a26dc Clean a bit the NEC emulation files 2019-09-20 16:25:02 +01:00
Godzil
baf836a747 Change ROM loading using mmap instead of malloc/fread 2019-09-20 16:23:57 +01:00
Godzil
08132a1fd7 Add a tool to dump cart metadata 2019-09-12 17:54:27 +01:00
Godzil
b2b066ba22 Change button name to proper name and add missing (Seriously why it was missing?) support for the Y buttons.
Removed the "flipped" flag as it should not be part of the IO logic.
2019-09-10 16:00:55 +01:00
Godzil
ea6bfacb66 Don't use "pre made" EEPROM content, just fill it with 0, it works fine for now.
Also set the "system" at a proper time
And set the correct (?) size for EEPROM
2019-09-04 15:13:52 +01:00
Godzil
80253e2cd6 Fix stupidity in EEPROM code. Now it works 2019-09-04 14:33:27 +01:00
Godzil
b1abbf6bfe Reindented most of the files (still work to be done there)
Now support the BW and Color IROM
Internal EEPROM support is now nearly correct (still some odd thing
happening)
2019-09-03 17:33:29 +01:00
Godzil
84804c8d0a Remove things that are build 2019-09-02 16:03:26 +01:00
Godzil
0219258ee9 Now build on x64 platform, still need lots of rework... 2019-09-02 16:02:03 +01:00
221 changed files with 14910 additions and 41056 deletions

22
.gitignore vendored
View File

@@ -1,10 +1,28 @@
.DS_Store
*.bak
*.a
*.o
*.bin
*.wsc
*~
testserial
wonderswan
*.orig
*.rej
rom/
ROMs/
.idea/
*.zip
*.sav
*.iep
*.tags
*#
*.bck
*-
# Executables:
dumpinfo
testserial
wonderswan
# Build folder
cmake-*/
build*/

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "external/portaudio"]
path = external/portaudio
url = https://git.assembla.com/portaudio.git
[submodule "external/glfw"]
path = external/glfw
url = https://github.com/glfw/glfw.git

63
.travis.yml Normal file
View File

@@ -0,0 +1,63 @@
language: c
addons:
apt:
packages:
- xorg-dev
- libglu1-mesa-dev
script:
- mkdir build
- cd build
- cmake ..
- make
jobs:
include:
- os: linux
dist: bionic
arch: amd64
compiler: gcc
- os: linux
dist: bionic
arch: amd64
compiler: clang
- os: linux
dist: focal
arch: amd64
compiler: gcc
- os: linux
dist: focal
arch: amd64
compiler: clang
- os: osx
compiler: clang
osx_image: xcode12.2
- os: linux
dist: focal
arch: arm64
compiler: gcc
- os: osx
compiler: clang
osx_image: xcode10.3
- os: osx
compiler: clang
osx_image: xcode11.6
- os: osx
compiler: clang
osx_image: xcode12
allow_failures:
- os: linux
arch: arm64
- os: osx

50
CMakeLists.txt Normal file
View File

@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.1)
# External cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/cmake ${CMAKE_MODULE_PATH})
project("NewOswan")
include(GetGitRevisionDescription)
git_describe(VERSION --tags --dirty=-dirty)
# Include GLFW3
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory("external/glfw")
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
option(WARN_AS_ERROR "Enable warning as error" OFF)
set(COMP_FLAGS "-march=native -Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Wno-write-strings")
if (WARN_AS_ERROR)
set(COMP_FLAGS "${COMP_FLAGS} -Werror")
endif()
set(CMAKE_C_FLAGS ${COMP_FLAGS})
set(CMAKE_CXX_FLAGS ${COMP_FLAGS})
message("-- Building version ${VERSION}")
add_executable(wonderswan main.c)
set_property(TARGET wonderswan PROPERTY CXX_STANDARD 98)
target_compile_definitions(wonderswan PUBLIC VERSION="${VERSION}")
target_include_directories(wonderswan PUBLIC source)
add_custom_command(
TARGET wonderswan POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/irom_stub/*.bin
${CMAKE_CURRENT_BINARY_DIR}/
)
add_subdirectory(source)
target_link_libraries(wonderswan wswan glfw ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
add_executable(dumpinfo dumpinfo.c)

76
README.md Normal file
View File

@@ -0,0 +1,76 @@
NewOswan *(name likely to change)*
==================================
![TravisBadge](https://travis-ci.org/Godzil/NewOswan.svg?branch=master)
### What is this project?
NewOswan is a WonderSwan emulator originally based on oswan-unix and heavily modified to be more accurate and better
hardware support.
### I don't care about the blabla, just show me the thing running
Ok ok, here are some screenshots:
Using a Swan Crystal boot rom:
![Console configuration menu](./doc/configmenu.png)
Wonderswan Crystal boot splash:
![SwanCrystal boot splash](./doc/bootsplash.png)
Clock Tower:
![Boot screen of ClockTower](./doc/clocktower.png)
Star Hearts:
![Boot screen of Star Hearts](./doc/starhearts1.png)
![Ingame screen of Star Hearts](./doc/starhearts2.png)
### What's different from oswan-unix?
A couple of things:
- NewOswan do properly support the internal EEPROM and cartridge EEPROM.
The original version was based in improper and innacurate hardware documentation and was accessing and storing the
information in an incorrect way.
- NewOswan support the internal bootrom of all the three model of the WonderSwan.
- NewOswan also provide stub version for the bootrom if you don't own the original console, you can still
use the emulator withtout copyright infreigement. (no copyrighted materiel is included with the emulator for obvious
reasons)
- NewOswan use OpenGL instead of SDL
- Sound is currently not supported
- NewOswan is currently not meant as a fully operational emulator as this project mostly started as a way to test game
and the original hardware. Still the idea is to make it overtime as accurate as possible
- It is now pure C (the original code was based on a C project with some unneeded C++ here and there)
- 64-Bit clean, the original code was making assumption on some type size that can break on a 64bit system
- Build and run on Mac OS X, Linux x86 and ARM, and probably more systems.
- Some crude debugging tools that can only be enabled at compile time
- Tons of fancy logs in the console! Like:
```
IEEP: RA:143F RD:0006 A:03F C:WRI - Write? Yes : 0006
IEEP: RA:1440 RD:0101 A:040 C:WRI - Write? Yes : 0101
IEEP: RA:1441 RD:0016 A:041 C:WRI - Write? Yes : 0016
IEEP: RA:1442 RD:0000 A:042 C:WRI - Write? Yes : 0000
WriteIO(6A, 00) [F000:0018h];
WriteIO(6B, 00) [F000:0018h];
Icons H
WriteIO(6A, 00) [F000:0018h];
WriteIO(6B, 00) [F000:0018h];
```
- And many more thing I probably forgot about as this project was originally not version managed as it was just a crude
hack on the original code and are not in the logs.
### Futur plans
- Complete refactor of the code.
- Add a proper CPU debugger
- Add other nice debugging tool like the GPU status and other things that could be needed. Acheiving the level of the tools
provided by the NES emulator [Mesen](https://www.mesen.ca) would be nice.
- Being able to rotate the screen
- Maybe being able to change the game at runtime instead of start time
- Full Audio support
### The boot rom stubs
You can find the source and file in the `irom_stub` folder.
They are identical and for now provide only the logic to boot a cart. There is no bootsplash nor configuration menu.
A bootsplash may be added later.
Feel free to use these stub for your own emulator if you wish, just be nice and put a line saying you are using it and
a link to this project in your documentation :)

BIN
doc/bootsplash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

BIN
doc/clocktower.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

BIN
doc/configmenu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

BIN
doc/starhearts1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 KiB

BIN
doc/starhearts2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 KiB

110
dumpinfo.c Normal file
View File

@@ -0,0 +1,110 @@
/*
* NewOswan
* dumpinfo.c: Tool to dump the metadata info about a cart rom image.
*
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
char *load_file(char *filename, uint32_t *fileSize)
{
int fd;
char *ret_ptr;
struct stat FileStat;
fd = open(filename, O_RDWR);
fstat(fd, &FileStat);
ret_ptr = (char *)mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
*fileSize = FileStat.st_size;
close(fd);
if (ret_ptr == MAP_FAILED)
{
ret_ptr = NULL;
}
return ret_ptr;
}
#pragma pack(1)
struct cart_metadata
{
uint8_t farjump[5];
uint8_t flagExt;
uint8_t publishId;
uint8_t gameId[2];
uint8_t flags2;
uint8_t romInfo;
uint8_t saveInfo;
uint16_t flags;
uint16_t crc;
};
#pragma pack()
int main(int argc, char *argv[])
{
char *content;
uint32_t size;
struct cart_metadata *data;
int ret = -1;
if (argc != 2)
{
printf("Usage: %s file.ws[c]\n", argv[0]);
}
else
{
content = load_file(argv[1], &size);
if (content != NULL)
{
data = (struct cart_metadata *)&(content[size - sizeof(struct cart_metadata)]);
printf("%s:\n", argv[1]);
if (data->farjump[0] == 0xEA)
{
printf("[%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]", data->publishId, data->gameId[0],
data->gameId[1], data->flags2, data->romInfo, data->saveInfo, data->flags & 0xFF,
(data->flags >> 8) & 0xFF, data->crc & 0xFF, (data->crc >> 8) & 0xFF);
printf(" - Reset @ %02X%02X:%02X%02Xh\n", data->farjump[4], data->farjump[3], data->farjump[2],
data->farjump[1]);
printf(" - publisher: %02X, gameId: %01X%02X\n", data->publishId, data->gameId[0], data->gameId[1]);
printf(" - %s want to write to EEPROM\n", data->flags2 & 0x80 ? "Do" : "Do not");
printf(" - %s user defined bootsplash\n", data->flagExt & 0x80 ? "Dissallow" : "Allow");
printf(" - Is %sbootable on a normal swan\n", data->flagExt & 0x0F ? "not " : "");
printf(" - ROM Size: %02Xh\n", data->romInfo);
printf(" - Save type & Size: %02Xh\n", data->saveInfo);
printf(" - Flags: %d cycles ROM, %d bit ROM bus, %sRTC, %s orientation\n", data->flags & 0x004 ? 1 : 3,
data->flags & 0x002 ? 8 : 16, data->flags & 0x100 ? "" : "No ",
data->flags & 0x001 ? "Vertical" : "Horizontal");
printf(" - CRC: %04Xh\n", data->crc);
ret = 0;
}
else
{
printf(" - File is not a valid WonderSwan ROM.\n");
}
}
else
{
printf("Cannot open '%s'\n", argv[1]);
}
}
return ret;
}

View File

@@ -0,0 +1,168 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# git_local_changes(<var>)
#
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
# Uses the return code of "git diff-index --quiet HEAD --".
# Does not regard untracked files.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
#${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
execute_process(COMMAND
"${GIT_EXECUTABLE}"
diff-index --quiet HEAD --
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res EQUAL 0)
set(${_var} "CLEAN" PARENT_SCOPE)
else()
set(${_var} "DIRTY" PARENT_SCOPE)
endif()
endfunction()

View File

@@ -0,0 +1,41 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

1
external/glfw vendored Submodule

Submodule external/glfw added at 0ef149c8f2

1
external/portaudio vendored Submodule

Submodule external/portaudio added at c5d2c51bd6

20
irom_stub/Makefile Normal file
View File

@@ -0,0 +1,20 @@
.PHONY: all clean
all: ws_irom.bin wsc_irom.bin wc_irom.bin
clean:
@echo " RM"
@rm -f *.bin
ws_irom.bin: irom_stub.asm
@echo " AS $@"
@nasm $^ -o $@ -DWONDERSWAN=1
wsc_irom.bin: irom_stub.asm
@echo " AS $@"
@nasm $^ -o $@ -DWONDERSWANCOLOR=1
wc_irom.bin: irom_stub.asm
@echo " AS $@"
@nasm $^ -o $@ -DSWANCRYSTAL=1

110
irom_stub/irom_stub.asm Normal file
View File

@@ -0,0 +1,110 @@
; WonderSwan Internal ROM Stub
; --------------------------------------
; Version 1.0
; This is a replacement for the internal rom to prevent using/including any copyrighted material.
; It does nothing, just lauching the cartridge.
; It may later include a bootsplah.
%ifdef WONDERSWAN
%define ROM_SIZE 4096
%define ROM_SEG 0FF00h
%else
%define ROM_SIZE 8192
%define ROM_SEG 0FE00h
%endif
; Setup NASM for a 80186
bits 16
cpu 186
org 0000h
%define JUMPER_LOCATION 0000h:0400h
; ---------------------------------------------------------------------------------------------
; Boot ROM jumper
; ---------------------------------------------------------------------------------------------
; Lock the bootrom
; Clear a bit of itself
; Jump to FFFF:FFF0
;
; Must be copied to 0000:0400 then jmp 0000:0400
ram_jumper:
; Lock the boot rom away
IN al, 0A0h
OR al, 001h ; Bit 0 lock the boot rom
out 0A0h, al
mov ax, cs
mov es, ax
mov di, 0400h
mov cx, (.rm_te_end - ram_jumper)
xor ax, ax
xor bx, bx
.rm_te_end:
rep stosb
jmp 0FFFFh:00000h
ram_jumper_end:
_start:
cli
cld
push cs
pop ds
in al, 0A0h
; Bit 2 - 1 = cart using 16bit data bus
or al, 004h
out 0A0h, al
xor ax, ax
mov es, ax
; Clear the IRAM
mov di, 0
mov cx, 16384
xor al, al
rep stosb ; STOSB -> ES:DI
; Copy the jumper
mov si, ram_jumper
mov cx, (ram_jumper_end - ram_jumper)
mov di, 0400h
xor ax, ax
mov es, ax
rep movsb ; DS:SI -> ES:DI
; Do some register cleanup
mov al, 0FFh
out 0C0h, al
out 0C1h, al
out 0C2h, al
xor ax, ax
xor cx, cx
xor dx, dx
mov ds, ax
mov es, ax
; Jump to the jumper!
jmp JUMPER_LOCATION
%ifdef WONDERSWAN
db "WonderSwan"
%elifdef WONDERSWANCOLOR
db "WonderSwan Color"
%elifdef SWANCRYSTAL
db "WonderSwan Crystal"
%else
%endif
db " internal ROM Stub for NewOswan (c)2021 986-Studio"
; Create at the end of the block, add padding if needed
TIMES (ROM_SIZE - 16) - ($-$$) DB 0FFh
jmp ROM_SEG:_start ; 0
db 00 ; ?? ; 5
db 0F0h ; Dev ID ; 6
db 00 ; Min Swan type ; 7
db 00000100b ; flags ; C
db 01 ; No RTC ; D
dw 0FFFFh ; CRC (need to update it after, but as not used by the rom, no need for now)

BIN
irom_stub/wc_irom.bin Normal file

Binary file not shown.

BIN
irom_stub/ws_irom.bin Normal file

Binary file not shown.

BIN
irom_stub/wsc_irom.bin Normal file

Binary file not shown.

194
main.c Normal file
View File

@@ -0,0 +1,194 @@
/*
* NewOswan
* main.c: Entry point
* Based on the original Oswan-unix
* Copyright (c) 2014-2021 986-Studio. All rights reserved.
*
*/
////////////////////////////////////////////////////////////////////////////////
//
// 13.04.2002: Fixed a small bug causing crashes
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include "source/log.h"
#include "source/rom.h"
#include "source/nec/nec.h"
#include "source/memory.h"
#include "source/gpu.h"
#include "source/io.h"
#include "source/ws.h"
#include "source/emulate.h"
#include "source/audio.h"
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define LOG_PATH "oswan.log"
int sram_path_explicit = 0;
int ieep_path_explicit = 0;
int ws_mk_savpath()
{
char *w;
if (sram_path_explicit)
{
return 0;
}
if (ws_sram_path != NULL)
{
free(ws_sram_path);
}
ws_sram_path = (char *)malloc(strlen(ws_rom_path) + 2);
strcpy(ws_sram_path, ws_rom_path);
w = strrchr(ws_sram_path, '.');
if (NULL == w)
{
strcpy(ws_sram_path, "error.sav");
return 1;
}
strcpy(w, ".sav");
return 0;
}
int ws_mk_ieppath()
{
char *w;
if (ieep_path_explicit)
{
return 0;
}
if (ws_ieep_path != NULL)
{
free(ws_ieep_path);
}
ws_ieep_path = (char *)malloc(strlen(ws_rom_path) + 2);
strcpy(ws_ieep_path, ws_rom_path);
w = strrchr(ws_ieep_path, '.');
if (NULL == w)
{
strcpy(ws_ieep_path, "error.iep");
return 1;
}
strcpy(w, ".iep");
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
wssystem_t ws_system = WS_SYSTEM_AUTODETECT;
snprintf(app_window_title, 255, "Oswan %s - Esc to return to GUI", VERSION);
Log(TLOG_ALWAYS, NULL, "NewOswan %s (built at: %s %s)", VERSION, __DATE__, __TIME__);
ws_rom_path = NULL;
for (int n = 1 ; n < argc ; ++n)
{
if (argv[n][0] == '-')
{
switch (argv[n][1])
{
case 'C':
if (++n < argc)
{
ws_cyclesByLine = atoi(argv[n]);
}
Log(TLOG_ALWAYS, "main", "Cycles by line set to %d", ws_cyclesByLine);
break;
case 'w':
if (++n < argc)
{
ws_system = atoi(argv[n]);
}
Log(TLOG_ALWAYS, "main", "WonderSwan set to %d", ws_system);
break;
case 's':
if (++n < argc)
{
ws_sram_path = argv[n];
}
sram_path_explicit = 1;
break;
default:break;
}
}
else
{
ws_rom_path = argv[n];
ws_mk_savpath();
ws_mk_ieppath();
}
}
while (!app_terminate)
{
if (!ws_rom_path)
{
exit(0);
}
if (ws_rom_path)
{
ws_set_system(ws_system);
if (ws_init(ws_rom_path))
{
ws_reset();
ws_emulate();
}
ws_done();
}
}
return (0);
}

View File

@@ -1,54 +0,0 @@
wonderswan_CXX_SRCS = main.cpp \
source/2xSaI.cpp \
source/audio.cpp \
source/gpu.cpp \
source/io.cpp \
source/log.cpp \
source/memory.cpp \
source/rom.cpp \
source/ws.cpp \
source/nec/nec.cpp
OBJS = $(wonderswan_CXX_SRCS:.cpp=.o)
all: wonderswan
CXX = clang++
CXXFLAGS = -g -O2 `sdl-config --cflags` -arch i386
OPTIONS = -D_REENTRANT -I. -I../seal-hack/include
LIBRARY_PATH = -L../seal-hack/lib/SDL
LIBS = -g $(LIBRARY_PATH) `sdl-config --libs` -arch i386
ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS)
ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS)
CLEAN_FILES = wonderswan
.SUFFIXES: .cpp
main.o: main.cpp source/filters/2xsai.h source/filters/doubled.h source/filters/filter_partA.h source/filters/filter_partB.h source/filters/filter_partC.h source/filters/filter_partD.h source/filters/filter_partE.h source/filters/halfscanlines.h source/filters/interpolate.h source/filters/scanlines.h source/filters/special.h source/filters/standard.h source/filters/super2xsai.h source/filters/supereagle.h source/SDLptc.h
$(CXX) -c $(ALLCXXFLAGS) -o $@ $<
.c.o:
$(CC) -c $(ALLCFLAGS) -o $@ $<
.cpp.o:
$(CXX) -c $(ALLCXXFLAGS) -o $@ $<
.PHONY: all install uninstall clean distclean depend dummy
$(SUBDIRS:%=%/__clean__): dummy
cd `dirname $@` && $(MAKE) clean
$(EXTRASUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(RM) $(CLEAN_FILES)
clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
$(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(OBJS) $(EXES:%.exe=%) $(EXES:%=%.so) $(EXES:%=%.spec.o) $(DLLS:%=%.so) $(DLLS:%=%.spec.o)
wonderswan: $(OBJS)
$(CXX) $(LIBS) -o $@ $(OBJS) -laudio

View File

@@ -1,32 +0,0 @@
_____ _____ ___ _ __
\ | /___ /\__ ___> /___ /\__ ___ /\__ ___ | |/ / ___
\ / \ // .\/ . \/ . // __\/ _// __>/ . \/. || < / __\
\_____/ \___/\_/\_/\___/ \___/\_/ <___ \\_/\_/\___||_|\_\\___/
--- Wondersnake for WSC -------------\___/----- 09. 11. 2001 ---
This game is Freeware! You are more than welcome to copy it to
your friends or anyone else! Please note that it is not allowed
to charge any money for this game in any case! It is Freeware and
it will stay Freeware!
.................................................................
: Code: Dox dox@space.pl http://cygne.emuunlim.com :
: Gfx: Dox dox@space.pl http://cygne.emuunlim.com :
: Levels: Kojote kojote1980@yahoo.com http://www.pdroms.com :
:...............................................................:
Special "Thank you" goes out to Sir Dragoon for Hardwaretesting!
(Yes... Wondersnake will work on real Hardware!!!) But it will
even work on the latest version of Cygne! URL above...
Since some people were complaining that we forgot to mention them
in some of our previous productions, we want to greet everyone who
knows us ;) ... but Kojote want's to greet his wife "Amina" ;))
We hope you'll enjoy Wondersnake for Wonderswan Color, and if you
like it, please sent Feedback to both of us!
=====================
Regards, Dox & Kojote
=====================

Binary file not shown.

View File

@@ -1,150 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG_MAIN DIALOG DISCARDABLE 0, 0, 283, 236
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Oswan 0.70"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "&Load",IDC_BUTTON_LOAD,25,170,80,14
PUSHBUTTON "&Reset",IDC_BUTTON_RESET,110,170,50,14
PUSHBUTTON "&Exit",IDC_BUTTON_EXIT,170,170,85,14
GROUPBOX "Video mode",IDC_STATIC,105,30,60,40
CONTROL "Windowed",IDC_RADIO_WINDOWED,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,111,40,49,10
CONTROL "Fullscreen",IDC_RADIO_FULLSCREEN,"Button",
BS_AUTORADIOBUTTON,111,54,49,10
PUSHBUTTON "L&oad state",IDC_BUTTON_LOADSTATE,170,110,85,14
PUSHBUTTON "&Save state",IDC_BUTTON_SAVESTATE,170,130,85,14
GROUPBOX "Video enhancement",IDC_STATIC,25,30,75,135
CONTROL 102,IDC_STATIC,"Static",SS_BITMAP | SS_SUNKEN,1,1,281,23
GROUPBOX "System",IDC_STATIC,171,30,85,55
CONTROL "Autodetect",IDC_RADIO_SYSTEM_AUTODETECT,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,175,41,51,10
CONTROL "Wonderswan mono",IDC_RADIO_SYSTEM_MONO,"Button",
BS_AUTORADIOBUTTON,175,54,77,10
CONTROL "Wonderswan color",IDC_RADIO_SYSTEM_COLOR,"Button",
BS_AUTORADIOBUTTON,175,70,75,10
CONTROL 103,IDC_STATIC,"Static",SS_BITMAP | SS_SUNKEN |
WS_BORDER,0,192,283,43
GROUPBOX "Colour scheme",IDC_STATIC,105,75,60,90
CONTROL "Default",IDC_COLOUR_DEFAULT,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,111,86,39,10
CONTROL "Amber",IDC_COLOUR_AMBER,"Button",BS_AUTORADIOBUTTON,111,
100,36,10
CONTROL "Green",IDC_COLOUR_GREEN,"Button",BS_AUTORADIOBUTTON,111,
116,35,10
PUSHBUTTON "&Return to game",IDC_BUTTON_CONTINUE,170,90,85,14
PUSHBUTTON "Co&nfigure controls",IDC_BUTTON_CONTROLS,170,150,85,14,
WS_DISABLED
CONTROL "None",IDC_RADIO_STANDARD_MODE,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,31,41,60,10
CONTROL "Double size",IDC_RADIO_DOUBLESIZE_MODE,"Button",
BS_AUTORADIOBUTTON,31,54,60,10
CONTROL "Scanlines",IDC_RADIO_SCANLINES_MODE,"Button",
BS_AUTORADIOBUTTON,31,70,60,10
CONTROL "50% scanlines",IDC_RADIO_50PRCTSCANLINES_MODE,"Button",
BS_AUTORADIOBUTTON,31,86,60,10
CONTROL "Special",IDC_RADIO_SPECIAL_MODE,"Button",
BS_AUTORADIOBUTTON,31,99,60,10
CONTROL "2xSaI",IDC_RADIO_2XSAI,"Button",BS_AUTORADIOBUTTON,31,
114,60,10
CONTROL "Super 2xSaI",IDC_RADIO_SUPER2XSAI,"Button",
BS_AUTORADIOBUTTON,31,130,60,10
CONTROL "Super Eagle",IDC_RADIO_SUPEREAGLE,"Button",
BS_AUTORADIOBUTTON,31,145,60,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 276
TOPMARGIN, 6
BOTTOMMARGIN, 229
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP DISCARDABLE "source\\gui\\logo.bmp"
IDB_BITMAP2 BITMAP DISCARDABLE "source\\gui\\sponsor.bmp"
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

View File

@@ -1,650 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Wonderswan emulator
////////////////////////////////////////////////////////////////////////////////
//
// 13.04.2002: Fixed a small bug causing crashes
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
/*#include <windows.h>
#include <commctrl.h>
#include <direct.h>*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
//#include "resource.h"
#include "SDL.h"
#include "source/types.h"
#include "source/SDLptc.h"
#include "source/log.h"
#include "source/rom.h"
#include "source/nec/nec.h"
#include "source/memory.h"
#include "source/gpu.h"
#include "source/io.h"
#include "source/ws.h"
#include "source/ticker.h"
#include "source/2xSaI.h"
#include "source/audio.h"
#undef DWORD
#include <audio.h>
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define LOG_PATH "wswan.log"
#define KEY_ENTER 0x0D
#define KEY_SPACE 0x20
#define KEY_ESC 0x1b
#define KEY_UP 0x26
#define KEY_DOWN 0x28
#define KEY_LEFT 0x25
#define KEY_RIGHT 0x27
#define KEY_BUTTON1 0x57
#define KEY_BUTTON2 0x58
#define GUI_COMMAND_NONE 0
#define GUI_COMMAND_RESET 1
#define GUI_COMMAND_SCHEME_CHANGE 2
#define GUI_COMMAND_FILTER_CHANGE 3
char *app_window_title="Oswan 0.70 - Esc to return to GUI";
int app_gameRunning=0;
int app_terminate=0;
int app_fullscreen=0;
SDL_Event app_input_event;
int app_rotated=0;
int gui_command=GUI_COMMAND_NONE;
int gui_mainDialogRunning;
int gui_controls_configuration_Running;
int gui_get_key_Running;
int gui_get_key_key;
SDL_Joystick *joystick=NULL;
int ws_videoEnhancementType=0;
int ws_colourScheme=COLOUR_SCHEME_DEFAULT;
int ws_system=WS_SYSTEM_COLOR;
char *ws_rom_path;
extern char *ws_sram_path;
int sram_path_explicit = 0;
char old_rom_path[4096];
#if 0
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
char *gui_getRomPath(HWND hWnd)
{
static OPENFILENAME ofn; // common dialog box structure
static char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
static char oldDir[1024];
InitCommonControls();
_getcwd(oldDir,1024);
szFile[0]=0;
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Wonderswan mono\0*.ws\0Wonderswan color\0*.wsc\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.hInstance=NULL;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
return(ofn.lpstrFile);
chdir(oldDir);
return(NULL);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
char *gui_loadState(HWND hWnd)
{
static OPENFILENAME ofn; // common dialog box structure
static char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
static char oldDir[1024];
InitCommonControls();
_getcwd(oldDir,1024);
szFile[0]=0;
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Wonderswan state\0*.wss\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.hInstance=NULL;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
return(ofn.lpstrFile);
chdir(oldDir);
return(NULL);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
char *gui_saveState(HWND hWnd)
{
static OPENFILENAME ofn; // common dialog box structure
static char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
static char oldDir[1024];
InitCommonControls();
_getcwd(oldDir,1024);
szFile[0]=0;
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Wonderswan state\0*.wss\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = 0;
ofn.hInstance=NULL;
// Display the Open dialog box.
if (GetSaveFileName(&ofn)==TRUE)
return(ofn.lpstrFile);
chdir(oldDir);
return(NULL);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK GuiMainDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static BOOL bButton = FALSE;
switch(message)
{
case WM_INITDIALOG:
break;
case WM_CLOSE:
{
gui_mainDialogRunning=0;
DestroyWindow(hWnd);
return 1;
}
case WM_COMMAND:
{
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_LOAD))
{
ws_rom_path=gui_getRomPath(hWnd);
if (ws_rom_path)
SendMessage(hWnd, WM_CLOSE, 0,0);
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_SAVESTATE))
{
char *path=gui_saveState(hWnd);
if (path)
{
int err=ws_saveState(path);
if (err==0)
MessageBox(hWnd,"State cannot be saved","Error",MB_OK);
else
SendMessage(hWnd, WM_CLOSE, 0,0);
}
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_LOADSTATE))
{
char *path=gui_loadState(hWnd);
if (path)
{
int err=ws_loadState(path);
if (err==0)
MessageBox(hWnd,"State cannot be loaded","Error",MB_OK);
else
if (err==-1)
MessageBox(hWnd,"Please load the correct rom first","Error",MB_OK);
else
SendMessage(hWnd, WM_CLOSE, 0,0);
}
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_RESET))
{
gui_command=GUI_COMMAND_RESET;
SendMessage(hWnd, WM_CLOSE, 0,0);
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_CONTINUE))
{
SendMessage(hWnd, WM_CLOSE, 0,0);
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_BUTTON_EXIT))
{
SendMessage(hWnd, WM_CLOSE, 0,0);
app_terminate=1;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_STANDARD_MODE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_STANDARD_MODE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=0;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_DOUBLESIZE_MODE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_DOUBLESIZE_MODE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=1;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SCANLINES_MODE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SCANLINES_MODE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=2;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_50PRCTSCANLINES_MODE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_50PRCTSCANLINES_MODE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=3;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SPECIAL_MODE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SPECIAL_MODE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=4;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_2XSAI))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_2XSAI),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=5;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SUPER2XSAI))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SUPER2XSAI),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=6;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SUPEREAGLE))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SUPEREAGLE),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_videoEnhancementType=7;
gui_command=GUI_COMMAND_FILTER_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_FULLSCREEN))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_FULLSCREEN),BM_GETCHECK ,0,0)==BST_CHECKED)
app_fullscreen=1;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_WINDOWED))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_WINDOWED),BM_GETCHECK ,0,0)==BST_CHECKED)
app_fullscreen=0;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_COLOUR_DEFAULT))
{
if (SendMessage(GetDlgItem(hWnd, IDC_COLOUR_DEFAULT),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_colourScheme=COLOUR_SCHEME_DEFAULT;
gui_command=GUI_COMMAND_SCHEME_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_COLOUR_AMBER))
{
if (SendMessage(GetDlgItem(hWnd, IDC_COLOUR_AMBER),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_colourScheme=COLOUR_SCHEME_AMBER;
gui_command=GUI_COMMAND_SCHEME_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_COLOUR_GREEN))
{
if (SendMessage(GetDlgItem(hWnd, IDC_COLOUR_GREEN),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_colourScheme=COLOUR_SCHEME_GREEN;
gui_command=GUI_COMMAND_SCHEME_CHANGE;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SYSTEM_AUTODETECT))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SYSTEM_AUTODETECT),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_system=WS_SYSTEM_AUTODETECT;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SYSTEM_COLOR))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SYSTEM_COLOR),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_system=WS_SYSTEM_COLOR;
return 1;
}
if ((HIWORD(wParam)==BN_CLICKED)&&(LOWORD(wParam)==IDC_RADIO_SYSTEM_MONO))
{
if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_SYSTEM_MONO),BM_GETCHECK ,0,0)==BST_CHECKED)
ws_system=WS_SYSTEM_MONO;
return 1;
}
}
}
if(message == WM_INITDIALOG)
return(TRUE);
return (FALSE);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void gui_open(void)
{
HWND hwnd, hCtrl;
MSG msg;
gui_command=GUI_COMMAND_NONE;
InitCommonControls();
ws_rom_path=NULL;
hwnd = CreateDialog(gui_hInstance, MAKEINTRESOURCE(IDD_DIALOG_MAIN), NULL, (DLGPROC)GuiMainDialogProc);
if (hwnd==NULL)
{
MessageBox(NULL,"Cannot create gui","Error",MB_OK);
return;
}
if (ws_colourScheme==COLOUR_SCHEME_DEFAULT)
SendMessage(GetDlgItem(hwnd, IDC_COLOUR_DEFAULT),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_colourScheme==COLOUR_SCHEME_AMBER)
SendMessage(GetDlgItem(hwnd, IDC_COLOUR_AMBER),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_colourScheme==COLOUR_SCHEME_GREEN)
SendMessage(GetDlgItem(hwnd, IDC_COLOUR_GREEN),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
if (ws_videoEnhancementType==0)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_STANDARD_MODE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==1)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_DOUBLESIZE_MODE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==2)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SCANLINES_MODE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==3)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_50PRCTSCANLINES_MODE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==4)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SPECIAL_MODE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==5)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_2XSAI),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==6)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SUPER2XSAI),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_videoEnhancementType==7)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SUPEREAGLE),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
if (app_fullscreen)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_FULLSCREEN),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
SendMessage(GetDlgItem(hwnd, IDC_RADIO_WINDOWED),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
if (ws_system==WS_SYSTEM_AUTODETECT)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SYSTEM_AUTODETECT),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_system==WS_SYSTEM_COLOR)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SYSTEM_COLOR),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
else
if (ws_system==WS_SYSTEM_MONO)
SendMessage(GetDlgItem(hwnd, IDC_RADIO_SYSTEM_MONO),BM_SETCHECK ,(WPARAM)BST_CHECKED,0);
gui_mainDialogRunning=1;
ShowWindow(hwnd, SW_SHOWDEFAULT);
UpdateWindow(hwnd);
while(gui_mainDialogRunning)
{
if (GetMessage(&msg, hwnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
DestroyWindow(hwnd);
}
#endif
int ws_mk_savpath()
{
char *w;
if (sram_path_explicit) return 0;
if (ws_sram_path != NULL) free(ws_sram_path);
ws_sram_path = (char *)malloc(strlen(ws_rom_path) + 2);
strcpy(ws_sram_path, ws_rom_path);
w = strrchr(ws_sram_path, '.');
if (NULL == w)
{
strcpy(ws_sram_path, "error.sav");
return 1;
}
strcpy(w, ".sav");
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#include "./source/filters/standard.h"
#include "./source/filters/doubled.h"
#include "./source/filters/scanlines.h"
#include "./source/filters/halfscanlines.h"
#include "./source/filters/2xsai.h"
#include "./source/filters/super2xsai.h"
#include "./source/filters/supereagle.h"
#include "./source/filters/special.h"
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
atexit(SDL_Quit);
SDL_Init(SDL_INIT_TIMER);
if (!log_init(LOG_PATH)) printf("Warning: cannot open log file %s\n",LOG_PATH);
fprintf(log_get(),"Wonderswan emulator v0.70/portable (built at: %s %s)\n",__DATE__,__TIME__);
//fprintf(log_get(),"port hacking by hmaon@bumba.net\n");
ws_videoEnhancementType=1;
//ws_system = WS_SYSTEM_AUTODETECT;
ws_system = WS_SYSTEM_COLOR;
Init_2xSaI(555);
ws_rom_path = NULL;
/*gui_hInstance=hInstance;
gui_open();*/
// the hard-core UI, a command line:
for (int n = 1; n < argc; ++n)
{
if (argv[n][0] == '-')
{
switch(argv[n][1])
{
case 'E':
if (++n < argc) ws_videoEnhancementType = atoi(argv[n]);
else
{
fprintf(stderr, "\n0 - plain\n1 - doubled\n2 - scanlines\n3 - 1/2 bright scanlines\n4 - \"special\"\n5 - 2xSaI\n6 - Super2xSaI (default)\n7 - SuperEagle\n\n");
exit(1);
}
break;
case 'C':
if (++n < argc) ws_cyclesByLine = atoi(argv[n]);
fprintf(log_get(), "Cycles by line set to %d\n", ws_cyclesByLine);
break;
case 'w':
if (++n < argc) ws_system = atoi(argv[n]);
fprintf(log_get(), "WonderSwan set to %d\n", ws_system);
break;
case 's':
if (++n < argc) ws_sram_path = argv[n];
sram_path_explicit = 1;
break;
default:
break;
}
} else
{
ws_rom_path = argv[n];
ws_mk_savpath();
}
}
while (!app_terminate)
{
if (!ws_rom_path)
{
app_gameRunning=0;
//gui_open();
exit(0); // nothing to wait for at the moment...
}
if (ws_rom_path)
{
if (ws_init(ws_rom_path))
{
app_rotated=ws_rotated();
app_gameRunning=1;
ws_set_system(ws_system);
if (ws_system == WS_SYSTEM_COLOR)
ws_gpu_operatingInColor=1;
ws_set_colour_scheme(ws_colourScheme);
ws_buildHalfBrightnessTable();
ws_reset();
switch (ws_videoEnhancementType)
{
case 0: ws_emulate_standard(); break;
case 1: ws_emulate_doubled(); break;
case 2: ws_emulate_scanlines(); break;
case 3: ws_emulate_halfBrightnessScanlines(); break;
case 4: ws_emulate_special(); break;
case 5: ws_emulate_2xSaI(); break;
case 6: ws_emulate_Super2xSaI(); break;
case 7: ws_emulate_SuperEagle(); break;
}
}
ws_done();
}
}
log_done();
return(0);
}

View File

@@ -1,50 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by gui.rc
//
#define IDD_DIALOG_MAIN 101
#define IDB_BITMAP1 102
#define IDB_BITMAP2 103
#define IDC_BUTTON_LOAD 1000
#define IDC_BUTTON_RESET 1001
#define IDC_BUTTON_EXIT 1002
#define IDC_RADIO1 1003
#define IDC_RADIO_WINDOWED 1003
#define IDC_RADIO2 1004
#define IDC_RADIO_FULLSCREEN 1004
#define IDC_BUTTON_LOADSTATE 1005
#define IDC_BUTTON_SAVESTATE 1006
#define IDC_RADIO3 1007
#define IDC_BUTTON_CONTINUE 1007
#define IDC_RADIO4 1008
#define IDC_BUTTON_CONTROLS 1008
#define IDC_RADIO5 1009
#define IDC_RADIO_STANDARD_MODE 1009
#define IDC_RADIO6 1010
#define IDC_RADIO_DOUBLESIZE_MODE 1010
#define IDC_RADIO7 1011
#define IDC_RADIO_SCANLINES_MODE 1011
#define IDC_RADIO8 1012
#define IDC_RADIO_50PRCTSCANLINES_MODE 1012
#define IDC_RADIO9 1013
#define IDC_RADIO_SPECIAL_MODE 1013
#define IDC_RADIO_SYSTEM_AUTODETECT 1014
#define IDC_RADIO_SYSTEM_MONO 1015
#define IDC_RADIO_SYSTEM_COLOR 1016
#define IDC_RADIO_2XSAI 1017
#define IDC_RADIO_SUPER2XSAI 1018
#define IDC_COLOUR_DEFAULT 1019
#define IDC_COLOUR_AMBER 1020
#define IDC_COLOUR_GREEN 1021
#define IDC_RADIO_SUPEREAGLE 1022
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -1,773 +0,0 @@
/*
* Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
*
* (c) Copyright 1996 - 2001 Gary Henderson (gary@daniver.demon.co.uk) and
* Jerremy Koot (jkoot@snes9x.com)
*
* Super FX C emulator code
* (c) Copyright 1997 - 1999 Ivar (Ivar@snes9x.com) and
* Gary Henderson.
* Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
*
* DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
* C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
* C4 C code (c) Copyright 2001 Gary Henderson (gary@daniver.demon.co.uk).
*
* DOS port code contains the works of other authors. See headers in
* individual files.
*
* Snes9x homepage: www.snes9x.com
*
* Permission to use, copy, modify and distribute Snes9x in both binary and
* source form, for non-commercial purposes, is hereby granted without fee,
* providing that this license information and copyright notice appear with
* all copies and any derived work.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event shall the authors be held liable for any damages
* arising from the use of this software.
*
* Snes9x is freeware for PERSONAL USE only. Commercial users should
* seek permission of the copyright holders first. Commercial use includes
* charging money for Snes9x or software derived from Snes9x.
*
* The copyright holders request that bug fixes and improvements to the code
* should be forwarded to them so everyone can benefit from the modifications
* in future versions.
*
* Super NES and Super Nintendo Entertainment System are trademarks of
* Nintendo Co., Limited and its subsidiary companies.
*/
#include "types.h"
#include "2xSaI.h"
static u32 colorMask = 0xF7DEF7DE;
static u32 lowPixelMask = 0x08210821;
static u32 qcolorMask = 0xE79CE79C;
static u32 qlowpixelMask = 0x18631863;
static u32 redblueMask = 0xF81F;
static u32 greenMask = 0x7E0;
int Init_2xSaI(u32 BitFormat)
{
if (BitFormat == 565) {
colorMask = 0xF7DEF7DE;
lowPixelMask = 0x08210821;
qcolorMask = 0xE79CE79C;
qlowpixelMask = 0x18631863;
redblueMask = 0xF81F;
greenMask = 0x7E0;
} else if (BitFormat == 555) {
colorMask = 0x7BDE7BDE;
lowPixelMask = 0x04210421;
qcolorMask = 0x739C739C;
qlowpixelMask = 0x0C630C63;
redblueMask = 0x7C1F;
greenMask = 0x3E0;
} else {
return 0;
}
return 1;
}
static inline int GetResult1 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C)
x += 1;
else if (B == C)
y += 1;
if (A == D)
x += 1;
else if (B == D)
y += 1;
if (x <= 1)
r += 1;
if (y <= 1)
r -= 1;
return r;
}
static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C)
x += 1;
else if (B == C)
y += 1;
if (A == D)
x += 1;
else if (B == D)
y += 1;
if (x <= 1)
r -= 1;
if (y <= 1)
r += 1;
return r;
}
static inline int GetResult (u32 A, u32 B, u32 C, u32 D)
{
int x = 0;
int y = 0;
int r = 0;
if (A == C)
x += 1;
else if (B == C)
y += 1;
if (A == D)
x += 1;
else if (B == D)
y += 1;
if (x <= 1)
r += 1;
if (y <= 1)
r -= 1;
return r;
}
static inline u32 INTERPOLATE (u32 A, u32 B)
{
if (A != B) {
return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) +
(A & B & lowPixelMask));
} else
return A;
}
static inline u32 Q_INTERPOLATE (u32 A, u32 B, u32 C, u32 D)
{
register u32 x = ((A & qcolorMask) >> 2) +
((B & qcolorMask) >> 2) +
((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
register u32 y = (A & qlowpixelMask) +
(B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask);
y = (y >> 2) & qlowpixelMask;
return x + y;
}
#define BLUE_MASK565 0x001F001F
#define RED_MASK565 0xF800F800
#define GREEN_MASK565 0x07E007E0
#define BLUE_MASK555 0x001F001F
#define RED_MASK555 0x7C007C00
#define GREEN_MASK555 0x03E003E0
void Super2xSaI (u8 *srcPtr, u32 srcPitch,
u8 *deltaPtr, u8 *dstPtr, u32 dstPitch,
int width, int height)
{
u16 *bP;
u8 *dP;
u32 inc_bP;
u32 Nextline = srcPitch >> 1;
{
inc_bP = 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
dP = (u8 *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2
// 4 5 6 S2
// 1 2 3 S1
// A1 A2
colorB0 = *(bP - Nextline - 1);
colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1);
colorB3 = *(bP - Nextline + 2);
color4 = *(bP - 1);
color5 = *(bP);
color6 = *(bP + 1);
colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2);
colorA0 = *(bP + Nextline + Nextline - 1);
colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1);
colorA3 = *(bP + Nextline + Nextline + 2);
//--------------------------------------
if (color2 == color6 && color5 != color3) {
product2b = product1b = color2;
} else if (color5 == color3 && color2 != color6) {
product2b = product1b = color5;
} else if (color5 == color3 && color2 == color6) {
register int r = 0;
r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0)
product2b = product1b = color6;
else if (r < 0)
product2b = product1b = color5;
else {
product2b = product1b = INTERPOLATE (color5, color6);
}
} else {
if (color6 == color3 && color3 == colorA1
&& color2 != colorA2 && color3 != colorA0)
product2b =
Q_INTERPOLATE (color3, color3, color3, color2);
else if (color5 == color2 && color2 == colorA2
&& colorA1 != color3 && color2 != colorA3)
product2b =
Q_INTERPOLATE (color2, color2, color2, color3);
else
product2b = INTERPOLATE (color2, color3);
if (color6 == color3 && color6 == colorB1
&& color5 != colorB2 && color6 != colorB0)
product1b =
Q_INTERPOLATE (color6, color6, color6, color5);
else if (color5 == color2 && color5 == colorB2
&& colorB1 != color6 && color5 != colorB3)
product1b =
Q_INTERPOLATE (color6, color5, color5, color5);
else
product1b = INTERPOLATE (color5, color6);
}
if (color5 == color3 && color2 != color6 && color4 == color5
&& color5 != colorA2)
product2a = INTERPOLATE (color2, color5);
else
if (color5 == color1 && color6 == color5
&& color4 != color2 && color5 != colorA0)
product2a = INTERPOLATE (color2, color5);
else
product2a = color2;
if (color2 == color6 && color5 != color3 && color1 == color2
&& color2 != colorB2)
product1a = INTERPOLATE (color2, color5);
else
if (color4 == color2 && color3 == color2
&& color1 != color5 && color2 != colorB0)
product1a = INTERPOLATE (color2, color5);
else
product1a = color5;
product1a = product1a | (product1b << 16);
product2a = product2a | (product2b << 16);
*((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a;
bP += inc_bP;
dP += sizeof (u32);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
dstPtr += dstPitch * 2;
// deltaPtr += srcPitch;
} // endof: for (; height; height--)
}
}
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u8 *dP;
u16 *bP;
u16 *xP;
u32 inc_bP;
{
inc_bP = 1;
u32 Nextline = srcPitch >> 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
// xP = (u16 *) deltaPtr;
dP = dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1);
color4 = *(bP - 1);
color5 = *(bP);
color6 = *(bP + 1);
colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2);
colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1);
// --------------------------------------
if (color2 == color6 && color5 != color3) {
product1b = product2a = color2;
if ((color1 == color2) || (color6 == colorB2)) {
product1a = INTERPOLATE (color2, color5);
product1a = INTERPOLATE (color2, product1a);
// product1a = color2;
} else {
product1a = INTERPOLATE (color5, color6);
}
if ((color6 == colorS2) || (color2 == colorA1)) {
product2b = INTERPOLATE (color2, color3);
product2b = INTERPOLATE (color2, product2b);
// product2b = color2;
} else {
product2b = INTERPOLATE (color2, color3);
}
} else if (color5 == color3 && color2 != color6) {
product2b = product1a = color5;
if ((colorB1 == color5) || (color3 == colorS1)) {
product1b = INTERPOLATE (color5, color6);
product1b = INTERPOLATE (color5, product1b);
// product1b = color5;
} else {
product1b = INTERPOLATE (color5, color6);
}
if ((color3 == colorA2) || (color4 == color5)) {
product2a = INTERPOLATE (color5, color2);
product2a = INTERPOLATE (color5, product2a);
// product2a = color5;
} else {
product2a = INTERPOLATE (color2, color3);
}
} else if (color5 == color3 && color2 == color6) {
register int r = 0;
r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0) {
product1b = product2a = color2;
product1a = product2b = INTERPOLATE (color5, color6);
} else if (r < 0) {
product2b = product1a = color5;
product1b = product2a = INTERPOLATE (color5, color6);
} else {
product2b = product1a = color5;
product1b = product2a = color2;
}
} else {
product2b = product1a = INTERPOLATE (color2, color6);
product2b =
Q_INTERPOLATE (color3, color3, color3, product2b);
product1a =
Q_INTERPOLATE (color5, color5, color5, product1a);
product2a = product1b = INTERPOLATE (color5, color3);
product2a =
Q_INTERPOLATE (color2, color2, color2, product2a);
product1b =
Q_INTERPOLATE (color6, color6, color6, product1b);
// product1a = color5;
// product1b = color6;
// product2a = color2;
// product2b = color3;
}
product1a = product1a | (product1b << 16);
product2a = product2a | (product2b << 16);
*((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a;
// *xP = color5;
bP += inc_bP;
// xP += inc_bP;
dP += sizeof (u32);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
dstPtr += dstPitch * 2;
// deltaPtr += srcPitch;
} // endof: for (height; height; height--)
}
}
void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u8 *dP;
u16 *bP;
u32 inc_bP;
{
inc_bP = 1;
u32 Nextline = srcPitch >> 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
dP = dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
register u32 colorA, colorB;
u32 colorC, colorD,
colorE, colorF, colorG, colorH,
colorI, colorJ, colorK, colorL,
colorM, colorN, colorO, colorP;
u32 product, product1, product2;
//---------------------------------------
// Map of the pixels: I|E F|J
// G|A B|K
// H|C D|L
// M|N O|P
colorI = *(bP - Nextline - 1);
colorE = *(bP - Nextline);
colorF = *(bP - Nextline + 1);
colorJ = *(bP - Nextline + 2);
colorG = *(bP - 1);
colorA = *(bP);
colorB = *(bP + 1);
colorK = *(bP + 2);
colorH = *(bP + Nextline - 1);
colorC = *(bP + Nextline);
colorD = *(bP + Nextline + 1);
colorL = *(bP + Nextline + 2);
colorM = *(bP + Nextline + Nextline - 1);
colorN = *(bP + Nextline + Nextline);
colorO = *(bP + Nextline + Nextline + 1);
colorP = *(bP + Nextline + Nextline + 2);
if ((colorA == colorD) && (colorB != colorC)) {
if (((colorA == colorE) && (colorB == colorL)) ||
((colorA == colorC) && (colorA == colorF)
&& (colorB != colorE) && (colorB == colorJ))) {
product = colorA;
} else {
product = INTERPOLATE (colorA, colorB);
}
if (((colorA == colorG) && (colorC == colorO)) ||
((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM))) {
product1 = colorA;
} else {
product1 = INTERPOLATE (colorA, colorC);
}
product2 = colorA;
} else if ((colorB == colorC) && (colorA != colorD)) {
if (((colorB == colorF) && (colorA == colorH)) ||
((colorB == colorE) && (colorB == colorD)
&& (colorA != colorF) && (colorA == colorI))) {
product = colorB;
} else {
product = INTERPOLATE (colorA, colorB);
}
if (((colorC == colorH) && (colorA == colorF)) ||
((colorC == colorG) && (colorC == colorD)
&& (colorA != colorH) && (colorA == colorI))) {
product1 = colorC;
} else {
product1 = INTERPOLATE (colorA, colorC);
}
product2 = colorB;
} else if ((colorA == colorD) && (colorB == colorC)) {
if (colorA == colorB) {
product = colorA;
product1 = colorA;
product2 = colorA;
} else {
register int r = 0;
product1 = INTERPOLATE (colorA, colorC);
product = INTERPOLATE (colorA, colorB);
r +=
GetResult1 (colorA, colorB, colorG, colorE,
colorI);
r +=
GetResult2 (colorB, colorA, colorK, colorF,
colorJ);
r +=
GetResult2 (colorB, colorA, colorH, colorN,
colorM);
r +=
GetResult1 (colorA, colorB, colorL, colorO,
colorP);
if (r > 0)
product2 = colorA;
else if (r < 0)
product2 = colorB;
else {
product2 =
Q_INTERPOLATE (colorA, colorB, colorC,
colorD);
}
}
} else {
product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD);
if ((colorA == colorC) && (colorA == colorF)
&& (colorB != colorE) && (colorB == colorJ)) {
product = colorA;
} else if ((colorB == colorE) && (colorB == colorD)
&& (colorA != colorF) && (colorA == colorI)) {
product = colorB;
} else {
product = INTERPOLATE (colorA, colorB);
}
if ((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM)) {
product1 = colorA;
} else if ((colorC == colorG) && (colorC == colorD)
&& (colorA != colorH) && (colorA == colorI)) {
product1 = colorC;
} else {
product1 = INTERPOLATE (colorA, colorC);
}
}
product = colorA | (product << 16);
product1 = product1 | (product2 << 16);
*((s32 *) dP) = product;
*((u32 *) (dP + dstPitch)) = product1;
bP += inc_bP;
dP += sizeof (u32);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
dstPtr += dstPitch * 2;
// deltaPtr += srcPitch;
} // endof: for (height; height; height--)
}
}
static u32 Bilinear (u32 A, u32 B, u32 x)
{
unsigned long areaA, areaB;
unsigned long result;
if (A == B)
return A;
areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits
areaA = 0x20 - areaB;
A = (A & redblueMask) | ((A & greenMask) << 16);
B = (B & redblueMask) | ((B & greenMask) << 16);
result = ((areaA * A) + (areaB * B)) >> 5;
return (result & redblueMask) | ((result >> 16) & greenMask);
}
static u32 Bilinear4 (u32 A, u32 B, u32 C, u32 D, u32 x,
u32 y)
{
unsigned long areaA, areaB, areaC, areaD;
unsigned long result, xy;
x = (x >> 11) & 0x1f;
y = (y >> 11) & 0x1f;
xy = (x * y) >> 5;
A = (A & redblueMask) | ((A & greenMask) << 16);
B = (B & redblueMask) | ((B & greenMask) << 16);
C = (C & redblueMask) | ((C & greenMask) << 16);
D = (D & redblueMask) | ((D & greenMask) << 16);
areaA = 0x20 + xy - x - y;
areaB = x - xy;
areaC = y - xy;
areaD = xy;
result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5;
return (result & redblueMask) | ((result >> 16) & greenMask);
}
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch,
u32 dstWidth, u32 dstHeight, int width, int height)
{
u8 *dP;
u16 *bP;
u32 w;
u32 h;
u32 dw;
u32 dh;
u32 hfinish;
u32 wfinish;
u32 Nextline = srcPitch >> 1;
wfinish = (width - 1) << 16; // convert to fixed point
dw = wfinish / (dstWidth - 1);
hfinish = (height - 1) << 16; // convert to fixed point
dh = hfinish / (dstHeight - 1);
for (h = 0; h < hfinish; h += dh) {
u32 y1, y2;
y1 = h & 0xffff; // fraction part of fixed point
bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch));
dP = dstPtr;
y2 = 0x10000 - y1;
w = 0;
for (; w < wfinish;) {
u32 A, B, C, D;
u32 E, F, G, H;
u32 I, J, K, L;
u32 x1, x2, a1, f1, f2;
u32 position, product1;
position = w >> 16;
A = bP[position]; // current pixel
B = bP[position + 1]; // next pixel
C = bP[position + Nextline];
D = bP[position + Nextline + 1];
E = bP[position - Nextline];
F = bP[position - Nextline + 1];
G = bP[position - 1];
H = bP[position + Nextline - 1];
I = bP[position + 2];
J = bP[position + Nextline + 2];
K = bP[position + Nextline + Nextline];
L = bP[position + Nextline + Nextline + 1];
x1 = w & 0xffff; // fraction part of fixed point
x2 = 0x10000 - x1;
/*0*/
if (A == B && C == D && A == C)
product1 = A;
else /*1*/ if (A == D && B != C) {
f1 = (x1 >> 1) + (0x10000 >> 2);
f2 = (y1 >> 1) + (0x10000 >> 2);
if (y1 <= f1 && A == J && A != E) // close to B
{
a1 = f1 - y1;
product1 = Bilinear (A, B, a1);
} else if (y1 >= f1 && A == G && A != L) // close to C
{
a1 = y1 - f1;
product1 = Bilinear (A, C, a1);
}
else if (x1 >= f2 && A == E && A != J) // close to B
{
a1 = x1 - f2;
product1 = Bilinear (A, B, a1);
}
else if (x1 <= f2 && A == L && A != G) // close to C
{
a1 = f2 - x1;
product1 = Bilinear (A, C, a1);
}
else if (y1 >= x1) // close to C
{
a1 = y1 - x1;
product1 = Bilinear (A, C, a1);
}
else if (y1 <= x1) // close to B
{
a1 = x1 - y1;
product1 = Bilinear (A, B, a1);
}
}
else
/*2*/
if (B == C && A != D)
{
f1 = (x1 >> 1) + (0x10000 >> 2);
f2 = (y1 >> 1) + (0x10000 >> 2);
if (y2 >= f1 && B == H && B != F) // close to A
{
a1 = y2 - f1;
product1 = Bilinear (B, A, a1);
}
else if (y2 <= f1 && B == I && B != K) // close to D
{
a1 = f1 - y2;
product1 = Bilinear (B, D, a1);
}
else if (x2 >= f2 && B == F && B != H) // close to A
{
a1 = x2 - f2;
product1 = Bilinear (B, A, a1);
}
else if (x2 <= f2 && B == K && B != I) // close to D
{
a1 = f2 - x2;
product1 = Bilinear (B, D, a1);
}
else if (y2 >= x1) // close to A
{
a1 = y2 - x1;
product1 = Bilinear (B, A, a1);
}
else if (y2 <= x1) // close to D
{
a1 = x1 - y2;
product1 = Bilinear (B, D, a1);
}
}
/*3*/
else
{
product1 = Bilinear4 (A, B, C, D, x1, y1);
}
//end First Pixel
*(u32 *) dP = product1;
dP += 2;
w += dw;
}
dstPtr += dstPitch;
}
}

View File

@@ -1,22 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __2XSAI_H__
#define __2XSAI_H__
int Init_2xSaI(u32 BitFormat);
void Super2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height);
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height);
void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height);
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /*deltaPtr */, u8 *dstPtr, u32 dstPitch, u32 dstWidth, u32 dstHeight, int width, int height);
#endif

View File

@@ -1,246 +0,0 @@
/* Some simple emulation classes to get PTC code running on SDL */
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
typedef Uint8 char8;
typedef Sint32 int32;
#define randomize() srand(time(NULL))
#define random(max) (rand()%(max))
#ifndef stricmp
#define stricmp strcasecmp
#endif
class Error {
public:
Error(const char *message) {
strcpy(_message, message);
}
void report(void) {
printf("Error: %s\n", _message);
}
private:
char _message[1024];
};
class Area {
public:
Area(int left, int top, int right, int bottom) {
_left = left;
_top = top;
_right = right;
_bottom = bottom;
}
int left(void) const {
return(_left);
}
int right(void) const {
return(_right);
}
int top(void) const {
return(_top);
}
int bottom(void) const {
return(_bottom);
}
int width(void) const {
return(_right-_left);
}
int height(void) const {
return(_bottom-_top);
}
private:
int _left, _top, _right, _bottom;
};
class Format {
public:
Format(int bpp, int maskR = 0, int maskG = 0, int maskB = 0) {
_bpp = bpp;
_maskR = maskR;
_maskG = maskG;
_maskB = maskB;
}
Uint8 BPP(void) const { return(_bpp); }
Uint32 MaskR(void) const { return(_maskR); }
Uint32 MaskG(void) const { return(_maskG); }
Uint32 MaskB(void) const { return(_maskB); }
private:
Uint8 _bpp;
Uint32 _maskR, _maskG, _maskB;
};
class Surface {
public:
Surface(int w, int h, const Format &format) {
surface = SDL_AllocSurface(SDL_SWSURFACE, w, h, format.BPP(),
format.MaskR(),format.MaskG(),format.MaskB(),0);
if ( surface == NULL ) {
throw Error(SDL_GetError());
}
nupdates = 0;
is_console = 0;
}
Surface(void) {
nupdates = 0;
is_console = 1;
}
~Surface() {
if ( ! is_console ) {
SDL_FreeSurface(surface);
}
}
virtual int width(void) {
return surface->w;
}
virtual int height(void) {
return surface->h;
}
virtual int pitch(void) {
return surface->pitch;
}
virtual void palette(int32 *pcolors) {
SDL_Color colors[256];
for ( int i=0; i<256; ++i ) {
colors[i].r = (pcolors[i]>>16)&0xFF;
colors[i].g = (pcolors[i]>>8)&0xFF;
colors[i].b = (pcolors[i]>>0)&0xFF;
}
SDL_SetColors(surface, colors, 0, 256);
}
virtual void *lock(void) {
if ( SDL_MUSTLOCK(surface) ) {
while ( SDL_LockSurface(surface) < 0 ) {
SDL_Delay(10);
}
}
return (Uint8 *)surface->pixels;
}
virtual void unlock(void) {
if ( SDL_MUSTLOCK(surface) ) {
SDL_UnlockSurface(surface);
}
}
virtual void copy(Surface &dst,
const Area &srcarea, const Area &dstarea) {
SDL_Rect srcrect, dstrect;
srcrect.x = srcarea.left();
srcrect.y = srcarea.top();
srcrect.w = srcarea.width();
srcrect.h = srcarea.height();
dstrect.x = dstarea.left();
dstrect.y = dstarea.top();
dstrect.w = dstarea.width();
dstrect.h = dstarea.height();
SDL_BlitSurface(surface, &srcrect, dst.surface, &dstrect);
dst.updates[dst.nupdates++] = dstrect;
}
virtual void copy(Surface &dst) {
SDL_Rect srcrect, dstrect;
srcrect.x = 0;
srcrect.y = 0;
srcrect.w = surface->w;
srcrect.h = surface->h;
dstrect.x = 0;
dstrect.y = 0;
dstrect.w = surface->w;
dstrect.h = surface->h;
SDL_LowerBlit(surface, &srcrect, dst.surface, &dstrect);
dst.updates[dst.nupdates++] = dstrect;
}
virtual void update(void) {
SDL_UpdateRects(surface, nupdates, updates);
nupdates = 0;
}
protected:
SDL_Surface *surface;
int nupdates;
SDL_Rect updates[1]; /* Definitely increase this.. */
int is_console;
};
class Console : public Surface {
int fullscreen;
public:
Console() : Surface() {
fullscreen=0;
}
~Console() {
SDL_Quit();
}
void close(void)
{
SDL_Quit();
}
void option(char *option)
{
if (!stricmp(option,"fullscreen output"))
fullscreen=1;
else
if (!stricmp(option,"windowed output"))
fullscreen=0;
}
void open(const char *title, int width, int height, const Format &format) {
Uint32 flags;
if ( SDL_InitSubSystem(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
throw Error(SDL_GetError());
}
//flags = (SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);
flags = (SDL_HWSURFACE|SDL_HWPALETTE);
if (fullscreen)
flags|=SDL_FULLSCREEN;
surface = SDL_SetVideoMode(width, height, 0, flags);
if ( surface == NULL ) {
throw Error(SDL_GetError());
}
SDL_WM_SetCaption(title, title);
}
int key(void) {
SDL_Event event;
int keyevent;
keyevent = 0;
while ( SDL_PollEvent(&event) ) {
/* Real key events trigger this function */
if ( event.type == SDL_KEYDOWN ) {
keyevent = 1;
}
/* So do quit events -- let the app know about it */
if ( event.type == SDL_QUIT ) {
keyevent = 1;
}
}
return(keyevent);
}
private:
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,56 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_2xSaI(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
_2xSaI ((u8*)backbuffer,144*2, NULL,(u8*)vs, surfacePitch<<1,144,224);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
_2xSaI ((u8*)backbuffer,224*2, NULL,(u8*)vs, surfacePitch<<1,224,144);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,220 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
__inline void ws_drawDoubledScanline(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<224;pixel+=8)
{
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
__inline void ws_drawDoubledRotatedScanline(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<144;pixel+=8)
{
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint16 ws_halfBrightnessTable[32];
#define M_HALFBRIGHTNESS(D) (ws_halfBrightnessTable[(D>>10)&0x1f]<<10)|(ws_halfBrightnessTable[(D>>5)&0x1f]<<5)|(ws_halfBrightnessTable[D&0x1f]);
__inline void ws_drawDoubledHalfBrightnessScanline(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<224;pixel+=4)
{
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
}
}
__inline void ws_drawDoubledHalfBrightnessScanlineSpecialEven(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<224;pixel+=4)
{
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
}
}
__inline void ws_drawDoubledHalfBrightnessScanlineSpecialOdd(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<224;pixel+=4)
{
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
}
}
__inline void ws_drawDoubledHalfBrightnessRotatedScanline(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<144;pixel+=4)
{
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
}
}
__inline void ws_drawDoubledHalfBrightnessRotatedScanlineSpecialEven(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<144;pixel+=4)
{
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
}
}
__inline void ws_drawDoubledHalfBrightnessRotatedScanlineSpecialOdd(int16 *vs, int16 *backbuffer_alias)
{
register int32 *vs_alias=(int32*)vs;
register int32 data;
for (int pixel=0;pixel<144;pixel+=4)
{
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data|=(data<<16); *vs_alias++=data;
data=*backbuffer_alias++; data=M_HALFBRIGHTNESS(data); data|=(data<<16); *vs_alias++=data;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_doubled(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<224;line++)
{
ws_drawDoubledRotatedScanline(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledRotatedScanline(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=144;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<144;line++)
{
ws_drawDoubledScanline(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledScanline(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=224;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,13 +0,0 @@
Sint32 startTime, endTime, totalFrames;
Uint32 nNormalLast=0;
Sint32 nNormalFrac=0;
Sint32 nTime=0,nCount=0; int i=0;
double dTime = 0.0, dNormalLast = 0.0, dTemp;
Sint32 surfacePitch;
// 15 bits RGB555
Format format(16,0x007c00,0x00003e0,0x0000001f);
Console console;
Surface *surface;

View File

@@ -1,23 +0,0 @@
int16 *backbuffer=(int16*)malloc(224*144*sizeof(int16));
memset(backbuffer,0x00,224*144*sizeof(int16));
surfacePitch=(surface->pitch()>>1);
console.option("DirectX");
if (app_fullscreen)
console.option("fullscreen output");
else
console.option("windowed output");
console.option("fixed window");
console.option("center window");
totalFrames=0;
startTime=clock();
nNormalLast=0;// Last value of timeGetTime()
nNormalFrac=0; // Extra fraction we did
//nNormalLast=timeGetTime();
// hopefully, we only care about time delta, not time of day...
//nNormalLast = SDL_GetTicks();
dNormalLast = (double) SDL_GetTicks();
// filter change
if (gui_command==GUI_COMMAND_FILTER_CHANGE)
{
ws_loadState("oswan.wss");
}

View File

@@ -1,77 +0,0 @@
//nTime=SDL_GetTicks()-nNormalLast; // calcule le temps <20>coul<75> depuis le dernier affichage
dTemp = (double) SDL_GetTicks();
dTime = dTemp - dNormalLast;
// nTime est en mili-secondes.
// d<>termine le nombre de trames <20> passer + 1
//nCount = (Sint32) ((((double)nTime)*600.0 - (double)nNormalFrac) / 10000.0);
nCount = (Sint32) (dTime * 0.07547); // does this calculation make sense?
// 75.47Hz vblank is according to wstech22.txt
//printf("%d ", nCount);
// si le nombre de trames <20> passer + 1 est nul ou n<>gatif,
// ne rien faire pendant 2 ms
//AUpdateAudio();
if (nCount<=0)
{
SDL_Delay(2);
} // No need to do anything for a bit
else
{
//nNormalFrac+=nCount*10000; //
//nNormalLast+=nNormalFrac/600; // add the duration of nNormalFrac frames
//nNormalFrac%=600; //
//dNormalLast = dTemp;
dNormalLast += nCount * (1/0.07547);
// Pas plus de 9 (10-1) trames non affich<63>es
if (nCount>10)
nCount=10;
/*
ws_key_start=0;
ws_key_left=0;
ws_key_right=0;
ws_key_up=0;
ws_key_down=0;
ws_key_button_1=0;
ws_key_button_2=0;
*/
int ws_key_esc=0;
#include "source/temp/key.h"
if (ws_key_esc)
{
console.close();
if (ws_rom_path)
strcpy(old_rom_path,ws_rom_path);
//gui_open();
#ifndef GUI_OPEN_WARNED
#warning XXX something ought to take place here...
#define GUI_OPEN_WARNED
#endif
app_terminate = 1;
if ((ws_rom_path!=NULL)||(app_terminate))
break;
if (gui_command)
{
if (gui_command==GUI_COMMAND_RESET)
ws_reset();
if (gui_command==GUI_COMMAND_SCHEME_CHANGE)
ws_set_colour_scheme(ws_colourScheme);
if (gui_command==GUI_COMMAND_FILTER_CHANGE)
{
ws_saveState("oswan.wss");
ws_rom_path=old_rom_path;
delete surface;
return;
}
}
console.option("DirectX");
if (app_fullscreen)
console.option("fullscreen output");
else
console.option("windowed output");
console.option("fixed window");
console.option("center window");

View File

@@ -1,10 +0,0 @@
}
for (i=0;i<nCount-1;i++)
while (!ws_executeLine(backbuffer,0));
while (!ws_executeLine(backbuffer,1));
totalFrames++;

View File

@@ -1,4 +0,0 @@
endTime=clock();
float fps=totalFrames/(((float)(endTime-startTime))/(float)CLOCKS_PER_SEC);
console.close();
delete surface;

View File

@@ -1,86 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_buildHalfBrightnessTable(void)
{
for (int i=0;i<32;i++)
ws_halfBrightnessTable[i]=0.65*i;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_halfBrightnessScanlines(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<224;line++)
{
ws_drawDoubledRotatedScanline(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledHalfBrightnessRotatedScanline(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=144;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<144;line++)
{
ws_drawDoubledScanline(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledHalfBrightnessScanline(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=224;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,188 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define M_R(A) ((A&0x7c00)>>10)
#define M_G(A) ((A&0x03e0)>>5)
#define M_B(A) (A&0x1f)
#define NB_BUFFERS 8
#define NB_BUFFERS_DIV 3
void ws_mergeBackbuffers(int16 **buffers)
{
int16 *buffersAlias[NB_BUFFERS+1];
memcpy(buffersAlias,buffers,sizeof(int16*)*(NB_BUFFERS+1));
for (int i=0;i<224*144;i++)
{
int r,g,b;
r=g=b=0;
for (int j=0;j<NB_BUFFERS;j++)
{
r+=M_R(*buffersAlias[j]);
g+=M_G(*buffersAlias[j]);
b+=M_B(*buffersAlias[j]);
buffersAlias[j]++;
}
r>>=NB_BUFFERS_DIV;
g>>=NB_BUFFERS_DIV;
b>>=NB_BUFFERS_DIV;
*buffersAlias[NB_BUFFERS]++=(r<<10)|(g<<5)|b;
}
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_standard_interpolate(void)
{
#define KEY_ENTER 0x0D
#define KEY_ESC 0x1b
#define KEY_UP 0x26
#define KEY_DOWN 0x28
#define KEY_LEFT 0x25
#define KEY_RIGHT 0x27
#define KEY_BUTTON1 0x57
#define KEY_BUTTON2 0x58
uint32 startTime, endTime, totalFrames;
unsigned int nNormalLast=0;
int nNormalFrac=0;
int nTime=0,nCount=0; int i=0;
// 15 bits RGB555
Format format(16,0x007c00,0x00003e0,0x0000001f);
Console console;
Surface *surface;
if (app_rotated)
surface=new Surface(144,224,format);
else
surface=new Surface(224,144,format);
console.option("DirectX");
if (app_fullscreen)
console.option("fullscreen output");
else
console.option("windowed output");
console.option("fixed window");
console.option("center window");
console.open("Oswan",224,144,format);
int16 *backbuffer[NB_BUFFERS+1];
for (int fr=0;fr<NB_BUFFERS+1;fr++)
{
backbuffer[fr]=(int16*)malloc(224*144*sizeof(int16));
memset(backbuffer[fr],0x00,224*144*sizeof(int16));
}
totalFrames=0;
startTime=clock();
nNormalLast=0;// Last value of timeGetTime()
nNormalFrac=0; // Extra fraction we did
nNormalLast=timeGetTime();
// filter change
if (gui_command==GUI_COMMAND_FILTER_CHANGE)
{
ws_loadState("oswan.wss");
}
while (1)
{
nTime=timeGetTime()-nNormalLast; // calcule le temps <20>coul<75> depuis le dernier affichage
// nTime est en mili-secondes.
// d<>termine le nombre de trames <20> passer + 1
nCount=(nTime*600 - nNormalFrac) /10000;
// si le nombre de trames <20> passer + 1 est nul ou n<>gatif,
// ne rien faire pendant 2 ms
if (nCount<=0)
{
Sleep(2);
} // No need to do anything for a bit
else
{
nNormalFrac+=nCount*10000; //
nNormalLast+=nNormalFrac/600; // add the duration of nNormalFrac frames
nNormalFrac%=600; //
// Pas plus de 9 (10-1) trames non affich<63>es
if (nCount>10)
nCount=10;
/*
ws_key_start=0;
ws_key_left=0;
ws_key_right=0;
ws_key_up=0;
ws_key_down=0;
ws_key_button_1=0;
ws_key_button_2=0;
*/ int ws_key_esc=0;
#include "./source/temp/key.h"
if (ws_key_esc)
{
console.close();
strcpy(old_rom_path,ws_rom_path);
gui_open();
if ((ws_rom_path!=NULL)||(app_terminate))
break;
if (gui_command)
{
if (gui_command==GUI_COMMAND_RESET)
ws_reset();
if (gui_command==GUI_COMMAND_SCHEME_CHANGE)
ws_set_colour_scheme(ws_colourScheme);
if (gui_command==GUI_COMMAND_FILTER_CHANGE)
{
ws_saveState("oswan.wss");
ws_rom_path=old_rom_path;
delete surface;
return;
}
}
console.option("DirectX");
if (app_fullscreen)
console.option("fullscreen output");
else
console.option("windowed output");
console.option("fixed window");
console.option("center window");
console.open("Oswan",224,144,format);
}
for (i=0;i<nCount-1;i++)
while (!ws_executeLine(backbuffer[0],0));
while (!ws_executeLine(backbuffer[totalFrames&(NB_BUFFERS-1)],1));
ws_mergeBackbuffers(backbuffer);
if (app_rotated)
ws_rotate_backbuffer(backbuffer[NB_BUFFERS]);
totalFrames++;
int32 *vs = (int32 *)surface->lock();
memcpy(vs,backbuffer[NB_BUFFERS],224*144*2);
surface->unlock();
surface->copy(console);
console.update();
}
}
endTime=clock();
float fps=totalFrames/(((float)(endTime-startTime))/(float)CLOCKS_PER_SEC);
printf("%f fps (%i %% the original speed)\n",fps, (int)((fps*100)/60));
console.close();
delete surface;
}

View File

@@ -1,68 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_scanlines(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<224;line++)
{
ws_drawDoubledRotatedScanline(vs,backbuffer_alias);
vs+=surfacePitch;
vs+=surfacePitch;
backbuffer_alias+=144;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<144;line++)
{
ws_drawDoubledScanline(vs,backbuffer_alias);
vs+=surfacePitch;
vs+=surfacePitch;
backbuffer_alias+=224;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,71 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_special(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<224;line++)
{
ws_drawDoubledHalfBrightnessRotatedScanlineSpecialEven(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledHalfBrightnessRotatedScanlineSpecialOdd(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=144;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
while (!ws_executeLine(backbuffer,1));
int16 *vs = (int16 *)surface->lock();
int16 *backbuffer_alias=backbuffer;
for (int line=0;line<144;line++)
{
ws_drawDoubledHalfBrightnessScanlineSpecialEven(vs,backbuffer_alias);
vs+=surfacePitch;
ws_drawDoubledHalfBrightnessScanlineSpecialOdd(vs,backbuffer_alias);
vs+=surfacePitch;
backbuffer_alias+=224;
}
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,75 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// VERY SLOW !!!!
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_rotate_backbuffer(int16 *backbuffer)
{
static int16 temp[224*144];
memcpy(temp,backbuffer,224*144*2);
for (int line=0;line<144;line++)
for (int column=0;column<224;column++)
backbuffer[line+((223-column)<<7)+((223-column)<<4)]=temp[column+(line<<7)+(line<<6)+(line<<5)];
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_standard(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144,224,format);
#include "filter_partB.h"
surfacePitch>>=1;
console.open(app_window_title,144,224,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144,224,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int32 *vs = (int32 *)surface->lock();
memcpy(vs,backbuffer,224*144*2);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224,144,format);
#include "filter_partB.h"
console.open(app_window_title,224,144,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224,144,format);
#include "filter_partD.h"
int32 *vs = (int32 *)surface->lock();
memcpy(vs,backbuffer,224*144*2);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,54 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_Super2xSaI(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
Super2xSaI ((u8*)backbuffer,144*2, NULL,(u8*)vs, surfacePitch<<1,144,224);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
Super2xSaI ((u8*)backbuffer,224*2, NULL,(u8*)vs, surfacePitch<<1,224,144);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

View File

@@ -1,54 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_emulate_SuperEagle(void)
{
#include "filter_partA.h"
if (app_rotated)
{
surface=new Surface(144*2,224*2,format);
#include "filter_partB.h"
console.open(app_window_title,144*2,224*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,144*2,224*2,format);
#include "filter_partD.h"
ws_rotate_backbuffer(backbuffer);
int16 *vs = (int16 *)surface->lock();
SuperEagle ((u8*)backbuffer,144*2, NULL,(u8*)vs, surfacePitch<<1,144,224);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
else
{
surface=new Surface(224*2,144*2,format);
#include "filter_partB.h"
console.open(app_window_title,224*2,144*2,format);
while (1)
{
#include "filter_partC.h"
console.open(app_window_title,224*2,144*2,format);
#include "filter_partD.h"
int16 *vs = (int16 *)surface->lock();
SuperEagle ((u8*)backbuffer,224*2, NULL,(u8*)vs, surfacePitch<<1,224,144);
surface->unlock();
surface->copy(console);
console.update();
}
}
#include "filter_partE.h"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,45 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __GPU_H__
#define __GPU_H__
#define COLOUR_SCHEME_DEFAULT 0
#define COLOUR_SCHEME_AMBER 1
#define COLOUR_SCHEME_GREEN 2
extern uint8 ws_gpu_scanline;
extern uint8 ws_gpu_operatingInColor;
extern uint8 ws_videoMode;
extern int16 ws_palette[16*4];
extern int8 ws_paletteColors[8];
extern int16 wsc_palette[16*16];
extern unsigned int ws_gpu_unknownPort;
extern uint32 vblank_count;
void ws_gpu_init(void);
void ws_gpu_done(void);
void ws_gpu_reset(void);
void ws_gpu_renderScanline(int16 *framebuffer);
void ws_gpu_changeVideoMode(uint8 value);
void ws_gpu_write_byte(DWORD offset, BYTE value);
int ws_gpu_port_write(DWORD port,BYTE value);
BYTE ws_gpu_port_read(BYTE port);
void ws_gpu_set_colour_scheme(int scheme);
void ws_gpu_changeVideoMode(uint8 value);
void ws_gpu_forceColorSystem(void);
void ws_gpu_forceMonoSystem(void);
void ws_gpu_clearCache(void);
#endif

View File

@@ -1,100 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
uint8 internalEeprom[]=
{
0xff,0xff,0xff,0xff,0xff,0xff,192,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,127,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,252,0xff,1,0xff,253,0xff,253,0xff,253,0xff,253,
0xff,253,0xff,253,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,3,3,0x00,0x00,0x00,64,128,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
135,5,140,9,5,12,139,12,144,0x00,0x00,2,
0x00,76,165,0x00,128,0x00,0x00,0x00,0xff,127,0xff,127,
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,0xff,127,
0xff,127,0xff,127,0xff,127,0xff,127,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,6,6,6,6,6,0x00,0x00,0x00,0x00,0x00,
1,128,15,0x00,1,1,1,15,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
'D'-54,'A'-54,'V'-54,'I'-54,'D'-54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,32,1,1,33,1,4,0x00,1,
0x00,152,60,127,74,1,53,1,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff
};

View File

@@ -1,271 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Initial I/O values
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
uint8 initialIoValue[256]=
{
0x00,//0
0x00,//1
0x9d,//2
0xbb,//3
0x00,//4
0x00,//5
0x00,//6
0x26,//7
0xfe,//8
0xde,//9
0xf9,//a
0xfb,//b
0xdb,//c
0xd7,//d
0x7f,//e
0xf5,//f
0x00,//10
0x00,//11
0x00,//12
0x00,//13
0x01,//14
0x00,//15
0x9e,//16
0x9b,//17
0x00,//18
0x00,//19
0x00,//1a
0x00,//1b
0x99,//1c
0xfd,//1d
0xb7,//1e
0xdf,//1f
0x30,//20
0x57,//21
0x75,//22
0x76,//23
0x15,//24
0x73,//25
0x77,//26
0x77,//27
0x20,//28
0x75,//29
0x50,//2a
0x36,//2b
0x70,//2c
0x67,//2d
0x50,//2e
0x77,//2f
0x57,//30
0x54,//31
0x75,//32
0x77,//33
0x75,//34
0x17,//35
0x37,//36
0x73,//37
0x50,//38
0x57,//39
0x60,//3a
0x77,//3b
0x70,//3c
0x77,//3d
0x10,//3e
0x73,//3f
0x00,//40
0x00,//41
0x00,//42
0x00,//43
0x00,//44
0x00,//45
0x00,//46
0x00,//47
0x00,//48
0x00,//49
0x00,//4a
0x00,//4b
0x00,//4c
0x00,//4d
0x00,//4e
0x00,//4f
0x00,//50
0x00,//51
0x00,//52
0x00,//53
0x00,//54
0x00,//55
0x00,//56
0x00,//57
0x00,//58
0x00,//59
0x00,//5a
0x00,//5b
0x00,//5c
0x00,//5d
0x00,//5e
0x00,//5f
0x0a,//60
0x00,//61
0x00,//62
0x00,//63
0x00,//64
0x00,//65
0x00,//66
0x00,//67
0x00,//68
0x00,//69
0x00,//6a
0x0f,//6b
0x00,//6c
0x00,//6d
0x00,//6e
0x00,//6f
0x00,//70
0x00,//71
0x00,//72
0x00,//73
0x00,//74
0x00,//75
0x00,//76
0x00,//77
0x00,//78
0x00,//79
0x00,//7a
0x00,//7b
0x00,//7c
0x00,//7d
0x00,//7e
0x00,//7f
0x00,//80
0x00,//81
0x00,//82
0x00,//83
0x00,//84
0x00,//85
0x00,//86
0x00,//87
0x00,//88
0x00,//89
0x00,//8a
0x00,//8b
0x00,//8c
0x1f,//8d 1d ?
0x00,//8e
0x00,//8f
0x00,//90
0x00,//91
0x00,//92
0x00,//93
0x00,//94
0x00,//95
0x00,//96
0x00,//97
0x00,//98
0x00,//99
0x00,//9a
0x00,//9b
0x00,//9c
0x00,//9d
0x03,//9e
0x00,//9f
0x87-2,//a0
0x00,//a1
0x00,//a2
0x00,//a3
0x0,//a4 2b
0x0,//a5 7f
0x4f,//a6
0xff,//a7 cf ?
0x00,//a8
0x00,//a9
0x00,//aa
0x00,//ab
0x00,//ac
0x00,//ad
0x00,//ae
0x00,//af
0x00,//b0
0xdb,//b1
0x00,//b2
0x00,//b3
0x00,//b4
0x40,//b5
0x00,//b6
0x00,//b7
0x00,//b8
0x00,//b9
0x01,//ba
0x00,//bb
0x42,//bc
0x00,//bd
0x83,//be
0x00,//bf
0x2f,//c0
0x3f,//c1
0xff,//c2
0xff,//c3
0x00,//c4
0x00,//c5
0x00,//c6
0x00,//c7
0xd1,//c8?
0xd1,//c9
0xd1,//ca
0xd1,//cb
0xd1,//cc
0xd1,//cd
0xd1,//ce
0xd1,//cf
0xd1,//d0
0xd1,//d1
0xd1,//d2
0xd1,//d3
0xd1,//d4
0xd1,//d5
0xd1,//d6
0xd1,//d7
0xd1,//d8
0xd1,//d9
0xd1,//da
0xd1,//db
0xd1,//dc
0xd1,//dd
0xd1,//de
0xd1,//df
0xd1,//e0
0xd1,//e1
0xd1,//e2
0xd1,//e3
0xd1,//e4
0xd1,//e5
0xd1,//e6
0xd1,//e7
0xd1,//e8
0xd1,//e9
0xd1,//ea
0xd1,//eb
0xd1,//ec
0xd1,//ed
0xd1,//ee
0xd1,//ef
0xd1,//f0
0xd1,//f1
0xd1,//f2
0xd1,//f3
0xd1,//f4
0xd1,//f5
0xd1,//f6
0xd1,//f7
0xd1,//f8
0xd1,//f9
0xd1,//fa
0xd1,//fb
0xd1,//fc
0xd1,//fd
0xd1,//fe
0xd1 //ff
};

View File

@@ -1,715 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// I/O ports
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h> /* UNIX standard function definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include "log.h"
#include "rom.h"
#include "./nec/nec.h"
#include "initialIo.h"
#include "ieeprom.h"
#include "gpu.h"
#include "audio.h"
extern uint8 *externalEeprom;
extern uint32 externalEepromAddressMask;
extern uint32 romAddressMask;
uint8 *ws_ioRam=NULL;
uint8 ws_key_start;
uint8 ws_key_left;
uint8 ws_key_right;
uint8 ws_key_up;
uint8 ws_key_down;
uint8 ws_key_button_1;
uint8 ws_key_button_2;
uint8 ws_key_flipped;
int rtcDataRegisterReadCount=0;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_io_reset(void)
{
ws_key_start=0;
ws_key_left=0;
ws_key_right=0;
ws_key_up=0;
ws_key_down=0;
ws_key_button_1=0;
ws_key_button_2=0;
int i;
for (i=0;i<0x100;i++)
ws_ioRam[i]=initialIoValue[i];
for (i=0;i<0xc9;i++)
cpu_writeport(i,initialIoValue[i]);
rtcDataRegisterReadCount=0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_io_init(void)
{
if (ws_ioRam==NULL)
ws_ioRam=(uint8*)malloc(0x100);
ws_io_reset();
ws_key_flipped=0;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_io_flipControls(void)
{
ws_key_flipped=!ws_key_flipped;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_io_done(void)
{
if (ws_ioRam==NULL)
free(ws_ioRam);
}
/* Serial port */
#define BDR_9600 (0)
#define BDR_38400 (1)
#define SERIAL_PORT "/dev/tty.USA19H141P1.1"
int serialfd = -1;
int serial_have_data = 0;
unsigned char serial_data = 0;
int serial_speed = BDR_9600;
void open_serial()
{
if (serialfd < 0)
{
serialfd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
//set_baudrate(serial_speed);
serial_have_data = 0;
}
}
void set_baudrate(int speed)
{
struct termios options;
if (serialfd < 0)
return;
tcgetattr(serialfd, &options);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
if (speed == BDR_9600)
{
cfsetispeed(&options, B9600);
}
else
{
cfsetospeed(&options, B38400);
}
options.c_cflag &= ~CNEW_RTSCTS;
options.c_cflag |= (CLOCAL | CREAD);
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_oflag &= ~OPOST;
tcsetattr(serialfd, TCSANOW, &options);
/* Make sure read is not blocking */
fcntl(serialfd, F_SETFL, FNDELAY);
}
void close_serial()
{
close(serialfd);
serialfd = -1;
}
void nec_int(DWORD wektor);
void check_serial_data()
{
unsigned char buf[10];
int f;
if (serialfd < 0)
return;
if (serial_have_data == 0)
{
f = read(serialfd, buf, 1);
if (f > 0)
{
printf("Ho [%d]!\n", f);fflush(stdout);
serial_have_data = 0x01;
serial_data = buf[0];
}
}
if(serial_have_data > 0)
{
/* Gen an int if enabled */
if(ws_ioRam[0xB2] & 0x04)
{
ws_ioRam[0xb6] &= ~ 0x04;
printf("INNNNNTTTT!!!!!!!");
nec_int((ws_ioRam[0xb0]+3)*4);
}
}
}
unsigned char read_serial()
{
unsigned char buf[10];
int f;
if (serialfd < 0)
return 0xFF;
if (serial_have_data > 0)
{
serial_have_data = 0;
return serial_data;
}
f = read(serialfd, buf, 1);
if (f == 1)
return buf[0];
return 0x42;
}
void write_serial(unsigned char value)
{
if (serialfd < 0)
return;
write(serialfd, &value, 1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
BYTE cpu_readport(BYTE port)
{
int w1,w2;
BYTE retVal;
if (port >= 0xBA) && (port <= 0xBE)
{
printf("Reading IEEP %02X\n", port);
}
switch (port)
{
case 0x4e:
case 0x4f:
case 0x50:
case 0x51:
case 0x80:
case 0x81:
case 0x82:
case 0x83:
case 0x84:
case 0x85:
case 0x86:
case 0x87:
case 0x88:
case 0x89:
case 0x8a:
case 0x8b:
case 0x8c:
case 0x8d:
case 0x8e:
case 0x8f:
case 0x90:
case 0x91:
case 0x92:
case 0x93:
case 0x94:
return(ws_audio_port_read(port));
//case 0xaa: return 0xff;
/*case 0xb3: // ???
if (ws_ioRam[0xb3]<0x80)
return 0;
if (ws_ioRam[0xb3]<0xc0)
return 0x84;
return 0xc4;*/
case 0xb5:
w1=ws_ioRam[0xb5];
if(w1&0x40)
{
w2=0x00;
if (ws_key_flipped)
w2=(ws_key_start<<1);
else
w2=(ws_key_start<<1)|(ws_key_button_1<<2)|(ws_key_button_2<<3);
return (uint8)((w1&0xf0)|w2);
}
if(w1&0x20)
{
w2=0x00;
if (ws_key_flipped)
w2=(ws_key_button_1)|(ws_key_button_2<<2);
else
w2=(ws_key_up<<0)|(ws_key_right<<1)|(ws_key_down<<2)|(ws_key_left<<3);
return (uint8)((w1&0xf0)|w2);
}
if(w1&0x10)
{
w2=0x00;
if (ws_key_flipped)
w2=(ws_key_up<<1)|(ws_key_right<<2)|(ws_key_down<<3)|(ws_key_left);
return (uint8)((w1&0xf0)|w2);
}
break;
case 0xbe: // internal eeprom status/command register
// ack eeprom write
if(ws_ioRam[0xbe]&0x20)
return ws_ioRam[0xbe]|2;
// ack eeprom read
if(ws_ioRam[0xbe]&0x10)
return ws_ioRam[0xbe]|1;
// else ack both
return ws_ioRam[0xbe]|3;
case 0xba: // eeprom even byte read
w1=((((uint16)ws_ioRam[0xbd])<<8)|((uint16)ws_ioRam[0xbc]));
w1=(w1<<1)&0x3ff;
return internalEeprom[w1];
case 0xbb: // eeprom odd byte read
w1=((((uint16)ws_ioRam[0xbd])<<8)|((uint16)ws_ioRam[0xbc]));
w1=((w1<<1)+1)&0x3ff;
return internalEeprom[w1];
case 0xc0 : // ???
retVal = ((ws_ioRam[0xc0]&0xf)|0x20);
goto exit;
case 0xc4: // external eeprom even byte read
w1=(((((WORD)ws_ioRam[0xc7])<<8)|((WORD)ws_ioRam[0xc6]))<<1)&(externalEepromAddressMask);
retVal = externalEeprom[w1];
goto exit;
case 0xc5: // external eeprom odd byte read
w1=(((((WORD)ws_ioRam[0xc7])<<8)|((WORD)ws_ioRam[0xc6]))<<1)&(externalEepromAddressMask);
retVal = externalEeprom[w1+1];
goto exit;
case 0xc8: // external eeprom status/command register
// ack eeprom write
if(ws_ioRam[0xc8]&0x20)
{
retVal = ws_ioRam[0xc8]|2;
goto exit;
}
// ack eeprom read
if(ws_ioRam[0xc8]&0x10)
{
retVal = ws_ioRam[0xc8]|1;
goto exit;
}
// else ack both
retVal = ws_ioRam[0xc8]|3;
goto exit;
case 0xca : // RTC Command and status register
// set ack to always 1
retVal = (ws_ioRam[0xca]|0x80);
goto exit;
case 0xcb : // RTC data register
if(ws_ioRam[0xca]==0x15) // get time command
{
struct tm *newtime;
time_t long_time;
time( &long_time );
newtime = localtime( &long_time );
#define BCD(value) ((value/10)<<4)|(value%10)
switch(rtcDataRegisterReadCount)
{
case 0: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_year-100);
goto exit;
case 1: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_mon);
goto exit;
case 2: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_mday);
goto exit;
case 3: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_wday);
goto exit;
case 4: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_hour);
goto exit;
case 5: rtcDataRegisterReadCount++;
retVal = BCD(newtime->tm_min);
goto exit;
case 6: rtcDataRegisterReadCount=0;
retVal = BCD(newtime->tm_sec);
goto exit;
}
return 0;
}
else
{
// set ack
retVal = (ws_ioRam[0xcb]|0x80);
goto exit;
}
case 0xD0:
retVal = 0;
goto exit;
/* Serial port link.. */
case 0xB1:
retVal = read_serial();
printf("RS232: Read %02X\n", retVal);
goto exit;
case 0xB3:
check_serial_data();
if (ws_ioRam[0xB3] & 0x80)
retVal = (ws_ioRam[0xB3] & ~1) | serial_have_data | 0x04;
else
retVal = 0x00;
printf("<<<<RS232STA: %02X [%c%c%cxx%c%c%c]\n", retVal,
(retVal & 0x80)?'E':'d',
(retVal & 0x40)?'3':'9',
(retVal & 0x20)?'R':'n',
(retVal & 0x04)?'E':'f',
(retVal & 0x02)?'V':'n',
(retVal & 0x01)?'D':'e'
);
goto exit;
default:
if (port > 0xD0) printf("ReadIO %02X <= %02X\n", port, retVal);
break;
}
retVal = ws_gpu_port_read(port);
exit:
return retVal;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void cpu_writeport(DWORD port,BYTE value)
{
unsigned short F0dbg = 0;
int w1,w2;
int unknown_io_port=0;
if (port >= 0xBA) && (port <= 0xBE)
{
printf("Writing IEEP %02X <= %02X\n", port, value);
}
if ((ws_ioRam[port]==value) && (port < 0xF0) && ((port < 0xB0) || (port > 0xBF)) )
return;
ws_ioRam[port]=value;
switch (port)
{
/* GPU IOs */
case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x08:
case 0x09:
case 0x0A:
case 0x0B:
case 0x0C:
case 0x0D:
case 0x0E:
case 0x0F:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
break;
case 0x15: printf("Icons %c %c %c %c %c %c %c %c\n",
(value>>7)&1?'?':' ',
(value>>6)&1?'?':' ',
(value>>5)&1?'3':' ',
(value>>4)&1?'2':' ',
(value>>3)&1?'1':' ',
(value>>2)&1?'H':' ',
(value>>1)&1?'V':' ',
(value>>0)&1?'S':' '
); break;
/* Palettes ? */
case 0x1C: case 0x25: case 0x2F: case 0x38:
case 0x1D: case 0x26: case 0x30: case 0x39:
case 0x1E: case 0x27: case 0x31: case 0x3A:
case 0x1F: case 0x28: case 0x32: case 0x3B:
case 0x20: case 0x29: case 0x33: case 0x3C:
case 0x21: case 0x2A: case 0x34: case 0x3E:
case 0x22: case 0x2B: case 0x35: case 0x3F:
case 0x23: case 0x2C: case 0x36:
case 0x24: case 0x2E: case 0x37:
break;
/* DMAs */
case 0x40:
case 0x41:
case 0x42:
case 0x43:
case 0x44:
case 0x45:
case 0x46:
case 0x47:
break;
case 0x48: // DMA
// bit 7 set to start dma transfer
if(value&0x80)
{
int dma_start = (((DWORD)ws_ioRam[0x41])<<8)|(((DWORD)ws_ioRam[0x40]))|(((DWORD)ws_ioRam[0x42])<<16);
int dma_end = (((DWORD)ws_ioRam[0x45])<<8)|(((DWORD)ws_ioRam[0x44]))|(((DWORD)ws_ioRam[0x43])<<16);
int dma_size = (((DWORD)ws_ioRam[0x47])<<8)|(((DWORD)ws_ioRam[0x46]));
for(int ix=0;ix<dma_size;ix++)
cpu_writemem20(dma_end++,cpu_readmem20(dma_start++));
ws_ioRam[0x47]=0;
ws_ioRam[0x46]=0;
ws_ioRam[0x41]=(BYTE)(dma_start>>8);
ws_ioRam[0x40]=(BYTE)(dma_start&0xff);
ws_ioRam[0x45]=(BYTE)(dma_end>>8);
ws_ioRam[0x44]=(BYTE)(dma_end&0xff);
ws_ioRam[0x48]=0;
}
break;
/* Audio */
case 0x4a:
case 0x4b:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
ws_audio_port_write(port, value);
break;
/* DMA Start! */
case 0x52: break;
/* GPU (again) */
case 0x60:
break;
/* Audio */
case 0x80:
case 0x81:
case 0x82:
case 0x83:
case 0x84:
case 0x85:
case 0x86:
case 0x87:
case 0x88:
case 0x89:
case 0x8a:
case 0x8b:
case 0x8c:
case 0x8d:
case 0x8e:
case 0x8f:
case 0x90:
case 0x91:
case 0x92:
case 0x93:
case 0x94:
ws_audio_port_write(port,value);
break;
/* Hardeware */
case 0xA0:
break;
/*Timers */
case 0xA2:
case 0xA4:
case 0xA5:
case 0xA6:
case 0xA7:
case 0xA8:
case 0xA9:
case 0xAA:
case 0xAB:
break;
/* Hardware */
case 0xB0: break;
case 0xB1: write_serial(value); /*printf("RS232 TX: %02X\n", value);*/ break;
case 0xB2: break;
case 0xB3: printf(">>>>RS232STA: %02X [%c%c%cxx%c%c%c]\n", value,
(value & 0x80)?'E':'d',
(value & 0x40)?'3':'9',
(value & 0x20)?'R':'n',
(value & 0x04)?'E':'f',
(value & 0x02)?'V':'n',
(value & 0x01)?'D':'e'
);
/* Serial status: 7 = Enable, 6 = baudrate, 5 = Overrun reset
2 = Send Buffer empty
1 = Overrun
0 = Data Received
*/
serial_speed = ((value&040) == 0x00)?BDR_9600:BDR_38400;
if ((value & 0x80) == 0x80)
{
open_serial();
set_baudrate(serial_speed);
check_serial_data();
}
break;
case 0xB5:
break;
/* buttons */
case 0xB6:
break;
/* Internal EEPROM */
case 0xba: w1=(((((WORD)ws_ioRam[0xbd])<<8)|((WORD)ws_ioRam[0xbc])));
w1=(w1<<1)&0x3ff;
internalEeprom[w1]=value;
return;
case 0xbb: w1=(((((WORD)ws_ioRam[0xbd])<<8)|((WORD)ws_ioRam[0xbc])));
w1=((w1<<1)+1)&0x3ff;
internalEeprom[w1]=value;
return;
case 0xBC: case 0xBD: case 0xBE: break;
/* MBC */
case 0xC0: case 0xC1: case 0xC2: case 0xC3: break;
case 0xc4: w1=(((((WORD)ws_ioRam[0xc7])<<8)|((WORD)ws_ioRam[0xc6]))<<1)&externalEepromAddressMask;
externalEeprom[w1]=value;
return;
case 0xc5: w1=(((((WORD)ws_ioRam[0xc7])<<8)|((WORD)ws_ioRam[0xc6]))<<1)&externalEepromAddressMask;
externalEeprom[w1+1]=value;
return;
case 0xC6: case 0xC7: case 0xC8: break;
case 0xca: if(value==0x15)
rtcDataRegisterReadCount=0;
break;
break;
case 0xCB: break;
case 0xF0: break;
case 0xF1: printf("%d\n", (signed short)((value << 8) | ws_ioRam[0xF0])); break;
case 0xF2: printf("%c", value); fflush(stdout); break;
default:
unknown_io_port=1;
}
if ((ws_gpu_port_write(port,value) == 1) && (unknown_io_port == 1))
{
fprintf(log_get(),"WriteIO(%02X, %02X);\n",port, value);
}
/*if (port >= 0xC0)
{
fprintf(log_get(),"WriteMBCIO(%02X, %02X);\n",port, value);
}*/
// if ((ws_gpu_unknownPort)&&(unknown_io_port))
// {
// fprintf(log_get(),"io: writing 0x%.2x to unknown port 0x%.2x\n",value,port);
// }
}

View File

@@ -1,30 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __IO_H__
#define __IO_H__
extern uint8 *ws_ioRam;
extern uint8 ws_key_start;
extern uint8 ws_key_left;
extern uint8 ws_key_right;
extern uint8 ws_key_up;
extern uint8 ws_key_down;
extern uint8 ws_key_button_1;
extern uint8 ws_key_button_2;
void ws_io_init(void);
void ws_io_reset(void);
void ws_io_flipControls(void);
void ws_io_done(void);
#endif

View File

@@ -1,63 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include "log.h"
FILE *log_stream=NULL;
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
int log_init(char *path)
{
//log_stream=fopen(path,"wrt");
log_stream = stdout;
if (log_stream==NULL)
return(0);
return(1);
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
FILE *log_get(void)
{
return(log_stream);
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
void log_done(void)
{
fclose(log_stream);
}

View File

@@ -1,20 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __LOG_H__
#define __LOG_H__
int log_init(char *path);
FILE *log_get(void);
void log_done(void);
#endif

View File

@@ -1,308 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Memory
////////////////////////////////////////////////////////////////////////////////
// Notes: need to optimize cpu_writemem20
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include "log.h"
#include "rom.h"
#include "./nec/nec.h"
#include "io.h"
#include "gpu.h"
#include "audio.h"
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define IO_ROM_BANK_BASE_SELECTOR 0xC0
uint8 *ws_rom;
uint8 *ws_staticRam;
uint8 *internalRam;
uint8 *externalEeprom;
extern uint8 *ws_ioRam;
uint16 ws_rom_checksum;
uint32 sramAddressMask;
uint32 externalEepromAddressMask;
uint32 romAddressMask;
uint32 romSize;
int ws_sram_dirty = 0;
extern nec_Regs I;
void dump_memory()
{
int i;
FILE *fp;
printf("Dumping memory....\n");
fp = fopen("iram.bin", "wb");
fwrite(internalRam, 1, 0x10000, fp);
fclose(fp);
fp = fopen("sram.bin", "wb");
fwrite(ws_staticRam, 1, 0x10000, fp);
fclose(fp);
fp = fopen("rom.bin", "wb");
fwrite(ws_rom, 1, romSize, fp);
fclose(fp);
fp = fopen("memorydump.bin", "wb");
fwrite(internalRam, 1, 0x10000, fp);
/* page 1 */
fwrite(&(ws_staticRam[sramAddressMask]), 1, 0x10000, fp);
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+2]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp);
fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+3]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp);
for(i = 4; i < 0x10; i++)
{
int romBank=(256-(((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR]&0xf)<<4)|(i&0xf)));
fwrite(&(ws_rom[(unsigned)(romSize-(romBank<<16))]), 1, 0x10000, fp);
}
fclose(fp);
fp = fopen("registers.bin", "wb");
fwrite(ws_ioRam, 1, 256, fp);
fclose(fp);
fp = fopen("cpuregs.bin", "wb");
/* CS */
fwrite(&I.sregs[CS], 1, 2, fp);
/* IP */
fwrite(&I.ip, 1, 2, fp);
fclose(fp);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void cpu_writemem20(DWORD addr,BYTE value)
{
uint32 offset=addr&0xffff;
uint32 bank=addr>>16;
// 0 - RAM - 16 KB (WS) / 64 KB (WSC) internal RAM
if (!bank)
{
ws_gpu_write_byte(offset,value);
ws_audio_write_byte(offset,value);
}
else
// 1 - SRAM (cart)
if (bank==1)
{
ws_staticRam[offset&sramAddressMask]=value;
ws_sram_dirty = 1;
}
// other banks are read-only
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
BYTE cpu_readmem20(DWORD addr)
{
uint32 offset=addr&0xffff;
uint32 bank=addr>>16;
switch (bank)
{
case 0: // 0 - RAM - 16 KB (WS) / 64 KB (WSC) internal RAM
if (ws_gpu_operatingInColor)
return(internalRam[offset]);
else
if (offset<0x4000)
return(internalRam[offset]);
return(0x90);
case 1: // 1 - SRAM (cart)
return ws_staticRam[offset&sramAddressMask];
case 2:
case 3: return ws_rom[offset+((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+bank]&((romSize>>16)-1))<<16)];
default:
int romBank=(256-(((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR]&0xf)<<4)|(bank&0xf)));
return ws_rom[(unsigned)(offset+romSize-(romBank<<16))];
}
return(0xff);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_init(uint8 *rom, uint32 wsRomSize)
{
ws_romHeaderStruct *ws_romHeader;
ws_rom=rom;
romSize=wsRomSize;
ws_romHeader=ws_rom_getHeader(ws_rom,romSize);
ws_rom_checksum=ws_romHeader->checksum;
internalRam=(uint8*)malloc(0x10000);
ws_staticRam=(uint8*)malloc(0x10000);
externalEeprom=(uint8*)malloc(131072);//ws_rom_eepromSize(ws_rom,romSize));
sramAddressMask=ws_rom_sramSize(ws_rom,romSize)-1;
externalEepromAddressMask=ws_rom_eepromSize(ws_rom,romSize)-1;
romAddressMask=romSize-1;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_reset(void)
{
memset(internalRam,0,0x10000);
//memset(ws_staticRam,0,0x10000); // should the sram really be cleared? ...
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_memory_done(void)
{
free(ws_rom);
free(ws_staticRam);
free(internalRam);
free(externalEeprom);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8 *memory_getRom(void)
{
return(ws_rom);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32 memory_getRomSize(void)
{
return(romSize);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint16 memory_getRomCrc(void)
{
return(ws_rom_checksum);
}
void ws_sram_load(char *path)
{
FILE *f;
size_t read;
f = fopen(path, "r");
if (NULL == f)
{
memset(ws_staticRam, 0, 0x10000);
return;
}
read = fread(ws_staticRam, 1, 0x8000, f);
//fprintf(log_get(), "read 0x%x (of 0x%x?) bytes of save ram from %s\n", read, ws_rom_sramSize(ws_rom, romSize), path);
fclose(f);
}
void ws_sram_save(char *path)
{
FILE *f;
size_t wrote;
f = fopen(path, "wb");
if (NULL == f)
{
fprintf(log_get(), "error opening %s for writing save ram. (%s)\n", path, strerror(errno));
return;
}
wrote = fwrite(ws_staticRam, 1, 0x8000, f);
fflush(f);
//fprintf(log_get(), "wrote 0x%x bytes of save ram to %s\n", wrote, path);
fclose(f);
}

View File

@@ -1,34 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __MEMORY_H__
#define __MEMORY_H__
extern uint8 *ws_staticRam;
extern uint8 *internalRam;
extern uint8 *externalEeprom;
void ws_memory_init(uint8 *rom, uint32 romSize);
void ws_memory_reset(void);
uint8 *memory_getRom(void);
uint32 memory_getRomSize(void);
uint16 memory_getRomCrc(void);
void ws_memory_done(void);
void memory_load(int fp);
void memory_save(int fp);
void ws_sram_load(char *path);
void ws_sram_save(char *path);
void dump_memory();
#endif

View File

@@ -1,921 +0,0 @@
/****************************************************************************
NEC V30MZ(V20/V30/V33) emulator
Small changes made by toshi (Cycle count macros changed , "THROUGH" macro added)
Small changes made by dox@space.pl (Corrected bug in NEG instruction , different AUX flag handling in some opcodes)
(Re)Written June-September 2000 by Bryan McPhail (mish@tendril.co.uk) based
on code by Oliver Bergmann (Raul_Bloodworth@hotmail.com) who based code
on the i286 emulator by Fabrice Frances which had initial work based on
David Hedley's pcemu(!).
This new core features 99% accurate cycle counts for each processor,
there are still some complex situations where cycle counts are wrong,
typically where a few instructions have differing counts for odd/even
source and odd/even destination memory operands.
Flag settings are also correct for the NEC processors rather than the
I86 versions.
Nb: This emulation should be faster than previous NEC cores, but
because the old cycle count values were far too high in many cases
the processor has to do more 'work' than before, so the overall effect
may be a slower core.
****************************************************************************/
#include <stdio.h>
#include <string.h>
/*
#define UINT8 unsigned char
#define UINT16 unsigned short
#define UINT32 unsigned int
#define INT8 signed char
#define INT16 signed short
#define INT32 signed int
*/
#include "source/types.h"
#include "nec.h"
#include "necintrf.h"
/***************************************************************************/
/* cpu state */
/***************************************************************************/
int nec_ICount;
nec_Regs I;
static UINT32 cpu_type;
static UINT32 prefix_base; /* base address of the latest prefix segment */
char seg_prefix; /* prefix segment indicator */
/* The interrupt number of a pending external interrupt pending NMI is 2. */
/* For INTR interrupts, the level is caught on the bus during an INTA cycle */
#include "necinstr.h"
#include "necea.h"
#include "necmodrm.h"
static int no_interrupt;
static UINT8 parity_table[256];
/***************************************************************************/
void nec_reset (void *param)
{
unsigned int i,j,c;
BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH };
memset( &I, 0, sizeof(I) );
no_interrupt=0;
I.sregs[CS] = 0xffff;
for (i = 0;i < 256; i++)
{
for (j = i, c = 0; j > 0; j >>= 1)
if (j & 1) c++;
parity_table[i] = !(c & 1);
}
I.ZeroVal = I.ParityVal = 1;
SetMD(1); /* set the mode-flag = native mode */
for (i = 0; i < 256; i++)
{
Mod_RM.reg.b[i] = reg_name[(i & 0x38) >> 3];
Mod_RM.reg.w[i] = (WREGS) ( (i & 0x38) >> 3) ;
}
for (i = 0xc0; i < 0x100; i++)
{
Mod_RM.RM.w[i] = (WREGS)( i & 7 );
Mod_RM.RM.b[i] = (BREGS)reg_name[i & 7];
}
}
void nec_exit (void)
{
}
void nec_int(DWORD wektor)
{
DWORD dest_seg, dest_off;
if(I.IF)
{
i_pushf();
I.TF = I.IF = 0;
dest_off = ReadWord(wektor);
dest_seg = ReadWord(wektor+2);
PUSH(I.sregs[CS]);
PUSH(I.ip);
I.ip = (WORD)dest_off;
I.sregs[CS] = (WORD)dest_seg;
}
}
static void nec_interrupt(unsigned int_num, /*BOOLEAN*/ int md_flag)
{
UINT32 dest_seg, dest_off;
if (int_num == -1)
return;
i_pushf();
I.TF = I.IF = 0;
dest_off = ReadWord((int_num)*4);
dest_seg = ReadWord((int_num)*4+2);
PUSH(I.sregs[CS]);
PUSH(I.ip);
I.ip = (WORD)dest_off;
I.sregs[CS] = (WORD)dest_seg;
}
/****************************************************************************/
/* OPCODES */
/****************************************************************************/
#define OP(num,func_name) static void func_name(void)
OP( 0x00, i_add_br8 ) { DEF_br8; ADDB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x01, i_add_wr16 ) { DEF_wr16; ADDW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x02, i_add_r8b ) { DEF_r8b; ADDB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x03, i_add_r16w ) { DEF_r16w; ADDW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x04, i_add_ald8 ) { DEF_ald8; ADDB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x05, i_add_axd16) { DEF_axd16; ADDW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x06, i_push_es ) { PUSH(I.sregs[ES]); CLK(2); }
OP( 0x07, i_pop_es ) { POP(I.sregs[ES]); CLK(3); }
OP( 0x08, i_or_br8 ) { DEF_br8; ORB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x09, i_or_wr16 ) { DEF_wr16; ORW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x0a, i_or_r8b ) { DEF_r8b; ORB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x0b, i_or_r16w ) { DEF_r16w; ORW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x0c, i_or_ald8 ) { DEF_ald8; ORB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x0d, i_or_axd16 ) { DEF_axd16; ORW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x0e, i_push_cs ) { PUSH(I.sregs[CS]); CLK(2); }
OP( 0x0f, i_pre_nec ) { UINT32 ModRM, tmp, tmp2; /* pop cs at V30MZ? */
switch (FETCH) {
case 0x10 : BITOP_BYTE; CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0x7; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */
case 0x11 : BITOP_WORD; CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0xf; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */
case 0x12 : BITOP_BYTE; CLKS(5,5,4); tmp2 = I.regs.b[CL] & 0x7; tmp &= ~(1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Clr */
case 0x13 : BITOP_WORD; CLKS(5,5,4); tmp2 = I.regs.b[CL] & 0xf; tmp &= ~(1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Clr */
case 0x14 : BITOP_BYTE; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0x7; tmp |= (1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Set */
case 0x15 : BITOP_WORD; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0xf; tmp |= (1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Set */
case 0x16 : BITOP_BYTE; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0x7; BIT_NOT; PutbackRMByte(ModRM,tmp); break; /* Not */
case 0x17 : BITOP_WORD; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0xf; BIT_NOT; PutbackRMWord(ModRM,tmp); break; /* Not */
case 0x18 : BITOP_BYTE; CLKS(4,4,4); tmp2 = (FETCH) & 0x7; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */
case 0x19 : BITOP_WORD; CLKS(4,4,4); tmp2 = (FETCH) & 0xf; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */
case 0x1a : BITOP_BYTE; CLKS(6,6,4); tmp2 = (FETCH) & 0x7; tmp &= ~(1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Clr */
case 0x1b : BITOP_WORD; CLKS(6,6,4); tmp2 = (FETCH) & 0xf; tmp &= ~(1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Clr */
case 0x1c : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH) & 0x7; tmp |= (1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Set */
case 0x1d : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH) & 0xf; tmp |= (1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Set */
case 0x1e : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH) & 0x7; BIT_NOT; PutbackRMByte(ModRM,tmp); break; /* Not */
case 0x1f : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH) & 0xf; BIT_NOT; PutbackRMWord(ModRM,tmp); break; /* Not */
case 0x20 : ADD4S; CLKS(7,7,2); break;
case 0x22 : SUB4S; CLKS(7,7,2); break;
case 0x26 : CMP4S; CLKS(7,7,2); break;
case 0x28 : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp <<= 4; tmp |= I.regs.b[AL] & 0xf; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | ((tmp>>8)&0xf); tmp &= 0xff; PutbackRMByte(ModRM,tmp); CLKM(9,15); break;
case 0x2a : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp2 = (I.regs.b[AL] & 0xf)<<4; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | (tmp&0xf); tmp = tmp2 | (tmp>>4); PutbackRMByte(ModRM,tmp); CLKM(13,19); break;
case 0x31 : ModRM = FETCH; ModRM=0; break;
case 0x33 : ModRM = FETCH; ModRM=0; break;
case 0x92 : CLK(2); break; /* V25/35 FINT */
case 0xe0 : ModRM = FETCH; ModRM=0; break;
case 0xf0 : ModRM = FETCH; ModRM=0; break;
case 0xff : ModRM = FETCH; ModRM=0; break;
default: break;
}
}
OP( 0x10, i_adc_br8 ) { DEF_br8; src+=CF; ADDB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x11, i_adc_wr16 ) { DEF_wr16; src+=CF; ADDW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x12, i_adc_r8b ) { DEF_r8b; src+=CF; ADDB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x13, i_adc_r16w ) { DEF_r16w; src+=CF; ADDW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x14, i_adc_ald8 ) { DEF_ald8; src+=CF; ADDB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x15, i_adc_axd16) { DEF_axd16; src+=CF; ADDW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x16, i_push_ss ) { PUSH(I.sregs[SS]); CLK(2); }
OP( 0x17, i_pop_ss ) { POP(I.sregs[SS]); CLK(3); no_interrupt=1; }
OP( 0x18, i_sbb_br8 ) { DEF_br8; src+=CF; SUBB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x19, i_sbb_wr16 ) { DEF_wr16; src+=CF; SUBW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x1a, i_sbb_r8b ) { DEF_r8b; src+=CF; SUBB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x1b, i_sbb_r16w ) { DEF_r16w; src+=CF; SUBW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x1c, i_sbb_ald8 ) { DEF_ald8; src+=CF; SUBB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x1d, i_sbb_axd16) { DEF_axd16; src+=CF; SUBW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x1e, i_push_ds ) { PUSH(I.sregs[DS]); CLK(2); }
OP( 0x1f, i_pop_ds ) { POP(I.sregs[DS]); CLK(3); }
OP( 0x20, i_and_br8 ) { DEF_br8; ANDB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x21, i_and_wr16 ) { DEF_wr16; ANDW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x22, i_and_r8b ) { DEF_r8b; ANDB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x23, i_and_r16w ) { DEF_r16w; ANDW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x24, i_and_ald8 ) { DEF_ald8; ANDB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x25, i_and_axd16) { DEF_axd16; ANDW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x26, i_es ) { seg_prefix=TRUE; prefix_base=I.sregs[ES]<<4; CLK(1); nec_instruction[FETCHOP](); seg_prefix=FALSE; }
OP( 0x27, i_daa ) { ADJ4(6,0x60); CLK(10); }
OP( 0x28, i_sub_br8 ) { DEF_br8; SUBB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x29, i_sub_wr16 ) { DEF_wr16; SUBW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x2a, i_sub_r8b ) { DEF_r8b; SUBB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x2b, i_sub_r16w ) { DEF_r16w; SUBW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x2c, i_sub_ald8 ) { DEF_ald8; SUBB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x2d, i_sub_axd16) { DEF_axd16; SUBW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x2e, i_cs ) { seg_prefix=TRUE; prefix_base=I.sregs[CS]<<4; CLK(1); nec_instruction[FETCHOP](); seg_prefix=FALSE; }
OP( 0x2f, i_das ) { ADJ4(-6,-0x60); CLK(10); }
OP( 0x30, i_xor_br8 ) { DEF_br8; XORB; PutbackRMByte(ModRM,dst); CLKM(3,1); }
OP( 0x31, i_xor_wr16 ) { DEF_wr16; XORW; PutbackRMWord(ModRM,dst); CLKM(3,1); }
OP( 0x32, i_xor_r8b ) { DEF_r8b; XORB; RegByte(ModRM)=dst; CLKM(2,1); }
OP( 0x33, i_xor_r16w ) { DEF_r16w; XORW; RegWord(ModRM)=dst; CLKM(2,1); }
OP( 0x34, i_xor_ald8 ) { DEF_ald8; XORB; I.regs.b[AL]=dst; CLK(1); }
OP( 0x35, i_xor_axd16) { DEF_axd16; XORW; I.regs.w[AW]=dst; CLK(1); }
OP( 0x36, i_ss ) { seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; CLK(1); nec_instruction[FETCHOP](); seg_prefix=FALSE; }
OP( 0x37, i_aaa ) { ADJB(6,1); CLK(9); }
OP( 0x38, i_cmp_br8 ) { DEF_br8; SUBB; CLKM(2,1); }
OP( 0x39, i_cmp_wr16 ) { DEF_wr16; SUBW; CLKM(2,1); }
OP( 0x3a, i_cmp_r8b ) { DEF_r8b; SUBB; CLKM(2,1); }
OP( 0x3b, i_cmp_r16w ) { DEF_r16w; SUBW; CLKM(2,1); }
OP( 0x3c, i_cmp_ald8 ) { DEF_ald8; SUBB; CLK(1); }
OP( 0x3d, i_cmp_axd16) { DEF_axd16; SUBW; CLK(1); }
OP( 0x3e, i_ds ) { seg_prefix=TRUE; prefix_base=I.sregs[DS]<<4; CLK(1); nec_instruction[FETCHOP](); seg_prefix=FALSE; }
OP( 0x3f, i_aas ) { ADJB(-6,-1); CLK(9); }
OP( 0x40, i_inc_ax ) { IncWordReg(AW); CLK(1); }
OP( 0x41, i_inc_cx ) { IncWordReg(CW); CLK(1); }
OP( 0x42, i_inc_dx ) { IncWordReg(DW); CLK(1); }
OP( 0x43, i_inc_bx ) { IncWordReg(BW); CLK(1); }
OP( 0x44, i_inc_sp ) { IncWordReg(SP); CLK(1); }
OP( 0x45, i_inc_bp ) { IncWordReg(BP); CLK(1); }
OP( 0x46, i_inc_si ) { IncWordReg(IX); CLK(1); }
OP( 0x47, i_inc_di ) { IncWordReg(IY); CLK(1); }
OP( 0x48, i_dec_ax ) { DecWordReg(AW); CLK(1); }
OP( 0x49, i_dec_cx ) { DecWordReg(CW); CLK(1); }
OP( 0x4a, i_dec_dx ) { DecWordReg(DW); CLK(1); }
OP( 0x4b, i_dec_bx ) { DecWordReg(BW); CLK(1); }
OP( 0x4c, i_dec_sp ) { DecWordReg(SP); CLK(1); }
OP( 0x4d, i_dec_bp ) { DecWordReg(BP); CLK(1); }
OP( 0x4e, i_dec_si ) { DecWordReg(IX); CLK(1); }
OP( 0x4f, i_dec_di ) { DecWordReg(IY); CLK(1); }
OP( 0x50, i_push_ax ) { PUSH(I.regs.w[AW]); CLK(1); }
OP( 0x51, i_push_cx ) { PUSH(I.regs.w[CW]); CLK(1); }
OP( 0x52, i_push_dx ) { PUSH(I.regs.w[DW]); CLK(1); }
OP( 0x53, i_push_bx ) { PUSH(I.regs.w[BW]); CLK(1); }
OP( 0x54, i_push_sp ) { PUSH(I.regs.w[SP]); CLK(1); }
OP( 0x55, i_push_bp ) { PUSH(I.regs.w[BP]); CLK(1); }
OP( 0x56, i_push_si ) { PUSH(I.regs.w[IX]); CLK(1); }
OP( 0x57, i_push_di ) { PUSH(I.regs.w[IY]); CLK(1); }
OP( 0x58, i_pop_ax ) { POP(I.regs.w[AW]); CLK(1); }
OP( 0x59, i_pop_cx ) { POP(I.regs.w[CW]); CLK(1); }
OP( 0x5a, i_pop_dx ) { POP(I.regs.w[DW]); CLK(1); }
OP( 0x5b, i_pop_bx ) { POP(I.regs.w[BW]); CLK(1); }
OP( 0x5c, i_pop_sp ) { POP(I.regs.w[SP]); CLK(1); }
OP( 0x5d, i_pop_bp ) { POP(I.regs.w[BP]); CLK(1); }
OP( 0x5e, i_pop_si ) { POP(I.regs.w[IX]); CLK(1); }
OP( 0x5f, i_pop_di ) { POP(I.regs.w[IY]); CLK(1); }
OP( 0x60, i_pusha ) {
unsigned tmp=I.regs.w[SP];
PUSH(I.regs.w[AW]);
PUSH(I.regs.w[CW]);
PUSH(I.regs.w[DW]);
PUSH(I.regs.w[BW]);
PUSH(tmp);
PUSH(I.regs.w[BP]);
PUSH(I.regs.w[IX]);
PUSH(I.regs.w[IY]);
CLK(9);
}
OP( 0x61, i_popa ) {
unsigned tmp;
POP(I.regs.w[IY]);
POP(I.regs.w[IX]);
POP(I.regs.w[BP]);
POP(tmp);
POP(I.regs.w[BW]);
POP(I.regs.w[DW]);
POP(I.regs.w[CW]);
POP(I.regs.w[AW]);
CLK(8);
}
OP( 0x62, i_chkind ) {
UINT32 low,high,tmp;
GetModRM;
low = GetRMWord(ModRM);
high= GetnextRMWord;
tmp= RegWord(ModRM);
if (tmp<low || tmp>high) {
nec_interrupt(5,0);
CLK(7);
}
CLK(13);
}
/* OP 0x64 - 0x67 is nop at V30MZ */
OP( 0x64, i_repnc ) { UINT32 next = FETCHOP; UINT16 c = I.regs.w[CW];
switch(next) { /* Segments */
case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[ES]<<4; next = FETCHOP; CLK(2); break;
case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[CS]<<4; next = FETCHOP; CLK(2); break;
case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = FETCHOP; CLK(2); break;
case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS]<<4; next = FETCHOP; CLK(2); break;
}
switch(next) {
case 0x6c: CLK(2); if (c) do { i_insb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0x6d: CLK(2); if (c) do { i_insw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0x6e: CLK(2); if (c) do { i_outsb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0x6f: CLK(2); if (c) do { i_outsw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xa4: CLK(2); if (c) do { i_movsb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xa5: CLK(2); if (c) do { i_movsw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xa6: CLK(2); if (c) do { i_cmpsb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xa7: CLK(2); if (c) do { i_cmpsw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xaa: CLK(2); if (c) do { i_stosb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xab: CLK(2); if (c) do { i_stosw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xac: CLK(2); if (c) do { i_lodsb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xad: CLK(2); if (c) do { i_lodsw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xae: CLK(2); if (c) do { i_scasb(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
default: nec_instruction[next]();
}
seg_prefix=FALSE;
}
OP( 0x65, i_repc ) { UINT32 next = FETCHOP; UINT16 c = I.regs.w[CW];
switch(next) { /* Segments */
case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[ES]<<4; next = FETCHOP; CLK(2); break;
case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[CS]<<4; next = FETCHOP; CLK(2); break;
case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = FETCHOP; CLK(2); break;
case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS]<<4; next = FETCHOP; CLK(2); break;
}
switch(next) {
case 0x6c: CLK(2); if (c) do { i_insb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0x6d: CLK(2); if (c) do { i_insw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0x6e: CLK(2); if (c) do { i_outsb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0x6f: CLK(2); if (c) do { i_outsw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xa4: CLK(2); if (c) do { i_movsb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xa5: CLK(2); if (c) do { i_movsw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xa6: CLK(2); if (c) do { i_cmpsb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xa7: CLK(2); if (c) do { i_cmpsw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xaa: CLK(2); if (c) do { i_stosb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xab: CLK(2); if (c) do { i_stosw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xac: CLK(2); if (c) do { i_lodsb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xad: CLK(2); if (c) do { i_lodsw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xae: CLK(2); if (c) do { i_scasb(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break;
default: nec_instruction[next]();
}
seg_prefix=FALSE;
}
OP( 0x68, i_push_d16 ) { UINT32 tmp; FETCHWORD(tmp); PUSH(tmp); CLK(1); }
OP( 0x69, i_imul_d16 ) { UINT32 tmp; DEF_r16w; FETCHWORD(tmp); dst = (INT32)((INT16)src)*(INT32)((INT16)tmp); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; CLKM(4,3);}
OP( 0x6a, i_push_d8 ) { UINT32 tmp = (WORD)((INT16)((INT8)FETCH)); PUSH(tmp); CLK(1); }
OP( 0x6b, i_imul_d8 ) { UINT32 src2; DEF_r16w; src2= (WORD)((INT16)((INT8)FETCH)); dst = (INT32)((INT16)src)*(INT32)((INT16)src2); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; CLKM(4,3); }
OP( 0x6c, i_insb ) { PutMemB(ES,I.regs.w[IY],read_port(I.regs.w[DW])); I.regs.w[IY]+= -2 * I.DF + 1; CLK(6); }
OP( 0x6d, i_insw ) { PutMemB(ES,I.regs.w[IY],read_port(I.regs.w[DW])); PutMemB(ES,(I.regs.w[IY]+1)&0xffff,read_port((I.regs.w[DW]+1)&0xffff)); I.regs.w[IY]+= -4 * I.DF + 2; CLK(6); }
OP( 0x6e, i_outsb ) { write_port(I.regs.w[DW],GetMemB(DS,I.regs.w[IX])); I.regs.w[IX]+= -2 * I.DF + 1; CLK(7); }
OP( 0x6f, i_outsw ) { write_port(I.regs.w[DW],GetMemB(DS,I.regs.w[IX])); write_port((I.regs.w[DW]+1)&0xffff,GetMemB(DS,(I.regs.w[IX]+1)&0xffff)); I.regs.w[IX]+= -4 * I.DF + 2; CLK(7); }
OP( 0x70, i_jo ) { JMP( OF); CLK(1); }
OP( 0x71, i_jno ) { JMP(!OF); CLK(1); }
OP( 0x72, i_jc ) { JMP( CF); CLK(1); }
OP( 0x73, i_jnc ) { JMP(!CF); CLK(1); }
OP( 0x74, i_jz ) { JMP( ZF); CLK(1); }
OP( 0x75, i_jnz ) { JMP(!ZF); CLK(1); }
OP( 0x76, i_jce ) { JMP(CF || ZF); CLK(1); }
OP( 0x77, i_jnce ) { JMP(!(CF || ZF)); CLK(1); }
OP( 0x78, i_js ) { JMP( SF); CLK(1); }
OP( 0x79, i_jns ) { JMP(!SF); CLK(1); }
OP( 0x7a, i_jp ) { JMP( PF); CLK(1); }
OP( 0x7b, i_jnp ) { JMP(!PF); CLK(1); }
OP( 0x7c, i_jl ) { JMP((SF!=OF)&&(!ZF)); CLK(1); }
OP( 0x7d, i_jnl ) { JMP((ZF)||(SF==OF)); CLK(1); }
OP( 0x7e, i_jle ) { JMP((ZF)||(SF!=OF)); CLK(1); }
OP( 0x7f, i_jnle ) { JMP((SF==OF)&&(!ZF)); CLK(1); }
OP( 0x80, i_80pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH;
CLKM(3,1)
switch (ModRM & 0x38) {
case 0x00: ADDB; PutbackRMByte(ModRM,dst); break;
case 0x08: ORB; PutbackRMByte(ModRM,dst); break;
case 0x10: src+=CF; ADDB; PutbackRMByte(ModRM,dst); break;
case 0x18: src+=CF; SUBB; PutbackRMByte(ModRM,dst); break;
case 0x20: ANDB; PutbackRMByte(ModRM,dst); break;
case 0x28: SUBB; PutbackRMByte(ModRM,dst); break;
case 0x30: XORB; PutbackRMByte(ModRM,dst); break;
case 0x38: SUBB; break; /* CMP */
}
}
OP( 0x81, i_81pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH; src+= (FETCH << 8);
CLKM(3,1)
switch (ModRM & 0x38) {
case 0x00: ADDW; PutbackRMWord(ModRM,dst); break;
case 0x08: ORW; PutbackRMWord(ModRM,dst); break;
case 0x10: src+=CF; ADDW; PutbackRMWord(ModRM,dst); break;
case 0x18: src+=CF; SUBW; PutbackRMWord(ModRM,dst); break;
case 0x20: ANDW; PutbackRMWord(ModRM,dst); break;
case 0x28: SUBW; PutbackRMWord(ModRM,dst); break;
case 0x30: XORW; PutbackRMWord(ModRM,dst); break;
case 0x38: SUBW; break; /* CMP */
}
}
OP( 0x82, i_82pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (BYTE)((INT8)FETCH);
CLKM(3,1)
switch (ModRM & 0x38) {
case 0x00: ADDB; PutbackRMByte(ModRM,dst); break;
case 0x08: ORB; PutbackRMByte(ModRM,dst); break;
case 0x10: src+=CF; ADDB; PutbackRMByte(ModRM,dst); break;
case 0x18: src+=CF; SUBB; PutbackRMByte(ModRM,dst); break;
case 0x20: ANDB; PutbackRMByte(ModRM,dst); break;
case 0x28: SUBB; PutbackRMByte(ModRM,dst); break;
case 0x30: XORB; PutbackRMByte(ModRM,dst); break;
case 0x38: SUBB; break; /* CMP */
}
}
OP( 0x83, i_83pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (WORD)((INT16)((INT8)FETCH));
CLKM(3,1)
switch (ModRM & 0x38) {
case 0x00: ADDW; PutbackRMWord(ModRM,dst); break;
case 0x08: ORW; PutbackRMWord(ModRM,dst); break;
case 0x10: src+=CF; ADDW; PutbackRMWord(ModRM,dst); break;
case 0x18: src+=CF; SUBW; PutbackRMWord(ModRM,dst); break;
case 0x20: ANDW; PutbackRMWord(ModRM,dst); break;
case 0x28: SUBW; PutbackRMWord(ModRM,dst); break;
case 0x30: XORW; PutbackRMWord(ModRM,dst); break;
case 0x38: SUBW; break; /* CMP */
}
}
OP( 0x84, i_test_br8 ) { DEF_br8; ANDB; CLKM(2,1); }
OP( 0x85, i_test_wr16 ) { DEF_wr16; ANDW; CLKM(2,1); }
OP( 0x86, i_xchg_br8 ) { DEF_br8; RegByte(ModRM)=dst; PutbackRMByte(ModRM,src); CLKM(5,3); }
OP( 0x87, i_xchg_wr16 ) { DEF_wr16; RegWord(ModRM)=dst; PutbackRMWord(ModRM,src); CLKM(5,3); }
OP( 0x88, i_mov_br8 ) { UINT8 src; GetModRM; src = RegByte(ModRM); PutRMByte(ModRM,src); CLKM(1,1); }
OP( 0x89, i_mov_wr16 ) { UINT16 src; GetModRM; src = RegWord(ModRM); PutRMWord(ModRM,src); CLKM(1,1); }
OP( 0x8a, i_mov_r8b ) { UINT8 src; GetModRM; src = GetRMByte(ModRM); RegByte(ModRM)=src; CLKM(1,1); }
OP( 0x8b, i_mov_r16w ) { UINT16 src; GetModRM; src = GetRMWord(ModRM); RegWord(ModRM)=src; CLKM(1,1); }
OP( 0x8c, i_mov_wsreg ) { GetModRM; PutRMWord(ModRM,I.sregs[(ModRM & 0x38) >> 3]); CLKM(1,1); }
OP( 0x8d, i_lea ) { UINT16 ModRM = FETCH; (void)(*GetEA[ModRM])(); RegWord(ModRM)=EO; CLK(1); }
OP( 0x8e, i_mov_sregw ) { UINT16 src; GetModRM; src = GetRMWord(ModRM); CLKM(3,2);
switch (ModRM & 0x38) {
case 0x00: I.sregs[ES] = src; break; /* mov es,ew */
case 0x08: I.sregs[CS] = src; break; /* mov cs,ew */
case 0x10: I.sregs[SS] = src; break; /* mov ss,ew */
case 0x18: I.sregs[DS] = src; break; /* mov ds,ew */
default: ;
}
no_interrupt=1;
}
OP( 0x8f, i_popw ) { UINT16 tmp; GetModRM; POP(tmp); PutRMWord(ModRM,tmp); CLKM(3,1); }
OP( 0x90, i_nop ) { CLK(1);
/* Cycle skip for idle loops (0: NOP 1: JMP 0) */
if (no_interrupt==0 && nec_ICount>0 && (PEEKOP((I.sregs[CS]<<4)+I.ip))==0xeb && (PEEK((I.sregs[CS]<<4)+I.ip+1))==0xfd)
nec_ICount%=15;
}
OP( 0x91, i_xchg_axcx ) { XchgAWReg(CW); CLK(3); }
OP( 0x92, i_xchg_axdx ) { XchgAWReg(DW); CLK(3); }
OP( 0x93, i_xchg_axbx ) { XchgAWReg(BW); CLK(3); }
OP( 0x94, i_xchg_axsp ) { XchgAWReg(SP); CLK(3); }
OP( 0x95, i_xchg_axbp ) { XchgAWReg(BP); CLK(3); }
OP( 0x96, i_xchg_axsi ) { XchgAWReg(IX); CLK(3); }
OP( 0x97, i_xchg_axdi ) { XchgAWReg(IY); CLK(3); }
OP( 0x98, i_cbw ) { I.regs.b[AH] = (I.regs.b[AL] & 0x80) ? 0xff : 0; CLK(1); }
OP( 0x99, i_cwd ) { I.regs.w[DW] = (I.regs.b[AH] & 0x80) ? 0xffff : 0; CLK(1); }
OP( 0x9a, i_call_far ) { UINT32 tmp, tmp2; FETCHWORD(tmp); FETCHWORD(tmp2); PUSH(I.sregs[CS]); PUSH(I.ip); I.ip = (WORD)tmp; I.sregs[CS] = (WORD)tmp2; CLK(10); }
OP( 0x9b, i_wait ) { ; }
OP( 0x9c, i_pushf ) { PUSH( CompressFlags() ); CLK(2); }
OP( 0x9d, i_popf ) { UINT32 tmp; POP(tmp); ExpandFlags(tmp); CLK(3);}
OP( 0x9e, i_sahf ) { UINT32 tmp = (CompressFlags() & 0xff00) | (I.regs.b[AH] & 0xd5); ExpandFlags(tmp); CLK(4); }
OP( 0x9f, i_lahf ) { I.regs.b[AH] = CompressFlags() & 0xff; CLK(2); }
OP( 0xa0, i_mov_aldisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS, addr); CLK(1); }
OP( 0xa1, i_mov_axdisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS, addr); I.regs.b[AH] = GetMemB(DS, (addr+1)&0xffff); CLK(1); }
OP( 0xa2, i_mov_dispal ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS, addr, I.regs.b[AL]); CLK(1); }
OP( 0xa3, i_mov_dispax ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS, addr, I.regs.b[AL]); PutMemB(DS, (addr+1)&0xffff, I.regs.b[AH]); CLK(1); }
OP( 0xa4, i_movsb ) { UINT32 tmp = GetMemB(DS,I.regs.w[IX]); PutMemB(ES,I.regs.w[IY], tmp); I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLK(5); }
OP( 0xa5, i_movsw ) { UINT32 tmp = GetMemW(DS,I.regs.w[IX]); PutMemW(ES,I.regs.w[IY], tmp); I.regs.w[IY] += -4 * I.DF + 2; I.regs.w[IX] += -4 * I.DF + 2; CLK(5); }
OP( 0xa6, i_cmpsb ) { UINT32 src = GetMemB(ES, I.regs.w[IY]); UINT32 dst = GetMemB(DS, I.regs.w[IX]); SUBB; I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLK(6); }
OP( 0xa7, i_cmpsw ) { UINT32 src = GetMemW(ES, I.regs.w[IY]); UINT32 dst = GetMemW(DS, I.regs.w[IX]); SUBW; I.regs.w[IY] += -4 * I.DF + 2; I.regs.w[IX] += -4 * I.DF + 2; CLK(6); }
OP( 0xa8, i_test_ald8 ) { DEF_ald8; ANDB; CLK(1); }
OP( 0xa9, i_test_axd16 ) { DEF_axd16; ANDW; CLK(1); }
OP( 0xaa, i_stosb ) { PutMemB(ES,I.regs.w[IY],I.regs.b[AL]); I.regs.w[IY] += -2 * I.DF + 1; CLK(3); }
OP( 0xab, i_stosw ) { PutMemW(ES,I.regs.w[IY],I.regs.w[AW]); I.regs.w[IY] += -4 * I.DF + 2; CLK(3); }
OP( 0xac, i_lodsb ) { I.regs.b[AL] = GetMemB(DS,I.regs.w[IX]); I.regs.w[IX] += -2 * I.DF + 1; CLK(3); }
OP( 0xad, i_lodsw ) { I.regs.w[AW] = GetMemW(DS,I.regs.w[IX]); I.regs.w[IX] += -4 * I.DF + 2; CLK(3); }
OP( 0xae, i_scasb ) { UINT32 src = GetMemB(ES, I.regs.w[IY]); UINT32 dst = I.regs.b[AL]; SUBB; I.regs.w[IY] += -2 * I.DF + 1; CLK(4); }
OP( 0xaf, i_scasw ) { UINT32 src = GetMemW(ES, I.regs.w[IY]); UINT32 dst = I.regs.w[AW]; SUBW; I.regs.w[IY] += -4 * I.DF + 2; CLK(4); }
OP( 0xb0, i_mov_ald8 ) { I.regs.b[AL] = FETCH; CLK(1); }
OP( 0xb1, i_mov_cld8 ) { I.regs.b[CL] = FETCH; CLK(1); }
OP( 0xb2, i_mov_dld8 ) { I.regs.b[DL] = FETCH; CLK(1); }
OP( 0xb3, i_mov_bld8 ) { I.regs.b[BL] = FETCH; CLK(1); }
OP( 0xb4, i_mov_ahd8 ) { I.regs.b[AH] = FETCH; CLK(1); }
OP( 0xb5, i_mov_chd8 ) { I.regs.b[CH] = FETCH; CLK(1); }
OP( 0xb6, i_mov_dhd8 ) { I.regs.b[DH] = FETCH; CLK(1); }
OP( 0xb7, i_mov_bhd8 ) { I.regs.b[BH] = FETCH; CLK(1); }
OP( 0xb8, i_mov_axd16 ) { I.regs.b[AL] = FETCH; I.regs.b[AH] = FETCH; CLK(1); }
OP( 0xb9, i_mov_cxd16 ) { I.regs.b[CL] = FETCH; I.regs.b[CH] = FETCH; CLK(1); }
OP( 0xba, i_mov_dxd16 ) { I.regs.b[DL] = FETCH; I.regs.b[DH] = FETCH; CLK(1); }
OP( 0xbb, i_mov_bxd16 ) { I.regs.b[BL] = FETCH; I.regs.b[BH] = FETCH; CLK(1); }
OP( 0xbc, i_mov_spd16 ) { I.regs.b[SPL] = FETCH; I.regs.b[SPH] = FETCH; CLK(1); }
OP( 0xbd, i_mov_bpd16 ) { I.regs.b[BPL] = FETCH; I.regs.b[BPH] = FETCH; CLK(1); }
OP( 0xbe, i_mov_sid16 ) { I.regs.b[IXL] = FETCH; I.regs.b[IXH] = FETCH; CLK(1); }
OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH; I.regs.b[IYH] = FETCH; CLK(1); }
OP( 0xc0, i_rotshft_bd8 ) {
UINT32 src, dst; UINT8 c;
GetModRM; src = (unsigned)GetRMByte(ModRM); dst=src;
c=FETCH;
c&=0x1f;
CLKM(5,3);
if (c) switch (ModRM & 0x38) {
case 0x00: do { ROL_BYTE; c--; } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x08: do { ROR_BYTE; c--; } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x10: do { ROLC_BYTE; c--; } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x18: do { RORC_BYTE; c--; } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x20: SHL_BYTE(c); I.AuxVal = 1; break;//
case 0x28: SHR_BYTE(c); I.AuxVal = 1; break;//
case 0x30: break;
case 0x38: SHRA_BYTE(c); break;
}
}
OP( 0xc1, i_rotshft_wd8 ) {
UINT32 src, dst; UINT8 c;
GetModRM; src = (unsigned)GetRMWord(ModRM); dst=src;
c=FETCH;
c&=0x1f;
CLKM(5,3);
if (c) switch (ModRM & 0x38) {
case 0x00: do { ROL_WORD; c--; } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x08: do { ROR_WORD; c--; } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x10: do { ROLC_WORD; c--; } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x18: do { RORC_WORD; c--; } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x20: SHL_WORD(c); I.AuxVal = 1; break;
case 0x28: SHR_WORD(c); I.AuxVal = 1; break;
case 0x30: break;
case 0x38: SHRA_WORD(c); break;
}
}
OP( 0xc2, i_ret_d16 ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); I.regs.w[SP]+=count; CLK(6); }
OP( 0xc3, i_ret ) { POP(I.ip); CLK(6); }
OP( 0xc4, i_les_dw ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[ES] = GetnextRMWord; CLK(6); }
OP( 0xc5, i_lds_dw ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[DS] = GetnextRMWord; CLK(6); }
OP( 0xc6, i_mov_bd8 ) { GetModRM; PutImmRMByte(ModRM); CLK(1); }
OP( 0xc7, i_mov_wd16 ) { GetModRM; PutImmRMWord(ModRM); CLK(1); }
OP( 0xc8, i_enter ) {
UINT32 nb = FETCH;
UINT32 i,level;
CLK(19);
nb += FETCH << 8;
level = FETCH;
PUSH(I.regs.w[BP]);
I.regs.w[BP]=I.regs.w[SP];
I.regs.w[SP] -= nb;
for (i=1;i<level;i++) {
PUSH(GetMemW(SS,I.regs.w[BP]-i*2));
CLK(4);
}
if (level) PUSH(I.regs.w[BP]);
}
OP( 0xc9, i_leave ) {
I.regs.w[SP]=I.regs.w[BP];
POP(I.regs.w[BP]);
CLK(2);
}
OP( 0xca, i_retf_d16 ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); POP(I.sregs[CS]); I.regs.w[SP]+=count; CLK(9); }
OP( 0xcb, i_retf ) { POP(I.ip); POP(I.sregs[CS]); CLK(8); }
OP( 0xcc, i_int3 ) { nec_interrupt(3,0); CLK(9); }
OP( 0xcd, i_int ) { nec_interrupt(FETCH,0); CLK(10); }
OP( 0xce, i_into ) { if (OF) { nec_interrupt(4,0); CLK(13); } else CLK(6); }
OP( 0xcf, i_iret ) { POP(I.ip); POP(I.sregs[CS]); i_popf(); CLK(10); }
OP( 0xd0, i_rotshft_b ) {
UINT32 src, dst; GetModRM; src = (UINT32)GetRMByte(ModRM); dst=src;
CLKM(3,1);
switch (ModRM & 0x38) {
case 0x00: ROL_BYTE; PutbackRMByte(ModRM,(BYTE)dst); I.OverVal = (src^dst)&0x80; break;
case 0x08: ROR_BYTE; PutbackRMByte(ModRM,(BYTE)dst); I.OverVal = (src^dst)&0x80; break;
case 0x10: ROLC_BYTE; PutbackRMByte(ModRM,(BYTE)dst); I.OverVal = (src^dst)&0x80; break;
case 0x18: RORC_BYTE; PutbackRMByte(ModRM,(BYTE)dst); I.OverVal = (src^dst)&0x80; break;
case 0x20: SHL_BYTE(1); I.OverVal = (src^dst)&0x80;I.AuxVal = 1; break;
case 0x28: SHR_BYTE(1); I.OverVal = (src^dst)&0x80;I.AuxVal = 1; break;
case 0x30: break;
case 0x38: SHRA_BYTE(1); I.OverVal = 0; break;
}
}
OP( 0xd1, i_rotshft_w ) {
UINT32 src, dst; GetModRM; src = (UINT32)GetRMWord(ModRM); dst=src;
CLKM(3,1);
switch (ModRM & 0x38) {
case 0x00: ROL_WORD; PutbackRMWord(ModRM,(WORD)dst); I.OverVal = (src^dst)&0x8000; break;
case 0x08: ROR_WORD; PutbackRMWord(ModRM,(WORD)dst); I.OverVal = (src^dst)&0x8000; break;
case 0x10: ROLC_WORD; PutbackRMWord(ModRM,(WORD)dst); I.OverVal = (src^dst)&0x8000; break;
case 0x18: RORC_WORD; PutbackRMWord(ModRM,(WORD)dst); I.OverVal = (src^dst)&0x8000; break;
case 0x20: SHL_WORD(1); I.AuxVal = 1;I.OverVal = (src^dst)&0x8000; break;
case 0x28: SHR_WORD(1); I.AuxVal = 1;I.OverVal = (src^dst)&0x8000; break;
case 0x30: break;
case 0x38: SHRA_WORD(1); I.AuxVal = 1;I.OverVal = 0; break;
}
}
OP( 0xd2, i_rotshft_bcl ) {
UINT32 src, dst; UINT8 c; GetModRM; src = (UINT32)GetRMByte(ModRM); dst=src;
c=I.regs.b[CL];
CLKM(5,3);
c&=0x1f;
if (c) switch (ModRM & 0x38) {
case 0x00: do { ROL_BYTE; c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x08: do { ROR_BYTE; c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x10: do { ROLC_BYTE; c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x18: do { RORC_BYTE; c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
case 0x20: SHL_BYTE(c); I.AuxVal = 1; break;
case 0x28: SHR_BYTE(c); I.AuxVal = 1;break;
case 0x30: break;
case 0x38: SHRA_BYTE(c); break;
}
}
OP( 0xd3, i_rotshft_wcl ) {
UINT32 src, dst; UINT8 c; GetModRM; src = (UINT32)GetRMWord(ModRM); dst=src;
c=I.regs.b[CL];
c&=0x1f;
CLKM(5,3);
if (c) switch (ModRM & 0x38) {
case 0x00: do { ROL_WORD; c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x08: do { ROR_WORD; c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x10: do { ROLC_WORD; c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x18: do { RORC_WORD; c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
case 0x20: SHL_WORD(c); I.AuxVal = 1; break;
case 0x28: SHR_WORD(c); I.AuxVal = 1; break;
case 0x30: break;
case 0x38: SHRA_WORD(c); break;
}
}
OP( 0xd4, i_aam ) { UINT32 mult=FETCH; mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLK(17); }
OP( 0xd5, i_aad ) { UINT32 mult=FETCH; mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLK(6); }
OP( 0xd6, i_setalc ) { I.regs.b[AL] = (CF)?0xff:0x00; CLK(3); } /* nop at V30MZ? */
OP( 0xd7, i_trans ) { UINT32 dest = (I.regs.w[BW]+I.regs.b[AL])&0xffff; I.regs.b[AL] = GetMemB(DS, dest); CLK(5); }
OP( 0xd8, i_fpo ) { GetModRM; CLK(3); } /* nop at V30MZ? */
OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); CLK(6); } else CLK(3); }
OP( 0xe1, i_loope ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); CLK(6); } else CLK(3); }
OP( 0xe2, i_loop ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); CLK(5); } else CLK(2); }
OP( 0xe3, i_jcxz ) { INT8 disp = (INT8)FETCH; if (I.regs.w[CW] == 0) { I.ip = (WORD)(I.ip+disp); CLK(4); } else CLK(1); }
OP( 0xe4, i_inal ) { UINT8 port = FETCH; I.regs.b[AL] = read_port(port); CLK(6); }
OP( 0xe5, i_inax ) { UINT8 port = FETCH; I.regs.b[AL] = read_port(port); I.regs.b[AH] = read_port(port+1); CLK(6); }
OP( 0xe6, i_outal ) { UINT8 port = FETCH; write_port(port, I.regs.b[AL]); CLK(6); }
OP( 0xe7, i_outax ) { UINT8 port = FETCH; write_port(port, I.regs.b[AL]); write_port(port+1, I.regs.b[AH]); CLK(6); }
OP( 0xe8, i_call_d16 ) { UINT32 tmp; FETCHWORD(tmp); PUSH(I.ip); I.ip = (WORD)(I.ip+(INT16)tmp); CLK(5); }
OP( 0xe9, i_jmp_d16 ) { UINT32 tmp; FETCHWORD(tmp); I.ip = (WORD)(I.ip+(INT16)tmp); CLK(4); }
OP( 0xea, i_jmp_far ) { UINT32 tmp,tmp1; FETCHWORD(tmp); FETCHWORD(tmp1); I.sregs[CS] = (WORD)tmp1; I.ip = (WORD)tmp; CLK(7); }
OP( 0xeb, i_jmp_d8 ) { int tmp = (int)((INT8)FETCH); CLK(4);
if (tmp==-2 && no_interrupt==0 && nec_ICount>0) nec_ICount%=12; /* cycle skip */
I.ip = (WORD)(I.ip+tmp);
}
OP( 0xec, i_inaldx ) { I.regs.b[AL] = read_port(I.regs.w[DW]); CLK(6);}
OP( 0xed, i_inaxdx ) { UINT32 port = I.regs.w[DW]; I.regs.b[AL] = read_port(port); I.regs.b[AH] = read_port(port+1); CLK(6); }
OP( 0xee, i_outdxal ) { write_port(I.regs.w[DW], I.regs.b[AL]); CLK(6); }
OP( 0xef, i_outdxax ) { UINT32 port = I.regs.w[DW]; write_port(port, I.regs.b[AL]); write_port(port+1, I.regs.b[AH]); CLK(6); }
OP( 0xf0, i_lock ) { no_interrupt=1; CLK(1); }
#define THROUGH \
if(nec_ICount<0){ \
if(seg_prefix) \
I.ip-=(UINT16)3; \
else \
I.ip-=(UINT16)2; \
break;}
OP( 0xf2, i_repne ) { UINT32 next = FETCHOP; UINT16 c = I.regs.w[CW];
switch(next) { /* Segments */
case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[ES]<<4; next = FETCHOP; CLK(2); break;
case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[CS]<<4; next = FETCHOP; CLK(2); break;
case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = FETCHOP; CLK(2); break;
case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS]<<4; next = FETCHOP; CLK(2); break;
}
switch(next) {
case 0x6c: CLK(2); if (c) do { i_insb(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0x6d: CLK(2); if (c) do { i_insw(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0x6e: CLK(2); if (c) do { i_outsb(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0x6f: CLK(2); if (c) do { i_outsw(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xa4: CLK(2); if (c) do { i_movsb(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xa5: CLK(2); if (c) do { i_movsw(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xa6: CLK(5); if (c) do { THROUGH; i_cmpsb(); c--; CLK(3); } while (c>0 && ZF==0); I.regs.w[CW]=c; break;
case 0xa7: CLK(5); if (c) do { THROUGH; i_cmpsw(); c--; CLK(3); } while (c>0 && ZF==0); I.regs.w[CW]=c; break;
case 0xaa: CLK(2); if (c) do { i_stosb(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xab: CLK(2); if (c) do { i_stosw(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xac: CLK(2); if (c) do { i_lodsb(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xad: CLK(2); if (c) do { i_lodsw(); c--; } while (c>0); I.regs.w[CW]=c; break;
case 0xae: CLK(5); if (c) do { THROUGH; i_scasb(); c--; CLK(5); } while (c>0 && ZF==0); I.regs.w[CW]=c; break;
case 0xaf: CLK(5); if (c) do { THROUGH; i_scasw(); c--; CLK(5); } while (c>0 && ZF==0); I.regs.w[CW]=c; break;
default: nec_instruction[next]();
}
seg_prefix=FALSE;
}
OP( 0xf3, i_repe ) { UINT32 next = FETCHOP; UINT16 c = I.regs.w[CW];
switch(next) { /* Segments */
case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[ES]<<4; next = FETCHOP; CLK(2); break;
case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[CS]<<4; next = FETCHOP; CLK(2); break;
case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = FETCHOP; CLK(2); break;
case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS]<<4; next = FETCHOP; CLK(2); break;
}
switch(next) {
case 0x6c: CLK(5); if (c) do { THROUGH; i_insb(); c--; CLK( 0); } while (c>0); I.regs.w[CW]=c; break;
case 0x6d: CLK(5); if (c) do { THROUGH; i_insw(); c--; CLK( 0); } while (c>0); I.regs.w[CW]=c; break;
case 0x6e: CLK(5); if (c) do { THROUGH; i_outsb(); c--; CLK(-1); } while (c>0); I.regs.w[CW]=c; break;
case 0x6f: CLK(5); if (c) do { THROUGH; i_outsw(); c--; CLK(-1); } while (c>0); I.regs.w[CW]=c; break;
case 0xa4: CLK(5); if (c) do { THROUGH; i_movsb(); c--; CLK( 2); } while (c>0); I.regs.w[CW]=c; break;
case 0xa5: CLK(5); if (c) do { THROUGH; i_movsw(); c--; CLK( 2); } while (c>0); I.regs.w[CW]=c; break;
case 0xa6: CLK(5); if (c) do { THROUGH; i_cmpsb(); c--; CLK( 4); } while (c>0 && ZF==1); I.regs.w[CW]=c; break;
case 0xa7: CLK(5); if (c) do { THROUGH; i_cmpsw(); c--; CLK( 4); } while (c>0 && ZF==1); I.regs.w[CW]=c; break;
case 0xaa: CLK(5); if (c) do { THROUGH; i_stosb(); c--; CLK( 3); } while (c>0); I.regs.w[CW]=c; break;
case 0xab: CLK(5); if (c) do { THROUGH; i_stosw(); c--; CLK( 3); } while (c>0); I.regs.w[CW]=c; break;
case 0xac: CLK(5); if (c) do { THROUGH; i_lodsb(); c--; CLK( 3); } while (c>0); I.regs.w[CW]=c; break;
case 0xad: CLK(5); if (c) do { THROUGH; i_lodsw(); c--; CLK( 3); } while (c>0); I.regs.w[CW]=c; break;
case 0xae: CLK(5); if (c) do { THROUGH; i_scasb(); c--; CLK( 4); } while (c>0 && ZF==1); I.regs.w[CW]=c; break;
case 0xaf: CLK(5); if (c) do { THROUGH; i_scasw(); c--; CLK( 4); } while (c>0 && ZF==1); I.regs.w[CW]=c; break;
default: nec_instruction[next]();
}
seg_prefix=FALSE;
}
OP( 0xf4, i_hlt ) { nec_ICount=0; }
OP( 0xf5, i_cmc ) { I.CarryVal = !CF; CLK(4); }
OP( 0xf6, i_f6pre ) { UINT32 tmp; UINT32 uresult,uresult2; INT32 result,result2;
GetModRM; tmp = GetRMByte(ModRM);
switch (ModRM & 0x38) {
case 0x00: tmp &= FETCH; I.CarryVal = I.OverVal = I.AuxVal=0; SetSZPF_Byte(tmp); CLKM(2,1); break; /* TEST */
case 0x08: break;
case 0x10: PutbackRMByte(ModRM,~tmp); CLKM(3,1); break; /* NOT */
case 0x18: I.CarryVal=(tmp!=0);tmp=(~tmp)+1; SetSZPF_Byte(tmp); PutbackRMByte(ModRM,tmp&0xff); CLKM(3,1); break; /* NEG */
case 0x20: uresult = I.regs.b[AL]*tmp; I.regs.w[AW]=(WORD)uresult; I.CarryVal=I.OverVal=(I.regs.b[AH]!=0); CLKM(4,3); break; /* MULU */
case 0x28: result = (INT16)((INT8)I.regs.b[AL])*(INT16)((INT8)tmp); I.regs.w[AW]=(WORD)result; I.CarryVal=I.OverVal=(I.regs.b[AH]!=0); CLKM(4,3); break; /* MUL */
case 0x30: if (tmp) { DIVUB; } else nec_interrupt(0,0); CLKM(16,15); break;
case 0x38: if (tmp) { DIVB; } else nec_interrupt(0,0); CLKM(18,17); break;
}
}
OP( 0xf7, i_f7pre ) { UINT32 tmp,tmp2; UINT32 uresult,uresult2; INT32 result,result2;
GetModRM; tmp = GetRMWord(ModRM);
switch (ModRM & 0x38) {
case 0x00: FETCHWORD(tmp2); tmp &= tmp2; I.CarryVal = I.OverVal = I.AuxVal=0; SetSZPF_Word(tmp); CLKM(2,1); break; /* TEST */
case 0x08: break;
case 0x10: PutbackRMWord(ModRM,~tmp); CLKM(3,1); break; /* NOT */
case 0x18: I.CarryVal=(tmp!=0); tmp=(~tmp)+1; SetSZPF_Word(tmp); PutbackRMWord(ModRM,tmp&0xffff); CLKM(3,1); break; /* NEG */
case 0x20: uresult = I.regs.w[AW]*tmp; I.regs.w[AW]=uresult&0xffff; I.regs.w[DW]=((UINT32)uresult)>>16; I.CarryVal=I.OverVal=(I.regs.w[DW]!=0); CLKM(4,3); break; /* MULU */
case 0x28: result = (INT32)((INT16)I.regs.w[AW])*(INT32)((INT16)tmp); I.regs.w[AW]=result&0xffff; I.regs.w[DW]=result>>16; I.CarryVal=I.OverVal=(I.regs.w[DW]!=0); CLKM(4,3); break; /* MUL */
case 0x30: if (tmp) { DIVUW; } else nec_interrupt(0,0); CLKM(24,23); break;
case 0x38: if (tmp) { DIVW; } else nec_interrupt(0,0); CLKM(25,24); break;
}
}
OP( 0xf8, i_clc ) { I.CarryVal = 0; CLK(4); }
OP( 0xf9, i_stc ) { I.CarryVal = 1; CLK(4); }
OP( 0xfa, i_di ) { SetIF(0); CLK(4); }
OP( 0xfb, i_ei ) { SetIF(1); CLK(4); }
OP( 0xfc, i_cld ) { SetDF(0); CLK(4); }
OP( 0xfd, i_std ) { SetDF(1); CLK(4); }
OP( 0xfe, i_fepre ) { UINT32 tmp, tmp1; GetModRM; tmp=GetRMByte(ModRM);
switch(ModRM & 0x38) {
case 0x00: tmp1 = tmp+1; I.OverVal = (tmp==0x7f); SetAF(tmp1,tmp,1); SetSZPF_Byte(tmp1); PutbackRMByte(ModRM,(BYTE)tmp1); CLKM(3,1); break; /* INC */
case 0x08: tmp1 = tmp-1; I.OverVal = (tmp==0x80); SetAF(tmp1,tmp,1); SetSZPF_Byte(tmp1); PutbackRMByte(ModRM,(BYTE)tmp1); CLKM(3,1); break; /* DEC */
}
}
OP( 0xff, i_ffpre ) { UINT32 tmp, tmp1; GetModRM; tmp=GetRMWord(ModRM);
switch(ModRM & 0x38) {
case 0x00: tmp1 = tmp+1; I.OverVal = (tmp==0x7fff); SetAF(tmp1,tmp,1); SetSZPF_Word(tmp1); PutbackRMWord(ModRM,(WORD)tmp1); CLKM(3,1); break; /* INC */
case 0x08: tmp1 = tmp-1; I.OverVal = (tmp==0x8000); SetAF(tmp1,tmp,1); SetSZPF_Word(tmp1); PutbackRMWord(ModRM,(WORD)tmp1); CLKM(3,1); break; /* DEC */
case 0x10: PUSH(I.ip); I.ip = (WORD)tmp; CLKM(6,5); break; /* CALL */
case 0x18: tmp1 = I.sregs[CS]; I.sregs[CS] = GetnextRMWord; PUSH(tmp1); PUSH(I.ip); I.ip = tmp; CLKM(12,1); break; /* CALL FAR */
case 0x20: I.ip = tmp; CLKM(5,4); break; /* JMP */
case 0x28: I.ip = tmp; I.sregs[CS] = GetnextRMWord; CLKM(10,1); break; /* JMP FAR */
case 0x30: PUSH(tmp); CLKM(2,1); break;
default: ;
}
}
static void i_invalid(void)
{
CLK(10);
}
/*****************************************************************************/
unsigned nec_get_reg(int regnum)
{
switch( regnum )
{
case NEC_IP: return I.ip;
case NEC_SP: return I.regs.w[SP];
case NEC_FLAGS: return CompressFlags();
case NEC_AW: return I.regs.w[AW];
case NEC_CW: return I.regs.w[CW];
case NEC_DW: return I.regs.w[DW];
case NEC_BW: return I.regs.w[BW];
case NEC_BP: return I.regs.w[BP];
case NEC_IX: return I.regs.w[IX];
case NEC_IY: return I.regs.w[IY];
case NEC_ES: return I.sregs[ES];
case NEC_CS: return I.sregs[CS];
case NEC_SS: return I.sregs[SS];
case NEC_DS: return I.sregs[DS];
case NEC_VECTOR: return I.int_vector;
case NEC_PENDING: return I.pending_irq;
case NEC_NMI_STATE: return I.nmi_state;
case NEC_IRQ_STATE: return I.irq_state;
}
return 0;
}
void nec_set_irq_line(int irqline, int state);
void nec_set_reg(int regnum, unsigned val)
{
switch( regnum )
{
case NEC_IP: I.ip = val; break;
case NEC_SP: I.regs.w[SP] = val; break;
case NEC_FLAGS: ExpandFlags(val); break;
case NEC_AW: I.regs.w[AW] = val; break;
case NEC_CW: I.regs.w[CW] = val; break;
case NEC_DW: I.regs.w[DW] = val; break;
case NEC_BW: I.regs.w[BW] = val; break;
case NEC_BP: I.regs.w[BP] = val; break;
case NEC_IX: I.regs.w[IX] = val; break;
case NEC_IY: I.regs.w[IY] = val; break;
case NEC_ES: I.sregs[ES] = val; break;
case NEC_CS: I.sregs[CS] = val; break;
case NEC_SS: I.sregs[SS] = val; break;
case NEC_DS: I.sregs[DS] = val; break;
case NEC_VECTOR: I.int_vector = val; break;
}
}
int nec_execute(int cycles)
{
nec_ICount=cycles;
// cpu_type=V30;
while(nec_ICount>0) {
nec_instruction[FETCHOP]();
// nec_ICount++;
}
return cycles - nec_ICount;
}

View File

@@ -1,390 +0,0 @@
BYTE cpu_readport(BYTE);
void cpu_writeport(DWORD,BYTE);
#define cpu_readop cpu_readmem20
#define cpu_readop_arg cpu_readmem20
void cpu_writemem20(DWORD,BYTE);
BYTE cpu_readmem20(DWORD);
typedef enum { ES, CS, SS, DS } SREGS;
typedef enum { AW, CW, DW, BW, SP, BP, IX, IY } WREGS;
typedef enum { AL,AH,CL,CH,DL,DH,BL,BH,SPL,SPH,BPL,BPH,IXL,IXH,IYL,IYH } BREGS;
#pragma pack(1)
typedef union
{ /* eight general registers */
UINT16 w[8]; /* viewed as 16 bits registers */
UINT8 b[16]; /* or as 8 bit registers */
} necbasicregs;
typedef struct
{
necbasicregs regs;
UINT16 sregs[4];
UINT16 ip;
INT32 SignVal;
UINT32 AuxVal, OverVal, ZeroVal, CarryVal, ParityVal; /* 0 or non-0 valued flags */
UINT8 TF, IF, DF, MF; /* 0 or 1 valued flags */ /* OB[19.07.99] added Mode Flag V30 */
UINT32 int_vector;
UINT32 pending_irq;
UINT32 nmi_state;
UINT32 irq_state;
int (*irq_callback)(int irqline);
} nec_Regs;
#pragma pack()
#define NEC_NMI_INT_VECTOR 2
/* Cpu types, steps of 8 to help the cycle count calculation */
#define V33 0
#define V30 8
#define V20 16
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
/* parameter x = result, y = source 1, z = source 2 */
#define SetTF(x) (I.TF = (x))
#define SetIF(x) (I.IF = (x))
#define SetDF(x) (I.DF = (x))
#define SetMD(x) (I.MF = (x)) /* OB [19.07.99] Mode Flag V30 */
#define SetCFB(x) (I.CarryVal = (x) & 0x100)
#define SetCFW(x) (I.CarryVal = (x) & 0x10000)
#define SetAF(x,y,z) (I.AuxVal = ((x) ^ ((y) ^ (z))) & 0x10)
#define SetSF(x) (I.SignVal = (x))
#define SetZF(x) (I.ZeroVal = (x))
#define SetPF(x) (I.ParityVal = (x))
#define SetSZPF_Byte(x) (I.SignVal=I.ZeroVal=I.ParityVal=(INT8)(x))
#define SetSZPF_Word(x) (I.SignVal=I.ZeroVal=I.ParityVal=(INT16)(x))
#define SetOFW_Add(x,y,z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x8000)
#define SetOFB_Add(x,y,z) (I.OverVal = ((x) ^ (y)) & ((x) ^ (z)) & 0x80)
#define SetOFW_Sub(x,y,z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x8000)
#define SetOFB_Sub(x,y,z) (I.OverVal = ((z) ^ (y)) & ((z) ^ (x)) & 0x80)
#define ADDB { UINT32 res=dst+src; SetCFB(res); SetOFB_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Byte(res); dst=(BYTE)res; }
#define ADDW { UINT32 res=dst+src; SetCFW(res); SetOFW_Add(res,src,dst); SetAF(res,src,dst); SetSZPF_Word(res); dst=(WORD)res; }
#define SUBB { UINT32 res=dst-src; SetCFB(res); SetOFB_Sub(res,src,dst); SetAF(res,src,dst); SetSZPF_Byte(res); dst=(BYTE)res; }
#define SUBW { UINT32 res=dst-src; SetCFW(res); SetOFW_Sub(res,src,dst); SetAF(res,src,dst); SetSZPF_Word(res); dst=(WORD)res; }
#define ORB dst|=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Byte(dst)
#define ORW dst|=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Word(dst)
#define ANDB dst&=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Byte(dst)
#define ANDW dst&=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Word(dst)
#define XORB dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Byte(dst)
#define XORW dst^=src; I.CarryVal=I.OverVal=I.AuxVal=0; SetSZPF_Word(dst)
#define CF (I.CarryVal!=0)
#define SF (I.SignVal<0)
#define ZF (I.ZeroVal==0)
#define PF parity_table[(BYTE)I.ParityVal]
#define AF (I.AuxVal!=0)
#define OF (I.OverVal!=0)
#define MD (I.MF!=0)
/************************************************************************/
#define SegBase(Seg) (I.sregs[Seg] << 4)
#define DefaultBase(Seg) ((seg_prefix && (Seg==DS || Seg==SS)) ? prefix_base : I.sregs[Seg] << 4)
#define GetMemB(Seg,Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (UINT8)cpu_readmem20((DefaultBase(Seg)+(Off))))
#define GetMemW(Seg,Off) (/*nec_ICount-=((Off)&1)?1:0,*/ (UINT16) cpu_readmem20((DefaultBase(Seg)+(Off))) + (cpu_readmem20((DefaultBase(Seg)+((Off)+1)))<<8) )
#define PutMemB(Seg,Off,x) { /*nec_ICount-=((Off)&1)?1:0*/; cpu_writemem20((DefaultBase(Seg)+(Off)),(x)); }
#define PutMemW(Seg,Off,x) { /*nec_ICount-=((Off)&1)?1:0*/; PutMemB(Seg,Off,(x)&0xff); PutMemB(Seg,(Off)+1,(BYTE)((x)>>8)); }
/* Todo: Remove these later - plus readword could overflow */
#define ReadByte(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ (BYTE)cpu_readmem20((ea)))
#define ReadWord(ea) (/*nec_ICount-=((ea)&1)?1:0,*/ cpu_readmem20((ea))+(cpu_readmem20(((ea)+1))<<8))
#define WriteByte(ea,val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),val); }
#define WriteWord(ea,val) { /*nec_ICount-=((ea)&1)?1:0*/; cpu_writemem20((ea),(BYTE)(val)); cpu_writemem20(((ea)+1),(val)>>8); }
#define read_port(port) cpu_readport(port)
#define write_port(port,val) cpu_writeport(port,val)
#define FETCH (cpu_readop_arg((I.sregs[CS]<<4)+I.ip++))
#define FETCHOP (cpu_readop((I.sregs[CS]<<4)+I.ip++))
#define FETCHWORD(var) { var=cpu_readop_arg((((I.sregs[CS]<<4)+I.ip)))+(cpu_readop_arg((((I.sregs[CS]<<4)+I.ip+1)))<<8); I.ip+=2; }
#define PUSH(val) { I.regs.w[SP]-=2; WriteWord((((I.sregs[SS]<<4)+I.regs.w[SP])),val); }
#define POP(var) { var = ReadWord((((I.sregs[SS]<<4)+I.regs.w[SP]))); I.regs.w[SP]+=2; }
#define PEEK(addr) ((BYTE)cpu_readop_arg(addr))
#define PEEKOP(addr) ((BYTE)cpu_readop(addr))
#define GetModRM UINT32 ModRM=cpu_readop_arg((I.sregs[CS]<<4)+I.ip++)
/* Cycle count macros:
CLK - cycle count is the same on all processors
CLKS - cycle count differs between processors, list all counts
CLKW - cycle count for word read/write differs for odd/even source/destination address
CLKM - cycle count for reg/mem instructions
CLKR - cycle count for reg/mem instructions with different counts for odd/even addresses
Prefetch & buswait time is not emulated.
Extra cycles for PUSH'ing or POP'ing registers to odd addresses is not emulated.
#define CLK(all) nec_ICount-=all
#define CLKS(v20,v30,v33) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>cpu_type)&0x7f; }
#define CLKW(v20o,v30o,v33o,v20e,v30e,v33e) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; nec_ICount-=(I.ip&1)?((ocount>>cpu_type)&0x7f):((ecount>>cpu_type)&0x7f); }
#define CLKM(v20,v30,v33,v20m,v30m,v33m) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33, mcount=(v20m<<16)|(v30m<<8)|v33m; nec_ICount-=( ModRM >=0xc0 )?((ccount>>cpu_type)&0x7f):((mcount>>cpu_type)&0x7f); }
#define CLKR(v20o,v30o,v33o,v20e,v30e,v33e,vall) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?((ocount>>cpu_type)&0x7f):((ecount>>cpu_type)&0x7f); }
*/
#define CLKS(v20,v30,v33) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>cpu_type)&0x7f; }
#define CLK(all) nec_ICount-=all
#define CLKW(v30MZo,v30MZe) { nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
#define CLKM(v30MZm,v30MZ) { nec_ICount-=( ModRM >=0xc0 )?v30MZ:v30MZm; }
#define CLKR(v30MZo,v30MZe,vall) { if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(I.ip&1)?v30MZo:v30MZe; }
#define CompressFlags() (WORD)(CF | (PF << 2) | (AF << 4) | (ZF << 6) \
| (SF << 7) | (I.TF << 8) | (I.IF << 9) \
| (I.DF << 10) | (OF << 11))
#define ExpandFlags(f) \
{ \
I.CarryVal = (f) & 1; \
I.ParityVal = !((f) & 4); \
I.AuxVal = (f) & 16; \
I.ZeroVal = !((f) & 64); \
I.SignVal = (f) & 128 ? -1 : 0; \
I.TF = ((f) & 256) == 256; \
I.IF = ((f) & 512) == 512; \
I.DF = ((f) & 1024) == 1024; \
I.OverVal = (f) & 2048; \
I.MF = ((f) & 0x8000) == 0x8000; \
}
#define IncWordReg(Reg) \
unsigned tmp = (unsigned)I.regs.w[Reg]; \
unsigned tmp1 = tmp+1; \
I.OverVal = (tmp == 0x7fff); \
SetAF(tmp1,tmp,1); \
SetSZPF_Word(tmp1); \
I.regs.w[Reg]=tmp1
#define DecWordReg(Reg) \
unsigned tmp = (unsigned)I.regs.w[Reg]; \
unsigned tmp1 = tmp-1; \
I.OverVal = (tmp == 0x8000); \
SetAF(tmp1,tmp,1); \
SetSZPF_Word(tmp1); \
I.regs.w[Reg]=tmp1
#define JMP(flag) \
int tmp = (int)((INT8)FETCH); \
if (flag) \
{ \
I.ip = (WORD)(I.ip+tmp); \
nec_ICount-=3; \
return; \
}
#define ADJ4(param1,param2) \
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
{ \
int tmp; \
I.regs.b[AL] = tmp = I.regs.b[AL] + param1; \
I.AuxVal = 1; \
} \
if (CF || (I.regs.b[AL] > 0x9f)) \
{ \
I.regs.b[AL] += param2; \
I.CarryVal = 1; \
} \
SetSZPF_Byte(I.regs.b[AL])
#define ADJB(param1,param2) \
if (AF || ((I.regs.b[AL] & 0xf) > 9)) \
{ \
I.regs.b[AL] += param1; \
I.regs.b[AH] += param2; \
I.AuxVal = 1; \
I.CarryVal = 1; \
} \
else \
{ \
I.AuxVal = 0; \
I.CarryVal = 0; \
} \
I.regs.b[AL] &= 0x0F
#define BITOP_BYTE \
ModRM = FETCH; \
if (ModRM >= 0xc0) { \
tmp=I.regs.b[Mod_RM.RM.b[ModRM]]; \
} \
else { \
(*GetEA[ModRM])(); \
tmp=ReadByte(EA); \
}
#define BITOP_WORD \
ModRM = FETCH; \
if (ModRM >= 0xc0) { \
tmp=I.regs.w[Mod_RM.RM.w[ModRM]]; \
} \
else { \
(*GetEA[ModRM])(); \
tmp=ReadWord(EA); \
}
#define BIT_NOT \
if (tmp & (1<<tmp2)) \
tmp &= ~(1<<tmp2); \
else \
tmp |= (1<<tmp2)
#define XchgAWReg(Reg) \
WORD tmp; \
tmp = I.regs.w[Reg]; \
I.regs.w[Reg] = I.regs.w[AW]; \
I.regs.w[AW] = tmp
#define ROL_BYTE I.CarryVal = dst & 0x80; dst = (dst << 1)+CF
#define ROL_WORD I.CarryVal = dst & 0x8000; dst = (dst << 1)+CF
#define ROR_BYTE I.CarryVal = dst & 0x1; dst = (dst >> 1)+(CF<<7)
#define ROR_WORD I.CarryVal = dst & 0x1; dst = (dst >> 1)+(CF<<15)
#define ROLC_BYTE dst = (dst << 1) + CF; SetCFB(dst)
#define ROLC_WORD dst = (dst << 1) + CF; SetCFW(dst)
#define RORC_BYTE dst = (CF<<8)+dst; I.CarryVal = dst & 0x01; dst >>= 1
#define RORC_WORD dst = (CF<<16)+dst; I.CarryVal = dst & 0x01; dst >>= 1
#define SHL_BYTE(c) dst <<= c; SetCFB(dst); SetSZPF_Byte(dst); PutbackRMByte(ModRM,(BYTE)dst)
#define SHL_WORD(c) dst <<= c; SetCFW(dst); SetSZPF_Word(dst); PutbackRMWord(ModRM,(WORD)dst)
#define SHR_BYTE(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(BYTE)dst)
#define SHR_WORD(c) dst >>= c-1; I.CarryVal = dst & 0x1; dst >>= 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(WORD)dst)
#define SHRA_BYTE(c) dst = ((INT8)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((INT8)((BYTE)dst)) >> 1; SetSZPF_Byte(dst); PutbackRMByte(ModRM,(BYTE)dst)
#define SHRA_WORD(c) dst = ((INT16)dst) >> (c-1); I.CarryVal = dst & 0x1; dst = ((INT16)((WORD)dst)) >> 1; SetSZPF_Word(dst); PutbackRMWord(ModRM,(WORD)dst)
#define DIVUB \
uresult = I.regs.w[AW]; \
uresult2 = uresult % tmp; \
if ((uresult /= tmp) > 0xff) { \
nec_interrupt(0,0); break; \
} else { \
I.regs.b[AL] = uresult; \
I.regs.b[AH] = uresult2; \
}
#define DIVB \
result = (INT16)I.regs.w[AW]; \
result2 = result % (INT16)((INT8)tmp); \
if ((result /= (INT16)((INT8)tmp)) > 0xff) { \
nec_interrupt(0,0); break; \
} else { \
I.regs.b[AL] = result; \
I.regs.b[AH] = result2; \
}
#define DIVUW \
uresult = (((UINT32)I.regs.w[DW]) << 16) | I.regs.w[AW];\
uresult2 = uresult % tmp; \
if ((uresult /= tmp) > 0xffff) { \
nec_interrupt(0,0); break; \
} else { \
I.regs.w[AW]=uresult; \
I.regs.w[DW]=uresult2; \
}
#define DIVW \
result = ((UINT32)I.regs.w[DW] << 16) + I.regs.w[AW]; \
result2 = result % (INT32)((INT16)tmp); \
if ((result /= (INT32)((INT16)tmp)) > 0xffff) { \
nec_interrupt(0,0); break; \
} else { \
I.regs.w[AW]=result; \
I.regs.w[DW]=result2; \
}
#define ADD4S { \
int i,v1,v2,result; \
int count = (I.regs.b[CL]+1)/2; \
unsigned di = I.regs.w[IY]; \
unsigned si = I.regs.w[IX]; \
I.ZeroVal = I.CarryVal = 0; \
for (i=0;i<count;i++) { \
tmp = GetMemB(DS, si); \
tmp2 = GetMemB(ES, di); \
v1 = (tmp>>4)*10 + (tmp&0xf); \
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
result = v1+v2+I.CarryVal; \
I.CarryVal = result > 99 ? 1 : 0; \
result = result % 100; \
v1 = ((result/10)<<4) | (result % 10); \
PutMemB(ES, di,v1); \
if (v1) I.ZeroVal = 1; \
si++; \
di++; \
} \
}
#define SUB4S { \
int count = (I.regs.b[CL]+1)/2; \
int i,v1,v2,result; \
unsigned di = I.regs.w[IY]; \
unsigned si = I.regs.w[IX]; \
I.ZeroVal = I.CarryVal = 0; \
for (i=0;i<count;i++) { \
tmp = GetMemB(ES, di); \
tmp2 = GetMemB(DS, si); \
v1 = (tmp>>4)*10 + (tmp&0xf); \
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
if (v1 < (v2+I.CarryVal)) { \
v1+=100; \
result = v1-(v2+I.CarryVal); \
I.CarryVal = 1; \
} else { \
result = v1-(v2+I.CarryVal); \
I.CarryVal = 0; \
} \
v1 = ((result/10)<<4) | (result % 10); \
PutMemB(ES, di,v1); \
if (v1) I.ZeroVal = 1; \
si++; \
di++; \
} \
}
#define CMP4S { \
int count = (I.regs.b[CL]+1)/2; \
int i,v1,v2,result; \
unsigned di = I.regs.w[IY]; \
unsigned si = I.regs.w[IX]; \
I.ZeroVal = I.CarryVal = 0; \
for (i=0;i<count;i++) { \
tmp = GetMemB(ES, di); \
tmp2 = GetMemB(DS, si); \
v1 = (tmp>>4)*10 + (tmp&0xf); \
v2 = (tmp2>>4)*10 + (tmp2&0xf); \
if (v1 < (v2+I.CarryVal)) { \
v1+=100; \
result = v1-(v2+I.CarryVal); \
I.CarryVal = 1; \
} else { \
result = v1-(v2+I.CarryVal); \
I.CarryVal = 0; \
} \
v1 = ((result/10)<<4) | (result % 10); \
if (v1) I.ZeroVal = 1; \
si++; \
di++; \
} \
}

View File

@@ -1,60 +0,0 @@
static UINT32 EA;
static UINT16 EO;
static UINT16 E16;
static unsigned EA_000(void) { EO=I.regs.w[BW]+I.regs.w[IX]; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_001(void) { EO=I.regs.w[BW]+I.regs.w[IY]; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_002(void) { EO=I.regs.w[BP]+I.regs.w[IX]; EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_003(void) { EO=I.regs.w[BP]+I.regs.w[IY]; EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_004(void) { EO=I.regs.w[IX]; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_005(void) { EO=I.regs.w[IY]; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_006(void) { EO=FETCH; EO+=FETCH<<8; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_007(void) { EO=I.regs.w[BW]; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_100(void) { EO=(I.regs.w[BW]+I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_101(void) { EO=(I.regs.w[BW]+I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_102(void) { EO=(I.regs.w[BP]+I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_103(void) { EO=(I.regs.w[BP]+I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_104(void) { EO=(I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_105(void) { EO=(I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_106(void) { EO=(I.regs.w[BP]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_107(void) { EO=(I.regs.w[BW]+(INT8)FETCH); EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_200(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_201(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_202(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_203(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_204(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_205(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS)+EO; return EA; }
static unsigned EA_206(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
static unsigned EA_207(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+(INT16)E16; EA=DefaultBase(DS)+EO; return EA; }
static unsigned (*GetEA[192])(void)={
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_100, EA_101, EA_102, EA_103, EA_104, EA_105, EA_106, EA_107,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207,
EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207
};

View File

@@ -1,507 +0,0 @@
static void i_add_br8(void);
static void i_add_wr16(void);
static void i_add_r8b(void);
static void i_add_r16w(void);
static void i_add_ald8(void);
static void i_add_axd16(void);
static void i_push_es(void);
static void i_pop_es(void);
static void i_or_br8(void);
static void i_or_r8b(void);
static void i_or_wr16(void);
static void i_or_r16w(void);
static void i_or_ald8(void);
static void i_or_axd16(void);
static void i_push_cs(void);
static void i_pre_nec(void);
static void i_adc_br8(void);
static void i_adc_wr16(void);
static void i_adc_r8b(void);
static void i_adc_r16w(void);
static void i_adc_ald8(void);
static void i_adc_axd16(void);
static void i_push_ss(void);
static void i_pop_ss(void);
static void i_sbb_br8(void);
static void i_sbb_wr16(void);
static void i_sbb_r8b(void);
static void i_sbb_r16w(void);
static void i_sbb_ald8(void);
static void i_sbb_axd16(void);
static void i_push_ds(void);
static void i_pop_ds(void);
static void i_and_br8(void);
static void i_and_r8b(void);
static void i_and_wr16(void);
static void i_and_r16w(void);
static void i_and_ald8(void);
static void i_and_axd16(void);
static void i_es(void);
static void i_daa(void);
static void i_sub_br8(void);
static void i_sub_wr16(void);
static void i_sub_r8b(void);
static void i_sub_r16w(void);
static void i_sub_ald8(void);
static void i_sub_axd16(void);
static void i_cs(void);
static void i_das(void);
static void i_xor_br8(void);
static void i_xor_r8b(void);
static void i_xor_wr16(void);
static void i_xor_r16w(void);
static void i_xor_ald8(void);
static void i_xor_axd16(void);
static void i_ss(void);
static void i_aaa(void);
static void i_cmp_br8(void);
static void i_cmp_wr16(void);
static void i_cmp_r8b(void);
static void i_cmp_r16w(void);
static void i_cmp_ald8(void);
static void i_cmp_axd16(void);
static void i_ds(void);
static void i_aas(void);
static void i_inc_ax(void);
static void i_inc_cx(void);
static void i_inc_dx(void);
static void i_inc_bx(void);
static void i_inc_sp(void);
static void i_inc_bp(void);
static void i_inc_si(void);
static void i_inc_di(void);
static void i_dec_ax(void);
static void i_dec_cx(void);
static void i_dec_dx(void);
static void i_dec_bx(void);
static void i_dec_sp(void);
static void i_dec_bp(void);
static void i_dec_si(void);
static void i_dec_di(void);
static void i_push_ax(void);
static void i_push_cx(void);
static void i_push_dx(void);
static void i_push_bx(void);
static void i_push_sp(void);
static void i_push_bp(void);
static void i_push_si(void);
static void i_push_di(void);
static void i_pop_ax(void);
static void i_pop_cx(void);
static void i_pop_dx(void);
static void i_pop_bx(void);
static void i_pop_sp(void);
static void i_pop_bp(void);
static void i_pop_si(void);
static void i_pop_di(void);
static void i_pusha(void);
static void i_popa(void);
static void i_chkind(void);
static void i_repnc(void);
static void i_repc(void);
static void i_push_d16(void);
static void i_imul_d16(void);
static void i_push_d8(void);
static void i_imul_d8(void);
static void i_insb(void);
static void i_insw(void);
static void i_outsb(void);
static void i_outsw(void);
static void i_jo(void);
static void i_jno(void);
static void i_jc(void);
static void i_jnc(void);
static void i_jz(void);
static void i_jnz(void);
static void i_jce(void);
static void i_jnce(void);
static void i_js(void);
static void i_jns(void);
static void i_jp(void);
static void i_jnp(void);
static void i_jl(void);
static void i_jnl(void);
static void i_jle(void);
static void i_jnle(void);
static void i_80pre(void);
static void i_82pre(void);
static void i_81pre(void);
static void i_83pre(void);
static void i_test_br8(void);
static void i_test_wr16(void);
static void i_xchg_br8(void);
static void i_xchg_wr16(void);
static void i_mov_br8(void);
static void i_mov_r8b(void);
static void i_mov_wr16(void);
static void i_mov_r16w(void);
static void i_mov_wsreg(void);
static void i_lea(void);
static void i_mov_sregw(void);
static void i_invalid(void);
static void i_popw(void);
static void i_nop(void);
static void i_xchg_axcx(void);
static void i_xchg_axdx(void);
static void i_xchg_axbx(void);
static void i_xchg_axsp(void);
static void i_xchg_axbp(void);
static void i_xchg_axsi(void);
static void i_xchg_axdi(void);
static void i_cbw(void);
static void i_cwd(void);
static void i_call_far(void);
static void i_pushf(void);
static void i_popf(void);
static void i_sahf(void);
static void i_lahf(void);
static void i_mov_aldisp(void);
static void i_mov_axdisp(void);
static void i_mov_dispal(void);
static void i_mov_dispax(void);
static void i_movsb(void);
static void i_movsw(void);
static void i_cmpsb(void);
static void i_cmpsw(void);
static void i_test_ald8(void);
static void i_test_axd16(void);
static void i_stosb(void);
static void i_stosw(void);
static void i_lodsb(void);
static void i_lodsw(void);
static void i_scasb(void);
static void i_scasw(void);
static void i_mov_ald8(void);
static void i_mov_cld8(void);
static void i_mov_dld8(void);
static void i_mov_bld8(void);
static void i_mov_ahd8(void);
static void i_mov_chd8(void);
static void i_mov_dhd8(void);
static void i_mov_bhd8(void);
static void i_mov_axd16(void);
static void i_mov_cxd16(void);
static void i_mov_dxd16(void);
static void i_mov_bxd16(void);
static void i_mov_spd16(void);
static void i_mov_bpd16(void);
static void i_mov_sid16(void);
static void i_mov_did16(void);
static void i_rotshft_bd8(void);
static void i_rotshft_wd8(void);
static void i_ret_d16(void);
static void i_ret(void);
static void i_les_dw(void);
static void i_lds_dw(void);
static void i_mov_bd8(void);
static void i_mov_wd16(void);
static void i_enter(void);
static void i_leave(void);
static void i_retf_d16(void);
static void i_retf(void);
static void i_int3(void);
static void i_int(void);
static void i_into(void);
static void i_iret(void);
static void i_rotshft_b(void);
static void i_rotshft_w(void);
static void i_rotshft_bcl(void);
static void i_rotshft_wcl(void);
static void i_aam(void);
static void i_aad(void);
static void i_setalc(void);
static void i_trans(void);
static void i_fpo(void);
static void i_loopne(void);
static void i_loope(void);
static void i_loop(void);
static void i_jcxz(void);
static void i_inal(void);
static void i_inax(void);
static void i_outal(void);
static void i_outax(void);
static void i_call_d16(void);
static void i_jmp_d16(void);
static void i_jmp_far(void);
static void i_jmp_d8(void);
static void i_inaldx(void);
static void i_inaxdx(void);
static void i_outdxal(void);
static void i_outdxax(void);
static void i_lock(void);
static void i_repne(void);
static void i_repe(void);
static void i_hlt(void);
static void i_cmc(void);
static void i_f6pre(void);
static void i_f7pre(void);
static void i_clc(void);
static void i_stc(void);
static void i_di(void);
static void i_ei(void);
static void i_cld(void);
static void i_std(void);
static void i_fepre(void);
static void i_ffpre(void);
static void i_wait(void);
void (*nec_instruction[256])(void) =
{
i_add_br8, /* 0x00 */
i_add_wr16, /* 0x01 */
i_add_r8b, /* 0x02 */
i_add_r16w, /* 0x03 */
i_add_ald8, /* 0x04 */
i_add_axd16, /* 0x05 */
i_push_es, /* 0x06 */
i_pop_es, /* 0x07 */
i_or_br8, /* 0x08 */
i_or_wr16, /* 0x09 */
i_or_r8b, /* 0x0a */
i_or_r16w, /* 0x0b */
i_or_ald8, /* 0x0c */
i_or_axd16, /* 0x0d */
i_push_cs, /* 0x0e */
i_pre_nec /* 0x0f */,
i_adc_br8, /* 0x10 */
i_adc_wr16, /* 0x11 */
i_adc_r8b, /* 0x12 */
i_adc_r16w, /* 0x13 */
i_adc_ald8, /* 0x14 */
i_adc_axd16, /* 0x15 */
i_push_ss, /* 0x16 */
i_pop_ss, /* 0x17 */
i_sbb_br8, /* 0x18 */
i_sbb_wr16, /* 0x19 */
i_sbb_r8b, /* 0x1a */
i_sbb_r16w, /* 0x1b */
i_sbb_ald8, /* 0x1c */
i_sbb_axd16, /* 0x1d */
i_push_ds, /* 0x1e */
i_pop_ds, /* 0x1f */
i_and_br8, /* 0x20 */
i_and_wr16, /* 0x21 */
i_and_r8b, /* 0x22 */
i_and_r16w, /* 0x23 */
i_and_ald8, /* 0x24 */
i_and_axd16, /* 0x25 */
i_es, /* 0x26 */
i_daa, /* 0x27 */
i_sub_br8, /* 0x28 */
i_sub_wr16, /* 0x29 */
i_sub_r8b, /* 0x2a */
i_sub_r16w, /* 0x2b */
i_sub_ald8, /* 0x2c */
i_sub_axd16, /* 0x2d */
i_cs, /* 0x2e */
i_das, /* 0x2f */
i_xor_br8, /* 0x30 */
i_xor_wr16, /* 0x31 */
i_xor_r8b, /* 0x32 */
i_xor_r16w, /* 0x33 */
i_xor_ald8, /* 0x34 */
i_xor_axd16, /* 0x35 */
i_ss, /* 0x36 */
i_aaa, /* 0x37 */
i_cmp_br8, /* 0x38 */
i_cmp_wr16, /* 0x39 */
i_cmp_r8b, /* 0x3a */
i_cmp_r16w, /* 0x3b */
i_cmp_ald8, /* 0x3c */
i_cmp_axd16, /* 0x3d */
i_ds, /* 0x3e */
i_aas, /* 0x3f */
i_inc_ax, /* 0x40 */
i_inc_cx, /* 0x41 */
i_inc_dx, /* 0x42 */
i_inc_bx, /* 0x43 */
i_inc_sp, /* 0x44 */
i_inc_bp, /* 0x45 */
i_inc_si, /* 0x46 */
i_inc_di, /* 0x47 */
i_dec_ax, /* 0x48 */
i_dec_cx, /* 0x49 */
i_dec_dx, /* 0x4a */
i_dec_bx, /* 0x4b */
i_dec_sp, /* 0x4c */
i_dec_bp, /* 0x4d */
i_dec_si, /* 0x4e */
i_dec_di, /* 0x4f */
i_push_ax, /* 0x50 */
i_push_cx, /* 0x51 */
i_push_dx, /* 0x52 */
i_push_bx, /* 0x53 */
i_push_sp, /* 0x54 */
i_push_bp, /* 0x55 */
i_push_si, /* 0x56 */
i_push_di, /* 0x57 */
i_pop_ax, /* 0x58 */
i_pop_cx, /* 0x59 */
i_pop_dx, /* 0x5a */
i_pop_bx, /* 0x5b */
i_pop_sp, /* 0x5c */
i_pop_bp, /* 0x5d */
i_pop_si, /* 0x5e */
i_pop_di, /* 0x5f */
i_pusha, /* 0x60 */
i_popa, /* 0x61 */
i_chkind, /* 0x62 */
i_invalid, /* 0x63 */
i_repnc, /* 0x64 */
i_repc, /* 0x65 */
i_invalid, /* 0x66 */
i_invalid, /* 0x67 */
i_push_d16, /* 0x68 */
i_imul_d16, /* 0x69 */
i_push_d8, /* 0x6a */
i_imul_d8, /* 0x6b */
i_insb, /* 0x6c */
i_insw, /* 0x6d */
i_outsb, /* 0x6e */
i_outsw, /* 0x6f */
i_jo, /* 0x70 */
i_jno, /* 0x71 */
i_jc, /* 0x72 */
i_jnc, /* 0x73 */
i_jz, /* 0x74 */
i_jnz, /* 0x75 */
i_jce, /* 0x76 */
i_jnce, /* 0x77 */
i_js, /* 0x78 */
i_jns, /* 0x79 */
i_jp, /* 0x7a */
i_jnp, /* 0x7b */
i_jl, /* 0x7c */
i_jnl, /* 0x7d */
i_jle, /* 0x7e */
i_jnle, /* 0x7f */
i_80pre, /* 0x80 */
i_81pre, /* 0x81 */
i_82pre, /* 0x82 */
i_83pre, /* 0x83 */
i_test_br8, /* 0x84 */
i_test_wr16, /* 0x85 */
i_xchg_br8, /* 0x86 */
i_xchg_wr16, /* 0x87 */
i_mov_br8, /* 0x88 */
i_mov_wr16, /* 0x89 */
i_mov_r8b, /* 0x8a */
i_mov_r16w, /* 0x8b */
i_mov_wsreg, /* 0x8c */
i_lea, /* 0x8d */
i_mov_sregw, /* 0x8e */
i_popw, /* 0x8f */
i_nop, /* 0x90 */
i_xchg_axcx, /* 0x91 */
i_xchg_axdx, /* 0x92 */
i_xchg_axbx, /* 0x93 */
i_xchg_axsp, /* 0x94 */
i_xchg_axbp, /* 0x95 */
i_xchg_axsi, /* 0x97 */
i_xchg_axdi, /* 0x97 */
i_cbw, /* 0x98 */
i_cwd, /* 0x99 */
i_call_far, /* 0x9a */
i_wait, /* 0x9b */
i_pushf, /* 0x9c */
i_popf, /* 0x9d */
i_sahf, /* 0x9e */
i_lahf, /* 0x9f */
i_mov_aldisp, /* 0xa0 */
i_mov_axdisp, /* 0xa1 */
i_mov_dispal, /* 0xa2 */
i_mov_dispax, /* 0xa3 */
i_movsb, /* 0xa4 */
i_movsw, /* 0xa5 */
i_cmpsb, /* 0xa6 */
i_cmpsw, /* 0xa7 */
i_test_ald8, /* 0xa8 */
i_test_axd16, /* 0xa9 */
i_stosb, /* 0xaa */
i_stosw, /* 0xab */
i_lodsb, /* 0xac */
i_lodsw, /* 0xad */
i_scasb, /* 0xae */
i_scasw, /* 0xaf */
i_mov_ald8, /* 0xb0 */
i_mov_cld8, /* 0xb1 */
i_mov_dld8, /* 0xb2 */
i_mov_bld8, /* 0xb3 */
i_mov_ahd8, /* 0xb4 */
i_mov_chd8, /* 0xb5 */
i_mov_dhd8, /* 0xb6 */
i_mov_bhd8, /* 0xb7 */
i_mov_axd16, /* 0xb8 */
i_mov_cxd16, /* 0xb9 */
i_mov_dxd16, /* 0xba */
i_mov_bxd16, /* 0xbb */
i_mov_spd16, /* 0xbc */
i_mov_bpd16, /* 0xbd */
i_mov_sid16, /* 0xbe */
i_mov_did16, /* 0xbf */
i_rotshft_bd8, /* 0xc0 */
i_rotshft_wd8, /* 0xc1 */
i_ret_d16, /* 0xc2 */
i_ret, /* 0xc3 */
i_les_dw, /* 0xc4 */
i_lds_dw, /* 0xc5 */
i_mov_bd8, /* 0xc6 */
i_mov_wd16, /* 0xc7 */
i_enter, /* 0xc8 */
i_leave, /* 0xc9 */
i_retf_d16, /* 0xca */
i_retf, /* 0xcb */
i_int3, /* 0xcc */
i_int, /* 0xcd */
i_into, /* 0xce */
i_iret, /* 0xcf */
i_rotshft_b, /* 0xd0 */
i_rotshft_w, /* 0xd1 */
i_rotshft_bcl, /* 0xd2 */
i_rotshft_wcl, /* 0xd3 */
i_aam, /* 0xd4 */
i_aad, /* 0xd5 */
i_setalc,
i_trans, /* 0xd7 */
i_fpo, /* 0xd8 */
i_fpo, /* 0xd9 */
i_fpo, /* 0xda */
i_fpo, /* 0xdb */
i_fpo, /* 0xdc */
i_fpo, /* 0xdd */
i_fpo, /* 0xde */
i_fpo, /* 0xdf */
i_loopne, /* 0xe0 */
i_loope, /* 0xe1 */
i_loop, /* 0xe2 */
i_jcxz, /* 0xe3 */
i_inal, /* 0xe4 */
i_inax, /* 0xe5 */
i_outal, /* 0xe6 */
i_outax, /* 0xe7 */
i_call_d16, /* 0xe8 */
i_jmp_d16, /* 0xe9 */
i_jmp_far, /* 0xea */
i_jmp_d8, /* 0xeb */
i_inaldx, /* 0xec */
i_inaxdx, /* 0xed */
i_outdxal, /* 0xee */
i_outdxax, /* 0xef */
i_lock, /* 0xf0 */
i_invalid, /* 0xf1 */
i_repne, /* 0xf2 */
i_repe, /* 0xf3 */
i_hlt, /* 0xf4 */
i_cmc, /* 0xf5 */
i_f6pre, /* 0xf6 */
i_f7pre, /* 0xf7 */
i_clc, /* 0xf8 */
i_stc, /* 0xf9 */
i_di, /* 0xfa */
i_ei, /* 0xfb */
i_cld, /* 0xfc */
i_std, /* 0xfd */
i_fepre, /* 0xfe */
i_ffpre /* 0xff */
};

View File

@@ -1,67 +0,0 @@
/* ASG 971222 -- rewrote this interface */
#ifndef __NEC_H_
#define __NEC_H_
enum {
NEC_IP=1, NEC_AW, NEC_CW, NEC_DW, NEC_BW, NEC_SP, NEC_BP, NEC_IX, NEC_IY,
NEC_FLAGS, NEC_ES, NEC_CS, NEC_SS, NEC_DS,
NEC_VECTOR, NEC_PENDING, NEC_NMI_STATE, NEC_IRQ_STATE };
/* Public variables */
extern int nec_ICount;
/* Public functions */
/*
#define v20_ICount nec_ICount
extern void v20_init(void);
extern void v20_reset(void *param);
extern void v20_exit(void);
extern int v20_execute(int cycles);
extern unsigned v20_get_context(void *dst);
extern void v20_set_context(void *src);
extern unsigned v20_get_reg(int regnum);
extern void v20_set_reg(int regnum, unsigned val);
extern void v20_set_irq_line(int irqline, int state);
extern void v20_set_irq_callback(int (*callback)(int irqline));
extern const char *v20_info(void *context, int regnum);
extern unsigned v20_dasm(char *buffer, unsigned pc);
#define v30_ICount nec_ICount
extern void v30_init(void);
extern void v30_reset(void *param);
extern void v30_exit(void);
extern int v30_execute(int cycles);
extern unsigned v30_get_context(void *dst);
extern void v30_set_context(void *src);
extern unsigned v30_get_reg(int regnum);
extern void v30_set_reg(int regnum, unsigned val);
extern void v30_set_irq_line(int irqline, int state);
extern void v30_set_irq_callback(int (*callback)(int irqline));
extern const char *v30_info(void *context, int regnum);
extern unsigned v30_dasm(char *buffer, unsigned pc);
#define v33_ICount nec_ICount
extern void v33_init(void);
extern void v33_reset(void *param);
extern void v33_exit(void);
extern int v33_execute(int cycles);
extern unsigned v33_get_context(void *dst);
extern void v33_set_context(void *src);
extern unsigned v33_get_reg(int regnum);
extern void v33_set_reg(int regnum, unsigned val);
extern void v33_set_irq_line(int irqline, int state);
extern void v33_set_irq_callback(int (*callback)(int irqline));
extern const char *v33_info(void *context, int regnum);
extern unsigned v33_dasm(char *buffer, unsigned pc);
*/
void nec_set_reg(int,unsigned);
int nec_execute(int cycles);
unsigned nec_get_reg(int regnum);
void nec_reset (void *param);
void nec_int(DWORD wektor);
#endif

View File

@@ -1,104 +0,0 @@
static struct {
struct {
WREGS w[256];
BREGS b[256];
} reg;
struct {
WREGS w[256];
BREGS b[256];
} RM;
} Mod_RM;
#define RegWord(ModRM) I.regs.w[Mod_RM.reg.w[ModRM]]
#define RegByte(ModRM) I.regs.b[Mod_RM.reg.b[ModRM]]
#define GetRMWord(ModRM) \
((ModRM) >= 0xc0 ? I.regs.w[Mod_RM.RM.w[ModRM]] : ( (*GetEA[ModRM])(), ReadWord( EA ) ))
#define PutbackRMWord(ModRM,val) \
{ \
if (ModRM >= 0xc0) I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
else WriteWord(EA,val); \
}
#define GetnextRMWord ReadWord((EA&0xf0000)|((EA+2)&0xffff))
#define PutRMWord(ModRM,val) \
{ \
if (ModRM >= 0xc0) \
I.regs.w[Mod_RM.RM.w[ModRM]]=val; \
else { \
(*GetEA[ModRM])(); \
WriteWord( EA ,val); \
} \
}
#define PutImmRMWord(ModRM) \
{ \
WORD val; \
if (ModRM >= 0xc0) \
FETCHWORD(I.regs.w[Mod_RM.RM.w[ModRM]]) \
else { \
(*GetEA[ModRM])(); \
FETCHWORD(val) \
WriteWord( EA , val); \
} \
}
#define GetRMByte(ModRM) \
((ModRM) >= 0xc0 ? I.regs.b[Mod_RM.RM.b[ModRM]] : ReadByte( (*GetEA[ModRM])() ))
#define PutRMByte(ModRM,val) \
{ \
if (ModRM >= 0xc0) \
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
else \
WriteByte( (*GetEA[ModRM])() ,val); \
}
#define PutImmRMByte(ModRM) \
{ \
if (ModRM >= 0xc0) \
I.regs.b[Mod_RM.RM.b[ModRM]]=FETCH; \
else { \
(*GetEA[ModRM])(); \
WriteByte( EA , FETCH ); \
} \
}
#define PutbackRMByte(ModRM,val) \
{ \
if (ModRM >= 0xc0) \
I.regs.b[Mod_RM.RM.b[ModRM]]=val; \
else \
WriteByte(EA,val); \
}
#define DEF_br8 \
UINT32 ModRM = FETCH,src,dst; \
src = RegByte(ModRM); \
dst = GetRMByte(ModRM)
#define DEF_wr16 \
UINT32 ModRM = FETCH,src,dst; \
src = RegWord(ModRM); \
dst = GetRMWord(ModRM)
#define DEF_r8b \
UINT32 ModRM = FETCH,src,dst; \
dst = RegByte(ModRM); \
src = GetRMByte(ModRM)
#define DEF_r16w \
UINT32 ModRM = FETCH,src,dst; \
dst = RegWord(ModRM); \
src = GetRMWord(ModRM)
#define DEF_ald8 \
UINT32 src = FETCH; \
UINT32 dst = I.regs.b[AL]
#define DEF_axd16 \
UINT32 src = FETCH; \
UINT32 dst = I.regs.w[AW]; \
src += (FETCH << 8)

View File

@@ -1,153 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "types.h"
#include "log.h"
#include "rom.h"
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint8 *ws_rom_load(char *path, uint32 *romSize)
{
uint8 *rom=NULL;
Uint32 filepos;
FILE *fp=fopen(path,"rb");
if (fp==NULL)
return(NULL);
fseek(fp,0,SEEK_END);
//fgetpos(fp,&filepos);
filepos = ftell(fp);
*romSize=(uint32)filepos;
fseek(fp,0,SEEK_SET);
rom=(uint8*)malloc(*romSize);
fread(rom,1,*romSize,fp);
fclose(fp);
return(rom);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_rom_dumpInfo(uint8 *wsrom, uint32 romSize)
{
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,romSize);
fprintf(log_get(),"rom: developper Id 0x%.2x\n",romHeader->developperId);
fprintf(log_get(),"rom: cart Id 0x%.2x\n",romHeader->cartId);
fprintf(log_get(),"rom: minimum system %s\n",(romHeader->minimumSupportSystem==WS_SYSTEM_MONO)?"Wonderswan mono":"Wonderswan color");
fprintf(log_get(),"rom: size %i Mbits\n",(romSize>>20)<<3);
fprintf(log_get(),"rom: eeprom ");
switch (romHeader->eepromSize&0xf)
{
case WS_EEPROM_SIZE_NONE: { fprintf(log_get(),"none\n"); break; }
case WS_EEPROM_SIZE_64k: { fprintf(log_get(),"64 kb\n"); break; }
case WS_EEPROM_SIZE_256k: { fprintf(log_get(),"256 kb\n"); break; }
}
fprintf(log_get(),"rom: sram ");
switch (romHeader->eepromSize&0xf0)
{
case WS_SRAM_SIZE_NONE: { fprintf(log_get(),"none\n"); break; }
case WS_SRAM_SIZE_1k: { fprintf(log_get(),"1 kb\n"); break; }
case WS_SRAM_SIZE_16k: { fprintf(log_get(),"16 kb\n"); break; }
case WS_SRAM_SIZE_8k: { fprintf(log_get(),"8 kn\n"); break; }
}
fprintf(log_get(),"rom: rtc %s\n",(romHeader->realtimeClock)?"Yes":"None");
fprintf(log_get(),"checksum 0x%.4x\n",romHeader->checksum);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
ws_romHeaderStruct *ws_rom_getHeader(uint8 *wsrom, uint32 wsromSize)
{
ws_romHeaderStruct *wsromHeader=(ws_romHeaderStruct *)malloc(sizeof(ws_romHeaderStruct));
memcpy(wsromHeader,wsrom+(wsromSize-10),10);
return(wsromHeader);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32 ws_rom_sramSize(uint8 *wsrom, uint32 wsromSize)
{
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,wsromSize);
switch (romHeader->eepromSize&0xf0)
{
case WS_SRAM_SIZE_NONE: return(0);
case WS_SRAM_SIZE_1k: return(0x400);
case WS_SRAM_SIZE_16k: return(0x4000);
case WS_SRAM_SIZE_8k: return(0x2000);
}
return(0);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32 ws_rom_eepromSize(uint8 *wsrom, uint32 wsromSize)
{
ws_romHeaderStruct *romHeader=ws_rom_getHeader(wsrom,wsromSize);
switch (romHeader->eepromSize&0xf)
{
case WS_EEPROM_SIZE_NONE: return(0);
case WS_EEPROM_SIZE_64k: return(0x10000);
case WS_EEPROM_SIZE_256k: return(0x40000);
}
return(0);
}

View File

@@ -1,60 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __ROM_H__
#define __ROM_H__
#include "types.h"
#define WS_SYSTEM_MONO 0
#define WS_SYSTEM_COLOR 1
#define WS_ROM_SIZE_2MBIT 1
#define WS_ROM_SIZE_4MBIT 2
#define WS_ROM_SIZE_8MBIT 3
#define WS_ROM_SIZE_16MBIT 4
#define WS_ROM_SIZE_24MBIT 5
#define WS_ROM_SIZE_32MBIT 6
#define WS_ROM_SIZE_48MBIT 7
#define WS_ROM_SIZE_64MBIT 8
#define WS_ROM_SIZE_128MBIT 9
#define WS_EEPROM_SIZE_NONE 0
#define WS_SRAM_SIZE_NONE 0
#define WS_EEPROM_SIZE_64k 1
#define WS_EEPROM_SIZE_256k 2
#define WS_SRAM_SIZE_1k 10
#define WS_SRAM_SIZE_16k 20
#define WS_SRAM_SIZE_8k 50
typedef struct ws_romHeaderStruct
{
uint8 developperId;
uint8 minimumSupportSystem;
uint8 cartId;
uint8 romSize;
uint8 eepromSize;
uint8 additionnalCapabilities;
uint8 realtimeClock;
uint16 checksum;
} ws_romHeaderStruct;
uint8 *ws_rom_load(char *path, uint32 *romSize);
void ws_rom_dumpInfo(uint8 *wsrom, uint32 wsromSize);
ws_romHeaderStruct *ws_rom_getHeader(uint8 *wsrom, uint32 wsromSize);
uint32 ws_rom_sramSize(uint8 *wsrom, uint32 wsromSize);
uint32 ws_rom_eepromSize(uint8 *wsrom, uint32 wsromSize);
#endif

View File

@@ -1,98 +0,0 @@
static int testJoystick=1;
if (testJoystick==1)
{
testJoystick=0;
fprintf(log_get(),"%i joysticks were found.\n\n", SDL_NumJoysticks() );
fprintf(log_get(),"The names of the joysticks are:\n");
for(int tti=0; tti < SDL_NumJoysticks(); tti++ )
fprintf(log_get()," %s\n", SDL_JoystickName(tti));
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
}
else
{
if (joystick!=NULL)
{
SDL_JoystickClose(0);
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
}
}
while ( SDL_PollEvent(&app_input_event) )
{
if ( app_input_event.type == SDL_QUIT )
{
ws_key_esc = 1;
}
}
if (joystick)
{
if (SDL_JoystickGetButton(joystick,0))
ws_key_start=1;
else
ws_key_start=0;
if (SDL_JoystickGetButton(joystick,1))
ws_key_button_1=1;
else
ws_key_button_1=0;
if (SDL_JoystickGetButton(joystick,2))
ws_key_button_2=1;
else
ws_key_button_2=0;
if (SDL_JoystickGetAxis(joystick,0)<-7000)
ws_key_left=1;
else
ws_key_left=0;
if (SDL_JoystickGetAxis(joystick,0)>7000)
ws_key_right=1;
else
ws_key_right=0;
if (SDL_JoystickGetAxis(joystick,1)<-7000)
ws_key_up=1;
else
ws_key_up=0;
if (SDL_JoystickGetAxis(joystick,1)>7000)
ws_key_down=1;
else
ws_key_down=0;
}
else
{
ws_key_start=0;
ws_key_left=0;
ws_key_right=0;
ws_key_up=0;
ws_key_down=0;
ws_key_button_1=0;
ws_key_button_2=0;
}
uint8 *keystate = SDL_GetKeyState(NULL);
if ( keystate[SDLK_d])
{
dump_memory();
}
if ( keystate[SDLK_ESCAPE] )
ws_key_esc = 1;
if ( keystate[SDLK_UP] )
ws_key_up=1;
if ( keystate[SDLK_DOWN] )
ws_key_down=1;
if ( keystate[SDLK_RIGHT] )
ws_key_right=1;
if ( keystate[SDLK_LEFT] )
ws_key_left=1;
if (keystate[SDLK_RETURN])
ws_key_start=1;
if (keystate[SDLK_c])
ws_key_button_1=1;
if (keystate[SDLK_x])
ws_key_button_2=1;
if (keystate[SDLK_p])
ws_cyclesByLine+=10;
if (keystate[SDLK_o])
ws_cyclesByLine-=10;

Binary file not shown.

View File

@@ -1,42 +0,0 @@
bits 32
section .data
bits 32
times ($$-$)&7 db 0
section .text
bits 32
global rdtscCapableCpu_
global _rdtscCapableCpu
global _ticker
global ticker_
_ticker:
ticker_:
push edx
rdtsc
shr eax,8
shl edx,24
and edx,0xff000000
or eax,edx
pop edx
ret
rdtscCapableCpu_:
_rdtscCapableCpu:
push ebx
push ecx
push edx
mov eax,1
xor ebx,ebx
xor ecx,ecx
xor edx,edx
cpuid
test edx,0x10
setne al
and eax,1
pop edx
pop ecx
pop ebx
ret
end

View File

@@ -1,5 +0,0 @@
extern "C"
{
long ticker();
};

View File

@@ -1,44 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
// this file is a travesty. [SU]int(8|16|32) should be used instead.
#ifndef __TYPES_H__
#define __TYPES_H__
#include "SDL.h"
#define UINT8 Uint8
#define UINT16 Uint16
#define INT8 Sint8
#define INT16 Sint16
#define INT32 Sint32
#define UINT32 Uint32
#define uint8 UINT8
#define uint16 UINT16
#define uint32 UINT32
#define int8 INT8
#define int16 INT16
#define int32 INT32
#define u8 uint8
#define u16 uint16
#define u32 uint32
#define s8 int8
#define s16 int16
#define s32 int32
#define BYTE Uint8
#define WORD Uint16
#define DWORD Uint32
#endif

View File

@@ -1,461 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Wonderswan emulator
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
// 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 <string.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
#include "rom.h"
#include "./nec/nec.h"
#include "./nec/necintrf.h"
#include "memory.h"
#include "gpu.h"
#include "io.h"
#include "audio.h"
#include "ws.h"
#ifndef O_BINARY
// silly windows systems with their CR/LF screwiness...
#define O_BINARY 0
#endif
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
uint32 ws_cycles;
uint32 ws_skip;
uint32 ws_cyclesByLine=0;
uint32 vblank_count=0;
char *ws_sram_path = NULL;
extern int ws_sram_dirty;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_patchRom(void)
{
uint8 *rom=memory_getRom();
uint32 romSize=memory_getRomSize();
fprintf(log_get(),"developper Id: 0x%.2x\nGame Id: 0x%.2x\n",rom[romSize-10],rom[romSize-8]);
if((rom[romSize-10]==0x01)&&(rom[romSize-8]==0x27)) // Detective Conan
{
// WS cpu is using cache/pipeline or
// there's protected ROM bank where
// pointing CS
rom[0xfffe8]=0xea;
rom[0xfffe9]=0x00;
rom[0xfffea]=0x00;
rom[0xfffeb]=0x00;
rom[0xfffec]=0x20;
}
if (!ws_cyclesByLine) ws_cyclesByLine=256;
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_init(char *rompath)
{
uint8 *rom;
uint32 romSize;
if ((rom=ws_rom_load(rompath,&romSize))==NULL)
{
printf("Error: cannot load %s\n",rompath);
return(0);
}
if (rompath[strlen(rompath)-1]=='c')
ws_gpu_operatingInColor=1;
else
ws_gpu_operatingInColor=0;
ws_memory_init(rom,romSize);
ws_patchRom();
ws_sram_load(ws_sram_path);
ws_io_init();
ws_audio_init();
ws_gpu_init();
if (ws_rotated())
ws_io_flipControls();
return(1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_reset(void)
{
ws_memory_reset();
ws_io_reset();
ws_audio_reset();
ws_gpu_reset();
nec_reset(NULL);
nec_set_reg(NEC_SP,0x2000);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_executeLine(int16 *framebuffer, int renderLine)
{
int drawWholeScreen=0;
ws_audio_process();
// update scanline register
ws_ioRam[2]=ws_gpu_scanline;
ws_cycles=nec_execute((ws_cyclesByLine>>1)+(rand()&7));
ws_cycles+=nec_execute((ws_cyclesByLine>>1)+(rand()&7));
if(ws_cycles>=ws_cyclesByLine+ws_cyclesByLine)
ws_skip=ws_cycles/ws_cyclesByLine;
else
ws_skip=1;
ws_cycles%=ws_cyclesByLine;
for(uint32 uI=0;uI<ws_skip;uI++)
{
if (renderLine)
ws_gpu_renderScanline(framebuffer);
ws_gpu_scanline++;
if(ws_gpu_scanline==144)
drawWholeScreen=1;
}
if(ws_gpu_scanline>158)
{
ws_gpu_scanline=0;
{
if((ws_ioRam[0xb2]&32))/*VBLANK END INT*/
{
if(ws_ioRam[0xa7]!=0x35)/*Beatmania Fix*/
{
ws_ioRam[0xb6]&=~32;
nec_int((ws_ioRam[0xb0]+5)*4);
}
}
}
}
ws_ioRam[2]=ws_gpu_scanline;
if(drawWholeScreen)
{
if(ws_ioRam[0xb2]&64) /*VBLANK INT*/
{
ws_ioRam[0xb6]&=~64;
nec_int((ws_ioRam[0xb0]+6)*4);
}
vblank_count++;
}
if(ws_ioRam[0xa4]&&(ws_ioRam[0xb2]&128)) /*HBLANK INT*/
{
if(!ws_ioRam[0xa5])
ws_ioRam[0xa5]=ws_ioRam[0xa4];
if(ws_ioRam[0xa5])
ws_ioRam[0xa5]--;
if((!ws_ioRam[0xa5])&&(ws_ioRam[0xb2]&128))
{
ws_ioRam[0xb6]&=~128;
nec_int((ws_ioRam[0xb0]+7)*4);
}
}
if((ws_ioRam[0x2]==ws_ioRam[0x3])&&(ws_ioRam[0xb2]&16)) /*SCANLINE INT*/
{
ws_ioRam[0xb6]&=~16;
nec_int((ws_ioRam[0xb0]+4)*4);
}
if (drawWholeScreen && ws_sram_dirty)
{
ws_sram_save(ws_sram_path);
ws_sram_dirty = 0;
}
return(drawWholeScreen);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_done(void)
{
ws_memory_done();
ws_io_done();
ws_audio_done();
ws_gpu_done();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_set_colour_scheme(int scheme)
{
ws_gpu_set_colour_scheme(scheme);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
void ws_set_system(int system)
{
if (system==WS_SYSTEM_COLOR)
ws_gpu_forceColorSystem();
else
if (system==WS_SYSTEM_MONO)
ws_gpu_forceMonoSystem();
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define MacroLoadNecRegisterFromFile(F,R) \
read(fp,&value,sizeof(value)); \
nec_set_reg(R,value);
int ws_loadState(char *statepath)
{
fprintf(log_get(),"loading %s\n",statepath);
uint16 crc=memory_getRomCrc();
uint16 newCrc;
unsigned value;
uint8 ws_newVideoMode;
int fp = open(statepath,O_BINARY|O_RDONLY);
if (fp == -1)
return(0);
read(fp, &newCrc, 2);
if (newCrc!=crc)
{
return(-1);
}
MacroLoadNecRegisterFromFile(fp,NEC_IP);
MacroLoadNecRegisterFromFile(fp,NEC_AW);
MacroLoadNecRegisterFromFile(fp,NEC_BW);
MacroLoadNecRegisterFromFile(fp,NEC_CW);
MacroLoadNecRegisterFromFile(fp,NEC_DW);
MacroLoadNecRegisterFromFile(fp,NEC_CS);
MacroLoadNecRegisterFromFile(fp,NEC_DS);
MacroLoadNecRegisterFromFile(fp,NEC_ES);
MacroLoadNecRegisterFromFile(fp,NEC_SS);
MacroLoadNecRegisterFromFile(fp,NEC_IX);
MacroLoadNecRegisterFromFile(fp,NEC_IY);
MacroLoadNecRegisterFromFile(fp,NEC_BP);
MacroLoadNecRegisterFromFile(fp,NEC_SP);
MacroLoadNecRegisterFromFile(fp,NEC_FLAGS);
MacroLoadNecRegisterFromFile(fp,NEC_VECTOR);
MacroLoadNecRegisterFromFile(fp,NEC_PENDING);
MacroLoadNecRegisterFromFile(fp,NEC_NMI_STATE);
MacroLoadNecRegisterFromFile(fp,NEC_IRQ_STATE);
read(fp,internalRam,65536);
read(fp,ws_staticRam,65536);
read(fp,ws_ioRam,256);
read(fp,ws_paletteColors,8);
read(fp,ws_palette,16*4*2);
read(fp,wsc_palette,16*16*2);
read(fp,&ws_newVideoMode,1);
read(fp,&ws_gpu_scanline,1);
read(fp,externalEeprom,131072);
ws_audio_readState(fp);
close(fp);
// force a video mode change to make all tiles dirty
ws_gpu_clearCache();
return(1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
#define MacroStoreNecRegisterToFile(F,R) \
value=nec_get_reg(R); \
write(fp,&value,sizeof(value));
int ws_saveState(char *statepath)
{
uint16 crc=memory_getRomCrc();
unsigned value;
char *newPath;
fprintf(log_get(),"saving %s\n",statepath);
newPath=new char[1024];
if (strlen(statepath)<4)
sprintf(newPath,"%s.wss",statepath);
else
{
int len=strlen(statepath);
if ((statepath[len-1]!='s')&&(statepath[len-1]!='S'))
sprintf(newPath,"%s.wss",statepath);
else
if ((statepath[len-2]!='s')&&(statepath[len-2]!='S'))
sprintf(newPath,"%s.wss",statepath);
else
if ((statepath[len-3]!='w')&&(statepath[len-3]!='w'))
sprintf(newPath,"%s.wss",statepath);
else
if (statepath[len-4]!='.')
sprintf(newPath,"%s.wss",statepath);
else
sprintf(newPath,"%s",statepath);
}
int fp=open(newPath,O_BINARY|O_RDWR|O_CREAT);
delete newPath;
if (fp==-1)
return(0);
write(fp,&crc,2);
MacroStoreNecRegisterToFile(fp,NEC_IP);
MacroStoreNecRegisterToFile(fp,NEC_AW);
MacroStoreNecRegisterToFile(fp,NEC_BW);
MacroStoreNecRegisterToFile(fp,NEC_CW);
MacroStoreNecRegisterToFile(fp,NEC_DW);
MacroStoreNecRegisterToFile(fp,NEC_CS);
MacroStoreNecRegisterToFile(fp,NEC_DS);
MacroStoreNecRegisterToFile(fp,NEC_ES);
MacroStoreNecRegisterToFile(fp,NEC_SS);
MacroStoreNecRegisterToFile(fp,NEC_IX);
MacroStoreNecRegisterToFile(fp,NEC_IY);
MacroStoreNecRegisterToFile(fp,NEC_BP);
MacroStoreNecRegisterToFile(fp,NEC_SP);
MacroStoreNecRegisterToFile(fp,NEC_FLAGS);
MacroStoreNecRegisterToFile(fp,NEC_VECTOR);
MacroStoreNecRegisterToFile(fp,NEC_PENDING);
MacroStoreNecRegisterToFile(fp,NEC_NMI_STATE);
MacroStoreNecRegisterToFile(fp,NEC_IRQ_STATE);
write(fp,internalRam,65536);
write(fp,ws_staticRam,65536);
write(fp,ws_ioRam,256);
write(fp,ws_paletteColors,8);
write(fp,ws_palette,16*4*2);
write(fp,wsc_palette,16*16*2);
write(fp,&ws_videoMode,1);
write(fp,&ws_gpu_scanline,1);
write(fp,externalEeprom,131072);
ws_audio_writeState(fp);
close(fp);
return(1);
}
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
int ws_rotated(void)
{
uint8 *rom=memory_getRom();
uint32 romSize=memory_getRomSize();
return(rom[romSize-4]&1);
}

View File

@@ -1,33 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __WS_H__
#define __WS_H__
#define WS_SYSTEM_MONO 0
#define WS_SYSTEM_COLOR 1
#define WS_SYSTEM_AUTODETECT 2
// <20> supprimer !
extern uint32 ws_cyclesByLine;
int ws_init(char *rompath);
int ws_rotated(void);
void ws_set_colour_scheme(int scheme);
void ws_set_system(int system);
void ws_reset(void);
int ws_executeLine(int16 *framebuffer, int renderLine);
void ws_patchRom(void);
int ws_loadState(char *statepath);
int ws_saveState(char *statepath);
void ws_done(void);
#endif

View File

@@ -1,409 +0,0 @@
# Microsoft Developer Studio Project File - Name="wonderswan" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=wonderswan - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wonderswan.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wonderswan.mak" CFG="wonderswan - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wonderswan - Win32 Release" (based on\
"Win32 (x86) Console Application")
!MESSAGE "wonderswan - Win32 Debug" (based on\
"Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "wonderswan - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MT /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /c
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 comctl32.lib comdlg32.lib kernel32.lib user32.lib gdi32.lib winmm.lib winspool.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "wonderswan - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gm /GX /Zi /O2 /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 comctl32.lib comdlg32.lib kernel32.lib user32.lib gdi32.lib winspool.lib winmm.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "wonderswan - Win32 Release"
# Name "wonderswan - Win32 Debug"
# Begin Group "nec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\nec\nec.cpp
!IF "$(CFG)" == "wonderswan - Win32 Release"
# ADD CPP /W1
!ELSEIF "$(CFG)" == "wonderswan - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\source\nec\nec.h
# End Source File
# Begin Source File
SOURCE=.\source\nec\necea.h
# End Source File
# Begin Source File
SOURCE=.\source\nec\necinstr.h
# End Source File
# Begin Source File
SOURCE=.\source\nec\necmodrm.h
# End Source File
# End Group
# Begin Group "documentation"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\documentation\ws_communication.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_controls.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_dma.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_external_eeprom.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_gpu.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_hardware_type.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_internal_eeprom.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_interrupts.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_lcd_control.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_line_execution_behaviour.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_palette.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_realtimeclock.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_rom_banks_selectors.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_rom_header.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_sound.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\ws_tileformat.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\wstech20.txt
# End Source File
# Begin Source File
SOURCE=.\documentation\wstech20work.txt
# End Source File
# End Group
# Begin Group "tools"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\log.cpp
# End Source File
# Begin Source File
SOURCE=.\source\LOG.H
# End Source File
# Begin Source File
SOURCE=.\source\ticker.h
# End Source File
# Begin Source File
SOURCE=.\source\ticker.obj
# End Source File
# Begin Source File
SOURCE=.\source\types.h
# End Source File
# End Group
# Begin Group "gui"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\gui.rc
!IF "$(CFG)" == "wonderswan - Win32 Release"
!ELSEIF "$(CFG)" == "wonderswan - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\source\gui\logo.bmp
# End Source File
# Begin Source File
SOURCE=.\source\gui\sponsor.bmp
# End Source File
# End Group
# Begin Group "sdl"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\sdl\include\SDL.h
# End Source File
# Begin Source File
SOURCE=.\source\sdl\SDL.lib
# End Source File
# Begin Source File
SOURCE=.\source\sdl\SDLmain.lib
# End Source File
# Begin Source File
SOURCE=.\source\sdl\include\SDLptc.h
# End Source File
# End Group
# Begin Group "wonderswan"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\audio.cpp
# End Source File
# Begin Source File
SOURCE=.\source\audio.h
# End Source File
# Begin Source File
SOURCE=.\source\gpu.cpp
# End Source File
# Begin Source File
SOURCE=.\source\gpu.h
# End Source File
# Begin Source File
SOURCE=.\source\ieeprom.h
# End Source File
# Begin Source File
SOURCE=.\source\initialIo.h
# End Source File
# Begin Source File
SOURCE=.\source\io.cpp
# End Source File
# Begin Source File
SOURCE=.\source\io.h
# End Source File
# Begin Source File
SOURCE=.\source\memory.cpp
# End Source File
# Begin Source File
SOURCE=.\source\memory.h
# End Source File
# Begin Source File
SOURCE=.\source\rom.cpp
# End Source File
# Begin Source File
SOURCE=.\source\rom.h
# End Source File
# Begin Source File
SOURCE=.\source\ws.cpp
# End Source File
# Begin Source File
SOURCE=.\source\ws.h
# End Source File
# End Group
# Begin Group "filters"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\2xSaI.cpp
# End Source File
# Begin Source File
SOURCE=.\source\2xSaI.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\2xsai.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\doubled.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\filter_partA.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\filter_partB.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\filter_partC.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\filter_partD.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\filter_partE.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\halfscanlines.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\scanlines.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\special.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\standard.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\super2xsai.h
# End Source File
# Begin Source File
SOURCE=.\source\filters\supereagle.h
# End Source File
# End Group
# Begin Group "seal"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\source\seal\AUDIO.H
# End Source File
# Begin Source File
SOURCE=.\source\seal\AUDW32VC.LIB
# End Source File
# End Group
# Begin Source File
SOURCE=.\source\temp\key.h
# End Source File
# Begin Source File
SOURCE=.\main.cpp
# End Source File
# End Target
# End Project

View File

@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "wonderswan"=.\wonderswan.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,44 +0,0 @@
Release 1.0.7 July 30th, 1999
- Source code released under the GNU Lesser General Public License (LGPL)
Release 1.0.6 December 25th, 1998
- New API functions ASetAudioMixerValue and AUpdateAudioEx
- Minor fixes in ENSONIQ SoundScape and Windows Sound System drivers
- Fixed DJGPP memory protection fault due to page swapping
- Windows 95 and NT driver thread priority changed
- Workaround to get sound on some SB compatible cards
- Port to Intel BeOS R4 platforms
- New experimental accelerated DirectSound driver
Release 1.0.5 October 18th, 1998
- Fixed problems with ENSONIQ AudioPCI cards (Thanks Bomb!)
- Port to OS/2 platforms (Thanks Marty!)
- Port to Intel BeOS R3 platforms
- HTML documentation
Release 1.0.4 April 12th, 1998
- Memory leak in AFreeWaveFile() fixed
- New API call to retrieve tracks' parameters
Release 1.0.3 January 9th, 1997
- Windows Wave and DirectSound drivers bug fixes
- Minor bug fix in XM module file loader
- Silence driver now actually "play" modules
Release 1.0.1 September 25th, 1996
- Support for DirectSound in Windows 95 and NT
- Support for Sound Blaster AWE32 (EMU8000) sound cards
- Support for Ultrasound PnP (InterWave) sound cards
- Support for MultiTracker 1.0 module files
- New synchronization callback feature
- New file offset parameter in loading routines
- Data type names changed for better portability
- Fixed mono playback for non-wavetable sound cards
- Volume was too quiet for 8-bit sound cards
- Fixed WATCOM C/C++ 10.x naming convention bug
- Fixed 4DOS-only batch files to work with COMMAND.COM
- Many other minor bug fixes
Release 1.0.0 June 8th, 1996
- First release

View File

@@ -1,13 +0,0 @@
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
SEAL Audio Library Release 1.0.7
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
32-bit multichannel audio system
for DOS, Windows 95, Windows NT,
OS/2, BeOS and Linux platforms.
Supports SB, SBPro, SB16, AWE32,
PAS, PAS16, GUS, GUSDB, GUSMAX,
IW, WSS, ESS and Aria cards.
Plays MOD/MTM/S3M/XM modules.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Full source code available!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

View File

@@ -1,505 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and an idea of what it does.>
Copyright (C) year name of author
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,6 +0,0 @@
all:
cd src ; make
clean:
-rm lib/SDL/*.a
cd src ; make clean

View File

@@ -1,39 +0,0 @@
This is the OS/2 port of the Synthetic Audio Library (SEAL).
The DLL included can be used to add OS/2 native support for playing module
files and streamed audio to OS/2 Presentation Manager (PM) and VIO
applications. It can also be used to assist in the porting of other DOS,
Windows, and Linux applications that also use the SEAL API.
To build applications with the SEAL library, simply link them with the
AUDIO.LIB file and include the AUDIO.H file in your programs. The standard SEAL
documentation covers the usage of the standard SEAL API. There are a few
additional considerations in using the OS/2 version:
* The OS/2 version is multithreaded. This means that the SEAL library is
updating the audio buffers in the background while the rest of your
application is running. Unlike the DOS and Windows versions, you DO NOT
HAVE TO call the AUpdateAudio function to update the audio buffers. This
also means that some care needs to be taken when updating the voices
and sound buffers yourself. It is recommended that you use DosEnterCritSec
and DosExitCritSec around areas where voices are created and destroyed.
* Some of the SEAL API functions require other threads to be running when
they are called. If you are in a critical section when you call some
functions, it can cause deadlock because the critical section prevents
other threads in the same task from running. Do not call the following
functions in a critical section: AOpenAudio, ACloseAudio, AUpdateAudio.
* The AUpdateAudio function was implemented, but not to update the audio.
It was made to be a means of synchronizing your application with the audio
stream. When you call AUpdateAudio, the calling thread will block until
an audio buffer needs more data. For a good example of how to use this
function and the rest of the SEAL API, ask me for the source code for
MAME for OS/2. E-mail me at mta3206@grace.isc.rit.edu.
There are no known OS/2 specific bugs at this time.
Look for a DART-enabled version soon.
- Marty

View File

@@ -1,224 +0,0 @@
Synthetic Audio Library (SEAL) Development Kit
Copyright (C) 1995, 1996, 1997, 1998, 1999 Carlos Hasan
All Rights Reserved
OS/2 Sound Driver Copyright (C) 1998 Martin Amodeo
This 1.0.7 release of the Synthetic Audio Library (SEAL) lets you write
applications that conform to the 1.0 SEAL API which is able to play
digital audio waveforms and music modules on many platforms.
What's New
----------
- Source code released under the GNU Lesser General Public License (LGPL)
Features
--------
- simple and powerful API interface
- 32 simultaneous digital audio channels
- smooth pitch shifting, volume and panning controllers per channel
- smart digital filtering for improved sound quality
- efficient digital audio waveform mixing algorithms combined with
uncompromising low-level optimizations
- importing of wave and music file formats such as Protracker 1.1,
MultiTracker 1.0, Scream Tracker 3.0 and FastTracker 2.0 modules
- performance tuned for the i486 and Pentium processors
- native support in DOS for hardware wavetable accelerators such
as the Sound Blaster AWE32, Gravis Forte's UltraSound, and normal
digital audio devices such as the Sound Blaster 1.5/2.0/Pro/16,
Pro Audio Spectrum 16, Windows Sound System, Ensoniq Soundscape
and Aria soundcards
Supported platforms
-------------------
The SEAL SDK is available for DOS, Extended DOS, Windows 95, Windows NT,
OS/2, BeOS and Linux platforms. FreeBSD, SPARC SunOS, SPARC Solaris and
SGI Indigo ports are in progress. The following compilers were used to
build the library files:
- Borland C++ 4.5 compiler for DOS and Win32s
- WATCOM C/C++ 10.0 compiler for DOS and Windows
- Microsoft Visual C++ 4.1 compiler for Windows 95
- DJGPP 2.0 port of GNU C/C++ compiler for DOS
- GNU C/C++ 2.7.0 for Linux (a.out and ELF)
- Metrowerks CodeWarrior C++ for Intel BeOS Release 3
- EMX port of GNU CC 2.7.x for OS/2 platforms
The SEAL SDK contains
---------------------
- SEAL API header and library files
- SEAL audio library source code files (GPL license)
- set of example source code files
---------------------------------------------------------------------
IMPORTANT: Please make sure you understand the Copyright and License
information (in the file named LICENSE.TXT) before using this release.
---------------------------------------------------------------------
Installing the Software
-----------------------
The SEAL SDK can be installed unpacking the distribution archive
in your hard disk. For example,
C:\>PKUNZIP -d SEAL107.ZIP
The SEAL SDK include and library directories can be installed in
your C programming environment modifying the header and library
directory paths. Here are some examples to compile and link
the SEAL audio system library with your own programs:
- WATCOM C/C++32 10.0 and DOS4GW DOS Extender:
wcl386 -I\audio\include example.c \audio\lib\dos\audiowcf.lib
- DJGPP 2.0 port of GNU CC for DOS/DPMI32:
gcc -I\audio\include -o example example.c \audio\lib\dos\audiodjf.a
- Visual C/C++ 4.1 for Windows 95 and Windows NT:
cl -DWIN32 -I\audio\include example.c \audio\lib\Win32\audw32vc.lib
- Borland C++ 4.5 for Win32s:
bcc32a -WC -I\audio\include example.c \audio\lib\Win32\audw32bc.lib
- GNU CC 2.7.0 for Linux (ELF binaries):
gcc -Iaudio/include -o example example.c audio/lib/Linux/libaudio.a
- Metrowerks CodeWarrior C++ for BeOS R3:
mwcc -Iaudio/include -o example example.c audio/lib/BeOS/libaudio.a
The above examples assume that the audio system was installed at the
root directory of the current drive. For Windows 95 and Windows NT
applications you must copy the AUDIOW32.DLL dynamic-link library into
the Windows system directory, usually located at C:\WINDOWS\SYSTEM in
your hard disk.
Notes about DOS Drivers
-----------------------
For applications running in DOS, the audio system will try to detect
the hardware sound devices installed on your system. Since there can
be problems to autodetect your sound hardware, your application should
provide a way to force the use of a particular audio device driver.
Here is a list of notes for the autodetection methods used by the audio
device drivers under the DOS operating system:
- Sound Blaster 1.0/1.5/2.0/Pro/16 device drivers:
These drivers use the BLASTER environment variable to determine
the hardware I/O base port address, IRQ interrupt line and DMA
channels. The model of the card is then determined by hardware
reading the DSP version number. If you do not get sound, try
forcing other SB model by using the "T" parameter of the BLASTER
environment variable:
T1 = Sound Blaster 1.0
T2 = Sound Blaster 1.5
T3 = Sound Blaster 2.0
T4 = Sound Blaster Pro
T6 = Sound Blaster 16
- Sound Blaster AWE32 and Sound Blaster 32 device drivers:
The driver uses the BLASTER environment variable, you must
specify the EMU8000 I/O base port address parameter. If your
card does not have DRAM local sound memory, you must use the
card as a Sound Blaster 16 or earlier.
- Pro Audio Spectrum, Pro Audio Spectrum Plus/16 device drivers:
These drivers need to have the MVSOUND.SYS driver installed
in your CONFIG.SYS configuration file. The model of the card
is determined by hardware checking the card features bits.
- Gravis Ultrasound, Ultrasound MAX device drivers:
This driver uses the ULTRASND environment variable to determine
the hardware configuration of your card. For applications using
the DOS4GW extender, the GF1-IRQ number must be less than 8 to
work correctly.
- Gravis Ultrasound Daughterboard / MAX (CS4231) device drivers:
This driver uses the CS4231 codec of your GUS DB/MAX card, so
you must have the ULTRASND and ULTRA16 environment variables.
- Gravis Ultrasound PnP (Pro), InterWave-based device drivers:
This driver uses the ULTRASND and INTERWAVE environment variables
to determine the hardware configuration of your sound board.
- Windows Sound System device driver:
This driver automatically detect WSS sound devices installed
at the 530, E80, F40 or 604 I/O base port addresses and uses
by default the IRQ line #7 and DMA channel #1 for playback.
Since there can be hardware conflicts, the driver first check
for the WSSCFG environment variable which has the following
format:
SET WSSCFG=Annn In Dn
| | |
| | +-- DMA channel (0,1,3)
| +---- IRQ number (7,9,10,11)
+----- I/O port (530,E80,F40,604)
You must write the above command in your AUTOEXEC.BAT start-up
batch file. Also, some WSS clone devices need to run an utility
to put the card in WSS mode (ie. MAD16 OPTi-based cards).
- Ensoniq Soundscape, Soundscape Elite device drivers:
These drivers uses the SNDSCAPE environment variable to read
the SNDSCAPE.INI configuration file.
- Sierra Semoconductors' Aria sound card driver:
This driver uses the ARIA environment variable to read the
hardware configuration parameters.
- Ensoniq AudioPCI and Creative PCI64 sound cards:
These cards have to be configured in Legacy emulation mode
under DOS. The library will use these cards as Ensoniq
SoundScape ISA cards.
If you experience any problems, please try avoiding autodetection and
tell your application what device driver to use. Also, ensure your
system has no TSR's loaded in memory (such as SBOS for GUS cards).
Notes about Windows 95
----------------------
The SEAL audio system for DOS and Extended DOS has been sucessfully
tested under Windows 95 DOS boxes running in foreground. However,
some Windows 95 sound drivers might not be able to share the sound
hardware with DOS sessions (such as the Ultrasound drivers). In such
cases, you must either remove the Windows 95 drivers or exit to DOS
to run your DOS programs.
Notes about Linux
-----------------
The SEAL audio system for Linux uses the UNIX Sound System interface,
also known as the VoxWare Kit. The audio system can be easily ported
to other UNIX operating system running in Intel x86 platforms where
the UNIX Sound System interface is also available, such as FreeBSD,
386bsd, SCO and SVR4.2 operating systems.
Notes about BeOS
----------------
The SEAL audio library for Intel BeOS Release 3 also works with
New MediaKit sound drivers found on BeOS R4. The SEAL 1.06 library
comes with ELF binaries for Intel BeOS Release 4.
Contacting the Author
---------------------
If you have questions, problems or comments you can contact the author
at the following email address: chasan@dcc.uchile.cl.
Closing Words
-------------
I would like to thank all the beta testers and specially to Jon L.
for the music module file used by the example programs, and to all
the IRC friends at the #coders channel.

File diff suppressed because it is too large Load Diff

View File

@@ -1,479 +0,0 @@
/* check.c - misc. routines from the reference guide */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifndef linux
#include <conio.h>
#endif
#include <audio.h>
/* enable filtering */
#define FILTER
/* soy paranoico! */
#define Assert(x) AssertFailed((x),#x,__LINE__,__FILE__)
void AssertFailed(UINT rc, LPSTR lpszExpr, int nLine, LPSTR lpszFileName)
{
CHAR szText[128];
if (rc != AUDIO_ERROR_NONE) {
AGetErrorText(rc, szText, sizeof(szText) - 1);
fprintf(stderr, "ASSERT(%s:%d): %s\nERROR: %s\n",
lpszFileName, nLine, lpszExpr, szText);
ACloseAudio();
exit(1);
}
}
/* APingAudio, AGetAudioDevCaps */
VOID DetectAudioDevice(VOID)
{
AUDIOCAPS caps;
UINT nDeviceId;
if (APingAudio(&nDeviceId) != AUDIO_ERROR_NONE)
printf("no audio found\n");
else {
AGetAudioDevCaps(nDeviceId, &caps);
printf("%s device found\n", caps.szProductName);
}
}
/* AGetAudioDevCaps, AGetAudioNumDevs */
VOID PrintAudioDevs(VOID)
{
AUDIOCAPS caps;
UINT nDeviceId;
for (nDeviceId = 0; nDeviceId < AGetAudioNumDevs(); nDeviceId++) {
Assert(AGetAudioDevCaps(nDeviceId, &caps));
printf("nDeviceId=%d wProductId=%d szProductName=%s\n",
nDeviceId, caps.wProductId, caps.szProductName);
}
}
/* AOpenAudio, AGetErrorText */
VOID InitializeAudio(VOID)
{
AUDIOINFO info;
CHAR szText[128];
UINT rc;
info.nDeviceId = AUDIO_DEVICE_MAPPER;
info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO;
#ifdef FILTER
info.wFormat |= AUDIO_FORMAT_FILTER;
#endif
info.nSampleRate = 44100;
if ((rc = AOpenAudio(&info)) != AUDIO_ERROR_NONE) {
AGetErrorText(rc, szText, sizeof(szText) - 1);
printf("ERROR: %s\n", szText);
exit(1);
}
else {
printf("Audio device initialized at %d bits %s %u Hz\n",
info.wFormat & AUDIO_FORMAT_16BITS ? 16 : 8,
info.wFormat & AUDIO_FORMAT_STEREO ?
"stereo" : "mono", info.nSampleRate);
}
}
/* ASetAudioTimerProc, ASetAudioTimerRate */
volatile UINT nTickCounter = 0;
VOID AIAPI TimerHandler(VOID)
{
nTickCounter++;
}
VOID InitTimerHandler(VOID)
{
Assert(ASetAudioTimerProc(TimerHandler));
Assert(ASetAudioTimerRate(125));
}
VOID DoneTimerHandler(VOID)
{
Assert(ASetAudioTimerProc(NULL));
}
VOID TestTimerServices(VOID)
{
InitTimerHandler();
do {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
fprintf(stderr, "Elapsed: %2.2f secs\r", nTickCounter / 50.0F);
} while (nTickCounter < 2*50);
DoneTimerHandler();
}
/* ACreateAudioVoice, ADestroyAudioVoice, APlayVoice, ASetVoiceXXX */
VOID PlayWaveform(LPAUDIOWAVE lpWave)
{
HAC hVoice;
BOOL stopped;
Assert(ACreateAudioVoice(&hVoice));
Assert(APlayVoice(hVoice, lpWave));
Assert(ASetVoiceVolume(hVoice, 64));
Assert(ASetVoicePanning(hVoice, 128));
printf("press any key to stop\n");
while (!kbhit()) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
Assert(AGetVoiceStatus(hVoice, &stopped));
if (stopped) break;
}
if (kbhit()) getch();
Assert(AStopVoice(hVoice));
Assert(ADestroyAudioVoice(hVoice));
}
VOID TestPlayWaveform(VOID)
{
LPAUDIOWAVE lpWave;
Assert(ALoadWaveFile("test.wav", &lpWave, 0));
lpWave->wFormat |= AUDIO_FORMAT_LOOP;
lpWave->dwLoopStart = 0;
lpWave->dwLoopEnd = lpWave->dwLength;
Assert(AOpenVoices(1));
PlayWaveform(lpWave);
Assert(ACloseVoices());
Assert(AFreeWaveFile(lpWave));
}
/* APrimeVoice, AStartVoice, ASetVoiceXXX */
VOID PlayChord(HAC aVoices[3], LPAUDIOWAVE lpWave, LONG aFreqs[3])
{
UINT n;
for (n = 0; n < 3; n++) {
Assert(APrimeVoice(aVoices[n], lpWave));
Assert(ASetVoiceFrequency(aVoices[n], aFreqs[n]));
Assert(ASetVoiceVolume(aVoices[n], 64));
}
for (n = 0; n < 3; n++) {
Assert(AStartVoice(aVoices[n]));
}
}
VOID TestPlayChord(VOID)
{
LPAUDIOWAVE lpWave;
HAC aVoices[3];
LONG aFreqs[3] = { (8*6000)/8, (8*6000)/6, (8*6000)/5 };
UINT n;
Assert(ALoadWaveFile("test.wav", &lpWave, 0));
Assert(AOpenVoices(3));
for (n = 0; n < 3; n++)
Assert(ACreateAudioVoice(&aVoices[n]));
printf("press any key to stop\n");
InitTimerHandler();
while (!kbhit()) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
/* play chord two times per second */
if (nTickCounter >= 25) {
PlayChord(aVoices, lpWave, aFreqs);
nTickCounter -= 25;
}
}
if (kbhit()) getch();
DoneTimerHandler();
for (n = 0; n < 3; n++) {
Assert(AStopVoice(aVoices[n]));
Assert(ADestroyAudioVoice(aVoices[n]));
}
Assert(ACloseVoices());
Assert(AFreeWaveFile(lpWave));
}
/* ASetVoicePosition, AGetVoicePosition */
VOID PlayEchoVoices(HAC aVoices[2], LPAUDIOWAVE lpWave, LONG dwDelay)
{
Assert(APrimeVoice(aVoices[0], lpWave));
Assert(APrimeVoice(aVoices[1], lpWave));
Assert(ASetVoiceFrequency(aVoices[0], lpWave->nSampleRate / 2));
Assert(ASetVoiceFrequency(aVoices[1], lpWave->nSampleRate / 2));
Assert(ASetVoiceVolume(aVoices[0], 64));
Assert(ASetVoiceVolume(aVoices[1], 48));
Assert(ASetVoicePosition(aVoices[1], dwDelay));
Assert(AStartVoice(aVoices[0]));
Assert(AStartVoice(aVoices[1]));
}
VOID TestPlayEcho(VOID)
{
LPAUDIOWAVE lpWave;
HAC aVoices[2];
UINT n;
Assert(ALoadWaveFile("test.wav", &lpWave, 0));
Assert(AOpenVoices(2));
for (n = 0; n < 2; n++)
Assert(ACreateAudioVoice(&aVoices[n]));
printf("press any key to stop\n");
InitTimerHandler();
while (!kbhit()) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
/* play voices two times per second */
if (nTickCounter >= 25) {
PlayEchoVoices(aVoices, lpWave, 800);
nTickCounter -= 25;
}
}
if (kbhit()) getch();
DoneTimerHandler();
for (n = 0; n < 2; n++) {
Assert(AStopVoice(aVoices[n]));
Assert(ADestroyAudioVoice(aVoices[n]));
}
Assert(ACloseVoices());
Assert(AFreeWaveFile(lpWave));
}
/* ASetVoiceFrequency */
VOID PlayVoiceStereo(HAC aVoices[2], LPAUDIOWAVE lpWave, LONG dwPitchShift)
{
Assert(APrimeVoice(aVoices[0], lpWave));
Assert(APrimeVoice(aVoices[1], lpWave));
Assert(ASetVoiceVolume(aVoices[0], 64));
Assert(ASetVoiceVolume(aVoices[1], 64));
Assert(ASetVoiceFrequency(aVoices[0], lpWave->nSampleRate));
Assert(ASetVoiceFrequency(aVoices[1], lpWave->nSampleRate + dwPitchShift));
Assert(ASetVoicePanning(aVoices[0], 0));
Assert(ASetVoicePanning(aVoices[1], 255));
Assert(AStartVoice(aVoices[0]));
Assert(AStartVoice(aVoices[1]));
}
VOID TestPlayStereoEnh(VOID)
{
LPAUDIOWAVE lpWave;
HAC aVoices[2];
UINT n;
Assert(ALoadWaveFile("test.wav", &lpWave, 0));
Assert(AOpenVoices(2));
for (n = 0; n < 2; n++)
Assert(ACreateAudioVoice(&aVoices[n]));
printf("press any key to stop\n");
InitTimerHandler();
while (!kbhit()) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
/* play voices two times per second */
if (nTickCounter >= 25) {
PlayVoiceStereo(aVoices, lpWave, 100);
nTickCounter -= 25;
}
}
if (kbhit()) getch();
DoneTimerHandler();
for (n = 0; n < 2; n++) {
Assert(AStopVoice(aVoices[n]));
Assert(ADestroyAudioVoice(aVoices[n]));
}
Assert(ACloseVoices());
Assert(AFreeWaveFile(lpWave));
}
/* ACreateAudioData, AWriteAudioData */
LPAUDIOWAVE CreateAudio8BitMono(WORD nSampleRate,
LPBYTE lpData, DWORD dwLength)
{
LPAUDIOWAVE lpWave;
if ((lpWave = (LPAUDIOWAVE) malloc(sizeof(AUDIOWAVE))) != NULL) {
lpWave->wFormat = AUDIO_FORMAT_8BITS | AUDIO_FORMAT_MONO;
lpWave->nSampleRate = nSampleRate;
lpWave->dwLength = dwLength;
lpWave->dwLoopStart = lpWave->dwLoopEnd = 0L;
Assert(ACreateAudioData(lpWave));
memcpy(lpWave->lpData, lpData, dwLength);
Assert(AWriteAudioData(lpWave, 0L, dwLength));
}
return lpWave;
}
VOID TestCreateAudioData(VOID)
{
LPAUDIOWAVE lpWave;
HAC hVoice;
static BYTE aData[4000];
UINT n;
/* create 500 Hz sinewave (sampled at 4 kHz) */
for (n = 0; n < sizeof(aData); n++)
aData[n] = (BYTE)(127.0 * sin((500.0 * 3.141592653 * n) / sizeof(aData)));
lpWave = CreateAudio8BitMono(4000, aData, sizeof(aData));
if (lpWave == NULL) {
printf("not enough memory\n");
return;
}
Assert(AOpenVoices(1));
Assert(ACreateAudioVoice(&hVoice));
printf("press any key to stop\n");
InitTimerHandler();
while (!kbhit()) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
/* play voices two times per second */
if (nTickCounter >= 25) {
Assert(APlayVoice(hVoice, lpWave));
Assert(ASetVoiceVolume(hVoice, 64));
nTickCounter -= 25;
}
}
if (kbhit()) getch();
DoneTimerHandler();
Assert(AStopVoice(hVoice));
Assert(ADestroyAudioVoice(hVoice));
Assert(ACloseVoices());
Assert(ADestroyAudioData(lpWave));
free(lpWave);
}
/* ACreateAudioData, AWriteAudioData */
VOID StreamData8BitMono(FILE *stream, HAC hVoice, LPAUDIOWAVE lpWave)
{
static BYTE aBuffer[1024];
LPBYTE lpChunk;
UINT nLength, nChunkSize;
DWORD dwOffset;
static LONG dwVoicePosition;
if (2*sizeof(aBuffer) > lpWave->dwLength) {
printf("the waveform is too small\n");
return;
}
memset(lpWave->lpData, 0x80, lpWave->dwLength);
Assert(AWriteAudioData(lpWave, 0L, lpWave->dwLength));
lpWave->wFormat |= AUDIO_FORMAT_LOOP;
lpWave->dwLoopStart = 0L;
lpWave->dwLoopEnd = lpWave->dwLength;
Assert(APlayVoice(hVoice, lpWave));
Assert(ASetVoiceVolume(hVoice, 64));
dwOffset = 0L;
while ((nLength = fread(aBuffer, 1, sizeof(aBuffer), stream)) != 0) {
if (kbhit()) break;
#ifndef SIGNED
{
UINT n;
for (n = 0; n < nLength; n++)
aBuffer[n] ^= 0x80;
}
#endif
lpChunk = aBuffer;
while (nLength > 0) {
nChunkSize = nLength;
if (dwOffset + nChunkSize > lpWave->dwLength)
nChunkSize = lpWave->dwLength - dwOffset;
for (;;) {
#ifndef WIN32
Assert(AUpdateAudio());
#endif
Assert(AGetVoicePosition(hVoice, &dwVoicePosition));
if (dwOffset + nChunkSize > lpWave->dwLength) {
if (dwVoicePosition < dwOffset &&
dwVoicePosition > dwOffset +
nChunkSize - lpWave->dwLength)
break;
}
else {
if (dwVoicePosition < dwOffset ||
dwVoicePosition > dwOffset + nChunkSize)
break;
}
}
memcpy(lpWave->lpData + dwOffset, lpChunk, nChunkSize);
Assert(AWriteAudioData(lpWave, dwOffset, nChunkSize));
if ((dwOffset += nChunkSize) >= lpWave->dwLength)
dwOffset = 0L;
lpChunk += nChunkSize;
nLength -= nChunkSize;
}
}
if (kbhit()) getch();
}
VOID TestAudioStream(VOID)
{
FILE *stream;
HAC hVoice;
AUDIOWAVE Wave;
/* open .wav file and skip header structure */
if ((stream = fopen("8mono.wav", "rb")) == NULL) {
printf("cant open raw 8-bit mono file\n");
return;
}
fseek(stream, 48L, SEEK_SET);
/* start playing the "data" chunk of the .wav file */
Assert(AOpenVoices(1));
Assert(ACreateAudioVoice(&hVoice));
Wave.wFormat = AUDIO_FORMAT_8BITS | AUDIO_FORMAT_MONO;
Wave.nSampleRate = 11025;
Wave.dwLength = Wave.dwLoopEnd = 10000;
Wave.dwLoopStart = 0;
Assert(ACreateAudioData(&Wave));
printf("press any key to stop\n");
StreamData8BitMono(stream, hVoice, &Wave);
Assert(AStopVoice(hVoice));
Assert(ADestroyAudioVoice(hVoice));
Assert(ACloseVoices());
Assert(ADestroyAudioData(&Wave));
fclose(stream);
}
void main(void)
{
#ifndef WIN32
AInitialize();
#endif
printf("------------ DetectAudioDevice() ------------\n");
DetectAudioDevice();
printf("------------ PrintAudioDevs() ---------------\n");
PrintAudioDevs();
printf("------------ InitializeAudio() --------------\n");
InitializeAudio();
printf("------------ TestTimerServices() ------------\n");
TestTimerServices();
printf("------------ TestPlayWaveform() -------------\n");
TestPlayWaveform();
printf("------------ TestPlayChord() ----------------\n");
TestPlayChord();
printf("------------ TestPlayEcho() -----------------\n");
TestPlayEcho();
printf("------------ TestPlayStereoEnh() ------------\n");
TestPlayStereoEnh();
printf("------------ TestCreateAudioData() ----------\n");
TestCreateAudioData();
printf("------------ TestAudioStream() --------------\n");
TestAudioStream();
printf("------------ ACloseAudio() ------------------\n");
Assert(ACloseAudio());
}

View File

@@ -1,49 +0,0 @@
program Demo;
uses
SysUtils, Audio;
var
Caps: TAudioCaps;
Info: TAudioInfo;
pModule: PAudioModule;
szFileName : Array [0..127] of Char;
bStatus: Integer;
begin
if ParamCount <> 1 then
begin
Writeln('use: demo filename[.mod|.s3m|.xm]');
Halt(0);
end;
Info.nDeviceId := AUDIO_DEVICE_MAPPER;
Info.wFormat := AUDIO_FORMAT_16BITS or AUDIO_FORMAT_STEREO or AUDIO_FORMAT_FILTER;
Info.nSampleRate := 44100;
if AOpenAudio(Info) <> 0 then
begin
Writeln('Audio initialization failed');
Halt(1);
end;
AGetAudioDevCaps(Info.nDeviceId, Caps);
Write(Caps.szProductName,' playing at ');
if Info.wFormat and AUDIO_FORMAT_16BITS <> 0 then
Write('16-bit ') else Write('8-bit ');
if Info.wFormat and AUDIO_FORMAT_STEREO <> 0 then
Write('stereo ') else Write('mono ');
Writeln(Info.nSampleRate,' Hz');
if ALoadModuleFile(StrPCopy(szFileName, ParamStr(1)), pModule, 0) <> 0 then
begin
Writeln('Cant load module file');
ACloseAudio;
Halt(1);
end;
AOpenVoices(pModule^.nTracks);
APlayModule(pModule);
while (AGetModuleStatus(bStatus) = 0) do
begin
if bStatus <> 0 then break;
AUpdateAudio;
end;
AStopModule;
ACloseVoices;
AFreeModuleFile(pModule);
ACloseAudio;
end.

Binary file not shown.

View File

@@ -1,67 +0,0 @@
/* example1.c - initialize and print device information */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <audio.h>
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__)
#include <conio.h>
#else
#define kbhit() 0
#endif
int main(void)
{
AUDIOINFO info;
AUDIOCAPS caps;
UINT rc, nDevId;
/* initialize audio library */
AInitialize();
/* show registered device drivers */
printf("List of registered devices:\n");
for (nDevId = 0; nDevId < AGetAudioNumDevs(); nDevId++) {
AGetAudioDevCaps(nDevId, &caps);
printf(" %2d. %s\n", nDevId, caps.szProductName);
}
printf("\n");
/*
* NOTE: Here we can use any of the above devices, or we can
* use the virtual device AUDIO_DEVICE_MAPPER for detection.
*/
/* open audio device */
info.nDeviceId = AUDIO_DEVICE_MAPPER;
info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO;
info.nSampleRate = 44100;
if ((rc = AOpenAudio(&info)) != AUDIO_ERROR_NONE) {
CHAR szText[80];
AGetErrorText(rc, szText, sizeof(szText) - 1);
printf("ERROR: %s\n", szText);
exit(1);
}
/*
* NOTE: Since the audio device may not support the playback
* format and sampling frequency, the audio system uses the
* closest configuration which is then returned to the user
* in the AUDIOINFO structure.
*
*/
/* print information */
AGetAudioDevCaps(info.nDeviceId, &caps);
printf("%s at %d-bit %s %u Hz detected\n",
caps.szProductName,
info.wFormat & AUDIO_FORMAT_16BITS ? 16 : 8,
info.wFormat & AUDIO_FORMAT_STEREO ? "stereo" : "mono",
info.nSampleRate);
/* close audio device */
ACloseAudio();
return 0;
}

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.example1</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Binary file not shown.

View File

@@ -1,70 +0,0 @@
/* example2.c - play a module file */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <audio.h>
#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__DJGPP__)
#include <conio.h>
#else
#define kbhit() 0
#endif
int main(void)
{
AUDIOINFO info;
LPAUDIOMODULE lpModule;
int ret;
/* initialize audio library */
AInitialize();
/* open audio device */
info.nDeviceId = 2;// AUDIO_DEVICE_MAPPER;
info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO;
info.nSampleRate = 44100;
#ifdef USEFILTER
/* enable antialias dynamic filtering */
info.wFormat |= AUDIO_FORMAT_FILTER;
#endif
AOpenAudio(&info);
/* load module file */
ret = ALoadModuleFile("test.s3m", &lpModule, 0);
if (lpModule == NULL)
{
printf("Error loding file... [%d]\n", ret);
return -1;
}
/* open voices and play module */
AOpenVoices(lpModule->nTracks);
APlayModule(lpModule);
/* program main execution loop */
printf("Playing module file, press any key to stop.\n");
while (!kbhit()) {
BOOL stopped;
/* check if the module is stopped */
AGetModuleStatus(&stopped);
if (stopped) break;
/* update audio system */
AUpdateAudio();
}
/* stop module and close voices */
AStopModule();
ACloseVoices();
/* release module file */
AFreeModuleFile(lpModule);
/* close audio device */
ACloseAudio();
return 0;
}

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.example2</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Binary file not shown.

View File

@@ -1,87 +0,0 @@
/* example3.c - play a waveform file */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <audio.h>
#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__DJGPP__)
#include <conio.h>
#else
#define kbhit() 0
#endif
#define NUMVOICES 3*3
#define FREQ(nPeriod) (((LONG) lpWave->nSampleRate * 428) / nPeriod)
UINT aPeriodTable[48] =
{ /* C C# D D# E F F# G G# A A# B */
856,808,762,720,678,640,604,570,538,508,480,453,
428,404,381,360,339,320,302,285,269,254,240,226,
214,202,190,180,170,160,151,143,135,127,120,113,
107,101,95,90,85,80,75,71,67,63,60,56
};
int main(void)
{
AUDIOINFO info;
LPAUDIOWAVE lpWave;
HAC hVoice[NUMVOICES];
BOOL stopped;
UINT n, m;
/* initialize audio library */
AInitialize();
/* open audio device */
info.nDeviceId = AUDIO_DEVICE_MAPPER;
info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO;
info.nSampleRate = 44100;
AOpenAudio(&info);
/* load waveform file */
ALoadWaveFile("test.wav", &lpWave, 0);
/* open and allocate voices */
AOpenVoices(NUMVOICES);
for (n = 0; n < NUMVOICES; n++) {
ACreateAudioVoice(&hVoice[n]);
ASetVoiceVolume(hVoice[n], 64);
ASetVoicePanning(hVoice[n], n & 1 ? 0 : 255);
}
/* program main execution loop */
printf("Playing waveform, press any key to stop.\n");
for (n = m = 0; !kbhit() && n < 48 - 7; n++) {
/* play chord C-E-G */
APlayVoice(hVoice[m+0], lpWave);
APlayVoice(hVoice[m+1], lpWave);
APlayVoice(hVoice[m+2], lpWave);
ASetVoiceFrequency(hVoice[m+0], FREQ(aPeriodTable[n+0]));
ASetVoiceFrequency(hVoice[m+1], FREQ(aPeriodTable[n+4]));
ASetVoiceFrequency(hVoice[m+2], FREQ(aPeriodTable[n+7]));
m = (m + 3) % NUMVOICES;
/* wait until note finishes */
do {
/* update audio system */
AUpdateAudio();
AGetVoiceStatus(hVoice[0], &stopped);
} while (!stopped);
}
/* stop and release voices */
for (n = 0; n < NUMVOICES; n++) {
AStopVoice(hVoice[n]);
ADestroyAudioVoice(hVoice[n]);
}
ACloseVoices();
/* release the waveform file */
AFreeWaveFile(lpWave);
/* close audio device */
ACloseAudio();
return 0;
}

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.example3</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Binary file not shown.

View File

@@ -1,78 +0,0 @@
/* example4.c - play module and waveform file */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <audio.h>
#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__DJGPP__)
#include <conio.h>
#else
#define kbhit() 0
#endif
int main(void)
{
AUDIOINFO info;
LPAUDIOMODULE lpModule;
LPAUDIOWAVE lpWave;
HAC hVoice;
BOOL stopped;
/* initialize audio library */
AInitialize();
/* open audio device */
info.nDeviceId = 1;//AUDIO_DEVICE_MAPPER;
info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO;
info.nSampleRate = 44100;
AOpenAudio(&info);
/* load module and waveform file */
ALoadModuleFile("test.s3m", &lpModule, 0);
ALoadWaveFile("test.wav", &lpWave, 0);
/* open voices for module and waveform */
AOpenVoices(lpModule->nTracks + 1);
/* play the module file */
APlayModule(lpModule);
ASetModuleVolume(64);
/* play the waveform through a voice */
ACreateAudioVoice(&hVoice);
APlayVoice(hVoice, lpWave);
ASetVoiceVolume(hVoice, 48);
ASetVoicePanning(hVoice, 128);
/* program main execution loop */
printf("Playing module and waveform, press any key to stop.\n");
while (!kbhit()) {
/* update audio system */
AUpdateAudio();
/* restart waveform if stopped */
AGetVoiceStatus(hVoice, &stopped);
if (stopped) APlayVoice(hVoice, lpWave);
/* check if the module is stopped */
AGetModuleStatus(&stopped);
if (stopped) break;
}
/* stop playing the waveform */
AStopVoice(hVoice);
ADestroyAudioVoice(hVoice);
/* stop playing the module */
AStopModule();
ACloseVoices();
/* release the waveform & module */
AFreeWaveFile(lpWave);
AFreeModuleFile(lpModule);
/* close audio device */
ACloseAudio();
return 0;
}

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.example4</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More