mirror of
https://github.com/ares-emulator/ares.git
synced 2026-11-08 08:03:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fc86eae6d | ||
|
|
927c97eb06 | ||
|
|
cf09d41669 | ||
|
|
724747ac9e | ||
|
|
e1e275eb38 | ||
|
|
e30fcade43 | ||
|
|
42dbf73d18 | ||
|
|
2a90e12999 | ||
|
|
d129b72ced | ||
|
|
bc0b86891a | ||
|
|
52443936e6 | ||
|
|
6694a1c986 | ||
|
|
7ffaeb2ac1 | ||
|
|
67e6a6e742 | ||
|
|
9a3650c6ab | ||
|
|
0a3d6e4c53 | ||
|
|
378b78dad7 | ||
|
|
721e0b1762 | ||
|
|
2bf3dbf375 | ||
|
|
396003e7f6 | ||
|
|
a92a554d7b | ||
|
|
9ea35ce569 | ||
|
|
348bace8ed | ||
|
|
5cbf5b617b | ||
|
|
d5cd21eb0c | ||
|
|
8b7dd89059 | ||
|
|
6c4e3ec790 | ||
|
|
8d64f9b155 | ||
|
|
bc5fd8c53c |
No files matched your search
+6
-1
@@ -1,9 +1,12 @@
|
||||
include nall/Makefile
|
||||
snes := snes
|
||||
gameboy := gameboy
|
||||
profile := accuracy
|
||||
profile := compatibility
|
||||
ui := ui
|
||||
|
||||
# debugger
|
||||
options :=
|
||||
|
||||
# compiler
|
||||
c := $(compiler) -std=gnu99
|
||||
cpp := $(subst cc,++,$(compiler)) -std=gnu++0x
|
||||
@@ -18,6 +21,8 @@ objects := libco
|
||||
# profile-guided optimization
|
||||
# flags += -fprofile-use
|
||||
|
||||
flags := $(flags) $(foreach o,$(call strupper,$(options)),-D$o)
|
||||
|
||||
# platform
|
||||
ifeq ($(platform),x)
|
||||
link += -s -ldl -lX11 -lXext
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
@mingw32-make -j 2
|
||||
@mingw32-make -j 8
|
||||
@pause
|
||||
+3644
-3013
File diff suppressed because it is too large.
Load diff
@@ -73,7 +73,7 @@ void APU::Wave::power() {
|
||||
frequency = 0;
|
||||
counter = 0;
|
||||
|
||||
random_cyclic r;
|
||||
random_lfsr r;
|
||||
foreach(n, pattern) n = r() & 15;
|
||||
|
||||
output = 0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Interface {
|
||||
public:
|
||||
virtual void lcd_scanline() {}
|
||||
virtual void joyp_write(bool p15, bool p14) {}
|
||||
|
||||
virtual void video_refresh(const uint8_t *data) {}
|
||||
|
||||
@@ -75,6 +75,7 @@ void LCD::render() {
|
||||
|
||||
uint8_t *output = screen + status.ly * 160;
|
||||
for(unsigned n = 0; n < 160; n++) output[n] = (3 - line[n]) * 0x55;
|
||||
system.interface->lcd_scanline();
|
||||
}
|
||||
|
||||
uint16 LCD::read_tile(bool select, unsigned x, unsigned y) {
|
||||
|
||||
@@ -41,21 +41,22 @@ struct directory {
|
||||
if(handle != INVALID_HANDLE_VALUE) {
|
||||
if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
|
||||
if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
string name = utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(string(name, "/"));
|
||||
string name = (const char*)utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(name);
|
||||
}
|
||||
}
|
||||
while(FindNextFile(handle, &data) != false) {
|
||||
if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
|
||||
if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
string name = utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(string(name, "/"));
|
||||
string name = (const char*)utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
FindClose(handle);
|
||||
}
|
||||
if(list.size() > 0) sort(&list[0], list.size());
|
||||
foreach(name, list) name.append("/"); //must append after sorting
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -70,12 +71,12 @@ struct directory {
|
||||
handle = FindFirstFile(utf16_t(path), &data);
|
||||
if(handle != INVALID_HANDLE_VALUE) {
|
||||
if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
||||
string name = utf8_t(data.cFileName);
|
||||
string name = (const char*)utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(name);
|
||||
}
|
||||
while(FindNextFile(handle, &data) != false) {
|
||||
if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
||||
string name = utf8_t(data.cFileName);
|
||||
string name = (const char*)utf8_t(data.cFileName);
|
||||
if(wildcard(name, pattern)) list.append(name);
|
||||
}
|
||||
}
|
||||
@@ -109,14 +110,14 @@ struct directory {
|
||||
if(!strcmp(ep->d_name, ".")) continue;
|
||||
if(!strcmp(ep->d_name, "..")) continue;
|
||||
if(ep->d_type & DT_DIR) {
|
||||
if(wildcard(ep->d_name, pattern)) list.append(string(ep->d_name, "/"));
|
||||
if(wildcard(ep->d_name, pattern)) list.append(ep->d_name);
|
||||
}
|
||||
}
|
||||
closedir(dp);
|
||||
}
|
||||
if(list.size() > 0) sort(&list[0], list.size());
|
||||
foreach(name, list) name.append("/"); //must append after sorting
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
inline lstring directory::files(const string &pathname, const string &pattern) {
|
||||
|
||||
+36
-35
@@ -1,15 +1,7 @@
|
||||
#ifndef NALL_FILE_HPP
|
||||
#define NALL_FILE_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <nall/platform.hpp>
|
||||
#include <nall/stdint.hpp>
|
||||
#include <nall/string.hpp>
|
||||
#include <nall/utf8.hpp>
|
||||
@@ -28,6 +20,7 @@ namespace nall {
|
||||
public:
|
||||
enum class mode : unsigned { read, write, readwrite, writeread };
|
||||
enum class index : unsigned { absolute, relative };
|
||||
enum class time : unsigned { create, modify, access };
|
||||
|
||||
uint8_t read() {
|
||||
if(!fp) return 0xff; //file not open
|
||||
@@ -142,52 +135,60 @@ namespace nall {
|
||||
return file_offset >= file_size;
|
||||
}
|
||||
|
||||
static bool exists(const char *fn) {
|
||||
static bool exists(const char *filename) {
|
||||
#if !defined(_WIN32)
|
||||
FILE *fp = fopen(fn, "rb");
|
||||
struct stat64 data;
|
||||
return stat64(filename, &data) == 0;
|
||||
#else
|
||||
FILE *fp = _wfopen(utf16_t(fn), L"rb");
|
||||
struct __stat64 data;
|
||||
return _wstat64(utf16_t(filename), &data) == 0;
|
||||
#endif
|
||||
if(fp) {
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static unsigned size(const char *fn) {
|
||||
static uintmax_t size(const char *filename) {
|
||||
#if !defined(_WIN32)
|
||||
FILE *fp = fopen(fn, "rb");
|
||||
struct stat64 data;
|
||||
stat64(filename, &data);
|
||||
#else
|
||||
FILE *fp = _wfopen(utf16_t(fn), L"rb");
|
||||
struct __stat64 data;
|
||||
_wstat64(utf16_t(filename), &data);
|
||||
#endif
|
||||
unsigned filesize = 0;
|
||||
if(fp) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
filesize = ftell(fp);
|
||||
fclose(fp);
|
||||
return S_ISREG(data.st_mode) ? data.st_size : 0u;
|
||||
}
|
||||
|
||||
static time_t timestamp(const char *filename, file::time mode = file::time::create) {
|
||||
#if !defined(_WIN32)
|
||||
struct stat64 data;
|
||||
stat64(filename, &data);
|
||||
#else
|
||||
struct __stat64 data;
|
||||
_wstat64(utf16_t(filename), &data);
|
||||
#endif
|
||||
switch(mode) { default:
|
||||
case file::time::create: return data.st_ctime;
|
||||
case file::time::modify: return data.st_mtime;
|
||||
case file::time::access: return data.st_atime;
|
||||
}
|
||||
return filesize;
|
||||
}
|
||||
|
||||
bool open() {
|
||||
return fp;
|
||||
}
|
||||
|
||||
bool open(const char *fn, mode mode_) {
|
||||
bool open(const char *filename, mode mode_) {
|
||||
if(fp) return false;
|
||||
|
||||
switch(file_mode = mode_) {
|
||||
#if !defined(_WIN32)
|
||||
case mode::read: fp = fopen(fn, "rb"); break;
|
||||
case mode::write: fp = fopen(fn, "wb+"); break; //need read permission for buffering
|
||||
case mode::readwrite: fp = fopen(fn, "rb+"); break;
|
||||
case mode::writeread: fp = fopen(fn, "wb+"); break;
|
||||
case mode::read: fp = fopen(filename, "rb" ); break;
|
||||
case mode::write: fp = fopen(filename, "wb+"); break; //need read permission for buffering
|
||||
case mode::readwrite: fp = fopen(filename, "rb+"); break;
|
||||
case mode::writeread: fp = fopen(filename, "wb+"); break;
|
||||
#else
|
||||
case mode::read: fp = _wfopen(utf16_t(fn), L"rb"); break;
|
||||
case mode::write: fp = _wfopen(utf16_t(fn), L"wb+"); break;
|
||||
case mode::readwrite: fp = _wfopen(utf16_t(fn), L"rb+"); break;
|
||||
case mode::writeread: fp = _wfopen(utf16_t(fn), L"wb+"); break;
|
||||
case mode::read: fp = _wfopen(utf16_t(filename), L"rb" ); break;
|
||||
case mode::write: fp = _wfopen(utf16_t(filename), L"wb+"); break;
|
||||
case mode::readwrite: fp = _wfopen(utf16_t(filename), L"rb+"); break;
|
||||
case mode::writeread: fp = _wfopen(utf16_t(filename), L"wb+"); break;
|
||||
#endif
|
||||
}
|
||||
if(!fp) return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace nall {
|
||||
public:
|
||||
enum class mode : unsigned { read, write, readwrite, writeread };
|
||||
|
||||
bool opened() const { return p_opened(); }
|
||||
bool open() const { return p_open(); }
|
||||
bool open(const char *filename, mode mode_) { return p_open(filename, mode_); }
|
||||
void close() { return p_close(); }
|
||||
unsigned size() const { return p_size; }
|
||||
@@ -42,7 +42,7 @@ namespace nall {
|
||||
|
||||
HANDLE p_filehandle, p_maphandle;
|
||||
|
||||
bool p_opened() const {
|
||||
bool p_open() const {
|
||||
return p_handle;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace nall {
|
||||
|
||||
int p_fd;
|
||||
|
||||
bool p_opened() const {
|
||||
bool p_open() const {
|
||||
return p_handle;
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -1,6 +1,12 @@
|
||||
#ifndef NALL_PLATFORM_HPP
|
||||
#define NALL_PLATFORM_HPP
|
||||
|
||||
#if defined(_WIN32)
|
||||
//minimum version needed for _wstat64, etc
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define __MSVCRT_VERSION__ 0x0601
|
||||
#endif
|
||||
|
||||
#include <nall/utf8.hpp>
|
||||
|
||||
//=========================
|
||||
@@ -18,16 +24,19 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <shlobj.h>
|
||||
#include <wchar.h>
|
||||
#undef interface
|
||||
#define dllexport __declspec(dllexport)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#define dllexport
|
||||
#endif
|
||||
|
||||
@@ -53,11 +62,11 @@
|
||||
#if defined(_WIN32)
|
||||
#define getcwd _getcwd
|
||||
#define ftruncate _chsize
|
||||
#define putenv _putenv
|
||||
#define mkdir(n, m) _wmkdir(nall::utf16_t(n))
|
||||
#define putenv _putenv
|
||||
#define rmdir _rmdir
|
||||
#define vsnprintf _vsnprintf
|
||||
#define usleep(n) Sleep(n / 1000)
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
//================
|
||||
|
||||
+13
-5
@@ -8,12 +8,20 @@ namespace nall {
|
||||
return n = (n >> 1) ^ (((n & 1) - 1) & 0xedb88320);
|
||||
}
|
||||
|
||||
struct random_cyclic {
|
||||
unsigned seed;
|
||||
inline unsigned operator()() {
|
||||
return seed = (seed >> 1) ^ (((seed & 1) - 1) & 0xedb88320);
|
||||
struct random_lfsr {
|
||||
inline void seed(unsigned seed__) {
|
||||
seed_ = seed__;
|
||||
}
|
||||
random_cyclic() : seed(0) {}
|
||||
|
||||
inline unsigned operator()() {
|
||||
return seed_ = (seed_ >> 1) ^ (((seed_ & 1) - 1) & 0xedb88320);
|
||||
}
|
||||
|
||||
random_lfsr() : seed_(0) {
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned seed_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
if(type == TypeGameBoy) {
|
||||
xml << "<cartridge rtc='" << gameboy_has_rtc(data, size) << "'>\n";
|
||||
if(gameboy_ram_size(data, size) > 0) {
|
||||
xml << " <ram size='" << hex(gameboy_ram_size(data, size)) << "'/>\n";
|
||||
xml << " <ram size='0x" << hex(gameboy_ram_size(data, size)) << "'/>\n";
|
||||
}
|
||||
xml << "</cartridge>\n";
|
||||
xmlMemoryMap = xml.transform("'", "\"");
|
||||
@@ -158,6 +158,17 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map address='00-3f:6000-7fff'/>\n";
|
||||
xml << " <map address='80-bf:6000-7fff'/>\n";
|
||||
xml << " </icd2>\n";
|
||||
} else if(has_cx4) {
|
||||
xml << " <hitachidsp model='HG51B169' frequency='20000000' data='cx4.bin' sha256='ae8d4d1961b93421ff00b3caa1d0f0ce7783e749772a3369c36b3dbf0d37ef18'>\n";
|
||||
xml << " <rom>\n";
|
||||
xml << " <map mode='linear' address='00-7f:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='80-ff:8000-ffff'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <mmio>\n";
|
||||
xml << " <map address='00-3f:6000-7fff'/>\n";
|
||||
xml << " <map address='80-bf:6000-7fff'/>\n";
|
||||
xml << " </mmio>\n";
|
||||
xml << " </hitachidsp>\n";
|
||||
} else if(has_spc7110) {
|
||||
xml << " <rom>\n";
|
||||
xml << " <map mode='shadow' address='00-0f:8000-ffff'/>\n";
|
||||
@@ -167,9 +178,9 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
|
||||
xml << " <spc7110>\n";
|
||||
xml << " <mcu>\n";
|
||||
xml << " <map address='d0-ff:0000-ffff' offset='100000' size='" << hex(size - 0x100000) << "'/>\n";
|
||||
xml << " <map address='d0-ff:0000-ffff' offset='0x100000' size='0x" << hex(size - 0x100000) << "'/>\n";
|
||||
xml << " </mcu>\n";
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='00:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='30:6000-7fff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
@@ -194,7 +205,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " </rom>\n";
|
||||
|
||||
if(ram_size > 0) {
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
|
||||
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
|
||||
@@ -215,7 +226,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " </rom>\n";
|
||||
|
||||
if(ram_size > 0) {
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
|
||||
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
|
||||
@@ -233,7 +244,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " </rom>\n";
|
||||
|
||||
if(ram_size > 0) {
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
|
||||
@@ -241,14 +252,14 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
} else if(mapper == ExHiROM) {
|
||||
xml << " <rom>\n";
|
||||
xml << " <map mode='shadow' address='00-3f:8000-ffff' offset='400000'/>\n";
|
||||
xml << " <map mode='linear' address='40-7f:0000-ffff' offset='400000'/>\n";
|
||||
xml << " <map mode='shadow' address='80-bf:8000-ffff' offset='000000'/>\n";
|
||||
xml << " <map mode='linear' address='c0-ff:0000-ffff' offset='000000'/>\n";
|
||||
xml << " <map mode='shadow' address='00-3f:8000-ffff' offset='0x400000'/>\n";
|
||||
xml << " <map mode='linear' address='40-7f:0000-ffff' offset='0x400000'/>\n";
|
||||
xml << " <map mode='shadow' address='80-bf:8000-ffff' offset='0x000000'/>\n";
|
||||
xml << " <map mode='linear' address='c0-ff:0000-ffff' offset='0x000000'/>\n";
|
||||
xml << " </rom>\n";
|
||||
|
||||
if(ram_size > 0) {
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
|
||||
if((rom_size > 0x200000) || (ram_size > 32 * 1024)) {
|
||||
@@ -266,10 +277,10 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map mode='linear' address='80-bf:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='c0-df:0000-ffff'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='00-3f:6000-7fff' size='2000'/>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='00-3f:6000-7fff' size='0x2000'/>\n";
|
||||
xml << " <map mode='linear' address='60-7f:0000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='80-bf:6000-7fff' size='2000'/>\n";
|
||||
xml << " <map mode='linear' address='80-bf:6000-7fff' size='0x2000'/>\n";
|
||||
xml << " <map mode='linear' address='e0-ff:0000-ffff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
xml << " <mmio>\n";
|
||||
@@ -290,11 +301,11 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map mode='direct' address='80-bf:6000-7fff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
xml << " </mcu>\n";
|
||||
xml << " <iram size='800'>\n";
|
||||
xml << " <iram size='0x800'>\n";
|
||||
xml << " <map mode='linear' address='00-3f:3000-37ff'/>\n";
|
||||
xml << " <map mode='linear' address='80-bf:3000-37ff'/>\n";
|
||||
xml << " </iram>\n";
|
||||
xml << " <bwram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <bwram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='40-4f:0000-ffff'/>\n";
|
||||
xml << " </bwram>\n";
|
||||
xml << " <mmio>\n";
|
||||
@@ -304,12 +315,12 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " </sa1>\n";
|
||||
} else if(mapper == BSCLoROM) {
|
||||
xml << " <rom>\n";
|
||||
xml << " <map mode='linear' address='00-1f:8000-ffff' offset='000000'/>\n";
|
||||
xml << " <map mode='linear' address='20-3f:8000-ffff' offset='100000'/>\n";
|
||||
xml << " <map mode='linear' address='80-9f:8000-ffff' offset='200000'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:8000-ffff' offset='100000'/>\n";
|
||||
xml << " <map mode='linear' address='00-1f:8000-ffff' offset='0x000000'/>\n";
|
||||
xml << " <map mode='linear' address='20-3f:8000-ffff' offset='0x100000'/>\n";
|
||||
xml << " <map mode='linear' address='80-9f:8000-ffff' offset='0x200000'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:8000-ffff' offset='0x100000'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='70-7f:0000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='f0-ff:0000-7fff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
@@ -325,7 +336,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map mode='shadow' address='80-9f:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='c0-df:0000-ffff'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <ram size='" << hex(ram_size) << "'>\n";
|
||||
xml << " <ram size='0x" << hex(ram_size) << "'>\n";
|
||||
xml << " <map mode='linear' address='20-3f:6000-7fff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:6000-7fff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
@@ -362,7 +373,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map mode='linear' address='20-3f:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='a0-bf:8000-ffff'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <ram>\n";
|
||||
xml << " <ram size='0x20000'>\n";
|
||||
xml << " <map mode='linear' address='60-63:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='e0-e3:8000-ffff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
@@ -372,7 +383,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " <map mode='linear' address='40-5f:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='c0-df:8000-ffff'/>\n";
|
||||
xml << " </rom>\n";
|
||||
xml << " <ram>\n";
|
||||
xml << " <ram size='0x20000'>\n";
|
||||
xml << " <map mode='linear' address='70-73:8000-ffff'/>\n";
|
||||
xml << " <map mode='linear' address='f0-f3:8000-ffff'/>\n";
|
||||
xml << " </ram>\n";
|
||||
@@ -399,15 +410,8 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
xml << " </sdd1>\n";
|
||||
}
|
||||
|
||||
if(has_cx4) {
|
||||
xml << " <cx4>\n";
|
||||
xml << " <map address='00-3f:6000-7fff'/>\n";
|
||||
xml << " <map address='80-bf:6000-7fff'/>\n";
|
||||
xml << " </cx4>\n";
|
||||
}
|
||||
|
||||
if(has_dsp1) {
|
||||
xml << " <necdsp revision='upd7725' frequency='8000000' program='dsp1b.bin' sha256='4d42db0f36faef263d6b93f508e8c1c4ae8fc2605fd35e3390ecc02905cd420c'>\n";
|
||||
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp1b.bin' sha256='4d42db0f36faef263d6b93f508e8c1c4ae8fc2605fd35e3390ecc02905cd420c'>\n";
|
||||
if(dsp1_mapper == DSP1LoROM1MB) {
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='20-3f:8000-bfff'/>\n";
|
||||
@@ -440,7 +444,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
|
||||
if(has_dsp2) {
|
||||
xml << " <necdsp revision='upd7725' frequency='8000000' program='dsp2.bin' sha256='5efbdf96ed0652790855225964f3e90e6a4d466cfa64df25b110933c6cf94ea1'>\n";
|
||||
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp2.bin' sha256='5efbdf96ed0652790855225964f3e90e6a4d466cfa64df25b110933c6cf94ea1'>\n";
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='20-3f:8000-bfff'/>\n";
|
||||
xml << " <map address='a0-bf:8000-bfff'/>\n";
|
||||
@@ -453,7 +457,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
|
||||
if(has_dsp3) {
|
||||
xml << " <necdsp revision='upd7725' frequency='8000000' program='dsp3.bin' sha256='2e635f72e4d4681148bc35429421c9b946e4f407590e74e31b93b8987b63ba90'>\n";
|
||||
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp3.bin' sha256='2e635f72e4d4681148bc35429421c9b946e4f407590e74e31b93b8987b63ba90'>\n";
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='20-3f:8000-bfff'/>\n";
|
||||
xml << " <map address='a0-bf:8000-bfff'/>\n";
|
||||
@@ -466,7 +470,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
|
||||
if(has_dsp4) {
|
||||
xml << " <necdsp revision='upd7725' frequency='8000000' program='dsp4.bin' sha256='63ede17322541c191ed1fdf683872554a0a57306496afc43c59de7c01a6e764a'>\n";
|
||||
xml << " <necdsp model='uPD7725' frequency='8000000' program='dsp4.bin' sha256='63ede17322541c191ed1fdf683872554a0a57306496afc43c59de7c01a6e764a'>\n";
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='30-3f:8000-bfff'/>\n";
|
||||
xml << " <map address='b0-bf:8000-bfff'/>\n";
|
||||
@@ -486,7 +490,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
|
||||
if(has_st010) {
|
||||
xml << " <necdsp revision='upd96050' frequency='10000000' program='st0010.bin' sha256='55c697e864562445621cdf8a7bf6e84ae91361e393d382a3704e9aa55559041e'>\n";
|
||||
xml << " <necdsp model='uPD96050' frequency='10000000' program='st0010.bin' sha256='55c697e864562445621cdf8a7bf6e84ae91361e393d382a3704e9aa55559041e'>\n";
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='60:0000'/>\n";
|
||||
xml << " <map address='e0:0000'/>\n";
|
||||
@@ -503,7 +507,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
|
||||
}
|
||||
|
||||
if(has_st011) {
|
||||
xml << " <necdsp revision='upd96050' frequency='15000000' program='st0011.bin' sha256='651b82a1e26c4fa8dd549e91e7f923012ed2ca54c1d9fd858655ab30679c2f0e'>\n";
|
||||
xml << " <necdsp model='uPD96050' frequency='15000000' program='st0011.bin' sha256='651b82a1e26c4fa8dd549e91e7f923012ed2ca54c1d9fd858655ab30679c2f0e'>\n";
|
||||
xml << " <dr>\n";
|
||||
xml << " <map address='60:0000'/>\n";
|
||||
xml << " <map address='e0:0000'/>\n";
|
||||
|
||||
@@ -12,18 +12,16 @@
|
||||
|
||||
namespace nall {
|
||||
class string;
|
||||
template<typename T> inline string to_string(T);
|
||||
template<typename T> inline const char* to_string(T);
|
||||
|
||||
class string {
|
||||
public:
|
||||
inline void reserve(unsigned);
|
||||
|
||||
inline string& assign(const char*);
|
||||
inline string& append(const char*);
|
||||
inline string& append(bool);
|
||||
inline string& append(signed int value);
|
||||
inline string& append(unsigned int value);
|
||||
inline string& append(double value);
|
||||
template<typename... Args> inline string& assign(Args&&... args);
|
||||
template<typename... Args> inline string& append(Args&&... args);
|
||||
inline string& assign_(const char*);
|
||||
inline string& append_(const char*);
|
||||
|
||||
inline bool readfile(const string&);
|
||||
|
||||
|
||||
+12
-10
@@ -4,14 +4,16 @@
|
||||
namespace nall {
|
||||
|
||||
//this is needed, as C++0x does not support explicit template specialization inside classes
|
||||
template<> inline string to_string<bool> (bool v) { return v ? "true" : "false"; }
|
||||
template<> inline string to_string<signed int> (signed int v) { return integer(v); }
|
||||
template<> inline string to_string<unsigned int> (unsigned int v) { return decimal(v); }
|
||||
template<> inline string to_string<double> (double v) { return fp(v); }
|
||||
template<> inline string to_string<char*> (char *v) { return v; }
|
||||
template<> inline string to_string<const char*> (const char *v) { return v; }
|
||||
template<> inline string to_string<string> (string v) { return v; }
|
||||
template<> inline string to_string<const string&>(const string &v) { return v; }
|
||||
template<> inline const char* to_string<bool> (bool v) { return v ? "true" : "false"; }
|
||||
template<> inline const char* to_string<signed int> (signed int v) { static char temp[256]; snprintf(temp, 255, "%+d", v); return temp; }
|
||||
template<> inline const char* to_string<unsigned int> (unsigned int v) { static char temp[256]; snprintf(temp, 255, "%u", v); return temp; }
|
||||
template<> inline const char* to_string<intmax_t> (intmax_t v) { static char temp[256]; snprintf(temp, 255, "%+lld", (long long)v); return temp; }
|
||||
template<> inline const char* to_string<uintmax_t> (uintmax_t v) { static char temp[256]; snprintf(temp, 255, "%llu", (unsigned long long)v); return temp; }
|
||||
template<> inline const char* to_string<double> (double v) { static char temp[256]; snprintf(temp, 255, "%f", v); return temp; }
|
||||
template<> inline const char* to_string<char*> (char *v) { return v; }
|
||||
template<> inline const char* to_string<const char*> (const char *v) { return v; }
|
||||
template<> inline const char* to_string<string> (string v) { return v; }
|
||||
template<> inline const char* to_string<const string&>(const string &v) { return v; }
|
||||
|
||||
template<typename T> string& string::operator= (T value) { return assign(to_string<T>(value)); }
|
||||
template<typename T> string& string::operator<<(T value) { return append(to_string<T>(value)); }
|
||||
@@ -22,8 +24,8 @@ template<typename T> lstring& lstring::operator<<(T value) {
|
||||
}
|
||||
|
||||
#if defined(QSTRING_H)
|
||||
template<> inline string to_string<QString>(QString v) { return v.toUtf8().constData(); }
|
||||
template<> inline string to_string<const QString&>(const QString &v) { return v.toUtf8().constData(); }
|
||||
template<> inline const char* to_string<QString>(QString v) { return v.toUtf8().constData(); }
|
||||
template<> inline const char* to_string<const QString&>(const QString &v) { return v.toUtf8().constData(); }
|
||||
string::operator QString() const { return QString::fromUtf8(*this); }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -117,38 +117,7 @@ uintmax_t binary(const char *str) {
|
||||
}
|
||||
|
||||
double fp(const char *str) {
|
||||
if(!str) return 0.0;
|
||||
bool negate = false;
|
||||
|
||||
//check for negation
|
||||
if(*str == '-') {
|
||||
negate = true;
|
||||
str++;
|
||||
}
|
||||
|
||||
intmax_t result_integral = 0;
|
||||
while(*str) {
|
||||
uint8_t x = *str++;
|
||||
if(x >= '0' && x <= '9') x -= '0';
|
||||
else if(x == '.' || x == ',') break; //break loop and read fractional part
|
||||
else return (double)result_integral; //invalid value, assume no fractional part
|
||||
result_integral = result_integral * 10 + x;
|
||||
}
|
||||
|
||||
intmax_t result_fractional = 0;
|
||||
while(*str) {
|
||||
uint8_t x = *str++;
|
||||
if(x >= '0' && x <= '9') x -= '0';
|
||||
else break; //stop at first invalid character
|
||||
result_fractional = result_fractional * 10 + x;
|
||||
}
|
||||
|
||||
//calculate fractional portion
|
||||
double result = (double)result_fractional;
|
||||
while((uintmax_t)result > 0) result /= 10.0;
|
||||
result += (double)result_integral;
|
||||
|
||||
return !negate ? result : -result;
|
||||
return atof(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-16
@@ -3,6 +3,15 @@
|
||||
|
||||
namespace nall {
|
||||
|
||||
static void istring(string &output) {
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static void istring(string &output, const T &value, Args&&... args) {
|
||||
output.append_(to_string(value));
|
||||
istring(output, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void string::reserve(unsigned size_) {
|
||||
if(size_ > size) {
|
||||
size = size_;
|
||||
@@ -11,25 +20,31 @@ void string::reserve(unsigned size_) {
|
||||
}
|
||||
}
|
||||
|
||||
string& string::assign(const char *s) {
|
||||
template<typename... Args> string& string::assign(Args&&... args) {
|
||||
*data = 0;
|
||||
istring(*this, std::forward<Args>(args)...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename... Args> string& string::append(Args&&... args) {
|
||||
istring(*this, std::forward<Args>(args)...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& string::assign_(const char *s) {
|
||||
unsigned length = strlen(s);
|
||||
reserve(length);
|
||||
strcpy(data, s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& string::append(const char *s) {
|
||||
string& string::append_(const char *s) {
|
||||
unsigned length = strlen(data) + strlen(s);
|
||||
reserve(length);
|
||||
strcat(data, s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
string& string::append(bool value) { append(value ? "true" : "false"); return *this; }
|
||||
string& string::append(signed int value) { append(integer(value)); return *this; }
|
||||
string& string::append(unsigned int value) { append(decimal(value)); return *this; }
|
||||
string& string::append(double value) { append(fp(value)); return *this; }
|
||||
|
||||
string::operator const char*() const {
|
||||
return data;
|
||||
}
|
||||
@@ -64,15 +79,6 @@ string& string::operator=(string &&source) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void istring(string &output) {
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static void istring(string &output, const T &value, Args&&... args) {
|
||||
output.append(value);
|
||||
istring(output, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args> string::string(Args&&... args) {
|
||||
size = 64;
|
||||
data = (char*)malloc(size + 1);
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
|
||||
namespace nall {
|
||||
|
||||
string realpath(const char *name) {
|
||||
string currentpath() {
|
||||
char path[PATH_MAX];
|
||||
if(::realpath(name, path)) {
|
||||
if(::getcwd(path)) {
|
||||
string result(path);
|
||||
result.transform("\\", "/");
|
||||
if(result.endswith("/") == false) result.append("/");
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
return "./";
|
||||
}
|
||||
|
||||
string userpath() {
|
||||
@@ -22,18 +22,17 @@ string userpath() {
|
||||
if(result.endswith("/") == false) result.append("/");
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
return currentpath();
|
||||
}
|
||||
|
||||
string currentpath() {
|
||||
string realpath(const char *name) {
|
||||
char path[PATH_MAX];
|
||||
if(::getcwd(path)) {
|
||||
if(::realpath(name, path)) {
|
||||
string result(path);
|
||||
result.transform("\\", "/");
|
||||
if(result.endswith("/") == false) result.append("/");
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
return userpath();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ void OS::processEvents() { return pOS::processEvents(); }
|
||||
void OS::quit() { return pOS::quit(); }
|
||||
void OS::initialize() { static bool initialized = false; if(initialized == false) { initialized = true; return pOS::initialize(); } }
|
||||
|
||||
Geometry Font::geometry(const string &text) { return p.geometry(text); }
|
||||
void Font::setBold(bool bold) { state.bold = bold; return p.setBold(bold); }
|
||||
void Font::setFamily(const string &family) { state.family = family; return p.setFamily(family); }
|
||||
void Font::setItalic(bool italic) { state.italic = italic; return p.setItalic(italic); }
|
||||
@@ -33,6 +34,10 @@ void Font::setSize(unsigned size) { state.size = size; return p.setSize(size); }
|
||||
void Font::setUnderline(bool underline) { state.underline = underline; return p.setUnderline(underline); }
|
||||
Font::Font() : state(*new State), p(*new pFont(*this)) { p.constructor(); }
|
||||
|
||||
void Timer::setEnabled(bool enabled) { state.enabled = enabled; return p.setEnabled(enabled); }
|
||||
void Timer::setInterval(unsigned milliseconds) { state.milliseconds = milliseconds; return p.setInterval(milliseconds); }
|
||||
Timer::Timer() : state(*new State), p(*new pTimer(*this)) { p.constructor(); }
|
||||
|
||||
MessageWindow::Response MessageWindow::information(Window &parent, const string &text, MessageWindow::Buttons buttons) { return pMessageWindow::information(parent, text, buttons); }
|
||||
MessageWindow::Response MessageWindow::question(Window &parent, const string &text, MessageWindow::Buttons buttons) { return pMessageWindow::question(parent, text, buttons); }
|
||||
MessageWindow::Response MessageWindow::warning(Window &parent, const string &text, MessageWindow::Buttons buttons) { return pMessageWindow::warning(parent, text, buttons); }
|
||||
@@ -80,13 +85,15 @@ void CheckItem::setChecked(bool checked) { state.checked = checked; return p.set
|
||||
void CheckItem::setText(const string &text) { state.text = text; return p.setText(text); }
|
||||
CheckItem::CheckItem() : state(*new State), base_from_member<pCheckItem&>(*new pCheckItem(*this)), Action(base_from_member<pCheckItem&>::value), p(base_from_member<pCheckItem&>::value) { p.constructor(); }
|
||||
|
||||
void RadioItem::group_(const reference_array<RadioItem&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
|
||||
void RadioItem::group(const reference_array<RadioItem&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
|
||||
bool RadioItem::checked() { return p.checked(); }
|
||||
void RadioItem::setChecked() { foreach(item, state.group) item.state.checked = false; state.checked = true; return p.setChecked(); }
|
||||
void RadioItem::setText(const string &text) { state.text = text; return p.setText(text); }
|
||||
RadioItem::RadioItem() : state(*new State), base_from_member<pRadioItem&>(*new pRadioItem(*this)), Action(base_from_member<pRadioItem&>::value), p(base_from_member<pRadioItem&>::value) { p.constructor(); }
|
||||
|
||||
bool Widget::enabled() { return state.enabled; }
|
||||
Font& Widget::font() { return p.font(); }
|
||||
Geometry Widget::minimumGeometry() { return p.minimumGeometry(); }
|
||||
void Widget::setEnabled(bool enabled) { state.enabled = enabled; return p.setEnabled(enabled); }
|
||||
void Widget::setFocused() { return p.setFocused(); }
|
||||
void Widget::setFont(Font &font) { state.font = &font; return p.setFont(font); }
|
||||
@@ -99,6 +106,10 @@ Widget::Widget(pWidget &p) : state(*new State), p(p) { p.constructor(); }
|
||||
void Button::setText(const string &text) { state.text = text; return p.setText(text); }
|
||||
Button::Button() : state(*new State), base_from_member<pButton&>(*new pButton(*this)), Widget(base_from_member<pButton&>::value), p(base_from_member<pButton&>::value) { p.constructor(); }
|
||||
|
||||
uint32_t* Canvas::buffer() { return p.buffer(); }
|
||||
void Canvas::update() { return p.update(); }
|
||||
Canvas::Canvas() : base_from_member<pCanvas&>(*new pCanvas(*this)), Widget(base_from_member<pCanvas&>::value), p(base_from_member<pCanvas&>::value) { p.constructor(); }
|
||||
|
||||
bool CheckBox::checked() { return p.checked(); }
|
||||
void CheckBox::setChecked(bool checked) { state.checked = checked; return p.setChecked(checked); }
|
||||
void CheckBox::setText(const string &text) { state.text = text; return p.setText(text); }
|
||||
@@ -148,7 +159,7 @@ ListView::ListView() : state(*new State), base_from_member<pListView&>(*new pLis
|
||||
void ProgressBar::setPosition(unsigned position) { state.position = position; return p.setPosition(position); }
|
||||
ProgressBar::ProgressBar() : state(*new State), base_from_member<pProgressBar&>(*new pProgressBar(*this)), Widget(base_from_member<pProgressBar&>::value), p(base_from_member<pProgressBar&>::value) { p.constructor(); }
|
||||
|
||||
void RadioBox::group_(const reference_array<RadioBox&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
|
||||
void RadioBox::group(const reference_array<RadioBox&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
|
||||
bool RadioBox::checked() { return p.checked(); }
|
||||
void RadioBox::setChecked() { foreach(item, state.group) item.state.checked = false; state.checked = true; return p.setChecked(); }
|
||||
void RadioBox::setText(const string &text) { state.text = text; return p.setText(text); }
|
||||
|
||||
@@ -6,6 +6,7 @@ struct Widget;
|
||||
|
||||
struct pOS;
|
||||
struct pFont;
|
||||
struct pTimer;
|
||||
struct pWindow;
|
||||
struct pAction;
|
||||
struct pMenu;
|
||||
@@ -16,6 +17,7 @@ struct pRadioItem;
|
||||
struct pLayout;
|
||||
struct pWidget;
|
||||
struct pButton;
|
||||
struct pCanvas;
|
||||
struct pCheckBox;
|
||||
struct pComboBox;
|
||||
struct pHexEdit;
|
||||
@@ -29,6 +31,11 @@ struct pTextEdit;
|
||||
struct pVerticalSlider;
|
||||
struct pViewport;
|
||||
|
||||
enum : unsigned {
|
||||
MaximumSize = ~0u,
|
||||
MinimumSize = 0u,
|
||||
};
|
||||
|
||||
struct Geometry {
|
||||
signed x, y;
|
||||
unsigned width, height;
|
||||
@@ -63,6 +70,7 @@ private:
|
||||
};
|
||||
|
||||
struct Font : Object {
|
||||
Geometry geometry(const nall::string &text);
|
||||
void setBold(bool bold = true);
|
||||
void setFamily(const nall::string &family);
|
||||
void setItalic(bool italic = true);
|
||||
@@ -75,6 +83,18 @@ struct Font : Object {
|
||||
pFont &p;
|
||||
};
|
||||
|
||||
struct Timer : Object {
|
||||
nall::function<void ()> onTimeout;
|
||||
|
||||
void setEnabled(bool enabled = true);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
||||
Timer();
|
||||
struct State;
|
||||
State &state;
|
||||
pTimer &p;
|
||||
};
|
||||
|
||||
struct MessageWindow : Object {
|
||||
enum class Buttons : unsigned {
|
||||
Ok,
|
||||
@@ -179,7 +199,8 @@ struct CheckItem : private nall::base_from_member<pCheckItem&>, Action {
|
||||
};
|
||||
|
||||
struct RadioItem : private nall::base_from_member<pRadioItem&>, Action {
|
||||
template<typename... Args> static void group(Args&... args) { group_({ args... }); }
|
||||
template<typename... Args> static void group(Args&... args) { group({ args... }); }
|
||||
static void group(const nall::reference_array<RadioItem&> &list);
|
||||
|
||||
nall::function<void ()> onTick;
|
||||
|
||||
@@ -191,19 +212,18 @@ struct RadioItem : private nall::base_from_member<pRadioItem&>, Action {
|
||||
struct State;
|
||||
State &state;
|
||||
pRadioItem &p;
|
||||
|
||||
private:
|
||||
static void group_(const nall::reference_array<RadioItem&> &list);
|
||||
};
|
||||
|
||||
struct Layout : Object {
|
||||
virtual void setGeometry(Geometry &geometry) = 0;
|
||||
virtual void setGeometry(const Geometry &geometry) = 0;
|
||||
virtual void setParent(Window &parent) = 0;
|
||||
virtual void setVisible(bool visible = true) = 0;
|
||||
};
|
||||
|
||||
struct Widget : Object {
|
||||
bool enabled();
|
||||
Font& font();
|
||||
Geometry minimumGeometry();
|
||||
void setEnabled(bool enabled = true);
|
||||
void setFocused();
|
||||
void setFont(Font &font);
|
||||
@@ -229,6 +249,14 @@ struct Button : private nall::base_from_member<pButton&>, Widget {
|
||||
pButton &p;
|
||||
};
|
||||
|
||||
struct Canvas : private nall::base_from_member<pCanvas&>, Widget {
|
||||
uint32_t* buffer();
|
||||
void update();
|
||||
|
||||
Canvas();
|
||||
pCanvas &p;
|
||||
};
|
||||
|
||||
struct CheckBox : private nall::base_from_member<pCheckBox&>, Widget {
|
||||
nall::function<void ()> onTick;
|
||||
|
||||
@@ -348,7 +376,8 @@ struct ProgressBar : private nall::base_from_member<pProgressBar&>, Widget {
|
||||
};
|
||||
|
||||
struct RadioBox : private nall::base_from_member<pRadioBox&>, Widget {
|
||||
template<typename... Args> static void group(Args&... args) { group_({ args... }); }
|
||||
template<typename... Args> static void group(Args&... args) { group({ args... }); }
|
||||
static void group(const nall::reference_array<RadioBox&> &list);
|
||||
|
||||
nall::function<void ()> onTick;
|
||||
|
||||
@@ -360,9 +389,6 @@ struct RadioBox : private nall::base_from_member<pRadioBox&>, Widget {
|
||||
struct State;
|
||||
State &state;
|
||||
pRadioBox &p;
|
||||
|
||||
private:
|
||||
static void group_(const nall::reference_array<RadioBox&> &list);
|
||||
};
|
||||
|
||||
struct TextEdit : private nall::base_from_member<pTextEdit&>, Widget {
|
||||
|
||||
@@ -9,7 +9,7 @@ void FixedLayout::append(Widget &widget, const Geometry &geometry) {
|
||||
children.append({ &widget, geometry });
|
||||
}
|
||||
|
||||
void FixedLayout::setGeometry(Geometry &geometry) {
|
||||
void FixedLayout::setGeometry(const Geometry &geometry) {
|
||||
}
|
||||
|
||||
void FixedLayout::setVisible(bool visible) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
struct FixedLayout : Layout {
|
||||
void append(Widget &widget, const Geometry &geometry);
|
||||
void setGeometry(Geometry &geometry);
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void setParent(Window &parent);
|
||||
void setVisible(bool visible);
|
||||
FixedLayout();
|
||||
|
||||
@@ -1,77 +1,130 @@
|
||||
void HorizontalLayout::setParent(Window &parent) {
|
||||
foreach(child, children) {
|
||||
if(child.layout) child.layout->setParent(parent);
|
||||
if(child.widget) parent.append(*child.widget);
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing) {
|
||||
layout.width = width;
|
||||
layout.height = height;
|
||||
children.append({ &layout, 0, width, height, spacing });
|
||||
void HorizontalLayout::append(VerticalLayout &layout, unsigned spacing) {
|
||||
children.append({ &layout, 0, MinimumSize, MinimumSize, spacing });
|
||||
}
|
||||
|
||||
void HorizontalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) {
|
||||
children.append({ 0, &widget, width, height, spacing });
|
||||
}
|
||||
|
||||
void HorizontalLayout::setGeometry(Geometry &geometry) {
|
||||
geometry.x += margin;
|
||||
geometry.y += margin;
|
||||
geometry.width -= margin * 2;
|
||||
geometry.height -= margin * 2;
|
||||
Geometry HorizontalLayout::minimumGeometry() {
|
||||
unsigned width = 0, height = 0;
|
||||
|
||||
unsigned geometryWidth = width ? width : geometry.width;
|
||||
unsigned geometryHeight = height ? height : geometry.height;
|
||||
|
||||
Geometry baseGeometry = geometry;
|
||||
linear_vector<HorizontalLayout::Children> children = this->children;
|
||||
|
||||
unsigned minimumWidth = 0;
|
||||
foreach(child, children) minimumWidth += child.width + child.spacing;
|
||||
|
||||
unsigned autosizeWidgets = 0;
|
||||
foreach(child, children) {
|
||||
if(child.width == 0) autosizeWidgets++;
|
||||
}
|
||||
foreach(child, children) {
|
||||
if(child.width == 0) child.width = (geometryWidth - minimumWidth) / autosizeWidgets;
|
||||
if(child.height == 0) child.height = geometryHeight;
|
||||
width += child.spacing;
|
||||
if(child.width == MinimumSize || child.width == MaximumSize) {
|
||||
if(child.layout) width += child.layout->minimumGeometry().width;
|
||||
if(child.widget) width += child.widget->minimumGeometry().width;
|
||||
continue;
|
||||
}
|
||||
width += child.width;
|
||||
}
|
||||
|
||||
unsigned maxHeight = 0;
|
||||
foreach(child, children) {
|
||||
maxHeight = max(maxHeight, child.height);
|
||||
if(child.height == MinimumSize || child.height == MaximumSize) {
|
||||
if(child.layout) height = max(height, child.layout->minimumGeometry().height);
|
||||
if(child.widget) height = max(height, child.widget->minimumGeometry().height);
|
||||
continue;
|
||||
}
|
||||
height = max(height, child.height);
|
||||
}
|
||||
|
||||
return { 0, 0, margin * 2 + width, margin * 2 + height };
|
||||
}
|
||||
|
||||
Geometry HorizontalLayout::minimumLayoutGeometry() {
|
||||
unsigned width = 0, height = 0;
|
||||
bool maximumWidth = false;
|
||||
bool maximumHeight = false;
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.width == MaximumSize) {
|
||||
maximumWidth = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(child.width == MinimumSize) {
|
||||
if(child.layout) width += child.layout->minimumGeometry().width;
|
||||
if(child.widget) width += child.widget->minimumGeometry().width;
|
||||
continue;
|
||||
}
|
||||
|
||||
width += child.width;
|
||||
}
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.height == MaximumSize) {
|
||||
maximumHeight = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(child.height == MinimumSize) {
|
||||
if(child.layout) height = max(height, child.layout->minimumGeometry().height);
|
||||
if(child.widget) height = max(height, child.widget->minimumGeometry().height);
|
||||
continue;
|
||||
}
|
||||
|
||||
height = max(height, child.height);
|
||||
}
|
||||
|
||||
return { 0, 0, maximumWidth ? MaximumSize : margin * 2 + width, maximumHeight ? MaximumSize : margin * 2 + height };
|
||||
}
|
||||
|
||||
void HorizontalLayout::setGeometry(const Geometry &containerGeometry) {
|
||||
auto children = this->children;
|
||||
foreach(child, children) {
|
||||
if(child.layout) {
|
||||
child.layout->setGeometry(geometry);
|
||||
geometry.x += child.spacing;
|
||||
geometry.width -= child.spacing;
|
||||
geometry.y = baseGeometry.y;
|
||||
geometry.height = baseGeometry.height;
|
||||
child.width = child.layout->minimumLayoutGeometry().width;
|
||||
child.height = child.layout->minimumLayoutGeometry().height;
|
||||
}
|
||||
|
||||
if(child.widget) {
|
||||
child.widget->setGeometry({ geometry.x, geometry.y, child.width, child.height });
|
||||
geometry.x += child.width + child.spacing;
|
||||
geometry.width -= child.width + child.spacing;
|
||||
if(child.width == MinimumSize) child.width = child.widget->minimumGeometry().width;
|
||||
if(child.height == MinimumSize) child.height = child.widget->minimumGeometry().height;
|
||||
}
|
||||
}
|
||||
|
||||
geometry.y += maxHeight;
|
||||
geometry.height -= maxHeight;
|
||||
Geometry geometry = containerGeometry;
|
||||
geometry.x += margin;
|
||||
geometry.y += margin;
|
||||
geometry.width -= margin * 2;
|
||||
geometry.height -= margin * 2;
|
||||
|
||||
unsigned minimumWidth = 0, maximumWidthCounter = 0;
|
||||
foreach(child, children) {
|
||||
if(child.width == MaximumSize) maximumWidthCounter++;
|
||||
if(child.width != MaximumSize) minimumWidth += child.width;
|
||||
minimumWidth += child.spacing;
|
||||
}
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.width == MaximumSize) child.width = (geometry.width - minimumWidth) / maximumWidthCounter;
|
||||
if(child.height == MaximumSize) child.height = geometry.height;
|
||||
}
|
||||
|
||||
unsigned maximumHeight = 0;
|
||||
foreach(child, children) maximumHeight = max(maximumHeight, child.height);
|
||||
|
||||
foreach(child, children) {
|
||||
unsigned pivot = (maximumHeight - child.height) / 2;
|
||||
Geometry childGeometry = { geometry.x, geometry.y + pivot, child.width, child.height };
|
||||
|
||||
if(child.layout) child.layout->setGeometry(childGeometry);
|
||||
if(child.widget) child.widget->setGeometry(childGeometry);
|
||||
|
||||
geometry.x += child.width + child.spacing;
|
||||
geometry.width -= child.width + child.spacing;
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::setMargin(unsigned margin_) {
|
||||
margin = margin_;
|
||||
void HorizontalLayout::setMargin(unsigned margin) {
|
||||
this->margin = margin;
|
||||
}
|
||||
|
||||
unsigned HorizontalLayout::minimumWidth() {
|
||||
unsigned width = margin * 2;
|
||||
foreach(child, children) width += child.width + child.spacing;
|
||||
return width;
|
||||
void HorizontalLayout::setParent(Window &parent) {
|
||||
foreach(child, children) {
|
||||
if(child.layout) child.layout->setParent(parent);
|
||||
if(child.widget) parent.append(*child.widget);
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::setVisible(bool visible) {
|
||||
@@ -83,6 +136,4 @@ void HorizontalLayout::setVisible(bool visible) {
|
||||
|
||||
HorizontalLayout::HorizontalLayout() {
|
||||
margin = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
struct VerticalLayout;
|
||||
|
||||
struct HorizontalLayout : public Layout {
|
||||
void append(VerticalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0);
|
||||
void append(VerticalLayout &layout, unsigned spacing = 0);
|
||||
void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0);
|
||||
unsigned minimumWidth();
|
||||
void setGeometry(Geometry &geometry);
|
||||
Geometry minimumLayoutGeometry();
|
||||
Geometry minimumGeometry();
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void setMargin(unsigned margin);
|
||||
void setParent(Window &parent);
|
||||
void setVisible(bool visible);
|
||||
@@ -12,8 +13,6 @@ struct HorizontalLayout : public Layout {
|
||||
|
||||
//private:
|
||||
unsigned margin;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
struct Children {
|
||||
VerticalLayout *layout;
|
||||
Widget *widget;
|
||||
|
||||
@@ -1,77 +1,130 @@
|
||||
void VerticalLayout::setParent(Window &parent) {
|
||||
foreach(child, children) {
|
||||
if(child.layout) child.layout->setParent(parent);
|
||||
if(child.widget) parent.append(*child.widget);
|
||||
}
|
||||
}
|
||||
|
||||
void VerticalLayout::append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing) {
|
||||
layout.width = width;
|
||||
layout.height = height;
|
||||
children.append({ &layout, 0, width, height, spacing });
|
||||
void VerticalLayout::append(HorizontalLayout &layout, unsigned spacing) {
|
||||
children.append({ &layout, 0, MinimumSize, MinimumSize, spacing });
|
||||
}
|
||||
|
||||
void VerticalLayout::append(Widget &widget, unsigned width, unsigned height, unsigned spacing) {
|
||||
children.append({ 0, &widget, width, height, spacing });
|
||||
}
|
||||
|
||||
void VerticalLayout::setGeometry(Geometry &geometry) {
|
||||
geometry.x += margin;
|
||||
geometry.y += margin;
|
||||
geometry.width -= margin * 2;
|
||||
geometry.height -= margin * 2;
|
||||
Geometry VerticalLayout::minimumGeometry() {
|
||||
unsigned width = 0, height = 0;
|
||||
|
||||
unsigned geometryWidth = width ? width : geometry.width;
|
||||
unsigned geometryHeight = height ? height : geometry.height;
|
||||
|
||||
Geometry baseGeometry = geometry;
|
||||
linear_vector<VerticalLayout::Children> children = this->children;
|
||||
|
||||
unsigned minimumHeight = 0;
|
||||
foreach(child, children) minimumHeight += child.height + child.spacing;
|
||||
|
||||
unsigned autosizeWidgets = 0;
|
||||
foreach(child, children) {
|
||||
if(child.height == 0) autosizeWidgets++;
|
||||
}
|
||||
foreach(child, children) {
|
||||
if(child.width == 0) child.width = geometryWidth;
|
||||
if(child.height == 0) child.height = (geometryHeight - minimumHeight) / autosizeWidgets;
|
||||
if(child.width == MinimumSize || child.width == MaximumSize) {
|
||||
if(child.layout) width = max(width, child.layout->minimumGeometry().width);
|
||||
if(child.widget) width = max(width, child.widget->minimumGeometry().width);
|
||||
continue;
|
||||
}
|
||||
width = max(width, child.width);
|
||||
}
|
||||
|
||||
unsigned maxWidth = 0;
|
||||
foreach(child, children) {
|
||||
maxWidth = max(maxWidth, child.width);
|
||||
height += child.spacing;
|
||||
if(child.height == MinimumSize || child.height == MaximumSize) {
|
||||
if(child.layout) height += child.layout->minimumGeometry().height;
|
||||
if(child.widget) height += child.widget->minimumGeometry().height;
|
||||
continue;
|
||||
}
|
||||
height += child.height;
|
||||
}
|
||||
|
||||
return { 0, 0, margin * 2 + width, margin * 2 + height };
|
||||
}
|
||||
|
||||
Geometry VerticalLayout::minimumLayoutGeometry() {
|
||||
unsigned width = 0, height = 0;
|
||||
bool maximumWidth = false;
|
||||
bool maximumHeight = false;
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.width == MaximumSize) {
|
||||
maximumWidth = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(child.width == MinimumSize) {
|
||||
if(child.layout) width = max(width, child.layout->minimumGeometry().width);
|
||||
if(child.widget) width = max(width, child.widget->minimumGeometry().width);
|
||||
continue;
|
||||
}
|
||||
|
||||
width = max(width, child.width);
|
||||
}
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.height == MaximumSize) {
|
||||
maximumHeight = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(child.height == MinimumSize) {
|
||||
if(child.layout) height += child.layout->minimumGeometry().height;
|
||||
if(child.widget) height += child.widget->minimumGeometry().height;
|
||||
continue;
|
||||
}
|
||||
|
||||
height += child.height;
|
||||
}
|
||||
|
||||
return { 0, 0, maximumWidth ? MaximumSize : margin * 2 + width, maximumHeight ? MaximumSize : margin * 2 + height };
|
||||
}
|
||||
|
||||
void VerticalLayout::setGeometry(const Geometry &containerGeometry) {
|
||||
auto children = this->children;
|
||||
foreach(child, children) {
|
||||
if(child.layout) {
|
||||
child.layout->setGeometry(geometry);
|
||||
geometry.x = baseGeometry.x;
|
||||
geometry.width = baseGeometry.width;
|
||||
geometry.y += child.spacing;
|
||||
geometry.height -= child.spacing;
|
||||
child.width = child.layout->minimumLayoutGeometry().width;
|
||||
child.height = child.layout->minimumLayoutGeometry().height;
|
||||
}
|
||||
|
||||
if(child.widget) {
|
||||
child.widget->setGeometry({ geometry.x, geometry.y, child.width, child.height });
|
||||
geometry.y += child.height + child.spacing;
|
||||
geometry.height -= child.height + child.spacing;
|
||||
if(child.width == MinimumSize) child.width = child.widget->minimumGeometry().width;
|
||||
if(child.height == MinimumSize) child.height = child.widget->minimumGeometry().height;
|
||||
}
|
||||
}
|
||||
|
||||
geometry.x += maxWidth;
|
||||
geometry.width -= maxWidth;
|
||||
Geometry geometry = containerGeometry;
|
||||
geometry.x += margin;
|
||||
geometry.y += margin;
|
||||
geometry.width -= margin * 2;
|
||||
geometry.height -= margin * 2;
|
||||
|
||||
unsigned minimumHeight = 0, maximumHeightCounter = 0;
|
||||
foreach(child, children) {
|
||||
if(child.height == MaximumSize) maximumHeightCounter++;
|
||||
if(child.height != MaximumSize) minimumHeight += child.height;
|
||||
minimumHeight += child.spacing;
|
||||
}
|
||||
|
||||
foreach(child, children) {
|
||||
if(child.width == MaximumSize) child.width = geometry.width;
|
||||
if(child.height == MaximumSize) child.height = (geometry.height - minimumHeight) / maximumHeightCounter;
|
||||
}
|
||||
|
||||
unsigned maximumWidth = 0;
|
||||
foreach(child, children) maximumWidth = max(maximumWidth, child.width);
|
||||
|
||||
foreach(child, children) {
|
||||
unsigned pivot = 0; //(maximumWidth - child.width) / 2;
|
||||
Geometry childGeometry = { geometry.x + pivot, geometry.y, child.width, child.height };
|
||||
|
||||
if(child.layout) child.layout->setGeometry(childGeometry);
|
||||
if(child.widget) child.widget->setGeometry(childGeometry);
|
||||
|
||||
geometry.y += child.height + child.spacing;
|
||||
geometry.height -= child.height + child.spacing;
|
||||
}
|
||||
}
|
||||
|
||||
void VerticalLayout::setMargin(unsigned margin_) {
|
||||
margin = margin_;
|
||||
void VerticalLayout::setMargin(unsigned margin) {
|
||||
this->margin = margin;
|
||||
}
|
||||
|
||||
unsigned VerticalLayout::minimumHeight() {
|
||||
unsigned height = margin * 2;
|
||||
foreach(child, children) height += child.height + child.spacing;
|
||||
return height;
|
||||
void VerticalLayout::setParent(Window &parent) {
|
||||
foreach(child, children) {
|
||||
if(child.layout) child.layout->setParent(parent);
|
||||
if(child.widget) parent.append(*child.widget);
|
||||
}
|
||||
}
|
||||
|
||||
void VerticalLayout::setVisible(bool visible) {
|
||||
@@ -83,6 +136,4 @@ void VerticalLayout::setVisible(bool visible) {
|
||||
|
||||
VerticalLayout::VerticalLayout() {
|
||||
margin = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
struct HorizontalLayout;
|
||||
|
||||
struct VerticalLayout : public Layout {
|
||||
void append(HorizontalLayout &layout, unsigned width, unsigned height, unsigned spacing = 0);
|
||||
void append(HorizontalLayout &layout, unsigned spacing = 0);
|
||||
void append(Widget &widget, unsigned width, unsigned height, unsigned spacing = 0);
|
||||
unsigned minimumHeight();
|
||||
void setGeometry(Geometry &geometry);
|
||||
Geometry minimumGeometry();
|
||||
Geometry minimumLayoutGeometry();
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void setMargin(unsigned margin);
|
||||
void setParent(Window &parent);
|
||||
void setVisible(bool visible);
|
||||
@@ -12,8 +13,6 @@ struct VerticalLayout : public Layout {
|
||||
|
||||
//private:
|
||||
unsigned margin;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
struct Children {
|
||||
HorizontalLayout *layout;
|
||||
Widget *widget;
|
||||
|
||||
@@ -13,6 +13,16 @@ struct Font::State {
|
||||
}
|
||||
};
|
||||
|
||||
struct Timer::State {
|
||||
bool enabled;
|
||||
unsigned milliseconds;
|
||||
|
||||
State() {
|
||||
enabled = false;
|
||||
milliseconds = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct Window::State {
|
||||
bool backgroundColor;
|
||||
unsigned backgroundColorRed, backgroundColorGreen, backgroundColorBlue;
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
Geometry pFont::geometry(const string &text) {
|
||||
pango_layout_set_font_description(gtkLayout, gtkFont);
|
||||
pango_layout_set_text(gtkLayout, text, -1);
|
||||
int width = 0, height = 0;
|
||||
pango_layout_get_pixel_size(gtkLayout, &width, &height);
|
||||
return { 0, 0, width, height };
|
||||
}
|
||||
|
||||
void pFont::setBold(bool bold) {
|
||||
pango_font_description_set_weight(gtkFont, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
|
||||
}
|
||||
@@ -19,4 +27,6 @@ void pFont::setUnderline(bool underline) {
|
||||
|
||||
void pFont::constructor() {
|
||||
gtkFont = pango_font_description_new();
|
||||
PangoContext *context = gdk_pango_context_get_for_screen(gdk_screen_get_default());
|
||||
gtkLayout = pango_layout_new(context);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "settings.cpp"
|
||||
#include "font.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
|
||||
#include "widget/widget.cpp"
|
||||
#include "widget/button.cpp"
|
||||
#include "widget/canvas.cpp"
|
||||
#include "widget/check-box.cpp"
|
||||
#include "widget/combo-box.cpp"
|
||||
#include "widget/hex-edit.cpp"
|
||||
@@ -27,11 +29,32 @@
|
||||
#include "widget/vertical-slider.cpp"
|
||||
#include "widget/viewport.cpp"
|
||||
|
||||
Font pOS::defaultFont;
|
||||
|
||||
Geometry pOS::availableGeometry() {
|
||||
//TODO: is there a GTK+ function for this?
|
||||
//should return desktopGeometry() sans panels, toolbars, docks, etc.
|
||||
Geometry geometry = desktopGeometry();
|
||||
return { geometry.x + 64, geometry.y + 64, geometry.width - 128, geometry.height - 128 };
|
||||
Display *display = XOpenDisplay(0);
|
||||
int screen = DefaultScreen(display);
|
||||
|
||||
static Atom atom = X11None;
|
||||
if(atom == X11None) atom = XInternAtom(display, "_NET_WORKAREA", True);
|
||||
|
||||
int format;
|
||||
unsigned char *data = 0;
|
||||
unsigned long items, after;
|
||||
Atom returnAtom;
|
||||
|
||||
int result = XGetWindowProperty(
|
||||
display, RootWindow(display, screen), atom, 0, 4, False, XA_CARDINAL, &returnAtom, &format, &items, &after, &data
|
||||
);
|
||||
|
||||
XCloseDisplay(display);
|
||||
|
||||
if(result == Success && returnAtom == XA_CARDINAL && format == 32 && items == 4) {
|
||||
unsigned long *workarea = (unsigned long*)data;
|
||||
return { (signed)workarea[0], (signed)workarea[1], (unsigned)workarea[2], (unsigned)workarea[3] };
|
||||
}
|
||||
|
||||
return desktopGeometry();
|
||||
}
|
||||
|
||||
Geometry pOS::desktopGeometry() {
|
||||
|
||||
@@ -26,6 +26,8 @@ struct pObject {
|
||||
};
|
||||
|
||||
struct pOS : public pObject {
|
||||
static Font defaultFont;
|
||||
|
||||
static Geometry availableGeometry();
|
||||
static Geometry desktopGeometry();
|
||||
static string fileLoad(Window &parent, const string &path, const lstring &filter);
|
||||
@@ -42,7 +44,9 @@ struct pOS : public pObject {
|
||||
struct pFont : public pObject {
|
||||
Font &font;
|
||||
PangoFontDescription *gtkFont;
|
||||
PangoLayout *gtkLayout;
|
||||
|
||||
Geometry geometry(const string &text);
|
||||
void setBold(bool bold);
|
||||
void setFamily(const string &family);
|
||||
void setItalic(bool italic);
|
||||
@@ -53,6 +57,16 @@ struct pFont : public pObject {
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pTimer : public pObject {
|
||||
Timer &timer;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
||||
pTimer(Timer &timer) : timer(timer) {}
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pMessageWindow : public pObject {
|
||||
static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
@@ -164,10 +178,12 @@ struct pWidget : public pObject {
|
||||
pWindow *parentWindow;
|
||||
|
||||
bool enabled();
|
||||
Font& font();
|
||||
virtual Geometry minimumGeometry();
|
||||
void setEnabled(bool enabled);
|
||||
virtual void setFocused();
|
||||
virtual void setFont(Font &font);
|
||||
void setGeometry(const Geometry &geometry);
|
||||
virtual void setGeometry(const Geometry &geometry);
|
||||
void setVisible(bool visible);
|
||||
|
||||
pWidget(Widget &widget) : widget(widget) {}
|
||||
@@ -177,16 +193,32 @@ struct pWidget : public pObject {
|
||||
struct pButton : public pWidget {
|
||||
Button &button;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pButton(Button &button) : pWidget(button), button(button) {}
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pCanvas : public pWidget {
|
||||
Canvas &canvas;
|
||||
uint32_t *bufferRGB;
|
||||
uint32_t *bufferBGR;
|
||||
|
||||
uint32_t* buffer();
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void update();
|
||||
|
||||
pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {}
|
||||
void constructor();
|
||||
void redraw();
|
||||
};
|
||||
|
||||
struct pCheckBox : public pWidget {
|
||||
CheckBox &checkBox;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked(bool checked);
|
||||
void setText(const string &text);
|
||||
|
||||
@@ -199,6 +231,7 @@ struct pComboBox : public pWidget {
|
||||
unsigned itemCounter;
|
||||
|
||||
void append(const string &text);
|
||||
Geometry minimumGeometry();
|
||||
void reset();
|
||||
unsigned selection();
|
||||
void setSelection(unsigned row);
|
||||
@@ -234,6 +267,7 @@ struct pHexEdit : public pWidget {
|
||||
struct pHorizontalSlider : public pWidget {
|
||||
HorizontalSlider &horizontalSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
@@ -245,6 +279,7 @@ struct pHorizontalSlider : public pWidget {
|
||||
struct pLabel : public pWidget {
|
||||
Label &label;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pLabel(Label &label) : pWidget(label), label(label) {}
|
||||
@@ -254,6 +289,7 @@ struct pLabel : public pWidget {
|
||||
struct pLineEdit : public pWidget {
|
||||
LineEdit &lineEdit;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setEditable(bool editable);
|
||||
void setText(const string &text);
|
||||
string text();
|
||||
@@ -297,6 +333,7 @@ struct pListView : public pWidget {
|
||||
struct pProgressBar : public pWidget {
|
||||
ProgressBar &progressBar;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setPosition(unsigned position);
|
||||
|
||||
pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {}
|
||||
@@ -307,6 +344,7 @@ struct pRadioBox : public pWidget {
|
||||
RadioBox &radioBox;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked();
|
||||
void setGroup(const reference_array<RadioBox&> &group);
|
||||
void setText(const string &text);
|
||||
@@ -333,6 +371,7 @@ struct pTextEdit : public pWidget {
|
||||
struct pVerticalSlider : public pWidget {
|
||||
VerticalSlider &verticalSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
static guint Timer_trigger(pTimer *self) {
|
||||
//timer may have been disabled prior to triggering, so check state
|
||||
if(self->timer.state.enabled) {
|
||||
if(self->timer.onTimeout) self->timer.onTimeout();
|
||||
}
|
||||
//callback may have disabled timer, so check state again
|
||||
if(self->timer.state.enabled) {
|
||||
g_timeout_add(self->timer.state.milliseconds, (GSourceFunc)Timer_trigger, (gpointer)self);
|
||||
}
|
||||
//kill this timer instance (it is spawned above if needed again)
|
||||
return false;
|
||||
}
|
||||
|
||||
void pTimer::setEnabled(bool enabled) {
|
||||
if(enabled) {
|
||||
g_timeout_add(timer.state.milliseconds, (GSourceFunc)Timer_trigger, (gpointer)this);
|
||||
}
|
||||
}
|
||||
|
||||
void pTimer::setInterval(unsigned milliseconds) {
|
||||
}
|
||||
|
||||
void pTimer::constructor() {
|
||||
}
|
||||
@@ -2,6 +2,12 @@ static void Button_tick(Button *self) {
|
||||
if(self->onTick) self->onTick();
|
||||
}
|
||||
|
||||
Geometry pButton::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
Geometry geometry = font.geometry(button.state.text);
|
||||
return { 0, 0, geometry.width + 24, geometry.height + 14 };
|
||||
}
|
||||
|
||||
void pButton::setText(const string &text) {
|
||||
gtk_button_set_label(GTK_BUTTON(gtkWidget), text);
|
||||
}
|
||||
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
static void Canvas_expose(pCanvas *self) {
|
||||
self->redraw();
|
||||
}
|
||||
|
||||
uint32_t* pCanvas::buffer() {
|
||||
return bufferRGB;
|
||||
}
|
||||
|
||||
void pCanvas::setGeometry(const Geometry &geometry) {
|
||||
delete[] bufferRGB;
|
||||
delete[] bufferBGR;
|
||||
|
||||
bufferRGB = new uint32_t[geometry.width * geometry.height]();
|
||||
bufferBGR = new uint32_t[geometry.width * geometry.height]();
|
||||
|
||||
pWidget::setGeometry(geometry);
|
||||
update();
|
||||
}
|
||||
|
||||
void pCanvas::update() {
|
||||
if(gtk_widget_get_realized(gtkWidget) == false) return;
|
||||
GdkRectangle rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = gtkWidget->allocation.width;
|
||||
rect.height = gtkWidget->allocation.height;
|
||||
gdk_window_invalidate_rect(gtkWidget->window, &rect, true);
|
||||
}
|
||||
|
||||
void pCanvas::constructor() {
|
||||
bufferRGB = new uint32_t[256 * 256]();
|
||||
bufferBGR = new uint32_t[256 * 256]();
|
||||
|
||||
gtkWidget = gtk_drawing_area_new();
|
||||
GdkColor color;
|
||||
color.pixel = color.red = color.green = color.blue = 0;
|
||||
gtk_widget_modify_bg(gtkWidget, GTK_STATE_NORMAL, &color);
|
||||
gtk_widget_set_double_buffered(gtkWidget, false);
|
||||
gtk_widget_add_events(gtkWidget, GDK_EXPOSURE_MASK);
|
||||
g_signal_connect_swapped(G_OBJECT(gtkWidget), "expose_event", G_CALLBACK(Canvas_expose), (gpointer)this);
|
||||
}
|
||||
|
||||
void pCanvas::redraw() {
|
||||
if(gtk_widget_get_realized(gtkWidget) == false) return;
|
||||
uint32_t *rgb = bufferRGB, *bgr = bufferBGR;
|
||||
for(unsigned y = gtkWidget->allocation.height; y; y--) {
|
||||
for(unsigned x = gtkWidget->allocation.width; x; x--) {
|
||||
uint32_t pixel = *rgb++;
|
||||
*bgr++ = ((pixel << 16) & 0xff0000) | (pixel & 0x00ff00) | ((pixel >> 16) & 0x0000ff);
|
||||
}
|
||||
}
|
||||
|
||||
gdk_draw_rgb_32_image(
|
||||
gtkWidget->window,
|
||||
gtkWidget->style->fg_gc[GTK_WIDGET_STATE(gtkWidget)],
|
||||
0, 0, gtkWidget->allocation.width, gtkWidget->allocation.height,
|
||||
GDK_RGB_DITHER_NONE, (guchar*)bufferBGR, sizeof(uint32_t) * gtkWidget->allocation.width
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,12 @@ bool pCheckBox::checked() {
|
||||
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget));
|
||||
}
|
||||
|
||||
Geometry pCheckBox::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
Geometry geometry = font.geometry(checkBox.state.text);
|
||||
return { 0, 0, geometry.width + 28, geometry.height + 4 };
|
||||
}
|
||||
|
||||
void pCheckBox::setChecked(bool checked) {
|
||||
locked = true;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), checked);
|
||||
|
||||
@@ -7,6 +7,15 @@ void pComboBox::append(const string &text) {
|
||||
if(itemCounter++ == 0) setSelection(0);
|
||||
}
|
||||
|
||||
Geometry pComboBox::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
unsigned maximumWidth = 0;
|
||||
foreach(item, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(item).width);
|
||||
|
||||
Geometry geometry = font.geometry(" ");
|
||||
return { 0, 0, maximumWidth + 44, geometry.height + 10 };
|
||||
}
|
||||
|
||||
void pComboBox::reset() {
|
||||
locked = true;
|
||||
for(signed n = itemCounter - 1; n >= 0; n--) {
|
||||
|
||||
@@ -4,6 +4,10 @@ static void HorizontalSlider_change(HorizontalSlider *self) {
|
||||
if(self->onChange) self->onChange();
|
||||
}
|
||||
|
||||
Geometry pHorizontalSlider::minimumGeometry() {
|
||||
return { 0, 0, 0, 20 };
|
||||
}
|
||||
|
||||
unsigned pHorizontalSlider::position() {
|
||||
return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pLabel::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
Geometry geometry = font.geometry(label.state.text);
|
||||
return { 0, 0, geometry.width, geometry.height };
|
||||
}
|
||||
|
||||
void pLabel::setText(const string &text) {
|
||||
gtk_label_set_text(GTK_LABEL(gtkWidget), text);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,12 @@ static void LineEdit_change(LineEdit *self) {
|
||||
if(self->p.locked == false && self->onChange) self->onChange();
|
||||
}
|
||||
|
||||
Geometry pLineEdit::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
Geometry geometry = font.geometry(lineEdit.state.text);
|
||||
return { 0, 0, geometry.width + 10, geometry.height + 10 };
|
||||
}
|
||||
|
||||
void pLineEdit::setEditable(bool editable) {
|
||||
gtk_entry_set_editable(GTK_ENTRY(gtkWidget), editable);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pProgressBar::minimumGeometry() {
|
||||
return { 0, 0, 0, 25 };
|
||||
}
|
||||
|
||||
void pProgressBar::setPosition(unsigned position) {
|
||||
position = position <= 100 ? position : 0;
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(gtkWidget), (double)position / 100.0);
|
||||
|
||||
@@ -6,6 +6,12 @@ bool pRadioBox::checked() {
|
||||
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget));
|
||||
}
|
||||
|
||||
Geometry pRadioBox::minimumGeometry() {
|
||||
Font &font = pWidget::font();
|
||||
Geometry geometry = font.geometry(radioBox.state.text);
|
||||
return { 0, 0, geometry.width + 28, geometry.height + 4 };
|
||||
}
|
||||
|
||||
void pRadioBox::setChecked() {
|
||||
locked = true;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), true);
|
||||
|
||||
@@ -4,6 +4,10 @@ static void VerticalSlider_change(VerticalSlider *self) {
|
||||
if(self->onChange) self->onChange();
|
||||
}
|
||||
|
||||
Geometry pVerticalSlider::minimumGeometry() {
|
||||
return { 0, 0, 20, 0 };
|
||||
}
|
||||
|
||||
unsigned pVerticalSlider::position() {
|
||||
return (unsigned)gtk_range_get_value(GTK_RANGE(gtkWidget));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,15 @@ static void Widget_setFont(GtkWidget *widget, gpointer font) {
|
||||
}
|
||||
}
|
||||
|
||||
Font& pWidget::font() {
|
||||
if(widget.state.font) return *widget.state.font;
|
||||
return pOS::defaultFont;
|
||||
}
|
||||
|
||||
Geometry pWidget::minimumGeometry() {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
bool pWidget::enabled() {
|
||||
return gtk_widget_get_sensitive(gtkWidget);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef PHOENIX_CPP
|
||||
#define PHOENIX_CPP
|
||||
|
||||
#if defined(PHOENIX_WINDOWS)
|
||||
#define UNICODE
|
||||
#define WINVER 0x0501
|
||||
@@ -14,13 +17,15 @@
|
||||
#include <QApplication>
|
||||
#include <QtGui>
|
||||
#elif defined(PHOENIX_GTK)
|
||||
#define None X11None
|
||||
#define None
|
||||
#define Window X11Window
|
||||
#define X11None 0L
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <cairo.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#undef None
|
||||
#undef Window
|
||||
@@ -35,3 +40,5 @@ using namespace nall;
|
||||
namespace phoenix {
|
||||
#include "core/core.cpp"
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef PHOENIX_HPP
|
||||
#define PHOENIX_HPP
|
||||
|
||||
#include <nall/array.hpp>
|
||||
#include <nall/config.hpp>
|
||||
#include <nall/foreach.hpp>
|
||||
@@ -11,3 +14,5 @@
|
||||
namespace phoenix {
|
||||
#include "core/core.hpp"
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@ void pAction::setFont(Font &font) {
|
||||
|
||||
void pAction::setVisible(bool visible) {
|
||||
if(dynamic_cast<Menu*>(&action)) {
|
||||
((Menu&)action).p.qtMenu->setVisible(visible);
|
||||
((Menu&)action).p.qtMenu->menuAction()->setVisible(visible);
|
||||
} else if(dynamic_cast<Separator*>(&action)) {
|
||||
((Separator&)action).p.qtAction->setVisible(visible);
|
||||
} else if(dynamic_cast<Item*>(&action)) {
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
Geometry pFont::geometry(const string &text) {
|
||||
QFontMetrics metrics(*qtFont);
|
||||
|
||||
lstring lines;
|
||||
lines.split("\n", text);
|
||||
|
||||
unsigned maxWidth = 0;
|
||||
foreach(line, lines) {
|
||||
maxWidth = max(maxWidth, metrics.width(line));
|
||||
}
|
||||
|
||||
return { 0, 0, maxWidth, metrics.height() * lines.size() };
|
||||
}
|
||||
|
||||
void pFont::setBold(bool bold) { update(); }
|
||||
void pFont::setFamily(const string &family) { update(); }
|
||||
void pFont::setItalic(bool italic) { update(); }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "settings.cpp"
|
||||
#include "font.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
@@ -15,6 +16,7 @@
|
||||
|
||||
#include "widget/widget.cpp"
|
||||
#include "widget/button.cpp"
|
||||
#include "widget/canvas.cpp"
|
||||
#include "widget/check-box.cpp"
|
||||
#include "widget/combo-box.cpp"
|
||||
#include "widget/hex-edit.cpp"
|
||||
@@ -29,6 +31,7 @@
|
||||
#include "widget/viewport.cpp"
|
||||
|
||||
QApplication *pOS::application = 0;
|
||||
Font pOS::defaultFont;
|
||||
|
||||
Geometry pOS::availableGeometry() {
|
||||
QRect rect = QApplication::desktop()->availableGeometry();
|
||||
|
||||
+129
-17
@@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'qt.moc.hpp'
|
||||
**
|
||||
** Created: Thu Feb 24 07:36:07 2011
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
** Created: Tue May 24 19:33:16 2011
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
@@ -10,16 +10,77 @@
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'qt.moc.hpp' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "This file was generated using the moc from 4.7.0. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_pTimer[] = {
|
||||
|
||||
// content:
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
// slots: signature, parameters, type, tag, flags
|
||||
8, 7, 7, 7, 0x0a,
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_pTimer[] = {
|
||||
"pTimer\0\0onTimeout()\0"
|
||||
};
|
||||
|
||||
const QMetaObject pTimer::staticMetaObject = {
|
||||
{ &QObject::staticMetaObject, qt_meta_stringdata_pTimer,
|
||||
qt_meta_data_pTimer, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &pTimer::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *pTimer::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *pTimer::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_pTimer))
|
||||
return static_cast<void*>(const_cast< pTimer*>(this));
|
||||
if (!strcmp(_clname, "pObject"))
|
||||
return static_cast< pObject*>(const_cast< pTimer*>(this));
|
||||
return QObject::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int pTimer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QObject::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
switch (_id) {
|
||||
case 0: onTimeout(); break;
|
||||
default: ;
|
||||
}
|
||||
_id -= 1;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
static const uint qt_meta_data_pWindow[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
@@ -70,7 +131,7 @@ int pWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pItem[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -131,7 +192,7 @@ int pItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pCheckItem[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -192,7 +253,7 @@ int pCheckItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pRadioItem[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -253,7 +314,7 @@ int pRadioItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pButton[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -311,10 +372,61 @@ int pButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
static const uint qt_meta_data_pCanvas[] = {
|
||||
|
||||
// content:
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_pCanvas[] = {
|
||||
"pCanvas\0"
|
||||
};
|
||||
|
||||
const QMetaObject pCanvas::staticMetaObject = {
|
||||
{ &QObject::staticMetaObject, qt_meta_stringdata_pCanvas,
|
||||
qt_meta_data_pCanvas, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &pCanvas::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *pCanvas::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *pCanvas::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_pCanvas))
|
||||
return static_cast<void*>(const_cast< pCanvas*>(this));
|
||||
if (!strcmp(_clname, "pWidget"))
|
||||
return static_cast< pWidget*>(const_cast< pCanvas*>(this));
|
||||
return QObject::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int pCanvas::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QObject::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
static const uint qt_meta_data_pCheckBox[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -375,7 +487,7 @@ int pCheckBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pComboBox[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -436,7 +548,7 @@ int pComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pHexEdit[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -497,7 +609,7 @@ int pHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pHorizontalSlider[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -558,7 +670,7 @@ int pHorizontalSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pLineEdit[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
2, 14, // methods
|
||||
@@ -621,7 +733,7 @@ int pLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pListView[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
3, 14, // methods
|
||||
@@ -687,7 +799,7 @@ int pListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pRadioBox[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -748,7 +860,7 @@ int pRadioBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pTextEdit[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
@@ -809,7 +921,7 @@ int pTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
static const uint qt_meta_data_pVerticalSlider[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
5, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
|
||||
@@ -25,6 +25,7 @@ struct pObject {
|
||||
|
||||
struct pOS : public pObject {
|
||||
static QApplication *application;
|
||||
static Font defaultFont;
|
||||
|
||||
static Geometry availableGeometry();
|
||||
static Geometry desktopGeometry();
|
||||
@@ -43,6 +44,7 @@ struct pFont : public pObject {
|
||||
Font &font;
|
||||
QFont *qtFont;
|
||||
|
||||
Geometry geometry(const string &text);
|
||||
void setBold(bool bold);
|
||||
void setFamily(const string &family);
|
||||
void setItalic(bool italic);
|
||||
@@ -54,6 +56,23 @@ struct pFont : public pObject {
|
||||
void update();
|
||||
};
|
||||
|
||||
struct pTimer : public QObject, public pObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Timer &timer;
|
||||
QTimer *qtTimer;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
||||
pTimer(Timer &timer) : timer(timer) {}
|
||||
void constructor();
|
||||
|
||||
public slots:
|
||||
void onTimeout();
|
||||
};
|
||||
|
||||
struct pMessageWindow : public pObject {
|
||||
static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
@@ -193,10 +212,12 @@ struct pWidget : public pObject {
|
||||
Widget &widget;
|
||||
QWidget *qtWidget;
|
||||
|
||||
Font& font();
|
||||
virtual Geometry minimumGeometry();
|
||||
void setEnabled(bool enabled);
|
||||
void setFocused();
|
||||
void setFont(Font &font);
|
||||
void setGeometry(const Geometry &geometry);
|
||||
virtual void setGeometry(const Geometry &geometry);
|
||||
void setVisible(bool visible);
|
||||
|
||||
pWidget(Widget &widget) : widget(widget) {}
|
||||
@@ -210,6 +231,7 @@ public:
|
||||
Button &button;
|
||||
QPushButton *qtButton;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pButton(Button &button) : pWidget(button), button(button) {}
|
||||
@@ -219,6 +241,28 @@ public slots:
|
||||
void onTick();
|
||||
};
|
||||
|
||||
struct pCanvas : public QObject, public pWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Canvas &canvas;
|
||||
QImage *qtImage;
|
||||
struct QtCanvas : public QWidget {
|
||||
pCanvas &self;
|
||||
void paintEvent(QPaintEvent*);
|
||||
QtCanvas(pCanvas &self);
|
||||
} *qtCanvas;
|
||||
|
||||
uint32_t* buffer();
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void update();
|
||||
|
||||
pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {}
|
||||
void constructor();
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
struct pCheckBox : public QObject, public pWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -227,6 +271,7 @@ public:
|
||||
QCheckBox *qtCheckBox;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked(bool checked);
|
||||
void setText(const string &text);
|
||||
|
||||
@@ -245,6 +290,7 @@ public:
|
||||
QComboBox *qtComboBox;
|
||||
|
||||
void append(const string &text);
|
||||
Geometry minimumGeometry();
|
||||
void reset();
|
||||
unsigned selection();
|
||||
void setSelection(unsigned row);
|
||||
@@ -291,6 +337,7 @@ public:
|
||||
HorizontalSlider &horizontalSlider;
|
||||
QSlider *qtSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
@@ -306,6 +353,7 @@ struct pLabel : public pWidget {
|
||||
Label &label;
|
||||
QLabel *qtLabel;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pLabel(Label &label) : pWidget(label), label(label) {}
|
||||
@@ -319,6 +367,7 @@ public:
|
||||
LineEdit &lineEdit;
|
||||
QLineEdit *qtLineEdit;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setEditable(bool editable);
|
||||
void setText(const string &text);
|
||||
string text();
|
||||
@@ -365,6 +414,7 @@ struct pProgressBar : public pWidget {
|
||||
ProgressBar &progressBar;
|
||||
QProgressBar *qtProgressBar;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setPosition(unsigned position);
|
||||
|
||||
pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {}
|
||||
@@ -380,6 +430,7 @@ public:
|
||||
QButtonGroup *qtGroup;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked();
|
||||
void setGroup(const reference_array<RadioBox&> &group);
|
||||
void setText(const string &text);
|
||||
@@ -418,6 +469,7 @@ public:
|
||||
VerticalSlider &verticalSlider;
|
||||
QSlider *qtSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
void pTimer::setEnabled(bool enabled) {
|
||||
if(enabled) {
|
||||
qtTimer->start();
|
||||
} else {
|
||||
qtTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void pTimer::setInterval(unsigned milliseconds) {
|
||||
qtTimer->setInterval(milliseconds);
|
||||
}
|
||||
|
||||
void pTimer::constructor() {
|
||||
qtTimer = new QTimer;
|
||||
qtTimer->setInterval(0);
|
||||
connect(qtTimer, SIGNAL(timeout()), SLOT(onTimeout()));
|
||||
}
|
||||
|
||||
void pTimer::onTimeout() {
|
||||
if(timer.onTimeout) timer.onTimeout();
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pButton::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(button.state.text);
|
||||
return { 0, 0, geometry.width + 20, geometry.height + 12 };
|
||||
}
|
||||
|
||||
void pButton::setText(const string &text) {
|
||||
qtButton->setText(QString::fromUtf8(text));
|
||||
}
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
uint32_t* pCanvas::buffer() {
|
||||
return (uint32_t*)qtImage->bits();
|
||||
}
|
||||
|
||||
void pCanvas::setGeometry(const Geometry &geometry) {
|
||||
qtImage = new QImage(geometry.width, geometry.height, QImage::Format_RGB32);
|
||||
qtImage->fill(0);
|
||||
update();
|
||||
pWidget::setGeometry(geometry);
|
||||
}
|
||||
|
||||
void pCanvas::update() {
|
||||
qtCanvas->update();
|
||||
}
|
||||
|
||||
void pCanvas::constructor() {
|
||||
qtWidget = qtCanvas = new QtCanvas(*this);
|
||||
qtImage = new QImage(256, 256, QImage::Format_RGB32);
|
||||
}
|
||||
|
||||
void pCanvas::QtCanvas::paintEvent(QPaintEvent *event) {
|
||||
QPainter painter(self.qtCanvas);
|
||||
painter.drawImage(0, 0, *self.qtImage);
|
||||
}
|
||||
|
||||
pCanvas::QtCanvas::QtCanvas(pCanvas &self) : self(self) {
|
||||
}
|
||||
@@ -2,6 +2,12 @@ bool pCheckBox::checked() {
|
||||
return qtCheckBox->isChecked();
|
||||
}
|
||||
|
||||
Geometry pCheckBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(checkBox.state.text);
|
||||
return { 0, 0, geometry.width + 26, geometry.height + 6 };
|
||||
}
|
||||
|
||||
void pCheckBox::setChecked(bool checked) {
|
||||
locked = true;
|
||||
qtCheckBox->setChecked(checked);
|
||||
|
||||
@@ -2,6 +2,14 @@ void pComboBox::append(const string &text) {
|
||||
qtComboBox->addItem(QString::fromUtf8(text));
|
||||
}
|
||||
|
||||
Geometry pComboBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
unsigned maximumWidth = 0;
|
||||
foreach(text, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(text).width);
|
||||
Geometry geometry = font.geometry(" ");
|
||||
return { 0, 0, maximumWidth + 32, geometry.height + 12 };
|
||||
}
|
||||
|
||||
void pComboBox::reset() {
|
||||
while(qtComboBox->count()) qtComboBox->removeItem(0);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pHorizontalSlider::minimumGeometry() {
|
||||
return { 0, 0, 0, 20 };
|
||||
}
|
||||
|
||||
unsigned pHorizontalSlider::position() {
|
||||
return qtSlider->value();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pLabel::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(label.state.text);
|
||||
return { 0, 0, geometry.width, geometry.height };
|
||||
}
|
||||
|
||||
void pLabel::setText(const string &text) {
|
||||
qtLabel->setText(QString::fromUtf8(text));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pLineEdit::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(lineEdit.state.text);
|
||||
return { 0, 0, geometry.width + 12, geometry.height + 12 };
|
||||
}
|
||||
|
||||
void pLineEdit::setEditable(bool editable) {
|
||||
qtLineEdit->setReadOnly(!editable);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pProgressBar::minimumGeometry() {
|
||||
return { 0, 0, 0, 25 };
|
||||
}
|
||||
|
||||
void pProgressBar::setPosition(unsigned position) {
|
||||
qtProgressBar->setValue(position);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ bool pRadioBox::checked() {
|
||||
return qtRadioBox->isChecked();
|
||||
}
|
||||
|
||||
Geometry pRadioBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(radioBox.state.text);
|
||||
return { 0, 0, geometry.width + 26, geometry.height + 6 };
|
||||
}
|
||||
|
||||
void pRadioBox::setChecked() {
|
||||
locked = true;
|
||||
foreach(item, radioBox.state.group) {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pVerticalSlider::minimumGeometry() {
|
||||
return { 0, 0, 20, 0 };
|
||||
}
|
||||
|
||||
unsigned pVerticalSlider::position() {
|
||||
return qtSlider->value();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
Font& pWidget::font() {
|
||||
if(widget.state.font) return *widget.state.font;
|
||||
return pOS::defaultFont;
|
||||
}
|
||||
|
||||
Geometry pWidget::minimumGeometry() {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
void pWidget::setEnabled(bool enabled) {
|
||||
qtWidget->setEnabled(enabled);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pFont::geometry(const string &text) {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
void pFont::setBold(bool bold) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "reference.hpp"
|
||||
|
||||
#include "font.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
@@ -13,6 +14,7 @@
|
||||
|
||||
#include "widget/widget.cpp"
|
||||
#include "widget/button.cpp"
|
||||
#include "widget/canvas.cpp"
|
||||
#include "widget/check-box.cpp"
|
||||
#include "widget/combo-box.cpp"
|
||||
#include "widget/hex-edit.cpp"
|
||||
|
||||
@@ -29,6 +29,7 @@ struct pOS : public pObject {
|
||||
struct pFont : public pObject {
|
||||
Font &font;
|
||||
|
||||
Geometry geometry(const string &text);
|
||||
void setBold(bool bold);
|
||||
void setFamily(const string &family);
|
||||
void setItalic(bool italic);
|
||||
@@ -39,6 +40,16 @@ struct pFont : public pObject {
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pTimer : public pObject {
|
||||
Timer &timer;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
||||
pTimer(Timer &timer) : timer(timer) {}
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pMessageWindow : public pObject {
|
||||
static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
@@ -136,6 +147,8 @@ struct pWidget : public pObject {
|
||||
Widget &widget;
|
||||
|
||||
bool enabled();
|
||||
Font& font();
|
||||
Geometry minimumGeometry();
|
||||
void setEnabled(bool enabled);
|
||||
void setFocused();
|
||||
void setFont(Font &font);
|
||||
@@ -155,6 +168,16 @@ struct pButton : public pWidget {
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pCanvas : public pWidget {
|
||||
Canvas &canvas;
|
||||
|
||||
uint32_t* buffer();
|
||||
void update();
|
||||
|
||||
pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {}
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pCheckBox : public pWidget {
|
||||
CheckBox &checkBox;
|
||||
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
void pTimer::setEnabled(bool enabled) {
|
||||
}
|
||||
|
||||
void pTimer::setInterval(unsigned milliseconds) {
|
||||
}
|
||||
|
||||
void pTimer::constructor() {
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
uint32_t* pCanvas::buffer() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pCanvas::update() {
|
||||
}
|
||||
|
||||
void pCanvas::constructor() {
|
||||
}
|
||||
@@ -2,6 +2,14 @@ bool pWidget::enabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Font& pWidget::font() {
|
||||
throw;
|
||||
}
|
||||
|
||||
Geometry pWidget::minimumGeometry() {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
void pWidget::setEnabled(bool enabled) {
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,19 @@ static HFONT Font_createFont(const string &family, unsigned size, bool bold, boo
|
||||
);
|
||||
}
|
||||
|
||||
Geometry pFont::geometry(const string &text) {
|
||||
HDC hdc = GetDC(0);
|
||||
SelectObject(hdc, hfont);
|
||||
RECT rc = { 0, 0, 0, 0 };
|
||||
DrawText(hdc, utf16_t(text), -1, &rc, DT_CALCRECT);
|
||||
ReleaseDC(0, hdc);
|
||||
return { 0, 0, rc.right, rc.bottom };
|
||||
}
|
||||
|
||||
unsigned pFont::height() {
|
||||
return geometry(" ").height;
|
||||
}
|
||||
|
||||
void pFont::setBold(bool bold) {
|
||||
if(hfont) { DeleteObject(hfont); hfont = 0; }
|
||||
hfont = Font_createFont(font.state.family, font.state.size, font.state.bold, font.state.italic, font.state.underline);
|
||||
@@ -32,5 +45,5 @@ void pFont::setUnderline(bool underline) {
|
||||
}
|
||||
|
||||
void pFont::constructor() {
|
||||
hfont = 0;
|
||||
hfont = Font_createFont("Tahoma", 8, false, false, false);
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
static linear_vector<pTimer*> timers;
|
||||
|
||||
static void CALLBACK Timer_timeoutProc(HWND hwnd, UINT msg, UINT_PTR timerID, DWORD time) {
|
||||
foreach(timer, timers) {
|
||||
if(timer->htimer == timerID) {
|
||||
if(timer->timer.onTimeout) timer->timer.onTimeout();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pTimer::setEnabled(bool enabled) {
|
||||
if(htimer) {
|
||||
KillTimer(NULL, htimer);
|
||||
htimer = 0;
|
||||
}
|
||||
|
||||
if(enabled == true) {
|
||||
htimer = SetTimer(NULL, 0U, timer.state.milliseconds, Timer_timeoutProc);
|
||||
}
|
||||
}
|
||||
|
||||
void pTimer::setInterval(unsigned milliseconds) {
|
||||
//destroy and recreate timer if interval changed
|
||||
setEnabled(timer.state.enabled);
|
||||
}
|
||||
|
||||
void pTimer::constructor() {
|
||||
timers.append(this);
|
||||
htimer = 0;
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pButton::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(button.state.text);
|
||||
return { 0, 0, geometry.width + 20, font.p.height() + 10 };
|
||||
}
|
||||
|
||||
void pButton::setText(const string &text) {
|
||||
SetWindowText(hwnd, utf16_t(text));
|
||||
}
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
static LRESULT CALLBACK Canvas_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
if(msg == WM_PAINT) {
|
||||
Object *object = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if(object && dynamic_cast<Canvas*>(object)) {
|
||||
Canvas &canvas = (Canvas&)*object;
|
||||
canvas.update();
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
uint32_t* pCanvas::buffer() {
|
||||
return bufferRGB;
|
||||
}
|
||||
|
||||
void pCanvas::setGeometry(const Geometry &geometry) {
|
||||
delete[] bufferRGB;
|
||||
bufferRGB = new uint32_t[geometry.width * geometry.height]();
|
||||
pWidget::setGeometry(geometry);
|
||||
update();
|
||||
}
|
||||
|
||||
void pCanvas::update() {
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
unsigned width = rc.right, height = rc.bottom;
|
||||
|
||||
BITMAPINFO bmi;
|
||||
memset(&bmi, 0, sizeof(BITMAPINFO));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biWidth = width;
|
||||
bmi.bmiHeader.biHeight = -height; //GDI stores bitmaps upside now; negative height flips bitmap
|
||||
bmi.bmiHeader.biSizeImage = sizeof(uint32_t) * width * height;
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
BeginPaint(hwnd, &ps);
|
||||
SetDIBitsToDevice(ps.hdc, 0, 0, width, height, 0, 0, 0, height, (void*)bufferRGB, &bmi, DIB_RGB_COLORS);
|
||||
EndPaint(hwnd, &ps);
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
}
|
||||
|
||||
void pCanvas::constructor() {
|
||||
bufferRGB = new uint32_t[256 * 256]();
|
||||
setParent(Window::None);
|
||||
}
|
||||
|
||||
void pCanvas::setParent(Window &parent) {
|
||||
if(hwnd) DestroyWindow(hwnd);
|
||||
hwnd = CreateWindow(L"phoenix_canvas", L"", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, parent.p.hwnd, (HMENU)id, GetModuleHandle(0), 0);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&canvas);
|
||||
}
|
||||
@@ -2,6 +2,12 @@ bool pCheckBox::checked() {
|
||||
return SendMessage(hwnd, BM_GETCHECK, 0, 0);
|
||||
}
|
||||
|
||||
Geometry pCheckBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(checkBox.state.text);
|
||||
return { 0, 0, geometry.width + 20, font.p.height() + 4 };
|
||||
}
|
||||
|
||||
void pCheckBox::setChecked(bool checked) {
|
||||
SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,13 @@ void pComboBox::append(const string &text) {
|
||||
if(SendMessage(hwnd, CB_GETCOUNT, 0, 0) == 1) setSelection(0);
|
||||
}
|
||||
|
||||
Geometry pComboBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
unsigned maximumWidth = 0;
|
||||
foreach(text, comboBox.state.text) maximumWidth = max(maximumWidth, font.geometry(text).width);
|
||||
return { 0, 0, maximumWidth + 24, font.p.height() + 10 };
|
||||
}
|
||||
|
||||
void pComboBox::reset() {
|
||||
SendMessage(hwnd, CB_RESETCONTENT, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pHorizontalSlider::minimumGeometry() {
|
||||
return { 0, 0, 0, 25 };
|
||||
}
|
||||
|
||||
unsigned pHorizontalSlider::position() {
|
||||
return SendMessage(hwnd, TBM_GETPOS, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pLabel::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(label.state.text);
|
||||
return { 0, 0, geometry.width, geometry.height };
|
||||
}
|
||||
|
||||
void pLabel::setText(const string &text) {
|
||||
SetWindowText(hwnd, utf16_t(text));
|
||||
InvalidateRect(hwnd, 0, false);
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
Geometry pLineEdit::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(lineEdit.state.text);
|
||||
return { 0, 0, geometry.width + 12, font.p.height() + 10 };
|
||||
}
|
||||
|
||||
void pLineEdit::setEditable(bool editable) {
|
||||
SendMessage(hwnd, EM_SETREADONLY, editable == false, 0);
|
||||
}
|
||||
@@ -13,7 +19,7 @@ string pLineEdit::text() {
|
||||
wchar_t text[length + 1];
|
||||
GetWindowText(hwnd, text, length + 1);
|
||||
text[length] = 0;
|
||||
return utf8_t(text);
|
||||
return (const char*)utf8_t(text);
|
||||
}
|
||||
|
||||
void pLineEdit::constructor() {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pProgressBar::minimumGeometry() {
|
||||
return { 0, 0, 0, 23 };
|
||||
}
|
||||
|
||||
void pProgressBar::setPosition(unsigned position) {
|
||||
SendMessage(hwnd, PBM_SETPOS, (WPARAM)position, 0);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ bool pRadioBox::checked() {
|
||||
return SendMessage(hwnd, BM_GETCHECK, 0, 0);
|
||||
}
|
||||
|
||||
Geometry pRadioBox::minimumGeometry() {
|
||||
Font &font = this->font();
|
||||
Geometry geometry = font.geometry(radioBox.state.text);
|
||||
return { 0, 0, geometry.width + 20, font.p.height() + 4 };
|
||||
}
|
||||
|
||||
void pRadioBox::setChecked() {
|
||||
foreach(item, radioBox.state.group) {
|
||||
SendMessage(item.p.hwnd, BM_SETCHECK, (WPARAM)(&item == &radioBox), 0);
|
||||
|
||||
@@ -29,7 +29,7 @@ string pTextEdit::text() {
|
||||
wchar_t buffer[length + 1];
|
||||
GetWindowText(hwnd, buffer, length + 1);
|
||||
buffer[length] = 0;
|
||||
string text = utf8_t(buffer);
|
||||
string text = (const char*)utf8_t(buffer);
|
||||
text.replace("\r", "");
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
Geometry pVerticalSlider::minimumGeometry() {
|
||||
return { 0, 0, 25, 0 };
|
||||
}
|
||||
|
||||
unsigned pVerticalSlider::position() {
|
||||
return SendMessage(hwnd, TBM_GETPOS, 0, 0);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,15 @@ bool pWidget::enabled() {
|
||||
return IsWindowEnabled(hwnd);
|
||||
}
|
||||
|
||||
Font& pWidget::font() {
|
||||
if(widget.state.font) return *widget.state.font;
|
||||
return pOS::state->defaultFont;
|
||||
}
|
||||
|
||||
Geometry pWidget::minimumGeometry() {
|
||||
return { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
void pWidget::setEnabled(bool enabled) {
|
||||
EnableWindow(hwnd, enabled);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,11 @@ Geometry pWindow::frameMargin() {
|
||||
|
||||
Geometry pWindow::geometry() {
|
||||
Geometry margin = frameMargin();
|
||||
RECT rc;
|
||||
GetWindowRect(hwnd, &rc);
|
||||
|
||||
//note: GetWindowRect returns -32000(x),-32000(y) when window is minimized
|
||||
WINDOWPLACEMENT wp;
|
||||
GetWindowPlacement(hwnd, &wp);
|
||||
RECT rc = wp.rcNormalPosition;
|
||||
|
||||
signed x = rc.left + margin.x;
|
||||
signed y = rc.top + margin.y;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "object.cpp"
|
||||
#include "font.cpp"
|
||||
#include "timer.cpp"
|
||||
#include "message-window.cpp"
|
||||
#include "window.cpp"
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
|
||||
#include "widget/widget.cpp"
|
||||
#include "widget/button.cpp"
|
||||
#include "widget/canvas.cpp"
|
||||
#include "widget/check-box.cpp"
|
||||
#include "widget/combo-box.cpp"
|
||||
#include "widget/hex-edit.cpp"
|
||||
@@ -80,7 +82,7 @@ static string pOS_fileDialog(bool save, Window &parent, const string &path, cons
|
||||
|
||||
bool result = (save == false ? GetOpenFileName(&ofn) : GetSaveFileName(&ofn));
|
||||
if(result == false) return "";
|
||||
string name = utf8_t(wfilename);
|
||||
string name = (const char*)utf8_t(wfilename);
|
||||
name.transform("\\", "/");
|
||||
return name;
|
||||
}
|
||||
@@ -117,7 +119,7 @@ string pOS::folderSelect(Window &parent, const string &path) {
|
||||
}
|
||||
}
|
||||
if(result == false) return "";
|
||||
string name = utf8_t(wfilename);
|
||||
string name = (const char*)utf8_t(wfilename);
|
||||
if(name == "") return "";
|
||||
name.transform("\\", "/");
|
||||
if(name.endswith("/") == false) name.append("/");
|
||||
@@ -183,6 +185,18 @@ void pOS::initialize() {
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
RegisterClass(&wc);
|
||||
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hInstance = GetModuleHandle(0);
|
||||
wc.lpfnWndProc = Canvas_windowProc;
|
||||
wc.lpszClassName = L"phoenix_canvas";
|
||||
wc.lpszMenuName = 0;
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
RegisterClass(&wc);
|
||||
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
||||
|
||||
@@ -37,6 +37,8 @@ struct pFont : public pObject {
|
||||
Font &font;
|
||||
HFONT hfont;
|
||||
|
||||
Geometry geometry(const string &text);
|
||||
unsigned height();
|
||||
void setBold(bool bold);
|
||||
void setFamily(const string &family);
|
||||
void setItalic(bool italic);
|
||||
@@ -47,6 +49,17 @@ struct pFont : public pObject {
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pTimer : public pObject {
|
||||
Timer &timer;
|
||||
UINT_PTR htimer;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setInterval(unsigned milliseconds);
|
||||
|
||||
pTimer(Timer &timer) : timer(timer) {}
|
||||
void constructor();
|
||||
};
|
||||
|
||||
struct pMessageWindow : public pObject {
|
||||
static MessageWindow::Response information(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
static MessageWindow::Response question(Window &parent, const string &text, MessageWindow::Buttons buttons);
|
||||
@@ -155,6 +168,8 @@ struct pWidget : public pObject {
|
||||
HWND hwnd;
|
||||
|
||||
bool enabled();
|
||||
Font& font();
|
||||
virtual Geometry minimumGeometry();
|
||||
void setEnabled(bool enabled);
|
||||
void setFocused();
|
||||
void setFont(Font &font);
|
||||
@@ -170,6 +185,7 @@ struct pWidget : public pObject {
|
||||
struct pButton : public pWidget {
|
||||
Button &button;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pButton(Button &button) : pWidget(button), button(button) {}
|
||||
@@ -177,10 +193,24 @@ struct pButton : public pWidget {
|
||||
void setParent(Window &parent);
|
||||
};
|
||||
|
||||
struct pCanvas : public pWidget {
|
||||
Canvas &canvas;
|
||||
uint32_t *bufferRGB;
|
||||
|
||||
uint32_t* buffer();
|
||||
void setGeometry(const Geometry &geometry);
|
||||
void update();
|
||||
|
||||
pCanvas(Canvas &canvas) : pWidget(canvas), canvas(canvas) {}
|
||||
void constructor();
|
||||
void setParent(Window &parent);
|
||||
};
|
||||
|
||||
struct pCheckBox : public pWidget {
|
||||
CheckBox &checkBox;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked(bool checked);
|
||||
void setText(const string &text);
|
||||
|
||||
@@ -193,6 +223,7 @@ struct pComboBox : public pWidget {
|
||||
ComboBox &comboBox;
|
||||
|
||||
void append(const string &text);
|
||||
Geometry minimumGeometry();
|
||||
void reset();
|
||||
unsigned selection();
|
||||
void setSelection(unsigned row);
|
||||
@@ -222,6 +253,7 @@ struct pHexEdit : public pWidget {
|
||||
struct pHorizontalSlider : public pWidget {
|
||||
HorizontalSlider &horizontalSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
@@ -234,6 +266,7 @@ struct pHorizontalSlider : public pWidget {
|
||||
struct pLabel : public pWidget {
|
||||
Label &label;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setText(const string &text);
|
||||
|
||||
pLabel(Label &label) : pWidget(label), label(label) {}
|
||||
@@ -244,6 +277,7 @@ struct pLabel : public pWidget {
|
||||
struct pLineEdit : public pWidget {
|
||||
LineEdit &lineEdit;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setEditable(bool editable);
|
||||
void setText(const string &text);
|
||||
string text();
|
||||
@@ -280,6 +314,7 @@ struct pListView : public pWidget {
|
||||
struct pProgressBar : public pWidget {
|
||||
ProgressBar &progressBar;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
void setPosition(unsigned position);
|
||||
|
||||
pProgressBar(ProgressBar &progressBar) : pWidget(progressBar), progressBar(progressBar) {}
|
||||
@@ -291,6 +326,7 @@ struct pRadioBox : public pWidget {
|
||||
RadioBox &radioBox;
|
||||
|
||||
bool checked();
|
||||
Geometry minimumGeometry();
|
||||
void setChecked();
|
||||
void setGroup(const reference_array<RadioBox&> &group);
|
||||
void setText(const string &text);
|
||||
@@ -317,6 +353,7 @@ struct pTextEdit : public pWidget {
|
||||
struct pVerticalSlider : public pWidget {
|
||||
VerticalSlider &verticalSlider;
|
||||
|
||||
Geometry minimumGeometry();
|
||||
unsigned position();
|
||||
void setLength(unsigned length);
|
||||
void setPosition(unsigned position);
|
||||
|
||||
@@ -342,7 +342,7 @@ public:
|
||||
|
||||
//per MSDN: XInput devices have "IG_" in their device strings,
|
||||
//which is how they should be identified.
|
||||
string p = utf8_t(pool[i].name);
|
||||
string p = (const char*)utf8_t(pool[i].name);
|
||||
if(auto position = strpos(p, "IG_")) {
|
||||
lgamepad[n].isXInputDevice = true;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <ruby/ruby.hpp>
|
||||
using namespace nall;
|
||||
|
||||
#undef mkdir
|
||||
#undef usleep
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
ruby
|
||||
version: 0.06 (2009-05-22)
|
||||
version: 0.06a (2011-02-27)
|
||||
license: public domain
|
||||
*/
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace nall;
|
||||
|
||||
/* Video */
|
||||
|
||||
#define DeclareVideo(Name) \
|
||||
|
||||
+19
-17
@@ -1,11 +1,11 @@
|
||||
snes_objects := snes-system
|
||||
snes_objects := snes-system snes-controller
|
||||
snes_objects += snes-cartridge snes-cheat
|
||||
snes_objects += snes-memory snes-cpucore snes-smpcore
|
||||
snes_objects += snes-cpu snes-smp snes-dsp snes-ppu
|
||||
snes_objects += snes-icd2 snes-superfx snes-sa1 snes-necdsp
|
||||
snes_objects += snes-bsx snes-srtc snes-sdd1 snes-spc7110 snes-cx4
|
||||
snes_objects += snes-nss snes-icd2 snes-superfx snes-sa1 snes-necdsp snes-hitachidsp
|
||||
snes_objects += snes-bsx snes-srtc snes-sdd1 snes-spc7110
|
||||
snes_objects += snes-obc1 snes-st0018 snes-sufamiturbo
|
||||
snes_objects += snes-msu1 snes-serial
|
||||
snes_objects += snes-msu1 snes-link
|
||||
objects += $(snes_objects)
|
||||
|
||||
ifeq ($(profile),accuracy)
|
||||
@@ -23,33 +23,35 @@ else ifeq ($(profile),compatibility)
|
||||
else ifeq ($(profile),performance)
|
||||
flags += -DPROFILE_PERFORMANCE
|
||||
snescpu := $(snes)/alt/cpu
|
||||
snessmp := $(snes)/smp
|
||||
snessmp := $(snes)/alt/smp
|
||||
snesdsp := $(snes)/alt/dsp
|
||||
snesppu := $(snes)/alt/ppu-performance
|
||||
endif
|
||||
|
||||
obj/snes-system.o : $(snes)/system/system.cpp $(call rwildcard,$(snes)/system/) $(call rwildcard,$(snes)/video/)
|
||||
obj/snes-memory.o : $(snes)/memory/memory.cpp $(call rwildcard,$(snes)/memory/)
|
||||
obj/snes-cpucore.o : $(snes)/cpu/core/core.cpp $(call rwildcard,$(snes)/cpu/core/)
|
||||
obj/snes-smpcore.o : $(snes)/smp/core/core.cpp $(call rwildcard,$(snes)/smp/core/)
|
||||
obj/snes-cpu.o : $(snescpu)/cpu.cpp $(call rwildcard,$(snescpu)/)
|
||||
obj/snes-smp.o : $(snessmp)/smp.cpp $(call rwildcard,$(snessmp)/)
|
||||
obj/snes-dsp.o : $(snesdsp)/dsp.cpp $(call rwildcard,$(snesdsp)/)
|
||||
obj/snes-ppu.o : $(snesppu)/ppu.cpp $(call rwildcard,$(snesppu)/)
|
||||
obj/snes-cartridge.o: $(snes)/cartridge/cartridge.cpp $(snes)/cartridge/*
|
||||
obj/snes-cheat.o : $(snes)/cheat/cheat.cpp $(snes)/cheat/*
|
||||
obj/snes-system.o : $(snes)/system/system.cpp $(call rwildcard,$(snes)/system/) $(call rwildcard,$(snes)/video/) $(call rwildcard,$(snes)/audio/) $(call rwildcard,$(snes)/input/)
|
||||
obj/snes-controller.o: $(snes)/controller/controller.cpp $(call rwildcard,$(snes)/controller/)
|
||||
obj/snes-memory.o : $(snes)/memory/memory.cpp $(call rwildcard,$(snes)/memory/)
|
||||
obj/snes-cpucore.o : $(snes)/cpu/core/core.cpp $(call rwildcard,$(snes)/cpu/core/)
|
||||
obj/snes-smpcore.o : $(snes)/smp/core/core.cpp $(call rwildcard,$(snes)/smp/core/)
|
||||
obj/snes-cpu.o : $(snescpu)/cpu.cpp $(call rwildcard,$(snescpu)/)
|
||||
obj/snes-smp.o : $(snessmp)/smp.cpp $(call rwildcard,$(snessmp)/)
|
||||
obj/snes-dsp.o : $(snesdsp)/dsp.cpp $(call rwildcard,$(snesdsp)/)
|
||||
obj/snes-ppu.o : $(snesppu)/ppu.cpp $(call rwildcard,$(snesppu)/)
|
||||
obj/snes-cartridge.o : $(snes)/cartridge/cartridge.cpp $(snes)/cartridge/*
|
||||
obj/snes-cheat.o : $(snes)/cheat/cheat.cpp $(snes)/cheat/*
|
||||
|
||||
obj/snes-nss.o : $(snes)/chip/nss/nss.cpp $(call rwildcard,$(snes)/chip/nss/)
|
||||
obj/snes-icd2.o : $(snes)/chip/icd2/icd2.cpp $(call rwildcard,$(snes)/chip/icd2/)
|
||||
obj/snes-superfx.o : $(snes)/chip/superfx/superfx.cpp $(call rwildcard,$(snes)/chip/superfx/)
|
||||
obj/snes-sa1.o : $(snes)/chip/sa1/sa1.cpp $(call rwildcard,$(snes)/chip/sa1/)
|
||||
obj/snes-necdsp.o : $(snes)/chip/necdsp/necdsp.cpp $(call rwildcard,$(snes)/chip/necdsp/)
|
||||
obj/snes-hitachidsp.o : $(snes)/chip/hitachidsp/hitachidsp.cpp $(call rwildcard,$(snes)/chip/hitachidsp/)
|
||||
obj/snes-bsx.o : $(snes)/chip/bsx/bsx.cpp $(call rwildcard,$(snes)/chip/bsx/)
|
||||
obj/snes-srtc.o : $(snes)/chip/srtc/srtc.cpp $(snes)/chip/srtc/*
|
||||
obj/snes-sdd1.o : $(snes)/chip/sdd1/sdd1.cpp $(snes)/chip/sdd1/*
|
||||
obj/snes-spc7110.o : $(snes)/chip/spc7110/spc7110.cpp $(snes)/chip/spc7110/*
|
||||
obj/snes-cx4.o : $(snes)/chip/cx4/cx4.cpp $(snes)/chip/cx4/*
|
||||
obj/snes-obc1.o : $(snes)/chip/obc1/obc1.cpp $(snes)/chip/obc1/*
|
||||
obj/snes-st0018.o : $(snes)/chip/st0018/st0018.cpp $(snes)/chip/st0018/*
|
||||
obj/snes-sufamiturbo.o: $(snes)/chip/sufamiturbo/sufamiturbo.cpp $(snes)/chip/sufamiturbo/*
|
||||
obj/snes-msu1.o : $(snes)/chip/msu1/msu1.cpp $(snes)/chip/msu1/*
|
||||
obj/snes-serial.o : $(snes)/chip/serial/serial.cpp $(snes)/chip/serial/*
|
||||
obj/snes-link.o : $(snes)/chip/link/link.cpp $(snes)/chip/link/*
|
||||
@@ -23,6 +23,9 @@ void CPU::step(unsigned clocks) {
|
||||
Processor &chip = *coprocessors[i];
|
||||
chip.clock -= clocks * (uint64)chip.frequency;
|
||||
}
|
||||
input.port1->clock -= clocks * (uint64)input.port1->frequency;
|
||||
input.port2->clock -= clocks * (uint64)input.port2->frequency;
|
||||
synchronize_controllers();
|
||||
}
|
||||
|
||||
void CPU::synchronize_smp() {
|
||||
@@ -41,13 +44,18 @@ void CPU::synchronize_ppu() {
|
||||
}
|
||||
}
|
||||
|
||||
void CPU::synchronize_coprocessor() {
|
||||
void CPU::synchronize_coprocessors() {
|
||||
for(unsigned i = 0; i < coprocessors.size(); i++) {
|
||||
Processor &chip = *coprocessors[i];
|
||||
if(chip.clock < 0) co_switch(chip.thread);
|
||||
}
|
||||
}
|
||||
|
||||
void CPU::synchronize_controllers() {
|
||||
if(input.port1->clock < 0) co_switch(input.port1->thread);
|
||||
if(input.port2->clock < 0) co_switch(input.port2->thread);
|
||||
}
|
||||
|
||||
void CPU::Enter() { cpu.enter(); }
|
||||
|
||||
void CPU::enter() {
|
||||
|
||||
@@ -7,7 +7,8 @@ public:
|
||||
alwaysinline void step(unsigned clocks);
|
||||
alwaysinline void synchronize_smp();
|
||||
void synchronize_ppu();
|
||||
void synchronize_coprocessor();
|
||||
void synchronize_coprocessors();
|
||||
void synchronize_controllers();
|
||||
|
||||
uint8 pio();
|
||||
bool joylatch();
|
||||
@@ -41,7 +42,6 @@ private:
|
||||
enum : unsigned {
|
||||
DramRefresh,
|
||||
HdmaRun,
|
||||
ControllerLatch,
|
||||
};
|
||||
};
|
||||
nall::priority_queue<unsigned> queue;
|
||||
|
||||
@@ -15,13 +15,13 @@ uint8 CPU::mmio_read(unsigned addr) {
|
||||
|
||||
case 0x4016: {
|
||||
uint8 result = regs.mdr & 0xfc;
|
||||
result |= input.port_read(0) & 3;
|
||||
result |= input.port1->data() & 3;
|
||||
return result;
|
||||
}
|
||||
|
||||
case 0x4017: {
|
||||
uint8 result = (regs.mdr & 0xe0) | 0x1c;
|
||||
result |= input.port_read(1) & 3;
|
||||
result |= input.port2->data() & 3;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -127,10 +127,8 @@ void CPU::mmio_write(unsigned addr, uint8 data) {
|
||||
}
|
||||
|
||||
case 0x4016: {
|
||||
bool old_latch = status.joypad_strobe_latch;
|
||||
bool new_latch = data & 1;
|
||||
status.joypad_strobe_latch = new_latch;
|
||||
if(old_latch != new_latch) input.poll();
|
||||
input.port1->latch(data & 1);
|
||||
input.port2->latch(data & 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ void CPU::queue_event(unsigned id) {
|
||||
switch(id) {
|
||||
case QueueEvent::DramRefresh: return add_clocks(40);
|
||||
case QueueEvent::HdmaRun: return hdma_run();
|
||||
case QueueEvent::ControllerLatch: return ppu.latch_counters();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +61,7 @@ void CPU::add_clocks(unsigned clocks) {
|
||||
void CPU::scanline() {
|
||||
synchronize_smp();
|
||||
synchronize_ppu();
|
||||
synchronize_coprocessor();
|
||||
synchronize_coprocessors();
|
||||
system.scanline();
|
||||
|
||||
if(vcounter() == 0) hdma_init();
|
||||
@@ -73,10 +72,6 @@ void CPU::scanline() {
|
||||
queue.enqueue(1104 + 8, QueueEvent::HdmaRun);
|
||||
}
|
||||
|
||||
if(vcounter() == input.latchy) {
|
||||
queue.enqueue(input.latchx, QueueEvent::ControllerLatch);
|
||||
}
|
||||
|
||||
bool nmi_valid = status.nmi_valid;
|
||||
status.nmi_valid = vcounter() >= (ppu.overscan() == false ? 225 : 240);
|
||||
if(!nmi_valid && status.nmi_valid) {
|
||||
@@ -87,16 +82,20 @@ void CPU::scanline() {
|
||||
}
|
||||
|
||||
if(status.auto_joypad_poll_enabled && vcounter() == (ppu.overscan() == false ? 227 : 242)) {
|
||||
input.poll();
|
||||
run_auto_joypad_poll();
|
||||
}
|
||||
}
|
||||
|
||||
void CPU::run_auto_joypad_poll() {
|
||||
input.port1->latch(1);
|
||||
input.port2->latch(1);
|
||||
input.port1->latch(0);
|
||||
input.port2->latch(0);
|
||||
|
||||
uint16 joy1 = 0, joy2 = 0, joy3 = 0, joy4 = 0;
|
||||
for(unsigned i = 0; i < 16; i++) {
|
||||
uint8 port0 = input.port_read(0);
|
||||
uint8 port1 = input.port_read(1);
|
||||
uint8 port0 = input.port1->data();
|
||||
uint8 port1 = input.port2->data();
|
||||
|
||||
joy1 |= (port0 & 1) ? (0x8000 >> i) : 0;
|
||||
joy2 |= (port1 & 1) ? (0x8000 >> i) : 0;
|
||||
|
||||
@@ -96,13 +96,16 @@ inline void PPU::render_line_output() {
|
||||
}
|
||||
} else {
|
||||
for(unsigned x = 0, prev = 0; x < 256; x++) {
|
||||
//blending is disabled below, as this should be done via video filtering
|
||||
//blending code is left for reference purposes
|
||||
|
||||
curr = luma[get_pixel_swap(x)];
|
||||
*ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1;
|
||||
prev = curr;
|
||||
*ptr++ = curr; //(prev + curr - ((prev ^ curr) & 0x0421)) >> 1;
|
||||
//prev = curr;
|
||||
|
||||
curr = luma[get_pixel_normal(x)];
|
||||
*ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1;
|
||||
prev = curr;
|
||||
*ptr++ = curr; //(prev + curr - ((prev ^ curr) & 0x0421)) >> 1;
|
||||
//prev = curr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+122
@@ -0,0 +1,122 @@
|
||||
uint8 SMP::op_adc(uint8 x, uint8 y) {
|
||||
int r = x + y + regs.p.c;
|
||||
regs.p.n = r & 0x80;
|
||||
regs.p.v = ~(x ^ y) & (x ^ r) & 0x80;
|
||||
regs.p.h = (x ^ y ^ r) & 0x10;
|
||||
regs.p.z = (uint8)r == 0;
|
||||
regs.p.c = r > 0xff;
|
||||
return r;
|
||||
}
|
||||
|
||||
uint16 SMP::op_addw(uint16 x, uint16 y) {
|
||||
uint16 r;
|
||||
regs.p.c = 0;
|
||||
r = op_adc(x, y);
|
||||
r |= op_adc(x >> 8, y >> 8) << 8;
|
||||
regs.p.z = r == 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
uint8 SMP::op_and(uint8 x, uint8 y) {
|
||||
x &= y;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_cmp(uint8 x, uint8 y) {
|
||||
int r = x - y;
|
||||
regs.p.n = r & 0x80;
|
||||
regs.p.z = (uint8)r == 0;
|
||||
regs.p.c = r >= 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint16 SMP::op_cmpw(uint16 x, uint16 y) {
|
||||
int r = x - y;
|
||||
regs.p.n = r & 0x8000;
|
||||
regs.p.z = (uint16)r == 0;
|
||||
regs.p.c = r >= 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_eor(uint8 x, uint8 y) {
|
||||
x ^= y;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_or(uint8 x, uint8 y) {
|
||||
x |= y;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_sbc(uint8 x, uint8 y) {
|
||||
int r = x - y - !regs.p.c;
|
||||
regs.p.n = r & 0x80;
|
||||
regs.p.v = (x ^ y) & (x ^ r) & 0x80;
|
||||
regs.p.h = !((x ^ y ^ r) & 0x10);
|
||||
regs.p.z = (uint8)r == 0;
|
||||
regs.p.c = r >= 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
uint16 SMP::op_subw(uint16 x, uint16 y) {
|
||||
uint16 r;
|
||||
regs.p.c = 1;
|
||||
r = op_sbc(x, y);
|
||||
r |= op_sbc(x >> 8, y >> 8) << 8;
|
||||
regs.p.z = r == 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
uint8 SMP::op_inc(uint8 x) {
|
||||
x++;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_dec(uint8 x) {
|
||||
x--;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_asl(uint8 x) {
|
||||
regs.p.c = x & 0x80;
|
||||
x <<= 1;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_lsr(uint8 x) {
|
||||
regs.p.c = x & 0x01;
|
||||
x >>= 1;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_rol(uint8 x) {
|
||||
unsigned carry = (unsigned)regs.p.c;
|
||||
regs.p.c = x & 0x80;
|
||||
x = (x << 1) | carry;
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint8 SMP::op_ror(uint8 x) {
|
||||
unsigned carry = (unsigned)regs.p.c << 7;
|
||||
regs.p.c = x & 0x01;
|
||||
x = carry | (x >> 1);
|
||||
regs.p.n = x & 0x80;
|
||||
regs.p.z = x == 0;
|
||||
return x;
|
||||
}
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
void SMP::tick() {
|
||||
timer0.tick();
|
||||
timer1.tick();
|
||||
timer2.tick();
|
||||
|
||||
clock += cycle_step_cpu;
|
||||
dsp.clock -= 24;
|
||||
synchronize_dsp();
|
||||
}
|
||||
|
||||
void SMP::op_io() {
|
||||
#if defined(CYCLE_ACCURATE)
|
||||
tick();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8 SMP::op_read(uint16 addr) {
|
||||
#if defined(CYCLE_ACCURATE)
|
||||
tick();
|
||||
#endif
|
||||
if((addr & 0xfff0) == 0x00f0) return mmio_read(addr);
|
||||
if(addr >= 0xffc0 && status.iplrom_enable) return iplrom[addr & 0x3f];
|
||||
return apuram[addr];
|
||||
}
|
||||
|
||||
void SMP::op_write(uint16 addr, uint8 data) {
|
||||
#if defined(CYCLE_ACCURATE)
|
||||
tick();
|
||||
#endif
|
||||
if((addr & 0xfff0) == 0x00f0) mmio_write(addr, data);
|
||||
apuram[addr] = data; //all writes go to RAM, even MMIO writes
|
||||
}
|
||||
|
||||
void SMP::op_step() {
|
||||
#define op_readpc() op_read(regs.pc++)
|
||||
#define op_readdp(addr) op_read((regs.p.p << 8) + addr)
|
||||
#define op_writedp(addr, data) op_write((regs.p.p << 8) + addr, data)
|
||||
#define op_readaddr(addr) op_read(addr)
|
||||
#define op_writeaddr(addr, data) op_write(addr, data)
|
||||
#define op_readstack() op_read(0x0100 | ++regs.sp)
|
||||
#define op_writestack(data) op_write(0x0100 | regs.sp--, data)
|
||||
static unsigned rd, wr, dp, sp, ya, bit;
|
||||
|
||||
#if defined(CYCLE_ACCURATE)
|
||||
|
||||
if(opcode_cycle == 0) {
|
||||
opcode_number = op_readpc();
|
||||
opcode_cycle++;
|
||||
} else switch(opcode_number) {
|
||||
#include "core/opcycle_misc.cpp"
|
||||
#include "core/opcycle_mov.cpp"
|
||||
#include "core/opcycle_pc.cpp"
|
||||
#include "core/opcycle_read.cpp"
|
||||
#include "core/opcycle_rmw.cpp"
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
unsigned opcode = op_readpc();
|
||||
switch(opcode) {
|
||||
#include "core/op_misc.cpp"
|
||||
#include "core/op_mov.cpp"
|
||||
#include "core/op_pc.cpp"
|
||||
#include "core/op_read.cpp"
|
||||
#include "core/op_rmw.cpp"
|
||||
}
|
||||
|
||||
//TODO: untaken branches should consume less cycles
|
||||
|
||||
timer0.tick(cycle_count_table[opcode]);
|
||||
timer1.tick(cycle_count_table[opcode]);
|
||||
timer2.tick(cycle_count_table[opcode]);
|
||||
|
||||
clock += cycle_table_cpu[opcode];
|
||||
dsp.clock -= cycle_table_dsp[opcode];
|
||||
synchronize_dsp();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
const unsigned SMP::cycle_count_table[256] = {
|
||||
#define c 12
|
||||
//0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,4,6,8, //0
|
||||
4,8,4,7, 4,5,5,6, 5,5,6,5, 2,2,4,6, //1
|
||||
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,4,7,4, //2
|
||||
4,8,4,7, 4,5,5,6, 5,5,6,5, 2,2,3,8, //3
|
||||
|
||||
2,8,4,7, 3,4,3,6, 2,6,4,4, 5,4,6,6, //4
|
||||
4,8,4,7, 4,5,5,6, 5,5,4,5, 2,2,4,3, //5
|
||||
2,8,4,7, 3,4,3,6, 2,6,4,4, 5,4,7,5, //6
|
||||
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,3,6, //7
|
||||
|
||||
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,2,4,5, //8
|
||||
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,c,5, //9
|
||||
3,8,4,7, 3,4,3,6, 2,6,4,4, 5,2,4,4, //A
|
||||
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,3,4, //B
|
||||
|
||||
3,8,4,7, 4,5,4,7, 2,5,6,4, 5,2,4,9, //C
|
||||
4,8,4,7, 5,6,6,7, 4,5,5,5, 2,2,8,3, //D
|
||||
2,8,4,7, 3,4,3,6, 2,4,5,3, 4,3,4,1, //E
|
||||
4,8,4,7, 4,5,5,6, 3,4,5,4, 2,2,6,1, //F
|
||||
|
||||
#undef c
|
||||
};
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
g++-4.5 -std=gnu++0x -I../../../.. -o generate generate.cpp
|
||||
Executable
+154
@@ -0,0 +1,154 @@
|
||||
#include <nall/file.hpp>
|
||||
#include <nall/stdint.hpp>
|
||||
#include <nall/string.hpp>
|
||||
using namespace nall;
|
||||
|
||||
static bool cycle_accurate;
|
||||
|
||||
struct opcode_t {
|
||||
string name;
|
||||
lstring args;
|
||||
unsigned opcode;
|
||||
};
|
||||
|
||||
void generate(const char *sourceFilename, const char *targetFilename) {
|
||||
file fp;
|
||||
fp.open(targetFilename, file::mode::write);
|
||||
|
||||
string filedata;
|
||||
filedata.readfile(sourceFilename);
|
||||
filedata.replace("\r", "");
|
||||
|
||||
lstring block;
|
||||
block.split("\n\n", filedata);
|
||||
|
||||
foreach(data, block) {
|
||||
lstring lines;
|
||||
lines.split("\n", data);
|
||||
|
||||
linear_vector<opcode_t> array;
|
||||
|
||||
unsigned sourceStart = 0;
|
||||
foreach(line, lines, currentLine) {
|
||||
line.transform("()", "``");
|
||||
lstring part;
|
||||
part.split("`", line);
|
||||
lstring arguments;
|
||||
arguments.split(", ", part[1]);
|
||||
|
||||
opcode_t opcode;
|
||||
opcode.name = part[0];
|
||||
opcode.args = arguments;
|
||||
opcode.opcode = hex(arguments[0]);
|
||||
array.append(opcode);
|
||||
|
||||
line.rtrim<1>(",");
|
||||
if(line.endswith(" {")) {
|
||||
line.rtrim<1>("{ ");
|
||||
sourceStart = currentLine + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(cycle_accurate == false) {
|
||||
foreach(opcode, array) {
|
||||
fp.print("case 0x", hex<2>(opcode.opcode), ": {\n");
|
||||
|
||||
for(unsigned n = sourceStart; n < lines.size(); n++) {
|
||||
if(lines[n] == "}") break;
|
||||
|
||||
string output;
|
||||
|
||||
if(lines[n].beginswith(" ")) {
|
||||
output = lines[n];
|
||||
} else {
|
||||
lstring part;
|
||||
part.split<1>(":", lines[n]);
|
||||
output = { " ", part[1] };
|
||||
}
|
||||
|
||||
output.replace("$1", opcode.args[1]);
|
||||
output.replace("$2", opcode.args[2]);
|
||||
output.replace("$3", opcode.args[3]);
|
||||
output.replace("$4", opcode.args[4]);
|
||||
output.replace("$5", opcode.args[5]);
|
||||
output.replace("$6", opcode.args[6]);
|
||||
output.replace("$7", opcode.args[7]);
|
||||
output.replace("$8", opcode.args[8]);
|
||||
output.replace("end;", "break;");
|
||||
|
||||
fp.print(output, "\n");
|
||||
}
|
||||
|
||||
fp.print(" break;\n");
|
||||
fp.print("}\n\n");
|
||||
}
|
||||
} else {
|
||||
foreach(opcode, array) {
|
||||
fp.print("case 0x", hex<2>(opcode.opcode), ": {\n");
|
||||
fp.print(" switch(opcode_cycle++) {\n");
|
||||
|
||||
for(unsigned n = sourceStart; n < lines.size(); n++) {
|
||||
if(lines[n] == "}") break;
|
||||
|
||||
bool nextLineEndsCycle = false;
|
||||
if(lines[n + 1] == "}") nextLineEndsCycle = true;
|
||||
if(lines[n + 1].beginswith(" ") == false) nextLineEndsCycle = true;
|
||||
|
||||
string output;
|
||||
|
||||
if(lines[n].beginswith(" ")) {
|
||||
output = { " ", lines[n] };
|
||||
} else {
|
||||
lstring part;
|
||||
part.split<1>(":", lines[n]);
|
||||
fp.print(" case ", (unsigned)decimal(part[0]), ":\n");
|
||||
output = { " ", part[1] };
|
||||
}
|
||||
|
||||
output.replace("$1", opcode.args[1]);
|
||||
output.replace("$2", opcode.args[2]);
|
||||
output.replace("$3", opcode.args[3]);
|
||||
output.replace("$4", opcode.args[4]);
|
||||
output.replace("$5", opcode.args[5]);
|
||||
output.replace("$6", opcode.args[6]);
|
||||
output.replace("$7", opcode.args[7]);
|
||||
output.replace("$8", opcode.args[8]);
|
||||
output.replace("end;", "{ opcode_cycle = 0; break; }");
|
||||
|
||||
fp.print(output, "\n");
|
||||
if(nextLineEndsCycle) {
|
||||
if(lines[n + 1].beginswith("}")) {
|
||||
fp.print(" opcode_cycle = 0;\n");
|
||||
}
|
||||
fp.print(" break;\n");
|
||||
}
|
||||
}
|
||||
|
||||
fp.print(" }\n");
|
||||
fp.print(" break;\n");
|
||||
fp.print("}\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fp.close();
|
||||
}
|
||||
|
||||
int main() {
|
||||
cycle_accurate = false;
|
||||
generate("op_misc.b", "op_misc.cpp");
|
||||
generate("op_mov.b", "op_mov.cpp" );
|
||||
generate("op_pc.b", "op_pc.cpp" );
|
||||
generate("op_read.b", "op_read.cpp");
|
||||
generate("op_rmw.b", "op_rmw.cpp" );
|
||||
|
||||
cycle_accurate = true;
|
||||
generate("op_misc.b", "opcycle_misc.cpp");
|
||||
generate("op_mov.b", "opcycle_mov.cpp" );
|
||||
generate("op_pc.b", "opcycle_pc.cpp" );
|
||||
generate("op_read.b", "opcycle_read.cpp");
|
||||
generate("op_rmw.b", "opcycle_rmw.cpp" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+163
@@ -0,0 +1,163 @@
|
||||
nop(0x00) {
|
||||
1:op_io();
|
||||
}
|
||||
|
||||
sleep(0xef),
|
||||
stop(0xff) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
regs.pc--;
|
||||
}
|
||||
|
||||
xcn(0x9f) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:op_io();
|
||||
4:op_io();
|
||||
regs.a = (regs.a >> 4) | (regs.a << 4);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
daa(0xdf) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
if(regs.p.c || (regs.a) > 0x99) {
|
||||
regs.a += 0x60;
|
||||
regs.p.c = 1;
|
||||
}
|
||||
if(regs.p.h || (regs.a & 15) > 0x09) {
|
||||
regs.a += 0x06;
|
||||
}
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
das(0xbe) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
if(!regs.p.c || (regs.a) > 0x99) {
|
||||
regs.a -= 0x60;
|
||||
regs.p.c = 0;
|
||||
}
|
||||
if(!regs.p.h || (regs.a & 15) > 0x09) {
|
||||
regs.a -= 0x06;
|
||||
}
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
clrc(0x60, regs.p.c = 0),
|
||||
clrp(0x20, regs.p.p = 0),
|
||||
setc(0x80, regs.p.c = 1),
|
||||
setp(0x40, regs.p.p = 1) {
|
||||
1:op_io();
|
||||
$1;
|
||||
}
|
||||
|
||||
clrv(0xe0) {
|
||||
1:op_io();
|
||||
regs.p.v = 0;
|
||||
regs.p.h = 0;
|
||||
}
|
||||
|
||||
notc(0xed) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
regs.p.c = !regs.p.c;
|
||||
}
|
||||
|
||||
ei(0xa0, 1),
|
||||
di(0xc0, 0) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
regs.p.i = $1;
|
||||
}
|
||||
|
||||
set0_dp(0x02, rd |= 0x01),
|
||||
clr0_dp(0x12, rd &= ~0x01),
|
||||
set1_dp(0x22, rd |= 0x02),
|
||||
clr1_dp(0x32, rd &= ~0x02),
|
||||
set2_dp(0x42, rd |= 0x04),
|
||||
clr2_dp(0x52, rd &= ~0x04),
|
||||
set3_dp(0x62, rd |= 0x08),
|
||||
clr3_dp(0x72, rd &= ~0x08),
|
||||
set4_dp(0x82, rd |= 0x10),
|
||||
clr4_dp(0x92, rd &= ~0x10),
|
||||
set5_dp(0xa2, rd |= 0x20),
|
||||
clr5_dp(0xb2, rd &= ~0x20),
|
||||
set6_dp(0xc2, rd |= 0x40),
|
||||
clr6_dp(0xd2, rd &= ~0x40),
|
||||
set7_dp(0xe2, rd |= 0x80),
|
||||
clr7_dp(0xf2, rd &= ~0x80) {
|
||||
1:dp = op_readpc();
|
||||
2:rd = op_readdp(dp);
|
||||
3:$1;
|
||||
op_writedp(dp, rd);
|
||||
}
|
||||
|
||||
push_a(0x2d, a),
|
||||
push_x(0x4d, x),
|
||||
push_y(0x6d, y),
|
||||
push_p(0x0d, p) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:op_writestack(regs.$1);
|
||||
}
|
||||
|
||||
pop_a(0xae, a),
|
||||
pop_x(0xce, x),
|
||||
pop_y(0xee, y),
|
||||
pop_p(0x8e, p) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:regs.$1 = op_readstack();
|
||||
}
|
||||
|
||||
mul_ya(0xcf) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:op_io();
|
||||
4:op_io();
|
||||
5:op_io();
|
||||
6:op_io();
|
||||
7:op_io();
|
||||
8:op_io();
|
||||
ya = regs.y * regs.a;
|
||||
regs.a = ya;
|
||||
regs.y = ya >> 8;
|
||||
//result is set based on y (high-byte) only
|
||||
regs.p.n = !!(regs.y & 0x80);
|
||||
regs.p.z = (regs.y == 0);
|
||||
}
|
||||
|
||||
div_ya_x(0x9e) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:op_io();
|
||||
4:op_io();
|
||||
5:op_io();
|
||||
6:op_io();
|
||||
7:op_io();
|
||||
8:op_io();
|
||||
9:op_io();
|
||||
10:op_io();
|
||||
11:op_io();
|
||||
ya = regs.ya;
|
||||
//overflow set if quotient >= 256
|
||||
regs.p.v = !!(regs.y >= regs.x);
|
||||
regs.p.h = !!((regs.y & 15) >= (regs.x & 15));
|
||||
if(regs.y < (regs.x << 1)) {
|
||||
//if quotient is <= 511 (will fit into 9-bit result)
|
||||
regs.a = ya / regs.x;
|
||||
regs.y = ya % regs.x;
|
||||
} else {
|
||||
//otherwise, the quotient won't fit into regs.p.v + regs.a
|
||||
//this emulates the odd behavior of the S-SMP in this case
|
||||
regs.a = 255 - (ya - (regs.x << 9)) / (256 - regs.x);
|
||||
regs.y = regs.x + (ya - (regs.x << 9)) % (256 - regs.x);
|
||||
}
|
||||
//result is set based on a (quotient) only
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
Executable
+346
@@ -0,0 +1,346 @@
|
||||
case 0x00: {
|
||||
op_io();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xef: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.pc--;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xff: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.pc--;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x9f: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
regs.a = (regs.a >> 4) | (regs.a << 4);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xdf: {
|
||||
op_io();
|
||||
op_io();
|
||||
if(regs.p.c || (regs.a) > 0x99) {
|
||||
regs.a += 0x60;
|
||||
regs.p.c = 1;
|
||||
}
|
||||
if(regs.p.h || (regs.a & 15) > 0x09) {
|
||||
regs.a += 0x06;
|
||||
}
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xbe: {
|
||||
op_io();
|
||||
op_io();
|
||||
if(!regs.p.c || (regs.a) > 0x99) {
|
||||
regs.a -= 0x60;
|
||||
regs.p.c = 0;
|
||||
}
|
||||
if(!regs.p.h || (regs.a & 15) > 0x09) {
|
||||
regs.a -= 0x06;
|
||||
}
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x60: {
|
||||
op_io();
|
||||
regs.p.c = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x20: {
|
||||
op_io();
|
||||
regs.p.p = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x80: {
|
||||
op_io();
|
||||
regs.p.c = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x40: {
|
||||
op_io();
|
||||
regs.p.p = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xe0: {
|
||||
op_io();
|
||||
regs.p.v = 0;
|
||||
regs.p.h = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xed: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.p.c = !regs.p.c;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xa0: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.p.i = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xc0: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.p.i = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x02: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x01;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x12: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x01;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x22: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x02;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x32: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x02;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x42: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x04;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x52: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x04;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x62: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x08;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x72: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x08;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x82: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x10;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x92: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x10;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xa2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x20;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xb2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x20;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xc2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x40;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xd2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x40;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xe2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd |= 0x80;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xf2: {
|
||||
dp = op_readpc();
|
||||
rd = op_readdp(dp);
|
||||
rd &= ~0x80;
|
||||
op_writedp(dp, rd);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x2d: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_writestack(regs.a);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4d: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_writestack(regs.x);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x6d: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_writestack(regs.y);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0d: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_writestack(regs.p);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xae: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.a = op_readstack();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xce: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.x = op_readstack();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xee: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.y = op_readstack();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x8e: {
|
||||
op_io();
|
||||
op_io();
|
||||
regs.p = op_readstack();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0xcf: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
ya = regs.y * regs.a;
|
||||
regs.a = ya;
|
||||
regs.y = ya >> 8;
|
||||
//result is set based on y (high-byte) only
|
||||
regs.p.n = !!(regs.y & 0x80);
|
||||
regs.p.z = (regs.y == 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x9e: {
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
op_io();
|
||||
ya = regs.ya;
|
||||
//overflow set if quotient >= 256
|
||||
regs.p.v = !!(regs.y >= regs.x);
|
||||
regs.p.h = !!((regs.y & 15) >= (regs.x & 15));
|
||||
if(regs.y < (regs.x << 1)) {
|
||||
//if quotient is <= 511 (will fit into 9-bit result)
|
||||
regs.a = ya / regs.x;
|
||||
regs.y = ya % regs.x;
|
||||
} else {
|
||||
//otherwise, the quotient won't fit into regs.p.v + regs.a
|
||||
//this emulates the odd behavior of the S-SMP in this case
|
||||
regs.a = 255 - (ya - (regs.x << 9)) / (256 - regs.x);
|
||||
regs.y = regs.x + (ya - (regs.x << 9)) % (256 - regs.x);
|
||||
}
|
||||
//result is set based on a (quotient) only
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
break;
|
||||
}
|
||||
|
||||
Executable
+217
@@ -0,0 +1,217 @@
|
||||
mov_a_x(0x7d, a, x),
|
||||
mov_a_y(0xdd, a, y),
|
||||
mov_x_a(0x5d, x, a),
|
||||
mov_y_a(0xfd, y, a),
|
||||
mov_x_sp(0x9d, x, sp) {
|
||||
1:op_io();
|
||||
regs.$1 = regs.$2;
|
||||
regs.p.n = !!(regs.$1 & 0x80);
|
||||
regs.p.z = (regs.$1 == 0);
|
||||
}
|
||||
|
||||
mov_sp_x(0xbd, sp, x) {
|
||||
1:op_io();
|
||||
regs.$1 = regs.$2;
|
||||
}
|
||||
|
||||
mov_a_const(0xe8, a),
|
||||
mov_x_const(0xcd, x),
|
||||
mov_y_const(0x8d, y) {
|
||||
1:regs.$1 = op_readpc();
|
||||
regs.p.n = !!(regs.$1 & 0x80);
|
||||
regs.p.z = (regs.$1 == 0);
|
||||
}
|
||||
|
||||
mov_a_ix(0xe6) {
|
||||
1:op_io();
|
||||
2:regs.a = op_readdp(regs.x);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
mov_a_ixinc(0xbf) {
|
||||
1:op_io();
|
||||
2:regs.a = op_readdp(regs.x++);
|
||||
3:op_io();
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
mov_a_dp(0xe4, a),
|
||||
mov_x_dp(0xf8, x),
|
||||
mov_y_dp(0xeb, y) {
|
||||
1:sp = op_readpc();
|
||||
2:regs.$1 = op_readdp(sp);
|
||||
regs.p.n = !!(regs.$1 & 0x80);
|
||||
regs.p.z = (regs.$1 == 0);
|
||||
}
|
||||
|
||||
mov_a_dpx(0xf4, a, x),
|
||||
mov_x_dpy(0xf9, x, y),
|
||||
mov_y_dpx(0xfb, y, x) {
|
||||
1:sp = op_readpc();
|
||||
2:op_io();
|
||||
3:regs.$1 = op_readdp(sp + regs.$2);
|
||||
regs.p.n = !!(regs.$1 & 0x80);
|
||||
regs.p.z = (regs.$1 == 0);
|
||||
}
|
||||
|
||||
mov_a_addr(0xe5, a),
|
||||
mov_x_addr(0xe9, x),
|
||||
mov_y_addr(0xec, y) {
|
||||
1:sp = op_readpc();
|
||||
2:sp |= op_readpc() << 8;
|
||||
3:regs.$1 = op_readaddr(sp);
|
||||
regs.p.n = !!(regs.$1 & 0x80);
|
||||
regs.p.z = (regs.$1 == 0);
|
||||
}
|
||||
|
||||
mov_a_addrx(0xf5, x),
|
||||
mov_a_addry(0xf6, y) {
|
||||
1:sp = op_readpc();
|
||||
2:sp |= op_readpc() << 8;
|
||||
3:op_io();
|
||||
4:regs.a = op_readaddr(sp + regs.$1);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
mov_a_idpx(0xe7) {
|
||||
1:dp = op_readpc() + regs.x;
|
||||
2:op_io();
|
||||
3:sp = op_readdp(dp);
|
||||
4:sp |= op_readdp(dp + 1) << 8;
|
||||
5:regs.a = op_readaddr(sp);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
mov_a_idpy(0xf7) {
|
||||
1:dp = op_readpc();
|
||||
2:op_io();
|
||||
3:sp = op_readdp(dp);
|
||||
4:sp |= op_readdp(dp + 1) << 8;
|
||||
5:regs.a = op_readaddr(sp + regs.y);
|
||||
regs.p.n = !!(regs.a & 0x80);
|
||||
regs.p.z = (regs.a == 0);
|
||||
}
|
||||
|
||||
mov_dp_dp(0xfa) {
|
||||
1:sp = op_readpc();
|
||||
2:rd = op_readdp(sp);
|
||||
3:dp = op_readpc();
|
||||
4:op_writedp(dp, rd);
|
||||
}
|
||||
|
||||
mov_dp_const(0x8f) {
|
||||
1:rd = op_readpc();
|
||||
2:dp = op_readpc();
|
||||
3:op_readdp(dp);
|
||||
4:op_writedp(dp, rd);
|
||||
}
|
||||
|
||||
mov_ix_a(0xc6) {
|
||||
1:op_io();
|
||||
2:op_readdp(regs.x);
|
||||
3:op_writedp(regs.x, regs.a);
|
||||
}
|
||||
|
||||
mov_ixinc_a(0xaf) {
|
||||
1:op_io();
|
||||
2:op_io();
|
||||
3:op_writedp(regs.x++, regs.a);
|
||||
}
|
||||
|
||||
mov_dp_a(0xc4, a),
|
||||
mov_dp_x(0xd8, x),
|
||||
mov_dp_y(0xcb, y) {
|
||||
1:dp = op_readpc();
|
||||
2:op_readdp(dp);
|
||||
3:op_writedp(dp, regs.$1);
|
||||
}
|
||||
|
||||
mov_dpx_a(0xd4, x, a),
|
||||
mov_dpy_x(0xd9, y, x),
|
||||
mov_dpx_y(0xdb, x, y) {
|
||||
1:dp = op_readpc();
|
||||
2:op_io();
|
||||
dp += regs.$1;
|
||||
3:op_readdp(dp);
|
||||
4:op_writedp(dp, regs.$2);
|
||||
}
|
||||
|
||||
mov_addr_a(0xc5, a),
|
||||
mov_addr_x(0xc9, x),
|
||||
mov_addr_y(0xcc, y) {
|
||||
1:dp = op_readpc();
|
||||
2:dp |= op_readpc() << 8;
|
||||
3:op_readaddr(dp);
|
||||
4:op_writeaddr(dp, regs.$1);
|
||||
}
|
||||
|
||||
mov_addrx_a(0xd5, x),
|
||||
mov_addry_a(0xd6, y) {
|
||||
1:dp = op_readpc();
|
||||
2:dp |= op_readpc() << 8;
|
||||
3:op_io();
|
||||
dp += regs.$1;
|
||||
4:op_readaddr(dp);
|
||||
5:op_writeaddr(dp, regs.a);
|
||||
}
|
||||
|
||||
mov_idpx_a(0xc7) {
|
||||
1:sp = op_readpc();
|
||||
2:op_io();
|
||||
sp += regs.x;
|
||||
3:dp = op_readdp(sp);
|
||||
4:dp |= op_readdp(sp + 1) << 8;
|
||||
5:op_readaddr(dp);
|
||||
6:op_writeaddr(dp, regs.a);
|
||||
}
|
||||
|
||||
mov_idpy_a(0xd7) {
|
||||
1:sp = op_readpc();
|
||||
2:dp = op_readdp(sp);
|
||||
3:dp |= op_readdp(sp + 1) << 8;
|
||||
4:op_io();
|
||||
dp += regs.y;
|
||||
5:op_readaddr(dp);
|
||||
6:op_writeaddr(dp, regs.a);
|
||||
}
|
||||
|
||||
movw_ya_dp(0xba) {
|
||||
1:sp = op_readpc();
|
||||
2:regs.a = op_readdp(sp);
|
||||
3:op_io();
|
||||
4:regs.y = op_readdp(sp + 1);
|
||||
regs.p.n = !!(regs.ya & 0x8000);
|
||||
regs.p.z = (regs.ya == 0);
|
||||
}
|
||||
|
||||
movw_dp_ya(0xda) {
|
||||
1:dp = op_readpc();
|
||||
2:op_readdp(dp);
|
||||
3:op_writedp(dp, regs.a);
|
||||
4:op_writedp(dp + 1, regs.y);
|
||||
}
|
||||
|
||||
mov1_c_bit(0xaa) {
|
||||
1:sp = op_readpc();
|
||||
2:sp |= op_readpc() << 8;
|
||||
3:bit = sp >> 13;
|
||||
sp &= 0x1fff;
|
||||
rd = op_readaddr(sp);
|
||||
regs.p.c = !!(rd & (1 << bit));
|
||||
}
|
||||
|
||||
mov1_bit_c(0xca) {
|
||||
1:dp = op_readpc();
|
||||
2:dp |= op_readpc() << 8;
|
||||
3:bit = dp >> 13;
|
||||
dp &= 0x1fff;
|
||||
rd = op_readaddr(dp);
|
||||
if(regs.p.c)rd |= (1 << bit);
|
||||
else rd &= ~(1 << bit);
|
||||
4:op_io();
|
||||
5:op_writeaddr(dp, rd);
|
||||
}
|
||||
Loaded 100 of 404 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user