mirror of https://github.com/bsnes-emu/bsnes.git
Update to bsnes v007 release.
I have done quite a bit, so I´ll try my best to recap most of the fixes since the last release... - HDMA was not running during DMA transfers - Emulator did not recognize any filetype other than .smc - Added configuration file support and imported my vector/string/config libraries into bsnes - Added option to use system RAM instead of video RAM for display, this can greatly increase speed on certain video cards - Increased speed by ~15% by adding 256x224 renderer (still very buggy when the SNES mixes video modes mid-frame) - mvn/mvp opcodes were not setting the DB register - Fixed joypad input in many games (Super Mario: All Stars, Dragon Quest III, etc.) - Major speedup with frakeskip option - Fixed default aspect ratio when emulator is first started There´s probably a lot more, but that´s all I remember offhand... this release should be a lot closer to the quality of v0.005a, but still needs a bit more polishing.
This commit is contained in:
parent
a60f667b25
commit
09b326ae86
|
@ -0,0 +1,21 @@
|
|||
#[bsnes v0.007 configuration file]
|
||||
|
||||
#[video mode]
|
||||
# 0: 256x224w
|
||||
# 1: 512x448w
|
||||
# 2: 960x720w
|
||||
video.mode = 1
|
||||
|
||||
#[video memory type]
|
||||
# true: video ram (VRAM)
|
||||
# false: system ram (SRAM)
|
||||
#
|
||||
# VRAM results in the image being stretched in hardware,
|
||||
# which is generally much faster, and automatically adds
|
||||
# bilinear filtering (if the card supports it).
|
||||
#
|
||||
# However, some video cards end up taking a major speed
|
||||
# loss when this option is enabled. It is also the only
|
||||
# way to guarantee that the output image will not be
|
||||
# filtered.
|
||||
video.use_vram = true
|
BIN
bsnes_g2.exe
BIN
bsnes_g2.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
src/base.h
18
src/base.h
|
@ -1,20 +1,4 @@
|
|||
//platform-independant includes
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//typecasts
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned long uint32;
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed long int32;
|
||||
#include "lib/libbase.h"
|
||||
|
||||
//structs
|
||||
typedef struct {
|
||||
|
|
|
@ -71,9 +71,7 @@ void bClock::inc_vcounter() {
|
|||
cc1.frame_lines = 262;
|
||||
}
|
||||
}
|
||||
cc1.render_frame = true;
|
||||
cpu->frame();
|
||||
if(frameskip.notify_ppu == true)ppu->frame();
|
||||
signal_frame = true;
|
||||
}
|
||||
|
||||
if(status.interlace == false && status.interlace_field == 1 && status.vcounter == 240) {
|
||||
|
@ -83,13 +81,7 @@ void bClock::inc_vcounter() {
|
|||
}
|
||||
|
||||
cc1.dram_refreshed = false;
|
||||
|
||||
cpu->scanline();
|
||||
if(frameskip.notify_ppu == true)ppu->scanline();
|
||||
|
||||
//if(status.vcounter == visible_scanlines()) {
|
||||
// cc1.render_frame = true;
|
||||
//}
|
||||
signal_scanline = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,12 +113,6 @@ uint32 new_cycles, cycles;
|
|||
inc_vcounter();
|
||||
}
|
||||
}
|
||||
cc1.last_pos = cc1.pos;
|
||||
|
||||
if(cc1.pos > cc1.frequency) {
|
||||
cc1.pos -= cc1.frequency;
|
||||
cc1.last_pos -= cc1.frequency;
|
||||
}
|
||||
|
||||
if(status.interlace == false && status.interlace_field == 1 && status.vcounter == 240) {
|
||||
status.hcounter = status.hcycles >> 2;
|
||||
|
@ -134,6 +120,12 @@ uint32 new_cycles, cycles;
|
|||
//1288 = 322 * 4, 1306 = 326 * 4 + 2
|
||||
status.hcounter = (status.hcycles - ((status.hcycles > 1288) << 1) - ((status.hcycles > 1306) << 1)) >> 2;
|
||||
}
|
||||
|
||||
cc1.last_pos = cc1.pos;
|
||||
if(cc1.pos > cc1.frequency) {
|
||||
cc1.pos -= cc1.frequency;
|
||||
cc1.last_pos -= cc1.frequency;
|
||||
}
|
||||
}
|
||||
|
||||
void bClock::set_frameskip(uint8 fs) {
|
||||
|
@ -141,21 +133,11 @@ void bClock::set_frameskip(uint8 fs) {
|
|||
frameskip.new_count = fs;
|
||||
}
|
||||
|
||||
bool bClock::update_frame() {
|
||||
if(cc1.render_frame == true) {
|
||||
cc1.render_frame = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void bClock::power() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void bClock::reset() {
|
||||
cc1.render_frame = false;
|
||||
|
||||
//upon SNES reset, start at scanline 0 non-interlace
|
||||
cc1.frame_cycles = 262 * 1364;
|
||||
cc1.frame_lines = 262;
|
||||
|
@ -178,6 +160,8 @@ void bClock::reset() {
|
|||
|
||||
cc2.pos = 0;
|
||||
|
||||
signal_scanline = false;
|
||||
signal_frame = false;
|
||||
sync();
|
||||
}
|
||||
|
||||
|
@ -185,6 +169,18 @@ void bClock::run() {
|
|||
cpu->run();
|
||||
if(frameskip.notify_ppu == true)ppu->run();
|
||||
sync();
|
||||
|
||||
if(signal_frame == true) {
|
||||
signal_frame = false;
|
||||
cpu->frame();
|
||||
if(frameskip.notify_ppu == true)ppu->frame();
|
||||
}
|
||||
|
||||
if(signal_scanline == true) {
|
||||
signal_scanline = false;
|
||||
cpu->scanline();
|
||||
if(frameskip.notify_ppu == true)ppu->scanline();
|
||||
}
|
||||
}
|
||||
|
||||
void bClock::add_cc1_cycles(uint32 cycles) {
|
||||
|
|
|
@ -4,6 +4,7 @@ struct {
|
|||
bool changed, notify_ppu;
|
||||
uint8 count, new_count, pos;
|
||||
}frameskip;
|
||||
bool signal_scanline, signal_frame;
|
||||
void frameskip_update_status();
|
||||
void inc_vcounter();
|
||||
void dram_refresh_test();
|
||||
|
@ -16,8 +17,6 @@ public:
|
|||
uint16 line_cycles;
|
||||
bool dram_refreshed; //whether or not dram has been refreshed on this line
|
||||
uint16 dram_refresh_pos;
|
||||
|
||||
bool render_frame;
|
||||
}cc1;
|
||||
struct {
|
||||
uint32 frequency;
|
||||
|
@ -25,7 +24,6 @@ public:
|
|||
}cc2;
|
||||
|
||||
void set_frameskip(uint8 fs);
|
||||
bool update_frame();
|
||||
|
||||
void add_cc1_cycles(uint32 cycles);
|
||||
void add_cc2_cycles(uint32 cycles);
|
||||
|
|
|
@ -22,7 +22,6 @@ public:
|
|||
virtual uint16 visible_scanlines();
|
||||
|
||||
virtual void set_frameskip(uint8 fs);
|
||||
virtual bool update_frame() = 0;
|
||||
|
||||
virtual void add_cc1_cycles(uint32 cycles) = 0;
|
||||
virtual void add_cc2_cycles(uint32 cycles) = 0;
|
||||
|
|
|
@ -58,17 +58,26 @@ void bCPU::irq(uint16 addr) {
|
|||
|
||||
void bCPU::run() {
|
||||
uint16 v, h, hc, vs;
|
||||
v = clock->vcounter();
|
||||
h = clock->hcounter();
|
||||
hc = clock->hcycles();
|
||||
vs = clock->visible_scanlines();
|
||||
|
||||
//HDMA test
|
||||
if(v < vs && h >= 278) {
|
||||
if(status.hdma_triggered == false) {
|
||||
status.hdma_triggered = true;
|
||||
dma->hdma_run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(cpustate) {
|
||||
case CPUSTATE_RUN:
|
||||
case CPUSTATE_WAI:
|
||||
v = clock->vcounter();
|
||||
h = clock->hcounter();
|
||||
hc = clock->hcycles();
|
||||
vs = clock->visible_scanlines();
|
||||
|
||||
//NMI test
|
||||
if(v >= (vs + 1) && status.nmi_triggered == false) {
|
||||
if((v == (vs + 1) && hc >= 12) || (v >= (vs + 1))) {
|
||||
if((v == (vs + 1) && hc >= 12) || (v > (vs + 1))) {
|
||||
status.nmi_triggered = true;
|
||||
status.nmi_pin = 0;
|
||||
if(status.nmi_enabled == true) {
|
||||
|
@ -104,12 +113,6 @@ uint16 v, h, hc, vs;
|
|||
}
|
||||
}
|
||||
|
||||
//HDMA test
|
||||
if(v < vs && h >= 278 && dma->hdma_triggered == false) {
|
||||
dma->hdma_run();
|
||||
dma->hdma_triggered = true;
|
||||
}
|
||||
|
||||
exec_opcode();
|
||||
break;
|
||||
case CPUSTATE_DMA:
|
||||
|
@ -123,16 +126,25 @@ uint16 v, h, hc, vs;
|
|||
|
||||
void bCPU::scanline() {
|
||||
uint16 v = clock->vcounter();
|
||||
status.hdma_triggered = false;
|
||||
|
||||
if(v == 225 && status.auto_joypad_poll == true) {
|
||||
snes->poll_input();
|
||||
//When the SNES auto-polls the joypads, it writes 1, then 0 to
|
||||
//$4016, then reads from each 16 times to get the joypad state
|
||||
//information. As a result, the joypad read positions are set
|
||||
//to 16 after such a poll. Position 16 is the controller
|
||||
//connected status bit.
|
||||
status.joypad1_read_pos = 16;
|
||||
}
|
||||
if(status.virq_enabled == false) {
|
||||
status.irq_pin = 1;
|
||||
}
|
||||
dma->hdma_triggered = false;
|
||||
}
|
||||
|
||||
void bCPU::frame() {
|
||||
status.hdma_triggered = false;
|
||||
|
||||
status.nmi_triggered = false;
|
||||
status.r4210_read = false;
|
||||
|
||||
|
@ -165,6 +177,10 @@ void bCPU::reset() {
|
|||
dma->reset();
|
||||
mmio_reset();
|
||||
|
||||
optbl = optbl_e;
|
||||
|
||||
status.hdma_triggered = false;
|
||||
|
||||
status.nmi_triggered = false;
|
||||
status.nmi_pin = 1;
|
||||
status.r4210_read = false;
|
||||
|
@ -290,6 +306,8 @@ void bCPU::stack_write(uint8 value) {
|
|||
bCPU::bCPU() {
|
||||
dma = new bDMA(this);
|
||||
mmio = new bCPUMMIO(this);
|
||||
|
||||
init_op_tables();
|
||||
}
|
||||
|
||||
bCPU::~bCPU() {
|
||||
|
|
|
@ -30,8 +30,6 @@ struct {
|
|||
uint32 hdma_address, hdma_iaddress;
|
||||
bool hdma_completed;
|
||||
}channel[8];
|
||||
bool hdma_triggered;
|
||||
|
||||
void hdma_write(uint8 i, uint8 l, uint8 x);
|
||||
void hdma_run();
|
||||
void hdma_initialize();
|
||||
|
@ -58,6 +56,10 @@ bCPU *cpu;
|
|||
};
|
||||
|
||||
class bCPU : public CPU {
|
||||
private:
|
||||
typedef void (bCPU::*op)();
|
||||
op *optbl, optbl_e[256], optbl_MX[256], optbl_Mx[256], optbl_mX[256], optbl_mx[256];
|
||||
|
||||
public:
|
||||
enum { CPUSTATE_RUN = 0, CPUSTATE_DMA, CPUSTATE_WAI, CPUSTATE_STP };
|
||||
uint8 cpustate;
|
||||
|
@ -72,6 +74,8 @@ CPUReg24 aa, rd;
|
|||
uint8 dp, sp;
|
||||
|
||||
struct {
|
||||
bool hdma_triggered;
|
||||
|
||||
bool nmi_triggered;
|
||||
bool nmi_pin;
|
||||
bool r4210_read;
|
||||
|
@ -175,406 +179,285 @@ struct {
|
|||
void cpu_c6(uint16 a);
|
||||
void cpu_io();
|
||||
|
||||
//opcode functions
|
||||
void init_op_tables();
|
||||
|
||||
//op_adc
|
||||
void flags_adc_b();
|
||||
void flags_adc_w();
|
||||
inline void flags_adc_b();
|
||||
inline void flags_adc_w();
|
||||
void op_adc_constb();
|
||||
void op_adc_constw();
|
||||
void op_adc_const();
|
||||
void op_adc_addrb();
|
||||
void op_adc_addrw();
|
||||
void op_adc_addr();
|
||||
void op_adc_addrxb();
|
||||
void op_adc_addrxw();
|
||||
void op_adc_addrx();
|
||||
void op_adc_dpb();
|
||||
void op_adc_dpw();
|
||||
void op_adc_dp();
|
||||
void op_adc_idpb();
|
||||
void op_adc_idpw();
|
||||
void op_adc_idp();
|
||||
void op_adc_ildpb();
|
||||
void op_adc_ildpw();
|
||||
void op_adc_ildp();
|
||||
void op_adc_longb();
|
||||
void op_adc_longw();
|
||||
void op_adc_long();
|
||||
void op_adc_longxb();
|
||||
void op_adc_longxw();
|
||||
void op_adc_longx();
|
||||
void op_adc_addryb();
|
||||
void op_adc_addryw();
|
||||
void op_adc_addry();
|
||||
void op_adc_dpxb();
|
||||
void op_adc_dpxw();
|
||||
void op_adc_dpx();
|
||||
void op_adc_idpxb();
|
||||
void op_adc_idpxw();
|
||||
void op_adc_idpx();
|
||||
void op_adc_idpyb();
|
||||
void op_adc_idpyw();
|
||||
void op_adc_idpy();
|
||||
void op_adc_ildpyb();
|
||||
void op_adc_ildpyw();
|
||||
void op_adc_ildpy();
|
||||
void op_adc_srb();
|
||||
void op_adc_srw();
|
||||
void op_adc_sr();
|
||||
void op_adc_isryb();
|
||||
void op_adc_isryw();
|
||||
void op_adc_isry();
|
||||
//op_and
|
||||
void flags_and_b();
|
||||
void flags_and_w();
|
||||
inline void flags_and_b();
|
||||
inline void flags_and_w();
|
||||
void op_and_constb();
|
||||
void op_and_constw();
|
||||
void op_and_const();
|
||||
void op_and_addrb();
|
||||
void op_and_addrw();
|
||||
void op_and_addr();
|
||||
void op_and_addrxb();
|
||||
void op_and_addrxw();
|
||||
void op_and_addrx();
|
||||
void op_and_dpb();
|
||||
void op_and_dpw();
|
||||
void op_and_dp();
|
||||
void op_and_idpb();
|
||||
void op_and_idpw();
|
||||
void op_and_idp();
|
||||
void op_and_ildpb();
|
||||
void op_and_ildpw();
|
||||
void op_and_ildp();
|
||||
void op_and_longb();
|
||||
void op_and_longw();
|
||||
void op_and_long();
|
||||
void op_and_longxb();
|
||||
void op_and_longxw();
|
||||
void op_and_longx();
|
||||
void op_and_addryb();
|
||||
void op_and_addryw();
|
||||
void op_and_addry();
|
||||
void op_and_dpxb();
|
||||
void op_and_dpxw();
|
||||
void op_and_dpx();
|
||||
void op_and_idpxb();
|
||||
void op_and_idpxw();
|
||||
void op_and_idpx();
|
||||
void op_and_idpyb();
|
||||
void op_and_idpyw();
|
||||
void op_and_idpy();
|
||||
void op_and_ildpyb();
|
||||
void op_and_ildpyw();
|
||||
void op_and_ildpy();
|
||||
void op_and_srb();
|
||||
void op_and_srw();
|
||||
void op_and_sr();
|
||||
void op_and_isryb();
|
||||
void op_and_isryw();
|
||||
void op_and_isry();
|
||||
//op_cmp
|
||||
void flags_cmp_b();
|
||||
void flags_cmp_w();
|
||||
inline void flags_cmp_b();
|
||||
inline void flags_cmp_w();
|
||||
void op_cmp_constb();
|
||||
void op_cmp_constw();
|
||||
void op_cmp_const();
|
||||
void op_cmp_addrb();
|
||||
void op_cmp_addrw();
|
||||
void op_cmp_addr();
|
||||
void op_cmp_addrxb();
|
||||
void op_cmp_addrxw();
|
||||
void op_cmp_addrx();
|
||||
void op_cmp_dpb();
|
||||
void op_cmp_dpw();
|
||||
void op_cmp_dp();
|
||||
void op_cmp_idpb();
|
||||
void op_cmp_idpw();
|
||||
void op_cmp_idp();
|
||||
void op_cmp_ildpb();
|
||||
void op_cmp_ildpw();
|
||||
void op_cmp_ildp();
|
||||
void op_cmp_longb();
|
||||
void op_cmp_longw();
|
||||
void op_cmp_long();
|
||||
void op_cmp_longxb();
|
||||
void op_cmp_longxw();
|
||||
void op_cmp_longx();
|
||||
void op_cmp_addryb();
|
||||
void op_cmp_addryw();
|
||||
void op_cmp_addry();
|
||||
void op_cmp_dpxb();
|
||||
void op_cmp_dpxw();
|
||||
void op_cmp_dpx();
|
||||
void op_cmp_idpxb();
|
||||
void op_cmp_idpxw();
|
||||
void op_cmp_idpx();
|
||||
void op_cmp_idpyb();
|
||||
void op_cmp_idpyw();
|
||||
void op_cmp_idpy();
|
||||
void op_cmp_ildpyb();
|
||||
void op_cmp_ildpyw();
|
||||
void op_cmp_ildpy();
|
||||
void op_cmp_srb();
|
||||
void op_cmp_srw();
|
||||
void op_cmp_sr();
|
||||
void op_cmp_isryb();
|
||||
void op_cmp_isryw();
|
||||
void op_cmp_isry();
|
||||
//op_eor
|
||||
void flags_eor_b();
|
||||
void flags_eor_w();
|
||||
inline void flags_eor_b();
|
||||
inline void flags_eor_w();
|
||||
void op_eor_constb();
|
||||
void op_eor_constw();
|
||||
void op_eor_const();
|
||||
void op_eor_addrb();
|
||||
void op_eor_addrw();
|
||||
void op_eor_addr();
|
||||
void op_eor_addrxb();
|
||||
void op_eor_addrxw();
|
||||
void op_eor_addrx();
|
||||
void op_eor_dpb();
|
||||
void op_eor_dpw();
|
||||
void op_eor_dp();
|
||||
void op_eor_idpb();
|
||||
void op_eor_idpw();
|
||||
void op_eor_idp();
|
||||
void op_eor_ildpb();
|
||||
void op_eor_ildpw();
|
||||
void op_eor_ildp();
|
||||
void op_eor_longb();
|
||||
void op_eor_longw();
|
||||
void op_eor_long();
|
||||
void op_eor_longxb();
|
||||
void op_eor_longxw();
|
||||
void op_eor_longx();
|
||||
void op_eor_addryb();
|
||||
void op_eor_addryw();
|
||||
void op_eor_addry();
|
||||
void op_eor_dpxb();
|
||||
void op_eor_dpxw();
|
||||
void op_eor_dpx();
|
||||
void op_eor_idpxb();
|
||||
void op_eor_idpxw();
|
||||
void op_eor_idpx();
|
||||
void op_eor_idpyb();
|
||||
void op_eor_idpyw();
|
||||
void op_eor_idpy();
|
||||
void op_eor_ildpyb();
|
||||
void op_eor_ildpyw();
|
||||
void op_eor_ildpy();
|
||||
void op_eor_srb();
|
||||
void op_eor_srw();
|
||||
void op_eor_sr();
|
||||
void op_eor_isryb();
|
||||
void op_eor_isryw();
|
||||
void op_eor_isry();
|
||||
//op_incdec
|
||||
void op_incb();
|
||||
void op_incw();
|
||||
void op_inc();
|
||||
void op_inc_addrb();
|
||||
void op_inc_addrw();
|
||||
void op_inc_addr();
|
||||
void op_inc_addrxb();
|
||||
void op_inc_addrxw();
|
||||
void op_inc_addrx();
|
||||
void op_inc_dpb();
|
||||
void op_inc_dpw();
|
||||
void op_inc_dp();
|
||||
void op_inc_dpxb();
|
||||
void op_inc_dpxw();
|
||||
void op_inc_dpx();
|
||||
void op_inxb();
|
||||
void op_inxw();
|
||||
void op_inx();
|
||||
void op_inyb();
|
||||
void op_inyw();
|
||||
void op_iny();
|
||||
void op_decb();
|
||||
void op_decw();
|
||||
void op_dec();
|
||||
void op_dec_addrb();
|
||||
void op_dec_addrw();
|
||||
void op_dec_addr();
|
||||
void op_dec_addrxb();
|
||||
void op_dec_addrxw();
|
||||
void op_dec_addrx();
|
||||
void op_dec_dpb();
|
||||
void op_dec_dpw();
|
||||
void op_dec_dp();
|
||||
void op_dec_dpxb();
|
||||
void op_dec_dpxw();
|
||||
void op_dec_dpx();
|
||||
void op_dexb();
|
||||
void op_dexw();
|
||||
void op_dex();
|
||||
void op_deyb();
|
||||
void op_deyw();
|
||||
void op_dey();
|
||||
//op_lda
|
||||
void flags_lda_b();
|
||||
void flags_lda_w();
|
||||
inline void flags_lda_b();
|
||||
inline void flags_lda_w();
|
||||
void op_lda_constb();
|
||||
void op_lda_constw();
|
||||
void op_lda_const();
|
||||
void op_lda_addrb();
|
||||
void op_lda_addrw();
|
||||
void op_lda_addr();
|
||||
void op_lda_addrxb();
|
||||
void op_lda_addrxw();
|
||||
void op_lda_addrx();
|
||||
void op_lda_dpb();
|
||||
void op_lda_dpw();
|
||||
void op_lda_dp();
|
||||
void op_lda_idpb();
|
||||
void op_lda_idpw();
|
||||
void op_lda_idp();
|
||||
void op_lda_ildpb();
|
||||
void op_lda_ildpw();
|
||||
void op_lda_ildp();
|
||||
void op_lda_longb();
|
||||
void op_lda_longw();
|
||||
void op_lda_long();
|
||||
void op_lda_longxb();
|
||||
void op_lda_longxw();
|
||||
void op_lda_longx();
|
||||
void op_lda_addryb();
|
||||
void op_lda_addryw();
|
||||
void op_lda_addry();
|
||||
void op_lda_dpxb();
|
||||
void op_lda_dpxw();
|
||||
void op_lda_dpx();
|
||||
void op_lda_idpxb();
|
||||
void op_lda_idpxw();
|
||||
void op_lda_idpx();
|
||||
void op_lda_idpyb();
|
||||
void op_lda_idpyw();
|
||||
void op_lda_idpy();
|
||||
void op_lda_ildpyb();
|
||||
void op_lda_ildpyw();
|
||||
void op_lda_ildpy();
|
||||
void op_lda_srb();
|
||||
void op_lda_srw();
|
||||
void op_lda_sr();
|
||||
void op_lda_isryb();
|
||||
void op_lda_isryw();
|
||||
void op_lda_isry();
|
||||
//op_misc
|
||||
void flags_bit_b();
|
||||
void flags_bit_w();
|
||||
inline void flags_bit_b();
|
||||
inline void flags_bit_w();
|
||||
void op_bit_constb();
|
||||
void op_bit_constw();
|
||||
void op_bit_const();
|
||||
void op_bit_addrb();
|
||||
void op_bit_addrw();
|
||||
void op_bit_addr();
|
||||
void op_bit_addrxb();
|
||||
void op_bit_addrxw();
|
||||
void op_bit_addrx();
|
||||
void op_bit_dpb();
|
||||
void op_bit_dpw();
|
||||
void op_bit_dp();
|
||||
void op_bit_dpxb();
|
||||
void op_bit_dpxw();
|
||||
void op_bit_dpx();
|
||||
void flags_cpx_b();
|
||||
void flags_cpx_w();
|
||||
inline void flags_cpx_b();
|
||||
inline void flags_cpx_w();
|
||||
void op_cpx_constb();
|
||||
void op_cpx_constw();
|
||||
void op_cpx_const();
|
||||
void op_cpx_addrb();
|
||||
void op_cpx_addrw();
|
||||
void op_cpx_addr();
|
||||
void op_cpx_dpb();
|
||||
void op_cpx_dpw();
|
||||
void op_cpx_dp();
|
||||
void flags_cpy_b();
|
||||
void flags_cpy_w();
|
||||
inline void flags_cpy_b();
|
||||
inline void flags_cpy_w();
|
||||
void op_cpy_constb();
|
||||
void op_cpy_constw();
|
||||
void op_cpy_const();
|
||||
void op_cpy_addrb();
|
||||
void op_cpy_addrw();
|
||||
void op_cpy_addr();
|
||||
void op_cpy_dpb();
|
||||
void op_cpy_dpw();
|
||||
void op_cpy_dp();
|
||||
void flags_ldx_b();
|
||||
void flags_ldx_w();
|
||||
inline void flags_ldx_b();
|
||||
inline void flags_ldx_w();
|
||||
void op_ldx_constb();
|
||||
void op_ldx_constw();
|
||||
void op_ldx_const();
|
||||
void op_ldx_addrb();
|
||||
void op_ldx_addrw();
|
||||
void op_ldx_addr();
|
||||
void op_ldx_addryb();
|
||||
void op_ldx_addryw();
|
||||
void op_ldx_addry();
|
||||
void op_ldx_dpb();
|
||||
void op_ldx_dpw();
|
||||
void op_ldx_dp();
|
||||
void op_ldx_dpyb();
|
||||
void op_ldx_dpyw();
|
||||
void op_ldx_dpy();
|
||||
void flags_ldy_b();
|
||||
void flags_ldy_w();
|
||||
inline void flags_ldy_b();
|
||||
inline void flags_ldy_w();
|
||||
void op_ldy_constb();
|
||||
void op_ldy_constw();
|
||||
void op_ldy_const();
|
||||
void op_ldy_addrb();
|
||||
void op_ldy_addrw();
|
||||
void op_ldy_addr();
|
||||
void op_ldy_addrxb();
|
||||
void op_ldy_addrxw();
|
||||
void op_ldy_addrx();
|
||||
void op_ldy_dpb();
|
||||
void op_ldy_dpw();
|
||||
void op_ldy_dp();
|
||||
void op_ldy_dpxb();
|
||||
void op_ldy_dpxw();
|
||||
void op_ldy_dpx();
|
||||
void op_stx_addrb();
|
||||
void op_stx_addrw();
|
||||
void op_stx_addr();
|
||||
void op_stx_dpb();
|
||||
void op_stx_dpw();
|
||||
void op_stx_dp();
|
||||
void op_stx_dpyb();
|
||||
void op_stx_dpyw();
|
||||
void op_stx_dpy();
|
||||
void op_sty_addrb();
|
||||
void op_sty_addrw();
|
||||
void op_sty_addr();
|
||||
void op_sty_dpb();
|
||||
void op_sty_dpw();
|
||||
void op_sty_dp();
|
||||
void op_sty_dpxb();
|
||||
void op_sty_dpxw();
|
||||
void op_sty_dpx();
|
||||
void op_stz_addrb();
|
||||
void op_stz_addrw();
|
||||
void op_stz_addr();
|
||||
void op_stz_addrxb();
|
||||
void op_stz_addrxw();
|
||||
void op_stz_addrx();
|
||||
void op_stz_dpb();
|
||||
void op_stz_dpw();
|
||||
void op_stz_dp();
|
||||
void op_stz_dpxb();
|
||||
void op_stz_dpxw();
|
||||
void op_stz_dpx();
|
||||
void op_xba();
|
||||
void op_trb_addrb();
|
||||
void op_trb_addrw();
|
||||
void op_trb_addr();
|
||||
void op_trb_dpb();
|
||||
void op_trb_dpw();
|
||||
void op_trb_dp();
|
||||
void op_tsb_addrb();
|
||||
void op_tsb_addrw();
|
||||
void op_tsb_addr();
|
||||
void op_tsb_dpb();
|
||||
void op_tsb_dpw();
|
||||
void op_tsb_dp();
|
||||
void op_mvn();
|
||||
void op_mvp();
|
||||
void op_brk();
|
||||
|
@ -595,80 +478,57 @@ struct {
|
|||
void op_sep();
|
||||
void op_taxb();
|
||||
void op_taxw();
|
||||
void op_tax();
|
||||
void op_tayb();
|
||||
void op_tayw();
|
||||
void op_tay();
|
||||
void op_tcd();
|
||||
void op_tcs();
|
||||
void op_tdc();
|
||||
void op_tsc();
|
||||
void op_tsxb();
|
||||
void op_tsxw();
|
||||
void op_tsx();
|
||||
void op_txab();
|
||||
void op_txaw();
|
||||
void op_txa();
|
||||
void op_txsb();
|
||||
void op_txsw();
|
||||
void op_txs();
|
||||
void op_txyb();
|
||||
void op_txyw();
|
||||
void op_txy();
|
||||
void op_tyab();
|
||||
void op_tyaw();
|
||||
void op_tya();
|
||||
void op_tyxb();
|
||||
void op_tyxw();
|
||||
void op_tyx();
|
||||
//op_ora
|
||||
void flags_ora_b();
|
||||
void flags_ora_w();
|
||||
inline void flags_ora_b();
|
||||
inline void flags_ora_w();
|
||||
void op_ora_constb();
|
||||
void op_ora_constw();
|
||||
void op_ora_const();
|
||||
void op_ora_addrb();
|
||||
void op_ora_addrw();
|
||||
void op_ora_addr();
|
||||
void op_ora_addrxb();
|
||||
void op_ora_addrxw();
|
||||
void op_ora_addrx();
|
||||
void op_ora_dpb();
|
||||
void op_ora_dpw();
|
||||
void op_ora_dp();
|
||||
void op_ora_idpb();
|
||||
void op_ora_idpw();
|
||||
void op_ora_idp();
|
||||
void op_ora_ildpb();
|
||||
void op_ora_ildpw();
|
||||
void op_ora_ildp();
|
||||
void op_ora_longb();
|
||||
void op_ora_longw();
|
||||
void op_ora_long();
|
||||
void op_ora_longxb();
|
||||
void op_ora_longxw();
|
||||
void op_ora_longx();
|
||||
void op_ora_addryb();
|
||||
void op_ora_addryw();
|
||||
void op_ora_addry();
|
||||
void op_ora_dpxb();
|
||||
void op_ora_dpxw();
|
||||
void op_ora_dpx();
|
||||
void op_ora_idpxb();
|
||||
void op_ora_idpxw();
|
||||
void op_ora_idpx();
|
||||
void op_ora_idpyb();
|
||||
void op_ora_idpyw();
|
||||
void op_ora_idpy();
|
||||
void op_ora_ildpyb();
|
||||
void op_ora_ildpyw();
|
||||
void op_ora_ildpy();
|
||||
void op_ora_srb();
|
||||
void op_ora_srw();
|
||||
void op_ora_sr();
|
||||
void op_ora_isryb();
|
||||
void op_ora_isryw();
|
||||
void op_ora_isry();
|
||||
//op_pc
|
||||
void op_jmp_addr();
|
||||
void op_jmp_long();
|
||||
|
@ -680,7 +540,6 @@ struct {
|
|||
void op_jsr_iaddrx();
|
||||
void op_rtie();
|
||||
void op_rtin();
|
||||
void op_rti();
|
||||
void op_rts();
|
||||
void op_rtl();
|
||||
void op_bra();
|
||||
|
@ -694,183 +553,128 @@ struct {
|
|||
void op_bvc();
|
||||
void op_bvs();
|
||||
//op_sbc
|
||||
void flags_sbc_b();
|
||||
void flags_sbc_w();
|
||||
inline void flags_sbc_b();
|
||||
inline void flags_sbc_w();
|
||||
void op_sbc_constb();
|
||||
void op_sbc_constw();
|
||||
void op_sbc_const();
|
||||
void op_sbc_addrb();
|
||||
void op_sbc_addrw();
|
||||
void op_sbc_addr();
|
||||
void op_sbc_addrxb();
|
||||
void op_sbc_addrxw();
|
||||
void op_sbc_addrx();
|
||||
void op_sbc_dpb();
|
||||
void op_sbc_dpw();
|
||||
void op_sbc_dp();
|
||||
void op_sbc_idpb();
|
||||
void op_sbc_idpw();
|
||||
void op_sbc_idp();
|
||||
void op_sbc_ildpb();
|
||||
void op_sbc_ildpw();
|
||||
void op_sbc_ildp();
|
||||
void op_sbc_longb();
|
||||
void op_sbc_longw();
|
||||
void op_sbc_long();
|
||||
void op_sbc_longxb();
|
||||
void op_sbc_longxw();
|
||||
void op_sbc_longx();
|
||||
void op_sbc_addryb();
|
||||
void op_sbc_addryw();
|
||||
void op_sbc_addry();
|
||||
void op_sbc_dpxb();
|
||||
void op_sbc_dpxw();
|
||||
void op_sbc_dpx();
|
||||
void op_sbc_idpxb();
|
||||
void op_sbc_idpxw();
|
||||
void op_sbc_idpx();
|
||||
void op_sbc_idpyb();
|
||||
void op_sbc_idpyw();
|
||||
void op_sbc_idpy();
|
||||
void op_sbc_ildpyb();
|
||||
void op_sbc_ildpyw();
|
||||
void op_sbc_ildpy();
|
||||
void op_sbc_srb();
|
||||
void op_sbc_srw();
|
||||
void op_sbc_sr();
|
||||
void op_sbc_isryb();
|
||||
void op_sbc_isryw();
|
||||
void op_sbc_isry();
|
||||
//op_shift
|
||||
void op_aslb();
|
||||
void op_aslw();
|
||||
void op_asl();
|
||||
void op_asl_addrb();
|
||||
void op_asl_addrw();
|
||||
void op_asl_addr();
|
||||
void op_asl_addrxb();
|
||||
void op_asl_addrxw();
|
||||
void op_asl_addrx();
|
||||
void op_asl_dpb();
|
||||
void op_asl_dpw();
|
||||
void op_asl_dp();
|
||||
void op_asl_dpxb();
|
||||
void op_asl_dpxw();
|
||||
void op_asl_dpx();
|
||||
void op_lsrb();
|
||||
void op_lsrw();
|
||||
void op_lsr();
|
||||
void op_lsr_addrb();
|
||||
void op_lsr_addrw();
|
||||
void op_lsr_addr();
|
||||
void op_lsr_addrxb();
|
||||
void op_lsr_addrxw();
|
||||
void op_lsr_addrx();
|
||||
void op_lsr_dpb();
|
||||
void op_lsr_dpw();
|
||||
void op_lsr_dp();
|
||||
void op_lsr_dpxb();
|
||||
void op_lsr_dpxw();
|
||||
void op_lsr_dpx();
|
||||
void op_rolb();
|
||||
void op_rolw();
|
||||
void op_rol();
|
||||
void op_rol_addrb();
|
||||
void op_rol_addrw();
|
||||
void op_rol_addr();
|
||||
void op_rol_addrxb();
|
||||
void op_rol_addrxw();
|
||||
void op_rol_addrx();
|
||||
void op_rol_dpb();
|
||||
void op_rol_dpw();
|
||||
void op_rol_dp();
|
||||
void op_rol_dpxb();
|
||||
void op_rol_dpxw();
|
||||
void op_rol_dpx();
|
||||
void op_rorb();
|
||||
void op_rorw();
|
||||
void op_ror();
|
||||
void op_ror_addrb();
|
||||
void op_ror_addrw();
|
||||
void op_ror_addr();
|
||||
void op_ror_addrxb();
|
||||
void op_ror_addrxw();
|
||||
void op_ror_addrx();
|
||||
void op_ror_dpb();
|
||||
void op_ror_dpw();
|
||||
void op_ror_dp();
|
||||
void op_ror_dpxb();
|
||||
void op_ror_dpxw();
|
||||
void op_ror_dpx();
|
||||
//op_sta
|
||||
void op_sta_addrb();
|
||||
void op_sta_addrw();
|
||||
void op_sta_addr();
|
||||
void op_sta_addrxb();
|
||||
void op_sta_addrxw();
|
||||
void op_sta_addrx();
|
||||
void op_sta_dpb();
|
||||
void op_sta_dpw();
|
||||
void op_sta_dp();
|
||||
void op_sta_idpb();
|
||||
void op_sta_idpw();
|
||||
void op_sta_idp();
|
||||
void op_sta_ildpb();
|
||||
void op_sta_ildpw();
|
||||
void op_sta_ildp();
|
||||
void op_sta_longb();
|
||||
void op_sta_longw();
|
||||
void op_sta_long();
|
||||
void op_sta_longxb();
|
||||
void op_sta_longxw();
|
||||
void op_sta_longx();
|
||||
void op_sta_addryb();
|
||||
void op_sta_addryw();
|
||||
void op_sta_addry();
|
||||
void op_sta_dpxb();
|
||||
void op_sta_dpxw();
|
||||
void op_sta_dpx();
|
||||
void op_sta_idpxb();
|
||||
void op_sta_idpxw();
|
||||
void op_sta_idpx();
|
||||
void op_sta_idpyb();
|
||||
void op_sta_idpyw();
|
||||
void op_sta_idpy();
|
||||
void op_sta_ildpyb();
|
||||
void op_sta_ildpyw();
|
||||
void op_sta_ildpy();
|
||||
void op_sta_srb();
|
||||
void op_sta_srw();
|
||||
void op_sta_sr();
|
||||
void op_sta_isryb();
|
||||
void op_sta_isryw();
|
||||
void op_sta_isry();
|
||||
//op_stack
|
||||
void op_phab();
|
||||
void op_phaw();
|
||||
void op_pha();
|
||||
void op_phb();
|
||||
void op_phd();
|
||||
void op_phk();
|
||||
void op_php();
|
||||
void op_phxb();
|
||||
void op_phxw();
|
||||
void op_phx();
|
||||
void op_phyb();
|
||||
void op_phyw();
|
||||
void op_phy();
|
||||
void op_plab();
|
||||
void op_plaw();
|
||||
void op_pla();
|
||||
void op_plb();
|
||||
void op_pld();
|
||||
void op_plp();
|
||||
void op_plxb();
|
||||
void op_plxw();
|
||||
void op_plx();
|
||||
void op_plyb();
|
||||
void op_plyw();
|
||||
void op_ply();
|
||||
void op_pea();
|
||||
void op_pei();
|
||||
void op_per();
|
||||
|
|
|
@ -1,280 +1,519 @@
|
|||
void bCPU::exec_opcode() {
|
||||
byte op;
|
||||
op = op_read();
|
||||
switch(op) {
|
||||
/* 0x */
|
||||
case 0x00:op_brk(); break;
|
||||
case 0x01:op_ora_idpx(); break;
|
||||
case 0x02:op_cop(); break;
|
||||
case 0x03:op_ora_sr(); break;
|
||||
case 0x04:op_tsb_dp(); break;
|
||||
case 0x05:op_ora_dp(); break;
|
||||
case 0x06:op_asl_dp(); break;
|
||||
case 0x07:op_ora_ildp(); break;
|
||||
case 0x08:op_php(); break;
|
||||
case 0x09:op_ora_const();break;
|
||||
case 0x0a:op_asl(); break;
|
||||
case 0x0b:op_phd(); break;
|
||||
case 0x0c:op_tsb_addr(); break;
|
||||
case 0x0d:op_ora_addr(); break;
|
||||
case 0x0e:op_asl_addr(); break;
|
||||
case 0x0f:op_ora_long(); break;
|
||||
/* 1x */
|
||||
case 0x10:op_bpl(); break;
|
||||
case 0x11:op_ora_idpy(); break;
|
||||
case 0x12:op_ora_idp(); break;
|
||||
case 0x13:op_ora_isry(); break;
|
||||
case 0x14:op_trb_dp(); break;
|
||||
case 0x15:op_ora_dpx(); break;
|
||||
case 0x16:op_asl_dpx(); break;
|
||||
case 0x17:op_ora_ildpy();break;
|
||||
case 0x18:op_clc(); break;
|
||||
case 0x19:op_ora_addry();break;
|
||||
case 0x1a:op_inc(); break;
|
||||
case 0x1b:op_tcs(); break;
|
||||
case 0x1c:op_trb_addr(); break;
|
||||
case 0x1d:op_ora_addrx();break;
|
||||
case 0x1e:op_asl_addrx();break;
|
||||
case 0x1f:op_ora_longx();break;
|
||||
/* 2x */
|
||||
case 0x20:op_jsr_addr(); break;
|
||||
case 0x21:op_and_idpx(); break;
|
||||
case 0x22:op_jsr_long(); break;
|
||||
case 0x23:op_and_sr(); break;
|
||||
case 0x24:op_bit_dp(); break;
|
||||
case 0x25:op_and_dp(); break;
|
||||
case 0x26:op_rol_dp(); break;
|
||||
case 0x27:op_and_ildp(); break;
|
||||
case 0x28:op_plp(); break;
|
||||
case 0x29:op_and_const();break;
|
||||
case 0x2a:op_rol(); break;
|
||||
case 0x2b:op_pld(); break;
|
||||
case 0x2c:op_bit_addr(); break;
|
||||
case 0x2d:op_and_addr(); break;
|
||||
case 0x2e:op_rol_addr(); break;
|
||||
case 0x2f:op_and_long(); break;
|
||||
/* 3x */
|
||||
case 0x30:op_bmi(); break;
|
||||
case 0x31:op_and_idpy(); break;
|
||||
case 0x32:op_and_idp(); break;
|
||||
case 0x33:op_and_isry(); break;
|
||||
case 0x34:op_bit_dpx(); break;
|
||||
case 0x35:op_and_dpx(); break;
|
||||
case 0x36:op_rol_dpx(); break;
|
||||
case 0x37:op_and_ildpy();break;
|
||||
case 0x38:op_sec(); break;
|
||||
case 0x39:op_and_addry();break;
|
||||
case 0x3a:op_dec(); break;
|
||||
case 0x3b:op_tsc(); break;
|
||||
case 0x3c:op_bit_addrx();break;
|
||||
case 0x3d:op_and_addrx();break;
|
||||
case 0x3e:op_rol_addrx();break;
|
||||
case 0x3f:op_and_longx();break;
|
||||
/* 4x */
|
||||
case 0x40:op_rti(); break;
|
||||
case 0x41:op_eor_idpx(); break;
|
||||
case 0x42:op_wdm(); break;
|
||||
case 0x43:op_eor_sr(); break;
|
||||
case 0x44:op_mvp(); break;
|
||||
case 0x45:op_eor_dp(); break;
|
||||
case 0x46:op_lsr_dp(); break;
|
||||
case 0x47:op_eor_ildp(); break;
|
||||
case 0x48:op_pha(); break;
|
||||
case 0x49:op_eor_const();break;
|
||||
case 0x4a:op_lsr(); break;
|
||||
case 0x4b:op_phk(); break;
|
||||
case 0x4c:op_jmp_addr(); break;
|
||||
case 0x4d:op_eor_addr(); break;
|
||||
case 0x4e:op_lsr_addr(); break;
|
||||
case 0x4f:op_eor_long(); break;
|
||||
/* 5x */
|
||||
case 0x50:op_bvc(); break;
|
||||
case 0x51:op_eor_idpy(); break;
|
||||
case 0x52:op_eor_idp(); break;
|
||||
case 0x53:op_eor_isry(); break;
|
||||
case 0x54:op_mvn(); break;
|
||||
case 0x55:op_eor_dpx(); break;
|
||||
case 0x56:op_lsr_dpx(); break;
|
||||
case 0x57:op_eor_ildpy();break;
|
||||
case 0x58:op_cli(); break;
|
||||
case 0x59:op_eor_addry();break;
|
||||
case 0x5a:op_phy(); break;
|
||||
case 0x5b:op_tcd(); break;
|
||||
case 0x5c:op_jmp_long(); break;
|
||||
case 0x5d:op_eor_addrx();break;
|
||||
case 0x5e:op_lsr_addrx();break;
|
||||
case 0x5f:op_eor_longx();break;
|
||||
/* 6x */
|
||||
case 0x60:op_rts(); break;
|
||||
case 0x61:op_adc_idpx(); break;
|
||||
case 0x62:op_per(); break;
|
||||
case 0x63:op_adc_sr(); break;
|
||||
case 0x64:op_stz_dp(); break;
|
||||
case 0x65:op_adc_dp(); break;
|
||||
case 0x66:op_ror_dp(); break;
|
||||
case 0x67:op_adc_ildp(); break;
|
||||
case 0x68:op_pla(); break;
|
||||
case 0x69:op_adc_const();break;
|
||||
case 0x6a:op_ror(); break;
|
||||
case 0x6b:op_rtl(); break;
|
||||
case 0x6c:op_jmp_iaddr();break;
|
||||
case 0x6d:op_adc_addr(); break;
|
||||
case 0x6e:op_ror_addr(); break;
|
||||
case 0x6f:op_adc_long(); break;
|
||||
/* 7x */
|
||||
case 0x70:op_bvs(); break;
|
||||
case 0x71:op_adc_idpy(); break;
|
||||
case 0x72:op_adc_idp(); break;
|
||||
case 0x73:op_adc_isry(); break;
|
||||
case 0x74:op_stz_dpx(); break;
|
||||
case 0x75:op_adc_dpx(); break;
|
||||
case 0x76:op_ror_dpx(); break;
|
||||
case 0x77:op_adc_ildpy(); break;
|
||||
case 0x78:op_sei(); break;
|
||||
case 0x79:op_adc_addry(); break;
|
||||
case 0x7a:op_ply(); break;
|
||||
case 0x7b:op_tdc(); break;
|
||||
case 0x7c:op_jmp_iaddrx();break;
|
||||
case 0x7d:op_adc_addrx(); break;
|
||||
case 0x7e:op_ror_addrx(); break;
|
||||
case 0x7f:op_adc_longx(); break;
|
||||
/* 8x */
|
||||
case 0x80:op_bra(); break;
|
||||
case 0x81:op_sta_idpx(); break;
|
||||
case 0x82:op_brl(); break;
|
||||
case 0x83:op_sta_sr(); break;
|
||||
case 0x84:op_sty_dp(); break;
|
||||
case 0x85:op_sta_dp(); break;
|
||||
case 0x86:op_stx_dp(); break;
|
||||
case 0x87:op_sta_ildp(); break;
|
||||
case 0x88:op_dey(); break;
|
||||
case 0x89:op_bit_const();break;
|
||||
case 0x8a:op_txa(); break;
|
||||
case 0x8b:op_phb(); break;
|
||||
case 0x8c:op_sty_addr(); break;
|
||||
case 0x8d:op_sta_addr(); break;
|
||||
case 0x8e:op_stx_addr(); break;
|
||||
case 0x8f:op_sta_long(); break;
|
||||
/* 9x */
|
||||
case 0x90:op_bcc(); break;
|
||||
case 0x91:op_sta_idpy(); break;
|
||||
case 0x92:op_sta_idp(); break;
|
||||
case 0x93:op_sta_isry(); break;
|
||||
case 0x94:op_sty_dpx(); break;
|
||||
case 0x95:op_sta_dpx(); break;
|
||||
case 0x96:op_stx_dpy(); break;
|
||||
case 0x97:op_sta_ildpy();break;
|
||||
case 0x98:op_tya(); break;
|
||||
case 0x99:op_sta_addry();break;
|
||||
case 0x9a:op_txs(); break;
|
||||
case 0x9b:op_txy(); break;
|
||||
case 0x9c:op_stz_addr(); break;
|
||||
case 0x9d:op_sta_addrx();break;
|
||||
case 0x9e:op_stz_addrx();break;
|
||||
case 0x9f:op_sta_longx();break;
|
||||
/* ax */
|
||||
case 0xa0:op_ldy_const();break;
|
||||
case 0xa1:op_lda_idpx(); break;
|
||||
case 0xa2:op_ldx_const();break;
|
||||
case 0xa3:op_lda_sr(); break;
|
||||
case 0xa4:op_ldy_dp(); break;
|
||||
case 0xa5:op_lda_dp(); break;
|
||||
case 0xa6:op_ldx_dp(); break;
|
||||
case 0xa7:op_lda_ildp(); break;
|
||||
case 0xa8:op_tay(); break;
|
||||
case 0xa9:op_lda_const();break;
|
||||
case 0xaa:op_tax(); break;
|
||||
case 0xab:op_plb(); break;
|
||||
case 0xac:op_ldy_addr(); break;
|
||||
case 0xad:op_lda_addr(); break;
|
||||
case 0xae:op_ldx_addr(); break;
|
||||
case 0xaf:op_lda_long(); break;
|
||||
/* bx */
|
||||
case 0xb0:op_bcs(); break;
|
||||
case 0xb1:op_lda_idpy(); break;
|
||||
case 0xb2:op_lda_idp(); break;
|
||||
case 0xb3:op_lda_isry(); break;
|
||||
case 0xb4:op_ldy_dpx(); break;
|
||||
case 0xb5:op_lda_dpx(); break;
|
||||
case 0xb6:op_ldx_dpy(); break;
|
||||
case 0xb7:op_lda_ildpy();break;
|
||||
case 0xb8:op_clv(); break;
|
||||
case 0xb9:op_lda_addry();break;
|
||||
case 0xba:op_tsx(); break;
|
||||
case 0xbb:op_tyx(); break;
|
||||
case 0xbc:op_ldy_addrx();break;
|
||||
case 0xbd:op_lda_addrx();break;
|
||||
case 0xbe:op_ldx_addry();break;
|
||||
case 0xbf:op_lda_longx();break;
|
||||
/* cx */
|
||||
case 0xc0:op_cpy_const();break;
|
||||
case 0xc1:op_cmp_idpx(); break;
|
||||
case 0xc2:op_rep(); break;
|
||||
case 0xc3:op_cmp_sr(); break;
|
||||
case 0xc4:op_cpy_dp(); break;
|
||||
case 0xc5:op_cmp_dp(); break;
|
||||
case 0xc6:op_dec_dp(); break;
|
||||
case 0xc7:op_cmp_ildp(); break;
|
||||
case 0xc8:op_iny(); break;
|
||||
case 0xc9:op_cmp_const();break;
|
||||
case 0xca:op_dex(); break;
|
||||
case 0xcb:op_wai(); break;
|
||||
case 0xcc:op_cpy_addr(); break;
|
||||
case 0xcd:op_cmp_addr(); break;
|
||||
case 0xce:op_dec_addr(); break;
|
||||
case 0xcf:op_cmp_long(); break;
|
||||
/* dx */
|
||||
case 0xd0:op_bne(); break;
|
||||
case 0xd1:op_cmp_idpy(); break;
|
||||
case 0xd2:op_cmp_idp(); break;
|
||||
case 0xd3:op_cmp_isry(); break;
|
||||
case 0xd4:op_pei(); break;
|
||||
case 0xd5:op_cmp_dpx(); break;
|
||||
case 0xd6:op_dec_dpx(); break;
|
||||
case 0xd7:op_cmp_ildpy(); break;
|
||||
case 0xd8:op_cld(); break;
|
||||
case 0xd9:op_cmp_addry(); break;
|
||||
case 0xda:op_phx(); break;
|
||||
case 0xdb:op_stp(); break;
|
||||
case 0xdc:op_jmp_iladdr();break;
|
||||
case 0xdd:op_cmp_addrx(); break;
|
||||
case 0xde:op_dec_addrx(); break;
|
||||
case 0xdf:op_cmp_longx(); break;
|
||||
/* ex */
|
||||
case 0xe0:op_cpx_const();break;
|
||||
case 0xe1:op_sbc_idpx(); break;
|
||||
case 0xe2:op_sep(); break;
|
||||
case 0xe3:op_sbc_sr(); break;
|
||||
case 0xe4:op_cpx_dp(); break;
|
||||
case 0xe5:op_sbc_dp(); break;
|
||||
case 0xe6:op_inc_dp(); break;
|
||||
case 0xe7:op_sbc_ildp(); break;
|
||||
case 0xe8:op_inx(); break;
|
||||
case 0xe9:op_sbc_const();break;
|
||||
case 0xea:op_nop(); break;
|
||||
case 0xeb:op_xba(); break;
|
||||
case 0xec:op_cpx_addr(); break;
|
||||
case 0xed:op_sbc_addr(); break;
|
||||
case 0xee:op_inc_addr(); break;
|
||||
case 0xef:op_sbc_long(); break;
|
||||
/* fx */
|
||||
case 0xf0:op_beq(); break;
|
||||
case 0xf1:op_sbc_idpy(); break;
|
||||
case 0xf2:op_sbc_idp(); break;
|
||||
case 0xf3:op_sbc_isry(); break;
|
||||
case 0xf4:op_pea(); break;
|
||||
case 0xf5:op_sbc_dpx(); break;
|
||||
case 0xf6:op_inc_dpx(); break;
|
||||
case 0xf7:op_sbc_ildpy(); break;
|
||||
case 0xf8:op_sed(); break;
|
||||
case 0xf9:op_sbc_addry(); break;
|
||||
case 0xfa:op_plx(); break;
|
||||
case 0xfb:op_xce(); break;
|
||||
case 0xfc:op_jsr_iaddrx();break;
|
||||
case 0xfd:op_sbc_addrx(); break;
|
||||
case 0xfe:op_inc_addrx(); break;
|
||||
case 0xff:op_sbc_longx(); break;
|
||||
}
|
||||
|
||||
(this->*optbl[op_read()])();
|
||||
snes->notify(SNES::CPU_EXEC_OPCODE);
|
||||
}
|
||||
|
||||
void bCPU::init_op_tables() {
|
||||
optbl = optbl_e;
|
||||
|
||||
/* 0x */
|
||||
optbl[0x00] = op_brk;
|
||||
optbl[0x01] = op_ora_idpxb;
|
||||
optbl[0x02] = op_cop;
|
||||
optbl[0x03] = op_ora_srb;
|
||||
optbl[0x04] = op_tsb_dpb;
|
||||
optbl[0x05] = op_ora_dpb;
|
||||
optbl[0x06] = op_asl_dpb;
|
||||
optbl[0x07] = op_ora_ildpb;
|
||||
optbl[0x08] = op_php;
|
||||
optbl[0x09] = op_ora_constb;
|
||||
optbl[0x0a] = op_aslb;
|
||||
optbl[0x0b] = op_phd;
|
||||
optbl[0x0c] = op_tsb_addrb;
|
||||
optbl[0x0d] = op_ora_addrb;
|
||||
optbl[0x0e] = op_asl_addrb;
|
||||
optbl[0x0f] = op_ora_longb;
|
||||
/* 1x */
|
||||
optbl[0x10] = op_bpl;
|
||||
optbl[0x11] = op_ora_idpyb;
|
||||
optbl[0x12] = op_ora_idpb;
|
||||
optbl[0x13] = op_ora_isryb;
|
||||
optbl[0x14] = op_trb_dpb;
|
||||
optbl[0x15] = op_ora_dpxb;
|
||||
optbl[0x16] = op_asl_dpxb;
|
||||
optbl[0x17] = op_ora_ildpyb;
|
||||
optbl[0x18] = op_clc;
|
||||
optbl[0x19] = op_ora_addryb;
|
||||
optbl[0x1a] = op_incb;
|
||||
optbl[0x1b] = op_tcs;
|
||||
optbl[0x1c] = op_trb_addrb;
|
||||
optbl[0x1d] = op_ora_addrxb;
|
||||
optbl[0x1e] = op_asl_addrxb;
|
||||
optbl[0x1f] = op_ora_longxb;
|
||||
/* 2x */
|
||||
optbl[0x20] = op_jsr_addr;
|
||||
optbl[0x21] = op_and_idpxb;
|
||||
optbl[0x22] = op_jsr_long;
|
||||
optbl[0x23] = op_and_srb;
|
||||
optbl[0x24] = op_bit_dpb;
|
||||
optbl[0x25] = op_and_dpb;
|
||||
optbl[0x26] = op_rol_dpb;
|
||||
optbl[0x27] = op_and_ildpb;
|
||||
optbl[0x28] = op_plp;
|
||||
optbl[0x29] = op_and_constb;
|
||||
optbl[0x2a] = op_rolb;
|
||||
optbl[0x2b] = op_pld;
|
||||
optbl[0x2c] = op_bit_addrb;
|
||||
optbl[0x2d] = op_and_addrb;
|
||||
optbl[0x2e] = op_rol_addrb;
|
||||
optbl[0x2f] = op_and_longb;
|
||||
/* 3x */
|
||||
optbl[0x30] = op_bmi;
|
||||
optbl[0x31] = op_and_idpyb;
|
||||
optbl[0x32] = op_and_idpb;
|
||||
optbl[0x33] = op_and_isryb;
|
||||
optbl[0x34] = op_bit_dpxb;
|
||||
optbl[0x35] = op_and_dpxb;
|
||||
optbl[0x36] = op_rol_dpxb;
|
||||
optbl[0x37] = op_and_ildpyb;
|
||||
optbl[0x38] = op_sec;
|
||||
optbl[0x39] = op_and_addryb;
|
||||
optbl[0x3a] = op_decb;
|
||||
optbl[0x3b] = op_tsc;
|
||||
optbl[0x3c] = op_bit_addrxb;
|
||||
optbl[0x3d] = op_and_addrxb;
|
||||
optbl[0x3e] = op_rol_addrxb;
|
||||
optbl[0x3f] = op_and_longxb;
|
||||
/* 4x */
|
||||
optbl[0x40] = op_rtie;
|
||||
optbl[0x41] = op_eor_idpxb;
|
||||
optbl[0x42] = op_wdm;
|
||||
optbl[0x43] = op_eor_srb;
|
||||
optbl[0x44] = op_mvp;
|
||||
optbl[0x45] = op_eor_dpb;
|
||||
optbl[0x46] = op_lsr_dpb;
|
||||
optbl[0x47] = op_eor_ildpb;
|
||||
optbl[0x48] = op_phab;
|
||||
optbl[0x49] = op_eor_constb;
|
||||
optbl[0x4a] = op_lsrb;
|
||||
optbl[0x4b] = op_phk;
|
||||
optbl[0x4c] = op_jmp_addr;
|
||||
optbl[0x4d] = op_eor_addrb;
|
||||
optbl[0x4e] = op_lsr_addrb;
|
||||
optbl[0x4f] = op_eor_longb;
|
||||
/* 5x */
|
||||
optbl[0x50] = op_bvc;
|
||||
optbl[0x51] = op_eor_idpyb;
|
||||
optbl[0x52] = op_eor_idpb;
|
||||
optbl[0x53] = op_eor_isryb;
|
||||
optbl[0x54] = op_mvn;
|
||||
optbl[0x55] = op_eor_dpxb;
|
||||
optbl[0x56] = op_lsr_dpxb;
|
||||
optbl[0x57] = op_eor_ildpyb;
|
||||
optbl[0x58] = op_cli;
|
||||
optbl[0x59] = op_eor_addryb;
|
||||
optbl[0x5a] = op_phyb;
|
||||
optbl[0x5b] = op_tcd;
|
||||
optbl[0x5c] = op_jmp_long;
|
||||
optbl[0x5d] = op_eor_addrxb;
|
||||
optbl[0x5e] = op_lsr_addrxb;
|
||||
optbl[0x5f] = op_eor_longxb;
|
||||
/* 6x */
|
||||
optbl[0x60] = op_rts;
|
||||
optbl[0x61] = op_adc_idpxb;
|
||||
optbl[0x62] = op_per;
|
||||
optbl[0x63] = op_adc_srb;
|
||||
optbl[0x64] = op_stz_dpb;
|
||||
optbl[0x65] = op_adc_dpb;
|
||||
optbl[0x66] = op_ror_dpb;
|
||||
optbl[0x67] = op_adc_ildpb;
|
||||
optbl[0x68] = op_plab;
|
||||
optbl[0x69] = op_adc_constb;
|
||||
optbl[0x6a] = op_rorb;
|
||||
optbl[0x6b] = op_rtl;
|
||||
optbl[0x6c] = op_jmp_iaddr;
|
||||
optbl[0x6d] = op_adc_addrb;
|
||||
optbl[0x6e] = op_ror_addrb;
|
||||
optbl[0x6f] = op_adc_longb;
|
||||
/* 7x */
|
||||
optbl[0x70] = op_bvs;
|
||||
optbl[0x71] = op_adc_idpyb;
|
||||
optbl[0x72] = op_adc_idpb;
|
||||
optbl[0x73] = op_adc_isryb;
|
||||
optbl[0x74] = op_stz_dpxb;
|
||||
optbl[0x75] = op_adc_dpxb;
|
||||
optbl[0x76] = op_ror_dpxb;
|
||||
optbl[0x77] = op_adc_ildpyb;
|
||||
optbl[0x78] = op_sei;
|
||||
optbl[0x79] = op_adc_addryb;
|
||||
optbl[0x7a] = op_plyb;
|
||||
optbl[0x7b] = op_tdc;
|
||||
optbl[0x7c] = op_jmp_iaddrx;
|
||||
optbl[0x7d] = op_adc_addrxb;
|
||||
optbl[0x7e] = op_ror_addrxb;
|
||||
optbl[0x7f] = op_adc_longxb;
|
||||
/* 8x */
|
||||
optbl[0x80] = op_bra;
|
||||
optbl[0x81] = op_sta_idpxb;
|
||||
optbl[0x82] = op_brl;
|
||||
optbl[0x83] = op_sta_srb;
|
||||
optbl[0x84] = op_sty_dpb;
|
||||
optbl[0x85] = op_sta_dpb;
|
||||
optbl[0x86] = op_stx_dpb;
|
||||
optbl[0x87] = op_sta_ildpb;
|
||||
optbl[0x88] = op_deyb;
|
||||
optbl[0x89] = op_bit_constb;
|
||||
optbl[0x8a] = op_txab;
|
||||
optbl[0x8b] = op_phb;
|
||||
optbl[0x8c] = op_sty_addrb;
|
||||
optbl[0x8d] = op_sta_addrb;
|
||||
optbl[0x8e] = op_stx_addrb;
|
||||
optbl[0x8f] = op_sta_longb;
|
||||
/* 9x */
|
||||
optbl[0x90] = op_bcc;
|
||||
optbl[0x91] = op_sta_idpyb;
|
||||
optbl[0x92] = op_sta_idpb;
|
||||
optbl[0x93] = op_sta_isryb;
|
||||
optbl[0x94] = op_sty_dpxb;
|
||||
optbl[0x95] = op_sta_dpxb;
|
||||
optbl[0x96] = op_stx_dpyb;
|
||||
optbl[0x97] = op_sta_ildpyb;
|
||||
optbl[0x98] = op_tyab;
|
||||
optbl[0x99] = op_sta_addryb;
|
||||
optbl[0x9a] = op_txsb;
|
||||
optbl[0x9b] = op_txyb;
|
||||
optbl[0x9c] = op_stz_addrb;
|
||||
optbl[0x9d] = op_sta_addrxb;
|
||||
optbl[0x9e] = op_stz_addrxb;
|
||||
optbl[0x9f] = op_sta_longxb;
|
||||
/* ax */
|
||||
optbl[0xa0] = op_ldy_constb;
|
||||
optbl[0xa1] = op_lda_idpxb;
|
||||
optbl[0xa2] = op_ldx_constb;
|
||||
optbl[0xa3] = op_lda_srb;
|
||||
optbl[0xa4] = op_ldy_dpb;
|
||||
optbl[0xa5] = op_lda_dpb;
|
||||
optbl[0xa6] = op_ldx_dpb;
|
||||
optbl[0xa7] = op_lda_ildpb;
|
||||
optbl[0xa8] = op_tayb;
|
||||
optbl[0xa9] = op_lda_constb;
|
||||
optbl[0xaa] = op_taxb;
|
||||
optbl[0xab] = op_plb;
|
||||
optbl[0xac] = op_ldy_addrb;
|
||||
optbl[0xad] = op_lda_addrb;
|
||||
optbl[0xae] = op_ldx_addrb;
|
||||
optbl[0xaf] = op_lda_longb;
|
||||
/* bx */
|
||||
optbl[0xb0] = op_bcs;
|
||||
optbl[0xb1] = op_lda_idpyb;
|
||||
optbl[0xb2] = op_lda_idpb;
|
||||
optbl[0xb3] = op_lda_isryb;
|
||||
optbl[0xb4] = op_ldy_dpxb;
|
||||
optbl[0xb5] = op_lda_dpxb;
|
||||
optbl[0xb6] = op_ldx_dpyb;
|
||||
optbl[0xb7] = op_lda_ildpyb;
|
||||
optbl[0xb8] = op_clv;
|
||||
optbl[0xb9] = op_lda_addryb;
|
||||
optbl[0xba] = op_tsxb;
|
||||
optbl[0xbb] = op_tyxb;
|
||||
optbl[0xbc] = op_ldy_addrxb;
|
||||
optbl[0xbd] = op_lda_addrxb;
|
||||
optbl[0xbe] = op_ldx_addryb;
|
||||
optbl[0xbf] = op_lda_longxb;
|
||||
/* cx */
|
||||
optbl[0xc0] = op_cpy_constb;
|
||||
optbl[0xc1] = op_cmp_idpxb;
|
||||
optbl[0xc2] = op_rep;
|
||||
optbl[0xc3] = op_cmp_srb;
|
||||
optbl[0xc4] = op_cpy_dpb;
|
||||
optbl[0xc5] = op_cmp_dpb;
|
||||
optbl[0xc6] = op_dec_dpb;
|
||||
optbl[0xc7] = op_cmp_ildpb;
|
||||
optbl[0xc8] = op_inyb;
|
||||
optbl[0xc9] = op_cmp_constb;
|
||||
optbl[0xca] = op_dexb;
|
||||
optbl[0xcb] = op_wai;
|
||||
optbl[0xcc] = op_cpy_addrb;
|
||||
optbl[0xcd] = op_cmp_addrb;
|
||||
optbl[0xce] = op_dec_addrb;
|
||||
optbl[0xcf] = op_cmp_longb;
|
||||
/* dx */
|
||||
optbl[0xd0] = op_bne;
|
||||
optbl[0xd1] = op_cmp_idpyb;
|
||||
optbl[0xd2] = op_cmp_idpb;
|
||||
optbl[0xd3] = op_cmp_isryb;
|
||||
optbl[0xd4] = op_pei;
|
||||
optbl[0xd5] = op_cmp_dpxb;
|
||||
optbl[0xd6] = op_dec_dpxb;
|
||||
optbl[0xd7] = op_cmp_ildpyb;
|
||||
optbl[0xd8] = op_cld;
|
||||
optbl[0xd9] = op_cmp_addryb;
|
||||
optbl[0xda] = op_phxb;
|
||||
optbl[0xdb] = op_stp;
|
||||
optbl[0xdc] = op_jmp_iladdr;
|
||||
optbl[0xdd] = op_cmp_addrxb;
|
||||
optbl[0xde] = op_dec_addrxb;
|
||||
optbl[0xdf] = op_cmp_longxb;
|
||||
/* ex */
|
||||
optbl[0xe0] = op_cpx_constb;
|
||||
optbl[0xe1] = op_sbc_idpxb;
|
||||
optbl[0xe2] = op_sep;
|
||||
optbl[0xe3] = op_sbc_srb;
|
||||
optbl[0xe4] = op_cpx_dpb;
|
||||
optbl[0xe5] = op_sbc_dpb;
|
||||
optbl[0xe6] = op_inc_dpb;
|
||||
optbl[0xe7] = op_sbc_ildpb;
|
||||
optbl[0xe8] = op_inxb;
|
||||
optbl[0xe9] = op_sbc_constb;
|
||||
optbl[0xea] = op_nop;
|
||||
optbl[0xeb] = op_xba;
|
||||
optbl[0xec] = op_cpx_addrb;
|
||||
optbl[0xed] = op_sbc_addrb;
|
||||
optbl[0xee] = op_inc_addrb;
|
||||
optbl[0xef] = op_sbc_longb;
|
||||
/* fx */
|
||||
optbl[0xf0] = op_beq;
|
||||
optbl[0xf1] = op_sbc_idpyb;
|
||||
optbl[0xf2] = op_sbc_idpb;
|
||||
optbl[0xf3] = op_sbc_isryb;
|
||||
optbl[0xf4] = op_pea;
|
||||
optbl[0xf5] = op_sbc_dpxb;
|
||||
optbl[0xf6] = op_inc_dpxb;
|
||||
optbl[0xf7] = op_sbc_ildpyb;
|
||||
optbl[0xf8] = op_sed;
|
||||
optbl[0xf9] = op_sbc_addryb;
|
||||
optbl[0xfa] = op_plxb;
|
||||
optbl[0xfb] = op_xce;
|
||||
optbl[0xfc] = op_jsr_iaddrx;
|
||||
optbl[0xfd] = op_sbc_addrxb;
|
||||
optbl[0xfe] = op_inc_addrxb;
|
||||
optbl[0xff] = op_sbc_longxb;
|
||||
|
||||
memcpy(optbl_MX, optbl_e, sizeof(optbl_e));
|
||||
memcpy(optbl_Mx, optbl_e, sizeof(optbl_e));
|
||||
memcpy(optbl_mX, optbl_e, sizeof(optbl_e));
|
||||
memcpy(optbl_mx, optbl_e, sizeof(optbl_e));
|
||||
|
||||
/* adc */
|
||||
optbl_mX[0x69] = optbl_mx[0x69] = op_adc_constw;
|
||||
optbl_mX[0x6d] = optbl_mx[0x6d] = op_adc_addrw;
|
||||
optbl_mX[0x7d] = optbl_mx[0x7d] = op_adc_addrxw;
|
||||
optbl_mX[0x65] = optbl_mx[0x65] = op_adc_dpw;
|
||||
optbl_mX[0x72] = optbl_mx[0x72] = op_adc_idpw;
|
||||
optbl_mX[0x67] = optbl_mx[0x67] = op_adc_ildpw;
|
||||
optbl_mX[0x6f] = optbl_mx[0x6f] = op_adc_longw;
|
||||
optbl_mX[0x7f] = optbl_mx[0x7f] = op_adc_longxw;
|
||||
optbl_mX[0x79] = optbl_mx[0x79] = op_adc_addryw;
|
||||
optbl_mX[0x75] = optbl_mx[0x75] = op_adc_dpxw;
|
||||
optbl_mX[0x61] = optbl_mx[0x61] = op_adc_idpxw;
|
||||
optbl_mX[0x71] = optbl_mx[0x71] = op_adc_idpyw;
|
||||
optbl_mX[0x77] = optbl_mx[0x77] = op_adc_ildpyw;
|
||||
optbl_mX[0x63] = optbl_mx[0x63] = op_adc_srw;
|
||||
optbl_mX[0x73] = optbl_mx[0x73] = op_adc_isryw;
|
||||
|
||||
/* and */
|
||||
optbl_mX[0x29] = optbl_mx[0x29] = op_and_constw;
|
||||
optbl_mX[0x2d] = optbl_mx[0x2d] = op_and_addrw;
|
||||
optbl_mX[0x3d] = optbl_mx[0x3d] = op_and_addrxw;
|
||||
optbl_mX[0x25] = optbl_mx[0x25] = op_and_dpw;
|
||||
optbl_mX[0x32] = optbl_mx[0x32] = op_and_idpw;
|
||||
optbl_mX[0x27] = optbl_mx[0x27] = op_and_ildpw;
|
||||
optbl_mX[0x2f] = optbl_mx[0x2f] = op_and_longw;
|
||||
optbl_mX[0x3f] = optbl_mx[0x3f] = op_and_longxw;
|
||||
optbl_mX[0x39] = optbl_mx[0x39] = op_and_addryw;
|
||||
optbl_mX[0x35] = optbl_mx[0x35] = op_and_dpxw;
|
||||
optbl_mX[0x21] = optbl_mx[0x21] = op_and_idpxw;
|
||||
optbl_mX[0x31] = optbl_mx[0x31] = op_and_idpyw;
|
||||
optbl_mX[0x37] = optbl_mx[0x37] = op_and_ildpyw;
|
||||
optbl_mX[0x23] = optbl_mx[0x23] = op_and_srw;
|
||||
optbl_mX[0x33] = optbl_mx[0x33] = op_and_isryw;
|
||||
|
||||
/* cmp */
|
||||
optbl_mX[0xc9] = optbl_mx[0xc9] = op_cmp_constw;
|
||||
optbl_mX[0xcd] = optbl_mx[0xcd] = op_cmp_addrw;
|
||||
optbl_mX[0xdd] = optbl_mx[0xdd] = op_cmp_addrxw;
|
||||
optbl_mX[0xc5] = optbl_mx[0xc5] = op_cmp_dpw;
|
||||
optbl_mX[0xd2] = optbl_mx[0xd2] = op_cmp_idpw;
|
||||
optbl_mX[0xc7] = optbl_mx[0xc7] = op_cmp_ildpw;
|
||||
optbl_mX[0xcf] = optbl_mx[0xcf] = op_cmp_longw;
|
||||
optbl_mX[0xdf] = optbl_mx[0xdf] = op_cmp_longxw;
|
||||
optbl_mX[0xd9] = optbl_mx[0xd9] = op_cmp_addryw;
|
||||
optbl_mX[0xd5] = optbl_mx[0xd5] = op_cmp_dpxw;
|
||||
optbl_mX[0xc1] = optbl_mx[0xc1] = op_cmp_idpxw;
|
||||
optbl_mX[0xd1] = optbl_mx[0xd1] = op_cmp_idpyw;
|
||||
optbl_mX[0xd7] = optbl_mx[0xd7] = op_cmp_ildpyw;
|
||||
optbl_mX[0xc3] = optbl_mx[0xc3] = op_cmp_srw;
|
||||
optbl_mX[0xd3] = optbl_mx[0xd3] = op_cmp_isryw;
|
||||
|
||||
/* eor */
|
||||
optbl_mX[0x49] = optbl_mx[0x49] = op_eor_constw;
|
||||
optbl_mX[0x4d] = optbl_mx[0x4d] = op_eor_addrw;
|
||||
optbl_mX[0x5d] = optbl_mx[0x5d] = op_eor_addrxw;
|
||||
optbl_mX[0x45] = optbl_mx[0x45] = op_eor_dpw;
|
||||
optbl_mX[0x52] = optbl_mx[0x52] = op_eor_idpw;
|
||||
optbl_mX[0x47] = optbl_mx[0x47] = op_eor_ildpw;
|
||||
optbl_mX[0x4f] = optbl_mx[0x4f] = op_eor_longw;
|
||||
optbl_mX[0x5f] = optbl_mx[0x5f] = op_eor_longxw;
|
||||
optbl_mX[0x59] = optbl_mx[0x59] = op_eor_addryw;
|
||||
optbl_mX[0x55] = optbl_mx[0x55] = op_eor_dpxw;
|
||||
optbl_mX[0x41] = optbl_mx[0x41] = op_eor_idpxw;
|
||||
optbl_mX[0x51] = optbl_mx[0x51] = op_eor_idpyw;
|
||||
optbl_mX[0x57] = optbl_mx[0x57] = op_eor_ildpyw;
|
||||
optbl_mX[0x43] = optbl_mx[0x43] = op_eor_srw;
|
||||
optbl_mX[0x53] = optbl_mx[0x53] = op_eor_isryw;
|
||||
|
||||
/* lda */
|
||||
optbl_mX[0xa9] = optbl_mx[0xa9] = op_lda_constw;
|
||||
optbl_mX[0xad] = optbl_mx[0xad] = op_lda_addrw;
|
||||
optbl_mX[0xbd] = optbl_mx[0xbd] = op_lda_addrxw;
|
||||
optbl_mX[0xa5] = optbl_mx[0xa5] = op_lda_dpw;
|
||||
optbl_mX[0xb2] = optbl_mx[0xb2] = op_lda_idpw;
|
||||
optbl_mX[0xa7] = optbl_mx[0xa7] = op_lda_ildpw;
|
||||
optbl_mX[0xaf] = optbl_mx[0xaf] = op_lda_longw;
|
||||
optbl_mX[0xbf] = optbl_mx[0xbf] = op_lda_longxw;
|
||||
optbl_mX[0xb9] = optbl_mx[0xb9] = op_lda_addryw;
|
||||
optbl_mX[0xb5] = optbl_mx[0xb5] = op_lda_dpxw;
|
||||
optbl_mX[0xa1] = optbl_mx[0xa1] = op_lda_idpxw;
|
||||
optbl_mX[0xb1] = optbl_mx[0xb1] = op_lda_idpyw;
|
||||
optbl_mX[0xb7] = optbl_mx[0xb7] = op_lda_ildpyw;
|
||||
optbl_mX[0xa3] = optbl_mx[0xa3] = op_lda_srw;
|
||||
optbl_mX[0xb3] = optbl_mx[0xb3] = op_lda_isryw;
|
||||
|
||||
/* ora */
|
||||
optbl_mX[0x09] = optbl_mx[0x09] = op_ora_constw;
|
||||
optbl_mX[0x0d] = optbl_mx[0x0d] = op_ora_addrw;
|
||||
optbl_mX[0x1d] = optbl_mx[0x1d] = op_ora_addrxw;
|
||||
optbl_mX[0x05] = optbl_mx[0x05] = op_ora_dpw;
|
||||
optbl_mX[0x12] = optbl_mx[0x12] = op_ora_idpw;
|
||||
optbl_mX[0x07] = optbl_mx[0x07] = op_ora_ildpw;
|
||||
optbl_mX[0x0f] = optbl_mx[0x0f] = op_ora_longw;
|
||||
optbl_mX[0x1f] = optbl_mx[0x1f] = op_ora_longxw;
|
||||
optbl_mX[0x19] = optbl_mx[0x19] = op_ora_addryw;
|
||||
optbl_mX[0x15] = optbl_mx[0x15] = op_ora_dpxw;
|
||||
optbl_mX[0x01] = optbl_mx[0x01] = op_ora_idpxw;
|
||||
optbl_mX[0x11] = optbl_mx[0x11] = op_ora_idpyw;
|
||||
optbl_mX[0x17] = optbl_mx[0x17] = op_ora_ildpyw;
|
||||
optbl_mX[0x03] = optbl_mx[0x03] = op_ora_srw;
|
||||
optbl_mX[0x13] = optbl_mx[0x13] = op_ora_isryw;
|
||||
|
||||
/* sbc */
|
||||
optbl_mX[0xe9] = optbl_mx[0xe9] = op_sbc_constw;
|
||||
optbl_mX[0xed] = optbl_mx[0xed] = op_sbc_addrw;
|
||||
optbl_mX[0xfd] = optbl_mx[0xfd] = op_sbc_addrxw;
|
||||
optbl_mX[0xe5] = optbl_mx[0xe5] = op_sbc_dpw;
|
||||
optbl_mX[0xf2] = optbl_mx[0xf2] = op_sbc_idpw;
|
||||
optbl_mX[0xe7] = optbl_mx[0xe7] = op_sbc_ildpw;
|
||||
optbl_mX[0xef] = optbl_mx[0xef] = op_sbc_longw;
|
||||
optbl_mX[0xff] = optbl_mx[0xff] = op_sbc_longxw;
|
||||
optbl_mX[0xf9] = optbl_mx[0xf9] = op_sbc_addryw;
|
||||
optbl_mX[0xf5] = optbl_mx[0xf5] = op_sbc_dpxw;
|
||||
optbl_mX[0xe1] = optbl_mx[0xe1] = op_sbc_idpxw;
|
||||
optbl_mX[0xf1] = optbl_mx[0xf1] = op_sbc_idpyw;
|
||||
optbl_mX[0xf7] = optbl_mx[0xf7] = op_sbc_ildpyw;
|
||||
optbl_mX[0xe3] = optbl_mx[0xe3] = op_sbc_srw;
|
||||
optbl_mX[0xf3] = optbl_mx[0xf3] = op_sbc_isryw;
|
||||
|
||||
/* sta */
|
||||
optbl_mX[0x8d] = optbl_mx[0x8d] = op_sta_addrw;
|
||||
optbl_mX[0x9d] = optbl_mx[0x9d] = op_sta_addrxw;
|
||||
optbl_mX[0x85] = optbl_mx[0x85] = op_sta_dpw;
|
||||
optbl_mX[0x92] = optbl_mx[0x92] = op_sta_idpw;
|
||||
optbl_mX[0x87] = optbl_mx[0x87] = op_sta_ildpw;
|
||||
optbl_mX[0x8f] = optbl_mx[0x8f] = op_sta_longw;
|
||||
optbl_mX[0x9f] = optbl_mx[0x9f] = op_sta_longxw;
|
||||
optbl_mX[0x99] = optbl_mx[0x99] = op_sta_addryw;
|
||||
optbl_mX[0x95] = optbl_mx[0x95] = op_sta_dpxw;
|
||||
optbl_mX[0x81] = optbl_mx[0x81] = op_sta_idpxw;
|
||||
optbl_mX[0x91] = optbl_mx[0x91] = op_sta_idpyw;
|
||||
optbl_mX[0x97] = optbl_mx[0x97] = op_sta_ildpyw;
|
||||
optbl_mX[0x83] = optbl_mx[0x83] = op_sta_srw;
|
||||
optbl_mX[0x93] = optbl_mx[0x93] = op_sta_isryw;
|
||||
|
||||
/* incdec */
|
||||
optbl_mX[0x1a] = optbl_mx[0x1a] = op_incw;
|
||||
optbl_mX[0xee] = optbl_mx[0xee] = op_inc_addrw;
|
||||
optbl_mX[0xfe] = optbl_mx[0xfe] = op_inc_addrxw;
|
||||
optbl_mX[0xe6] = optbl_mx[0xe6] = op_inc_dpw;
|
||||
optbl_mX[0xf6] = optbl_mx[0xf6] = op_inc_dpxw;
|
||||
optbl_mX[0x3a] = optbl_mx[0x3a] = op_decw;
|
||||
optbl_mX[0xce] = optbl_mx[0xce] = op_dec_addrw;
|
||||
optbl_mX[0xde] = optbl_mx[0xde] = op_dec_addrxw;
|
||||
optbl_mX[0xc6] = optbl_mx[0xc6] = op_dec_dpw;
|
||||
optbl_mX[0xd6] = optbl_mx[0xd6] = op_dec_dpxw;
|
||||
|
||||
optbl_Mx[0xe8] = optbl_mx[0xe8] = op_inxw;
|
||||
optbl_Mx[0xc8] = optbl_mx[0xc8] = op_inyw;
|
||||
optbl_Mx[0xca] = optbl_mx[0xca] = op_dexw;
|
||||
optbl_Mx[0x88] = optbl_mx[0x88] = op_deyw;
|
||||
|
||||
/* misc */
|
||||
optbl_mX[0x89] = optbl_mx[0x89] = op_bit_constw;
|
||||
optbl_mX[0x2c] = optbl_mx[0x2c] = op_bit_addrw;
|
||||
optbl_mX[0x3c] = optbl_mx[0x3c] = op_bit_addrxw;
|
||||
optbl_mX[0x24] = optbl_mx[0x24] = op_bit_dpw;
|
||||
optbl_mX[0x34] = optbl_mx[0x34] = op_bit_dpxw;
|
||||
optbl_mX[0x9c] = optbl_mx[0x9c] = op_stz_addrw;
|
||||
optbl_mX[0x9e] = optbl_mx[0x9e] = op_stz_addrxw;
|
||||
optbl_mX[0x64] = optbl_mx[0x64] = op_stz_dpw;
|
||||
optbl_mX[0x74] = optbl_mx[0x74] = op_stz_dpxw;
|
||||
optbl_mX[0x1c] = optbl_mx[0x1c] = op_trb_addrw;
|
||||
optbl_mX[0x14] = optbl_mx[0x14] = op_trb_dpw;
|
||||
optbl_mX[0x0c] = optbl_mx[0x0c] = op_tsb_addrw;
|
||||
optbl_mX[0x04] = optbl_mx[0x04] = op_tsb_dpw;
|
||||
optbl_mX[0x8a] = optbl_mx[0x8a] = op_txaw;
|
||||
optbl_mX[0x98] = optbl_mx[0x98] = op_tyaw;
|
||||
|
||||
optbl_Mx[0xe0] = optbl_mx[0xe0] = op_cpx_constw;
|
||||
optbl_Mx[0xec] = optbl_mx[0xec] = op_cpx_addrw;
|
||||
optbl_Mx[0xe4] = optbl_mx[0xe4] = op_cpx_dpw;
|
||||
optbl_Mx[0xc0] = optbl_mx[0xc0] = op_cpy_constw;
|
||||
optbl_Mx[0xcc] = optbl_mx[0xcc] = op_cpy_addrw;
|
||||
optbl_Mx[0xc4] = optbl_mx[0xc4] = op_cpy_dpw;
|
||||
optbl_Mx[0xa2] = optbl_mx[0xa2] = op_ldx_constw;
|
||||
optbl_Mx[0xae] = optbl_mx[0xae] = op_ldx_addrw;
|
||||
optbl_Mx[0xbe] = optbl_mx[0xbe] = op_ldx_addryw;
|
||||
optbl_Mx[0xa6] = optbl_mx[0xa6] = op_ldx_dpw;
|
||||
optbl_Mx[0xb6] = optbl_mx[0xb6] = op_ldx_dpyw;
|
||||
optbl_Mx[0xa0] = optbl_mx[0xa0] = op_ldy_constw;
|
||||
optbl_Mx[0xac] = optbl_mx[0xac] = op_ldy_addrw;
|
||||
optbl_Mx[0xbc] = optbl_mx[0xbc] = op_ldy_addrxw;
|
||||
optbl_Mx[0xa4] = optbl_mx[0xa4] = op_ldy_dpw;
|
||||
optbl_Mx[0xb4] = optbl_mx[0xb4] = op_ldy_dpxw;
|
||||
optbl_Mx[0x8e] = optbl_mx[0x8e] = op_stx_addrw;
|
||||
optbl_Mx[0x86] = optbl_mx[0x86] = op_stx_dpw;
|
||||
optbl_Mx[0x96] = optbl_mx[0x96] = op_stx_dpyw;
|
||||
optbl_Mx[0x8c] = optbl_mx[0x8c] = op_sty_addrw;
|
||||
optbl_Mx[0x84] = optbl_mx[0x84] = op_sty_dpw;
|
||||
optbl_Mx[0x94] = optbl_mx[0x94] = op_sty_dpxw;
|
||||
optbl_Mx[0xaa] = optbl_mx[0xaa] = op_taxw;
|
||||
optbl_Mx[0xa8] = optbl_mx[0xa8] = op_tayw;
|
||||
optbl_Mx[0xba] = optbl_mx[0xba] = op_tsxw;
|
||||
optbl_Mx[0x9a] = optbl_mx[0x9a] = op_txsw;
|
||||
optbl_Mx[0x9b] = optbl_mx[0x9b] = op_txyw;
|
||||
optbl_Mx[0xbb] = optbl_mx[0xbb] = op_tyxw;
|
||||
|
||||
/* pc */
|
||||
optbl_MX[0x40] = optbl_Mx[0x40] = op_rtin;
|
||||
optbl_mX[0x40] = optbl_mx[0x40] = op_rtin;
|
||||
|
||||
/* shift */
|
||||
optbl_mX[0x0a] = optbl_mx[0x0a] = op_aslw;
|
||||
optbl_mX[0x0e] = optbl_mx[0x0e] = op_asl_addrw;
|
||||
optbl_mX[0x1e] = optbl_mx[0x1e] = op_asl_addrxw;
|
||||
optbl_mX[0x06] = optbl_mx[0x06] = op_asl_dpw;
|
||||
optbl_mX[0x16] = optbl_mx[0x16] = op_asl_dpxw;
|
||||
optbl_mX[0x4a] = optbl_mx[0x4a] = op_lsrw;
|
||||
optbl_mX[0x4e] = optbl_mx[0x4e] = op_lsr_addrw;
|
||||
optbl_mX[0x5e] = optbl_mx[0x5e] = op_lsr_addrxw;
|
||||
optbl_mX[0x46] = optbl_mx[0x46] = op_lsr_dpw;
|
||||
optbl_mX[0x56] = optbl_mx[0x56] = op_lsr_dpxw;
|
||||
optbl_mX[0x2a] = optbl_mx[0x2a] = op_rolw;
|
||||
optbl_mX[0x2e] = optbl_mx[0x2e] = op_rol_addrw;
|
||||
optbl_mX[0x3e] = optbl_mx[0x3e] = op_rol_addrxw;
|
||||
optbl_mX[0x26] = optbl_mx[0x26] = op_rol_dpw;
|
||||
optbl_mX[0x36] = optbl_mx[0x36] = op_rol_dpxw;
|
||||
optbl_mX[0x6a] = optbl_mx[0x6a] = op_rorw;
|
||||
optbl_mX[0x6e] = optbl_mx[0x6e] = op_ror_addrw;
|
||||
optbl_mX[0x7e] = optbl_mx[0x7e] = op_ror_addrxw;
|
||||
optbl_mX[0x66] = optbl_mx[0x66] = op_ror_dpw;
|
||||
optbl_mX[0x76] = optbl_mx[0x76] = op_ror_dpxw;
|
||||
|
||||
/* stack */
|
||||
optbl_mX[0x48] = optbl_mx[0x48] = op_phaw;
|
||||
optbl_mX[0x68] = optbl_mx[0x68] = op_plaw;
|
||||
|
||||
optbl_Mx[0xda] = optbl_mx[0xda] = op_phxw;
|
||||
optbl_Mx[0x5a] = optbl_mx[0x5a] = op_phyw;
|
||||
optbl_Mx[0xfa] = optbl_mx[0xfa] = op_plxw;
|
||||
optbl_Mx[0x7a] = optbl_mx[0x7a] = op_plyw;
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ uint8 bCPU::mmio_r4218() {
|
|||
uint8 r = 0x00;
|
||||
uint16 v = clock->vcounter();
|
||||
if(status.auto_joypad_poll == false)return 0x00; //can't read joypad if auto polling not enabled
|
||||
if(v >= 225 && v <= 227)return 0x00; //can't read joypad while SNES is polling input
|
||||
//if(v >= 225 && v <= 227)return 0x00; //can't read joypad while SNES is polling input
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_A) << 7;
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_X) << 6;
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_L) << 5;
|
||||
|
@ -190,7 +190,7 @@ uint8 bCPU::mmio_r4219() {
|
|||
uint8 r = 0x00;
|
||||
uint16 v = clock->vcounter();
|
||||
if(status.auto_joypad_poll == false)return 0x00; //can't read joypad if auto polling not enabled
|
||||
if(v >= 225 && v <= 227)return 0x00; //can't read joypad while SNES is polling input
|
||||
//if(v >= 225 && v <= 227)return 0x00; //can't read joypad while SNES is polling input
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_B) << 7;
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_Y) << 6;
|
||||
r |= (uint8)snes->get_input_status(SNES::DEV_JOYPAD1, SNES::JOYPAD_SELECT) << 5;
|
||||
|
@ -250,9 +250,11 @@ void bCPU::mmio_w2183(uint8 value) {
|
|||
|
||||
//JOYSER0
|
||||
void bCPU::mmio_w4016(uint8 value) {
|
||||
status.joypad1_strobe_value = value;
|
||||
if(value == 1)snes->poll_input();
|
||||
if(value == 0)status.joypad1_read_pos = 0;
|
||||
status.joypad1_strobe_value = (value & 1);
|
||||
if(value == 1) {
|
||||
snes->poll_input();
|
||||
status.joypad1_read_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//NMITIMEN
|
||||
|
@ -320,22 +322,24 @@ void bCPU::mmio_w420a(uint8 value) {
|
|||
|
||||
//DMAEN
|
||||
void bCPU::mmio_w420b(uint8 value) {
|
||||
if(value != 0x00) {
|
||||
clock->add_cc1_cycles(18);
|
||||
}
|
||||
|
||||
for(int i=0;i<8;i++) {
|
||||
dma->channel[i].active = !!(value & (1 << i));
|
||||
if(dma->channel[i].active == true) {
|
||||
if(value & (1 << i)) {
|
||||
dma->channel[i].active = true;
|
||||
dma->channel[i].hdma_active = false;
|
||||
clock->add_cc1_cycles(8);
|
||||
cpustate = CPUSTATE_DMA;
|
||||
}
|
||||
}
|
||||
cpustate = CPUSTATE_DMA;
|
||||
}
|
||||
|
||||
//HDMAEN
|
||||
void bCPU::mmio_w420c(uint8 value) {
|
||||
for(int i=0;i<8;i++) {
|
||||
dma->channel[i].hdma_active = !!(value & (1 << i));
|
||||
if(dma->channel[i].hdma_active == true) {
|
||||
dma->channel[i].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,9 +614,10 @@ uint8 x, active_channels = 0;
|
|||
if(channel[i].hdma_indirect == false) {
|
||||
channel[i].hdma_iaddress = channel[i].hdma_address;
|
||||
} else {
|
||||
channel[i].hdma_iaddress = mem_bus->read(channel[i].hdma_address++);
|
||||
channel[i].hdma_iaddress |= mem_bus->read(channel[i].hdma_address++) << 8;
|
||||
channel[i].hdma_iaddress = mem_bus->read(channel[i].hdma_address);
|
||||
channel[i].hdma_iaddress |= mem_bus->read(channel[i].hdma_address + 1) << 8;
|
||||
channel[i].hdma_iaddress |= channel[i].hdma_indirect_bank << 16;
|
||||
channel[i].hdma_address += 2;
|
||||
clock->add_cc1_cycles(16);
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +653,7 @@ uint8 x, active_channels = 0;
|
|||
void bDMA::hdma_initialize() {
|
||||
uint8 active_channels = 0;
|
||||
for(int i=0;i<8;i++) {
|
||||
if(!channel[i].hdma_active) {
|
||||
if(channel[i].hdma_active == false) {
|
||||
channel[i].hdma_completed = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -687,9 +692,8 @@ void bDMA::reset() {
|
|||
channel[i].hdma_line_counter = 0;
|
||||
channel[i].hdma_address = 0;
|
||||
channel[i].hdma_iaddress = 0;
|
||||
channel[i].hdma_completed = false;
|
||||
channel[i].hdma_completed = true;
|
||||
}
|
||||
hdma_triggered = false;
|
||||
}
|
||||
|
||||
bDMA::bDMA(bCPU *_cpu) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void bCPU::flags_adc_b() {
|
||||
inline void bCPU::flags_adc_b() {
|
||||
int32 r = regs.a.l + rd.l + regs.p.c;
|
||||
//bcd
|
||||
if(regs.p.d) {
|
||||
|
@ -12,7 +12,7 @@ int32 r = regs.a.l + rd.l + regs.p.c;
|
|||
regs.a.l = r;
|
||||
}
|
||||
|
||||
void bCPU::flags_adc_w() {
|
||||
inline void bCPU::flags_adc_w() {
|
||||
int32 r = regs.a.w + rd.w + regs.p.c;
|
||||
//bcd
|
||||
if(regs.p.d) {
|
||||
|
@ -47,8 +47,6 @@ void bCPU::op_adc_constw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_const() { (regs.p.m)?op_adc_constb():op_adc_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x6d: adc addr ***
|
||||
**********************
|
||||
|
@ -74,8 +72,6 @@ void bCPU::op_adc_addrw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_addr() { (regs.p.m)?op_adc_addrb():op_adc_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x7d: adc addr,x ***
|
||||
************************
|
||||
|
@ -104,8 +100,6 @@ void bCPU::op_adc_addrxw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_addrx() { (regs.p.m)?op_adc_addrxb():op_adc_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x65: adc dp ***
|
||||
********************
|
||||
|
@ -131,8 +125,6 @@ void bCPU::op_adc_dpw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_dp() { (regs.p.m)?op_adc_dpb():op_adc_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x72: adc (dp) ***
|
||||
**********************
|
||||
|
@ -164,8 +156,6 @@ void bCPU::op_adc_idpw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_idp() { (regs.p.m)?op_adc_idpb():op_adc_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x67: adc [dp] ***
|
||||
**********************
|
||||
|
@ -200,8 +190,6 @@ void bCPU::op_adc_ildpw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_ildp() { (regs.p.m)?op_adc_ildpb():op_adc_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x6f: adc long ***
|
||||
**********************
|
||||
|
@ -230,8 +218,6 @@ void bCPU::op_adc_longw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_long() { (regs.p.m)?op_adc_longb():op_adc_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0x7f: adc long,x ***
|
||||
************************
|
||||
|
@ -260,8 +246,6 @@ void bCPU::op_adc_longxw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_longx() { (regs.p.m)?op_adc_longxb():op_adc_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x79: adc addr,y ***
|
||||
************************
|
||||
|
@ -290,8 +274,6 @@ void bCPU::op_adc_addryw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_addry() { (regs.p.m)?op_adc_addryb():op_adc_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x75: adc dp,x ***
|
||||
**********************
|
||||
|
@ -320,8 +302,6 @@ void bCPU::op_adc_dpxw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_dpx() { (regs.p.m)?op_adc_dpxb():op_adc_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x61: adc (dp,x) ***
|
||||
************************
|
||||
|
@ -356,8 +336,6 @@ void bCPU::op_adc_idpxw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_idpx() { (regs.p.m)?op_adc_idpxb():op_adc_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x71: adc (dp),y ***
|
||||
************************
|
||||
|
@ -392,8 +370,6 @@ void bCPU::op_adc_idpyw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_idpy() { (regs.p.m)?op_adc_idpyb():op_adc_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0x77: adc [dp],y ***
|
||||
************************
|
||||
|
@ -428,8 +404,6 @@ void bCPU::op_adc_ildpyw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_ildpy() { (regs.p.m)?op_adc_ildpyb():op_adc_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x63: adc sr,s ***
|
||||
**********************
|
||||
|
@ -455,8 +429,6 @@ void bCPU::op_adc_srw() {
|
|||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_sr() { (regs.p.m)?op_adc_srb():op_adc_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x73: adc (sr,s),y ***
|
||||
**************************
|
||||
|
@ -490,5 +462,3 @@ void bCPU::op_adc_isryw() {
|
|||
rd.h = op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_adc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_adc_isry() { (regs.p.m)?op_adc_isryb():op_adc_isryw(); }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
void bCPU::flags_and_b() {
|
||||
inline void bCPU::flags_and_b() {
|
||||
regs.p.n = !!(regs.a.l & 0x80);
|
||||
regs.p.z = (regs.a.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_and_w() {
|
||||
inline void bCPU::flags_and_w() {
|
||||
regs.p.n = !!(regs.a.w & 0x8000);
|
||||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ void bCPU::op_and_constw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_const() { (regs.p.m)?op_and_constb():op_and_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x2d: and addr ***
|
||||
**********************
|
||||
|
@ -54,8 +52,6 @@ void bCPU::op_and_addrw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_addr() { (regs.p.m)?op_and_addrb():op_and_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x3d: and addr,x ***
|
||||
************************
|
||||
|
@ -84,8 +80,6 @@ void bCPU::op_and_addrxw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_addrx() { (regs.p.m)?op_and_addrxb():op_and_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x25: and dp ***
|
||||
********************
|
||||
|
@ -111,8 +105,6 @@ void bCPU::op_and_dpw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_dp() { (regs.p.m)?op_and_dpb():op_and_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x32: and (dp) ***
|
||||
**********************
|
||||
|
@ -144,8 +136,6 @@ void bCPU::op_and_idpw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_idp() { (regs.p.m)?op_and_idpb():op_and_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x27: and [dp] ***
|
||||
**********************
|
||||
|
@ -180,8 +170,6 @@ void bCPU::op_and_ildpw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_ildp() { (regs.p.m)?op_and_ildpb():op_and_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x2f: and long ***
|
||||
**********************
|
||||
|
@ -210,8 +198,6 @@ void bCPU::op_and_longw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_long() { (regs.p.m)?op_and_longb():op_and_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0x3f: and long,x ***
|
||||
************************
|
||||
|
@ -240,8 +226,6 @@ void bCPU::op_and_longxw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_longx() { (regs.p.m)?op_and_longxb():op_and_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x39: and addr,y ***
|
||||
************************
|
||||
|
@ -270,8 +254,6 @@ void bCPU::op_and_addryw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_addry() { (regs.p.m)?op_and_addryb():op_and_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x35: and dp,x ***
|
||||
**********************
|
||||
|
@ -300,8 +282,6 @@ void bCPU::op_and_dpxw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_dpx() { (regs.p.m)?op_and_dpxb():op_and_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x21: and (dp,x) ***
|
||||
************************
|
||||
|
@ -336,8 +316,6 @@ void bCPU::op_and_idpxw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_idpx() { (regs.p.m)?op_and_idpxb():op_and_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x31: and (dp),y ***
|
||||
************************
|
||||
|
@ -372,8 +350,6 @@ void bCPU::op_and_idpyw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_idpy() { (regs.p.m)?op_and_idpyb():op_and_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0x37: and [dp],y ***
|
||||
************************
|
||||
|
@ -408,8 +384,6 @@ void bCPU::op_and_ildpyw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_ildpy() { (regs.p.m)?op_and_ildpyb():op_and_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x23: and sr,s ***
|
||||
**********************
|
||||
|
@ -435,8 +409,6 @@ void bCPU::op_and_srw() {
|
|||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_sr() { (regs.p.m)?op_and_srb():op_and_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x33: and (sr,s),y ***
|
||||
**************************
|
||||
|
@ -470,5 +442,3 @@ void bCPU::op_and_isryw() {
|
|||
regs.a.h &= op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_and_w();
|
||||
}
|
||||
|
||||
void bCPU::op_and_isry() { (regs.p.m)?op_and_isryb():op_and_isryw(); }
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
void bCPU::flags_cmp_b() {
|
||||
inline void bCPU::flags_cmp_b() {
|
||||
int32 r = regs.a.l - rd.l;
|
||||
regs.p.n = !!(r & 0x80);
|
||||
regs.p.z = ((uint8)r == 0);
|
||||
regs.p.c = (r >= 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_cmp_w() {
|
||||
inline void bCPU::flags_cmp_w() {
|
||||
int32 r = regs.a.w - rd.w;
|
||||
regs.p.n = !!(r & 0x8000);
|
||||
regs.p.z = ((uint16)r == 0);
|
||||
|
@ -31,8 +31,6 @@ void bCPU::op_cmp_constw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_const() { (regs.p.m)?op_cmp_constb():op_cmp_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xcd: cmp addr ***
|
||||
**********************
|
||||
|
@ -58,8 +56,6 @@ void bCPU::op_cmp_addrw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_addr() { (regs.p.m)?op_cmp_addrb():op_cmp_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xdd: cmp addr,x ***
|
||||
************************
|
||||
|
@ -88,8 +84,6 @@ void bCPU::op_cmp_addrxw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_addrx() { (regs.p.m)?op_cmp_addrxb():op_cmp_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xc5: cmp dp ***
|
||||
********************
|
||||
|
@ -115,8 +109,6 @@ void bCPU::op_cmp_dpw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_dp() { (regs.p.m)?op_cmp_dpb():op_cmp_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xd2: cmp (dp) ***
|
||||
**********************
|
||||
|
@ -148,8 +140,6 @@ void bCPU::op_cmp_idpw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_idp() { (regs.p.m)?op_cmp_idpb():op_cmp_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xc7: cmp [dp] ***
|
||||
**********************
|
||||
|
@ -184,8 +174,6 @@ void bCPU::op_cmp_ildpw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_ildp() { (regs.p.m)?op_cmp_ildpb():op_cmp_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xcf: cmp long ***
|
||||
**********************
|
||||
|
@ -214,8 +202,6 @@ void bCPU::op_cmp_longw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_long() { (regs.p.m)?op_cmp_longb():op_cmp_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0xdf: cmp long,x ***
|
||||
************************
|
||||
|
@ -244,8 +230,6 @@ void bCPU::op_cmp_longxw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_longx() { (regs.p.m)?op_cmp_longxb():op_cmp_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xd9: cmp addr,y ***
|
||||
************************
|
||||
|
@ -274,8 +258,6 @@ void bCPU::op_cmp_addryw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_addry() { (regs.p.m)?op_cmp_addryb():op_cmp_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xd5: cmp dp,x ***
|
||||
**********************
|
||||
|
@ -304,8 +286,6 @@ void bCPU::op_cmp_dpxw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_dpx() { (regs.p.m)?op_cmp_dpxb():op_cmp_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xc1: cmp (dp,x) ***
|
||||
************************
|
||||
|
@ -340,8 +320,6 @@ void bCPU::op_cmp_idpxw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_idpx() { (regs.p.m)?op_cmp_idpxb():op_cmp_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xd1: cmp (dp),y ***
|
||||
************************
|
||||
|
@ -376,8 +354,6 @@ void bCPU::op_cmp_idpyw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_idpy() { (regs.p.m)?op_cmp_idpyb():op_cmp_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0xd7: cmp [dp],y ***
|
||||
************************
|
||||
|
@ -412,8 +388,6 @@ void bCPU::op_cmp_ildpyw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_ildpy() { (regs.p.m)?op_cmp_ildpyb():op_cmp_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xc3: cmp sr,s ***
|
||||
**********************
|
||||
|
@ -439,8 +413,6 @@ void bCPU::op_cmp_srw() {
|
|||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_sr() { (regs.p.m)?op_cmp_srb():op_cmp_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0xd3: cmp (sr,s),y ***
|
||||
**************************
|
||||
|
@ -474,5 +446,3 @@ void bCPU::op_cmp_isryw() {
|
|||
rd.h = op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_cmp_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cmp_isry() { (regs.p.m)?op_cmp_isryb():op_cmp_isryw(); }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
void bCPU::flags_eor_b() {
|
||||
inline void bCPU::flags_eor_b() {
|
||||
regs.p.n = !!(regs.a.l & 0x80);
|
||||
regs.p.z = (regs.a.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_eor_w() {
|
||||
inline void bCPU::flags_eor_w() {
|
||||
regs.p.n = !!(regs.a.w & 0x8000);
|
||||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ void bCPU::op_eor_constw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_const() { (regs.p.m)?op_eor_constb():op_eor_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x4d: eor addr ***
|
||||
**********************
|
||||
|
@ -54,8 +52,6 @@ void bCPU::op_eor_addrw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_addr() { (regs.p.m)?op_eor_addrb():op_eor_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x5d: eor addr,x ***
|
||||
************************
|
||||
|
@ -84,8 +80,6 @@ void bCPU::op_eor_addrxw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_addrx() { (regs.p.m)?op_eor_addrxb():op_eor_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x45: eor dp ***
|
||||
********************
|
||||
|
@ -111,8 +105,6 @@ void bCPU::op_eor_dpw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_dp() { (regs.p.m)?op_eor_dpb():op_eor_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x52: eor (dp) ***
|
||||
**********************
|
||||
|
@ -144,8 +136,6 @@ void bCPU::op_eor_idpw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_idp() { (regs.p.m)?op_eor_idpb():op_eor_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x47: eor [dp] ***
|
||||
**********************
|
||||
|
@ -180,8 +170,6 @@ void bCPU::op_eor_ildpw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_ildp() { (regs.p.m)?op_eor_ildpb():op_eor_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x4f: eor long ***
|
||||
**********************
|
||||
|
@ -210,8 +198,6 @@ void bCPU::op_eor_longw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_long() { (regs.p.m)?op_eor_longb():op_eor_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0x5f: eor long,x ***
|
||||
************************
|
||||
|
@ -240,8 +226,6 @@ void bCPU::op_eor_longxw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_longx() { (regs.p.m)?op_eor_longxb():op_eor_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x59: eor addr,y ***
|
||||
************************
|
||||
|
@ -270,8 +254,6 @@ void bCPU::op_eor_addryw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_addry() { (regs.p.m)?op_eor_addryb():op_eor_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x55: eor dp,x ***
|
||||
**********************
|
||||
|
@ -300,8 +282,6 @@ void bCPU::op_eor_dpxw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_dpx() { (regs.p.m)?op_eor_dpxb():op_eor_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x41: eor (dp,x) ***
|
||||
************************
|
||||
|
@ -336,8 +316,6 @@ void bCPU::op_eor_idpxw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_idpx() { (regs.p.m)?op_eor_idpxb():op_eor_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x51: eor (dp),y ***
|
||||
************************
|
||||
|
@ -372,8 +350,6 @@ void bCPU::op_eor_idpyw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_idpy() { (regs.p.m)?op_eor_idpyb():op_eor_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0x57: eor [dp],y ***
|
||||
************************
|
||||
|
@ -408,8 +384,6 @@ void bCPU::op_eor_ildpyw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_ildpy() { (regs.p.m)?op_eor_ildpyb():op_eor_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x43: eor sr,s ***
|
||||
**********************
|
||||
|
@ -435,8 +409,6 @@ void bCPU::op_eor_srw() {
|
|||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_sr() { (regs.p.m)?op_eor_srb():op_eor_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x53: eor (sr,s),y ***
|
||||
**************************
|
||||
|
@ -470,5 +442,3 @@ void bCPU::op_eor_isryw() {
|
|||
regs.a.h ^= op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_eor_w();
|
||||
}
|
||||
|
||||
void bCPU::op_eor_isry() { (regs.p.m)?op_eor_isryb():op_eor_isryw(); }
|
||||
|
|
|
@ -19,8 +19,6 @@ void bCPU::op_incw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inc() { (regs.p.m)?op_incb():op_incw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xee: inc addr ***
|
||||
**********************
|
||||
|
@ -58,8 +56,6 @@ void bCPU::op_inc_addrw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inc_addr() { (regs.p.m)?op_inc_addrb():op_inc_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xfe: inc addr,x ***
|
||||
************************
|
||||
|
@ -100,8 +96,6 @@ void bCPU::op_inc_addrxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inc_addrx() { (regs.p.m)?op_inc_addrxb():op_inc_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xe6: inc dp ***
|
||||
********************
|
||||
|
@ -139,8 +133,6 @@ void bCPU::op_inc_dpw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inc_dp() { (regs.p.m)?op_inc_dpb():op_inc_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xf6: inc dp,x ***
|
||||
**********************
|
||||
|
@ -181,8 +173,6 @@ void bCPU::op_inc_dpxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inc_dpx() { (regs.p.m)?op_inc_dpxb():op_inc_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xe8: inx ***
|
||||
*****************
|
||||
|
@ -204,8 +194,6 @@ void bCPU::op_inxw() {
|
|||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_inx() { (regs.p.x)?op_inxb():op_inxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xc8: iny ***
|
||||
*****************
|
||||
|
@ -227,8 +215,6 @@ void bCPU::op_inyw() {
|
|||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_iny() { (regs.p.x)?op_inyb():op_inyw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x3a: dec ***
|
||||
*****************
|
||||
|
@ -250,8 +236,6 @@ void bCPU::op_decw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dec() { (regs.p.m)?op_decb():op_decw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xce: dec addr ***
|
||||
**********************
|
||||
|
@ -289,8 +273,6 @@ void bCPU::op_dec_addrw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dec_addr() { (regs.p.m)?op_dec_addrb():op_dec_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xde: dec addr,x ***
|
||||
************************
|
||||
|
@ -331,8 +313,6 @@ void bCPU::op_dec_addrxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dec_addrx() { (regs.p.m)?op_dec_addrxb():op_dec_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xc6: dec dp ***
|
||||
********************
|
||||
|
@ -370,8 +350,6 @@ void bCPU::op_dec_dpw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dec_dp() { (regs.p.m)?op_dec_dpb():op_dec_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xd6: dec dp,x ***
|
||||
**********************
|
||||
|
@ -412,8 +390,6 @@ void bCPU::op_dec_dpxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dec_dpx() { (regs.p.m)?op_dec_dpxb():op_dec_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xca: dex ***
|
||||
*****************
|
||||
|
@ -435,8 +411,6 @@ void bCPU::op_dexw() {
|
|||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dex() { (regs.p.x)?op_dexb():op_dexw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x88: dey ***
|
||||
*****************
|
||||
|
@ -457,5 +431,3 @@ void bCPU::op_deyw() {
|
|||
regs.p.n = !!(regs.y.w & 0x8000);
|
||||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_dey() { (regs.p.x)?op_deyb():op_deyw(); }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
void bCPU::flags_lda_b() {
|
||||
inline void bCPU::flags_lda_b() {
|
||||
regs.p.n = !!(regs.a.l & 0x80);
|
||||
regs.p.z = (regs.a.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_lda_w() {
|
||||
inline void bCPU::flags_lda_w() {
|
||||
regs.p.n = !!(regs.a.w & 0x8000);
|
||||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ void bCPU::op_lda_constw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_const() { (regs.p.m)?op_lda_constb():op_lda_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xad: lda addr ***
|
||||
**********************
|
||||
|
@ -54,8 +52,6 @@ void bCPU::op_lda_addrw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_addr() { (regs.p.m)?op_lda_addrb():op_lda_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xbd: lda addr,x ***
|
||||
************************
|
||||
|
@ -84,8 +80,6 @@ void bCPU::op_lda_addrxw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_addrx() { (regs.p.m)?op_lda_addrxb():op_lda_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xa5: lda dp ***
|
||||
********************
|
||||
|
@ -111,8 +105,6 @@ void bCPU::op_lda_dpw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_dp() { (regs.p.m)?op_lda_dpb():op_lda_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xb2: lda (dp) ***
|
||||
**********************
|
||||
|
@ -144,8 +136,6 @@ void bCPU::op_lda_idpw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_idp() { (regs.p.m)?op_lda_idpb():op_lda_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xa7: lda [dp] ***
|
||||
**********************
|
||||
|
@ -180,8 +170,6 @@ void bCPU::op_lda_ildpw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_ildp() { (regs.p.m)?op_lda_ildpb():op_lda_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xaf: lda long ***
|
||||
**********************
|
||||
|
@ -210,8 +198,6 @@ void bCPU::op_lda_longw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_long() { (regs.p.m)?op_lda_longb():op_lda_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0xbf: lda long,x ***
|
||||
************************
|
||||
|
@ -240,8 +226,6 @@ void bCPU::op_lda_longxw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_longx() { (regs.p.m)?op_lda_longxb():op_lda_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xb9: lda addr,y ***
|
||||
************************
|
||||
|
@ -270,8 +254,6 @@ void bCPU::op_lda_addryw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_addry() { (regs.p.m)?op_lda_addryb():op_lda_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xb5: lda dp,x ***
|
||||
**********************
|
||||
|
@ -300,8 +282,6 @@ void bCPU::op_lda_dpxw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_dpx() { (regs.p.m)?op_lda_dpxb():op_lda_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xa1: lda (dp,x) ***
|
||||
************************
|
||||
|
@ -336,8 +316,6 @@ void bCPU::op_lda_idpxw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_idpx() { (regs.p.m)?op_lda_idpxb():op_lda_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xb1: lda (dp),y ***
|
||||
************************
|
||||
|
@ -372,8 +350,6 @@ void bCPU::op_lda_idpyw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_idpy() { (regs.p.m)?op_lda_idpyb():op_lda_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0xb7: lda [dp],y ***
|
||||
************************
|
||||
|
@ -408,8 +384,6 @@ void bCPU::op_lda_ildpyw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_ildpy() { (regs.p.m)?op_lda_ildpyb():op_lda_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xa3: lda sr,s ***
|
||||
**********************
|
||||
|
@ -435,8 +409,6 @@ void bCPU::op_lda_srw() {
|
|||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_sr() { (regs.p.m)?op_lda_srb():op_lda_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0xb3: lda (sr,s),y ***
|
||||
**************************
|
||||
|
@ -470,5 +442,3 @@ void bCPU::op_lda_isryw() {
|
|||
regs.a.h = op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_lda_w();
|
||||
}
|
||||
|
||||
void bCPU::op_lda_isry() { (regs.p.m)?op_lda_isryb():op_lda_isryw(); }
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
void bCPU::flags_bit_b() {
|
||||
inline void bCPU::flags_bit_b() {
|
||||
regs.p.n = !!(rd.l & 0x80);
|
||||
regs.p.v = !!(rd.l & 0x40);
|
||||
regs.p.z = ((rd.l & regs.a.l) == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_bit_w() {
|
||||
inline void bCPU::flags_bit_w() {
|
||||
regs.p.n = !!(rd.w & 0x8000);
|
||||
regs.p.v = !!(rd.w & 0x4000);
|
||||
regs.p.z = ((rd.w & regs.a.w) == 0);
|
||||
|
@ -20,17 +20,15 @@ cycles:
|
|||
*/
|
||||
void bCPU::op_bit_constb() {
|
||||
rd.l = op_read(); //2
|
||||
flags_bit_b();
|
||||
regs.p.z = ((rd.l & regs.a.l) == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_bit_constw() {
|
||||
rd.l = op_read(); //2
|
||||
rd.h = op_read(); //2a
|
||||
flags_bit_w();
|
||||
regs.p.z = ((rd.w & regs.a.w) == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_bit_const() { (regs.p.m)?op_bit_constb():op_bit_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x2c: bit addr ***
|
||||
**********************
|
||||
|
@ -56,8 +54,6 @@ void bCPU::op_bit_addrw() {
|
|||
flags_bit_w();
|
||||
}
|
||||
|
||||
void bCPU::op_bit_addr() { (regs.p.m)?op_bit_addrb():op_bit_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x3c: bit addr,x ***
|
||||
************************
|
||||
|
@ -86,8 +82,6 @@ void bCPU::op_bit_addrxw() {
|
|||
flags_bit_w();
|
||||
}
|
||||
|
||||
void bCPU::op_bit_addrx() { (regs.p.m)?op_bit_addrxb():op_bit_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x24: bit dp ***
|
||||
********************
|
||||
|
@ -113,8 +107,6 @@ void bCPU::op_bit_dpw() {
|
|||
flags_bit_w();
|
||||
}
|
||||
|
||||
void bCPU::op_bit_dp() { (regs.p.m)?op_bit_dpb():op_bit_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x34: bit dp,x ***
|
||||
**********************
|
||||
|
@ -143,16 +135,14 @@ void bCPU::op_bit_dpxw() {
|
|||
flags_bit_w();
|
||||
}
|
||||
|
||||
void bCPU::op_bit_dpx() { (regs.p.m)?op_bit_dpxb():op_bit_dpxw(); }
|
||||
|
||||
void bCPU::flags_cpx_b() {
|
||||
inline void bCPU::flags_cpx_b() {
|
||||
int32 r = regs.x.l - rd.l;
|
||||
regs.p.n = !!(r & 0x80);
|
||||
regs.p.z = ((uint8)r == 0);
|
||||
regs.p.c = (r >= 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_cpx_w() {
|
||||
inline void bCPU::flags_cpx_w() {
|
||||
int32 r = regs.x.w - rd.w;
|
||||
regs.p.n = !!(r & 0x8000);
|
||||
regs.p.z = ((uint16)r == 0);
|
||||
|
@ -178,8 +168,6 @@ void bCPU::op_cpx_constw() {
|
|||
flags_cpx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpx_const() { (regs.p.x)?op_cpx_constb():op_cpx_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xec: cpx addr ***
|
||||
**********************
|
||||
|
@ -205,8 +193,6 @@ void bCPU::op_cpx_addrw() {
|
|||
flags_cpx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpx_addr() { (regs.p.x)?op_cpx_addrb():op_cpx_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0xe4: cpx dp ***
|
||||
********************
|
||||
|
@ -232,16 +218,14 @@ void bCPU::op_cpx_dpw() {
|
|||
flags_cpx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpx_dp() { (regs.p.x)?op_cpx_dpb():op_cpx_dpw(); }
|
||||
|
||||
void bCPU::flags_cpy_b() {
|
||||
inline void bCPU::flags_cpy_b() {
|
||||
int32 r = regs.y.l - rd.l;
|
||||
regs.p.n = !!(r & 0x80);
|
||||
regs.p.z = ((uint8)r == 0);
|
||||
regs.p.c = (r >= 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_cpy_w() {
|
||||
inline void bCPU::flags_cpy_w() {
|
||||
int32 r = regs.y.w - rd.w;
|
||||
regs.p.n = !!(r & 0x8000);
|
||||
regs.p.z = ((uint16)r == 0);
|
||||
|
@ -267,8 +251,6 @@ void bCPU::op_cpy_constw() {
|
|||
flags_cpy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpy_const() { (regs.p.x)?op_cpy_constb():op_cpy_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xcc: cpy addr ***
|
||||
**********************
|
||||
|
@ -294,8 +276,6 @@ void bCPU::op_cpy_addrw() {
|
|||
flags_cpy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpy_addr() { (regs.p.x)?op_cpy_addrb():op_cpy_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0xc4: cpy dp ***
|
||||
********************
|
||||
|
@ -321,14 +301,12 @@ void bCPU::op_cpy_dpw() {
|
|||
flags_cpy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_cpy_dp() { (regs.p.x)?op_cpy_dpb():op_cpy_dpw(); }
|
||||
|
||||
void bCPU::flags_ldx_b() {
|
||||
inline void bCPU::flags_ldx_b() {
|
||||
regs.p.n = !!(regs.x.l & 0x80);
|
||||
regs.p.z = (regs.x.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_ldx_w() {
|
||||
inline void bCPU::flags_ldx_w() {
|
||||
regs.p.n = !!(regs.x.w & 0x8000);
|
||||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
@ -352,8 +330,6 @@ void bCPU::op_ldx_constw() {
|
|||
flags_ldx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldx_const() { (regs.p.x)?op_ldx_constb():op_ldx_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xae: ldx addr ***
|
||||
**********************
|
||||
|
@ -379,8 +355,6 @@ void bCPU::op_ldx_addrw() {
|
|||
flags_ldx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldx_addr() { (regs.p.x)?op_ldx_addrb():op_ldx_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xbe: ldx addr,y ***
|
||||
************************
|
||||
|
@ -409,8 +383,6 @@ void bCPU::op_ldx_addryw() {
|
|||
flags_ldx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldx_addry() { (regs.p.x)?op_ldx_addryb():op_ldx_addryw(); }
|
||||
|
||||
/********************
|
||||
*** 0xa6: ldx dp ***
|
||||
********************
|
||||
|
@ -436,8 +408,6 @@ void bCPU::op_ldx_dpw() {
|
|||
flags_ldx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldx_dp() { (regs.p.x)?op_ldx_dpb():op_ldx_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xb6: ldx dp,y ***
|
||||
**********************
|
||||
|
@ -466,14 +436,12 @@ void bCPU::op_ldx_dpyw() {
|
|||
flags_ldx_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldx_dpy() { (regs.p.x)?op_ldx_dpyb():op_ldx_dpyw(); }
|
||||
|
||||
void bCPU::flags_ldy_b() {
|
||||
inline void bCPU::flags_ldy_b() {
|
||||
regs.p.n = !!(regs.y.l & 0x80);
|
||||
regs.p.z = (regs.y.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_ldy_w() {
|
||||
inline void bCPU::flags_ldy_w() {
|
||||
regs.p.n = !!(regs.y.w & 0x8000);
|
||||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
@ -497,8 +465,6 @@ void bCPU::op_ldy_constw() {
|
|||
flags_ldy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldy_const() { (regs.p.x)?op_ldy_constb():op_ldy_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xac: ldy addr ***
|
||||
**********************
|
||||
|
@ -524,8 +490,6 @@ void bCPU::op_ldy_addrw() {
|
|||
flags_ldy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldy_addr() { (regs.p.x)?op_ldy_addrb():op_ldy_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xbc: ldy addr,x ***
|
||||
************************
|
||||
|
@ -554,8 +518,6 @@ void bCPU::op_ldy_addrxw() {
|
|||
flags_ldy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldy_addrx() { (regs.p.x)?op_ldy_addrxb():op_ldy_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xa4: ldy dp ***
|
||||
********************
|
||||
|
@ -581,8 +543,6 @@ void bCPU::op_ldy_dpw() {
|
|||
flags_ldy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldy_dp() { (regs.p.x)?op_ldy_dpb():op_ldy_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xb4: ldy dp,x ***
|
||||
**********************
|
||||
|
@ -611,8 +571,6 @@ void bCPU::op_ldy_dpxw() {
|
|||
flags_ldy_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ldy_dpx() { (regs.p.x)?op_ldy_dpxb():op_ldy_dpxw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x8e: stx addr ***
|
||||
**********************
|
||||
|
@ -636,8 +594,6 @@ void bCPU::op_stx_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, regs.x.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_stx_addr() { (regs.p.x)?op_stx_addrb():op_stx_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0x86: stx dp ***
|
||||
********************
|
||||
|
@ -661,8 +617,6 @@ void bCPU::op_stx_dpw() {
|
|||
op_write(OPMODE_DP, dp + 1, regs.x.h); //3a
|
||||
}
|
||||
|
||||
void bCPU::op_stx_dp() { (regs.p.x)?op_stx_dpb():op_stx_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x96: stx dp,y ***
|
||||
**********************
|
||||
|
@ -689,8 +643,6 @@ void bCPU::op_stx_dpyw() {
|
|||
op_write(OPMODE_DP, dp + regs.y.w + 1, regs.x.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_stx_dpy() { (regs.p.x)?op_stx_dpyb():op_stx_dpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x8c: sty addr ***
|
||||
**********************
|
||||
|
@ -714,8 +666,6 @@ void bCPU::op_sty_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, regs.y.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sty_addr() { (regs.p.x)?op_sty_addrb():op_sty_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0x84: sty dp ***
|
||||
********************
|
||||
|
@ -739,8 +689,6 @@ void bCPU::op_sty_dpw() {
|
|||
op_write(OPMODE_DP, dp + 1, regs.y.h); //3a
|
||||
}
|
||||
|
||||
void bCPU::op_sty_dp() { (regs.p.x)?op_sty_dpb():op_sty_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x94: sty dp,x ***
|
||||
**********************
|
||||
|
@ -767,8 +715,6 @@ void bCPU::op_sty_dpxw() {
|
|||
op_write(OPMODE_DP, dp + regs.x.w + 1, regs.y.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sty_dpx() { (regs.p.x)?op_sty_dpxb():op_sty_dpxw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x9c: stz addr ***
|
||||
**********************
|
||||
|
@ -792,8 +738,6 @@ void bCPU::op_stz_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, 0); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_stz_addr() { (regs.p.m)?op_stz_addrb():op_stz_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x9e: stz addr,x ***
|
||||
************************
|
||||
|
@ -820,8 +764,6 @@ void bCPU::op_stz_addrxw() {
|
|||
op_write(OPMODE_DBR, aa.w + regs.x.w + 1, 0); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_stz_addrx() { (regs.p.m)?op_stz_addrxb():op_stz_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x64: stz dp ***
|
||||
********************
|
||||
|
@ -845,8 +787,6 @@ void bCPU::op_stz_dpw() {
|
|||
op_write(OPMODE_DP, dp + 1, 0); //3a
|
||||
}
|
||||
|
||||
void bCPU::op_stz_dp() { (regs.p.m)?op_stz_dpb():op_stz_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x74: stz dp,x ***
|
||||
**********************
|
||||
|
@ -873,8 +813,6 @@ void bCPU::op_stz_dpxw() {
|
|||
op_write(OPMODE_DP, dp + regs.x.w + 1, 0); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_stz_dpx() { (regs.p.m)?op_stz_dpxb():op_stz_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xeb: xba ***
|
||||
*****************
|
||||
|
@ -928,8 +866,6 @@ void bCPU::op_trb_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w, rd.l); //6
|
||||
}
|
||||
|
||||
void bCPU::op_trb_addr() { (regs.p.m)?op_trb_addrb():op_trb_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0x14: trb dp ***
|
||||
********************
|
||||
|
@ -965,8 +901,6 @@ void bCPU::op_trb_dpw() {
|
|||
op_write(OPMODE_DP, dp, rd.l); //5
|
||||
}
|
||||
|
||||
void bCPU::op_trb_dp() { (regs.p.m)?op_trb_dpb():op_trb_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x0c: tsb addr ***
|
||||
**********************
|
||||
|
@ -1002,8 +936,6 @@ void bCPU::op_tsb_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w, rd.l); //6
|
||||
}
|
||||
|
||||
void bCPU::op_tsb_addr() { (regs.p.m)?op_tsb_addrb():op_tsb_addrw(); }
|
||||
|
||||
/********************
|
||||
*** 0x04: tsb dp ***
|
||||
********************
|
||||
|
@ -1039,8 +971,6 @@ void bCPU::op_tsb_dpw() {
|
|||
op_write(OPMODE_DP, dp, rd.l); //5
|
||||
}
|
||||
|
||||
void bCPU::op_tsb_dp() { (regs.p.m)?op_tsb_dpb():op_tsb_dpw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x54: mvn src,dest ***
|
||||
**************************
|
||||
|
@ -1219,6 +1149,14 @@ bool c = regs.p.c;
|
|||
regs.x.h = 0x00;
|
||||
regs.y.h = 0x00;
|
||||
regs.s.h = 0x01;
|
||||
optbl = optbl_e;
|
||||
} else {
|
||||
switch((regs.p >> 4) & 3) {
|
||||
case 0:optbl = optbl_mx;break;
|
||||
case 1:optbl = optbl_mX;break;
|
||||
case 2:optbl = optbl_Mx;break;
|
||||
case 3:optbl = optbl_MX;break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1343,6 +1281,13 @@ void bCPU::op_rep() {
|
|||
regs.p &= ~rd.l;
|
||||
if(regs.e) {
|
||||
regs.p |= 0x30;
|
||||
} else {
|
||||
switch((regs.p >> 4) & 3) {
|
||||
case 0:optbl = optbl_mx;break;
|
||||
case 1:optbl = optbl_mX;break;
|
||||
case 2:optbl = optbl_Mx;break;
|
||||
case 3:optbl = optbl_MX;break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1360,6 +1305,13 @@ void bCPU::op_sep() {
|
|||
regs.p |= rd.l;
|
||||
if(regs.e) {
|
||||
regs.p |= 0x30;
|
||||
} else {
|
||||
switch((regs.p >> 4) & 3) {
|
||||
case 0:optbl = optbl_mx;break;
|
||||
case 1:optbl = optbl_mX;break;
|
||||
case 2:optbl = optbl_Mx;break;
|
||||
case 3:optbl = optbl_MX;break;
|
||||
}
|
||||
}
|
||||
if(regs.p.x) {
|
||||
regs.x.h = 0x00;
|
||||
|
@ -1388,8 +1340,6 @@ void bCPU::op_taxw() {
|
|||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_tax() { (regs.p.x)?op_taxb():op_taxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xa8: tay ***
|
||||
*****************
|
||||
|
@ -1411,8 +1361,6 @@ void bCPU::op_tayw() {
|
|||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_tay() { (regs.p.x)?op_tayb():op_tayw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x5b: tcd ***
|
||||
*****************
|
||||
|
@ -1496,8 +1444,6 @@ void bCPU::op_tsxw() {
|
|||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_tsx() { (regs.p.x)?op_tsxb():op_tsxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x8a: txa ***
|
||||
*****************
|
||||
|
@ -1519,8 +1465,6 @@ void bCPU::op_txaw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_txa() { (regs.p.m)?op_txab():op_txaw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x9a: txs ***
|
||||
*****************
|
||||
|
@ -1542,8 +1486,6 @@ void bCPU::op_txsw() {
|
|||
regs.p.z = (regs.s.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_txs() { (regs.p.x)?op_txsb():op_txsw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x9b: txy ***
|
||||
*****************
|
||||
|
@ -1565,8 +1507,6 @@ void bCPU::op_txyw() {
|
|||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_txy() { (regs.p.x)?op_txyb():op_txyw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x98: tya ***
|
||||
*****************
|
||||
|
@ -1588,8 +1528,6 @@ void bCPU::op_tyaw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_tya() { (regs.p.m)?op_tyab():op_tyaw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xbb: tyx ***
|
||||
*****************
|
||||
|
@ -1610,5 +1548,3 @@ void bCPU::op_tyxw() {
|
|||
regs.p.n = !!(regs.x.w & 0x8000);
|
||||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_tyx() { (regs.p.x)?op_tyxb():op_tyxw(); }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
void bCPU::flags_ora_b() {
|
||||
inline void bCPU::flags_ora_b() {
|
||||
regs.p.n = !!(regs.a.l & 0x80);
|
||||
regs.p.z = (regs.a.l == 0);
|
||||
}
|
||||
|
||||
void bCPU::flags_ora_w() {
|
||||
inline void bCPU::flags_ora_w() {
|
||||
regs.p.n = !!(regs.a.w & 0x8000);
|
||||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ void bCPU::op_ora_constw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_const() { (regs.p.m)?op_ora_constb():op_ora_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x0d: ora addr ***
|
||||
**********************
|
||||
|
@ -54,8 +52,6 @@ void bCPU::op_ora_addrw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_addr() { (regs.p.m)?op_ora_addrb():op_ora_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x1d: ora addr,x ***
|
||||
************************
|
||||
|
@ -84,8 +80,6 @@ void bCPU::op_ora_addrxw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_addrx() { (regs.p.m)?op_ora_addrxb():op_ora_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x05: ora dp ***
|
||||
********************
|
||||
|
@ -111,8 +105,6 @@ void bCPU::op_ora_dpw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_dp() { (regs.p.m)?op_ora_dpb():op_ora_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x12: ora (dp) ***
|
||||
**********************
|
||||
|
@ -144,8 +136,6 @@ void bCPU::op_ora_idpw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_idp() { (regs.p.m)?op_ora_idpb():op_ora_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x07: ora [dp] ***
|
||||
**********************
|
||||
|
@ -180,8 +170,6 @@ void bCPU::op_ora_ildpw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_ildp() { (regs.p.m)?op_ora_ildpb():op_ora_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x0f: ora long ***
|
||||
**********************
|
||||
|
@ -210,8 +198,6 @@ void bCPU::op_ora_longw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_long() { (regs.p.m)?op_ora_longb():op_ora_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0x1f: ora long,x ***
|
||||
************************
|
||||
|
@ -240,8 +226,6 @@ void bCPU::op_ora_longxw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_longx() { (regs.p.m)?op_ora_longxb():op_ora_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x19: ora addr,y ***
|
||||
************************
|
||||
|
@ -270,8 +254,6 @@ void bCPU::op_ora_addryw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_addry() { (regs.p.m)?op_ora_addryb():op_ora_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x15: ora dp,x ***
|
||||
**********************
|
||||
|
@ -300,8 +282,6 @@ void bCPU::op_ora_dpxw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_dpx() { (regs.p.m)?op_ora_dpxb():op_ora_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x01: ora (dp,x) ***
|
||||
************************
|
||||
|
@ -336,8 +316,6 @@ void bCPU::op_ora_idpxw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_idpx() { (regs.p.m)?op_ora_idpxb():op_ora_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x11: ora (dp),y ***
|
||||
************************
|
||||
|
@ -372,8 +350,6 @@ void bCPU::op_ora_idpyw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_idpy() { (regs.p.m)?op_ora_idpyb():op_ora_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0x17: ora [dp],y ***
|
||||
************************
|
||||
|
@ -408,8 +384,6 @@ void bCPU::op_ora_ildpyw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_ildpy() { (regs.p.m)?op_ora_ildpyb():op_ora_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x03: ora sr,s ***
|
||||
**********************
|
||||
|
@ -435,8 +409,6 @@ void bCPU::op_ora_srw() {
|
|||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_sr() { (regs.p.m)?op_ora_srb():op_ora_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x13: ora (sr,s),y ***
|
||||
**************************
|
||||
|
@ -470,5 +442,3 @@ void bCPU::op_ora_isryw() {
|
|||
regs.a.h |= op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_ora_w();
|
||||
}
|
||||
|
||||
void bCPU::op_ora_isry() { (regs.p.m)?op_ora_isryb():op_ora_isryw(); }
|
||||
|
|
|
@ -193,9 +193,14 @@ void bCPU::op_rtin() {
|
|||
regs.y.h = 0x00;
|
||||
}
|
||||
regs.pc.d = rd.d;
|
||||
}
|
||||
|
||||
void bCPU::op_rti() { (regs.e)?op_rtie():op_rtin(); }
|
||||
switch((regs.p >> 4) & 3) {
|
||||
case 0:optbl = optbl_mx;break;
|
||||
case 1:optbl = optbl_mX;break;
|
||||
case 2:optbl = optbl_Mx;break;
|
||||
case 3:optbl = optbl_MX;break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************
|
||||
*** 0x60: rts ***
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void bCPU::flags_sbc_b() {
|
||||
inline void bCPU::flags_sbc_b() {
|
||||
int32 r = regs.a.l - rd.l - !regs.p.c;
|
||||
//bcd
|
||||
if(regs.p.d) {
|
||||
|
@ -12,7 +12,7 @@ int32 r = regs.a.l - rd.l - !regs.p.c;
|
|||
regs.a.l = r;
|
||||
}
|
||||
|
||||
void bCPU::flags_sbc_w() {
|
||||
inline void bCPU::flags_sbc_w() {
|
||||
int32 r = regs.a.w - rd.w - !regs.p.c;
|
||||
//bcd
|
||||
if(regs.p.d) {
|
||||
|
@ -47,8 +47,6 @@ void bCPU::op_sbc_constw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_const() { (regs.p.m)?op_sbc_constb():op_sbc_constw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xed: sbc addr ***
|
||||
**********************
|
||||
|
@ -74,8 +72,6 @@ void bCPU::op_sbc_addrw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_addr() { (regs.p.m)?op_sbc_addrb():op_sbc_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0xfd: sbc addr,x ***
|
||||
************************
|
||||
|
@ -104,8 +100,6 @@ void bCPU::op_sbc_addrxw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_addrx() { (regs.p.m)?op_sbc_addrxb():op_sbc_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0xe5: sbc dp ***
|
||||
********************
|
||||
|
@ -131,8 +125,6 @@ void bCPU::op_sbc_dpw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_dp() { (regs.p.m)?op_sbc_dpb():op_sbc_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xf2: sbc (dp) ***
|
||||
**********************
|
||||
|
@ -164,8 +156,6 @@ void bCPU::op_sbc_idpw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_idp() { (regs.p.m)?op_sbc_idpb():op_sbc_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xe7: sbc [dp] ***
|
||||
**********************
|
||||
|
@ -200,8 +190,6 @@ void bCPU::op_sbc_ildpw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_ildp() { (regs.p.m)?op_sbc_ildpb():op_sbc_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xef: sbc long ***
|
||||
**********************
|
||||
|
@ -230,8 +218,6 @@ void bCPU::op_sbc_longw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_long() { (regs.p.m)?op_sbc_longb():op_sbc_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0xff: sbc long,x ***
|
||||
************************
|
||||
|
@ -260,8 +246,6 @@ void bCPU::op_sbc_longxw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_longx() { (regs.p.m)?op_sbc_longxb():op_sbc_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xf9: sbc addr,y ***
|
||||
************************
|
||||
|
@ -290,8 +274,6 @@ void bCPU::op_sbc_addryw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_addry() { (regs.p.m)?op_sbc_addryb():op_sbc_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xf5: sbc dp,x ***
|
||||
**********************
|
||||
|
@ -320,8 +302,6 @@ void bCPU::op_sbc_dpxw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_dpx() { (regs.p.m)?op_sbc_dpxb():op_sbc_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xe1: sbc (dp,x) ***
|
||||
************************
|
||||
|
@ -356,8 +336,6 @@ void bCPU::op_sbc_idpxw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_idpx() { (regs.p.m)?op_sbc_idpxb():op_sbc_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0xf1: sbc (dp),y ***
|
||||
************************
|
||||
|
@ -392,8 +370,6 @@ void bCPU::op_sbc_idpyw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_idpy() { (regs.p.m)?op_sbc_idpyb():op_sbc_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0xf7: sbc [dp],y ***
|
||||
************************
|
||||
|
@ -428,8 +404,6 @@ void bCPU::op_sbc_ildpyw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_ildpy() { (regs.p.m)?op_sbc_ildpyb():op_sbc_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xe3: sbc sr,s ***
|
||||
**********************
|
||||
|
@ -455,8 +429,6 @@ void bCPU::op_sbc_srw() {
|
|||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_sr() { (regs.p.m)?op_sbc_srb():op_sbc_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0xf3: sbc (sr,s),y ***
|
||||
**************************
|
||||
|
@ -490,5 +462,3 @@ void bCPU::op_sbc_isryw() {
|
|||
rd.h = op_read(OPMODE_DBR, aa.w + regs.y.w + 1); //7a
|
||||
flags_sbc_w();
|
||||
}
|
||||
|
||||
void bCPU::op_sbc_isry() { (regs.p.m)?op_sbc_isryb():op_sbc_isryw(); }
|
||||
|
|
|
@ -21,8 +21,6 @@ void bCPU::op_aslw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_asl() { (regs.p.m)?op_aslb():op_aslw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x0e: asl addr ***
|
||||
**********************
|
||||
|
@ -62,8 +60,6 @@ void bCPU::op_asl_addrw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_asl_addr() { (regs.p.m)?op_asl_addrb():op_asl_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x1e: asl addr,x ***
|
||||
************************
|
||||
|
@ -106,8 +102,6 @@ void bCPU::op_asl_addrxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_asl_addrx() { (regs.p.m)?op_asl_addrxb():op_asl_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x06: asl dp ***
|
||||
********************
|
||||
|
@ -147,8 +141,6 @@ void bCPU::op_asl_dpw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_asl_dp() { (regs.p.m)?op_asl_dpb():op_asl_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x16: asl dp,x ***
|
||||
**********************
|
||||
|
@ -191,8 +183,6 @@ void bCPU::op_asl_dpxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_asl_dpx() { (regs.p.m)?op_asl_dpxb():op_asl_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x4a: lsr ***
|
||||
*****************
|
||||
|
@ -216,8 +206,6 @@ void bCPU::op_lsrw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_lsr() { (regs.p.m)?op_lsrb():op_lsrw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x4e: lsr addr ***
|
||||
**********************
|
||||
|
@ -257,8 +245,6 @@ void bCPU::op_lsr_addrw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_lsr_addr() { (regs.p.m)?op_lsr_addrb():op_lsr_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x5e: lsr addr,x ***
|
||||
************************
|
||||
|
@ -301,8 +287,6 @@ void bCPU::op_lsr_addrxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_lsr_addrx() { (regs.p.m)?op_lsr_addrxb():op_lsr_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x46: lsr dp ***
|
||||
********************
|
||||
|
@ -342,8 +326,6 @@ void bCPU::op_lsr_dpw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_lsr_dp() { (regs.p.m)?op_lsr_dpb():op_lsr_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x56: lsr dp,x ***
|
||||
**********************
|
||||
|
@ -386,8 +368,6 @@ void bCPU::op_lsr_dpxw() {
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_lsr_dpx() { (regs.p.m)?op_lsr_dpxb():op_lsr_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x2a: rol ***
|
||||
*****************
|
||||
|
@ -415,8 +395,6 @@ uint16 c = regs.p.c;
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_rol() { (regs.p.m)?op_rolb():op_rolw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x2e: rol addr ***
|
||||
**********************
|
||||
|
@ -460,8 +438,6 @@ uint16 c = regs.p.c;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_rol_addr() { (regs.p.m)?op_rol_addrb():op_rol_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x3e: rol addr,x ***
|
||||
************************
|
||||
|
@ -508,8 +484,6 @@ uint16 c = regs.p.c;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_rol_addrx() { (regs.p.m)?op_rol_addrxb():op_rol_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x26: rol dp ***
|
||||
********************
|
||||
|
@ -553,8 +527,6 @@ uint16 c = regs.p.c;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_rol_dp() { (regs.p.m)?op_rol_dpb():op_rol_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x36: rol dp,x ***
|
||||
**********************
|
||||
|
@ -601,8 +573,6 @@ uint16 c = regs.p.c;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_rol_dpx() { (regs.p.m)?op_rol_dpxb():op_rol_dpxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x6a: ror ***
|
||||
*****************
|
||||
|
@ -630,8 +600,6 @@ uint16 c = (regs.p.c)?0x8000:0;
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ror() { (regs.p.m)?op_rorb():op_rorw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x6e: ror addr ***
|
||||
**********************
|
||||
|
@ -675,8 +643,6 @@ uint16 c = (regs.p.c)?0x8000:0;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ror_addr() { (regs.p.m)?op_ror_addrb():op_ror_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x7e: ror addr,x ***
|
||||
************************
|
||||
|
@ -723,8 +689,6 @@ uint16 c = (regs.p.c)?0x8000:0;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ror_addrx() { (regs.p.m)?op_ror_addrxb():op_ror_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x66: ror dp ***
|
||||
********************
|
||||
|
@ -768,8 +732,6 @@ uint16 c = (regs.p.c)?0x8000:0;
|
|||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ror_dp() { (regs.p.m)?op_ror_dpb():op_ror_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x76: ror dp,x ***
|
||||
**********************
|
||||
|
@ -815,5 +777,3 @@ uint16 c = (regs.p.c)?0x8000:0;
|
|||
regs.p.n = !!(rd.w & 0x8000);
|
||||
regs.p.z = (rd.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ror_dpx() { (regs.p.m)?op_ror_dpxb():op_ror_dpxw(); }
|
||||
|
|
|
@ -21,8 +21,6 @@ void bCPU::op_sta_addrw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, regs.a.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_addr() { (regs.p.m)?op_sta_addrb():op_sta_addrw(); }
|
||||
|
||||
/************************
|
||||
*** 0x9d: sta addr,x ***
|
||||
************************
|
||||
|
@ -49,8 +47,6 @@ void bCPU::op_sta_addrxw() {
|
|||
op_write(OPMODE_DBR, aa.w + regs.x.w + 1, regs.a.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_addrx() { (regs.p.m)?op_sta_addrxb():op_sta_addrxw(); }
|
||||
|
||||
/********************
|
||||
*** 0x85: sta dp ***
|
||||
********************
|
||||
|
@ -74,8 +70,6 @@ void bCPU::op_sta_dpw() {
|
|||
op_write(OPMODE_DP, dp + 1, regs.a.h); //3a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_dp() { (regs.p.m)?op_sta_dpb():op_sta_dpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x92: sta (dp) ***
|
||||
**********************
|
||||
|
@ -105,8 +99,6 @@ void bCPU::op_sta_idpw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, regs.a.h); //5
|
||||
}
|
||||
|
||||
void bCPU::op_sta_idp() { (regs.p.m)?op_sta_idpb():op_sta_idpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x87: sta [dp] ***
|
||||
**********************
|
||||
|
@ -139,8 +131,6 @@ void bCPU::op_sta_ildpw() {
|
|||
op_write(OPMODE_LONG, aa.d + 1, regs.a.h); //6a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_ildp() { (regs.p.m)?op_sta_ildpb():op_sta_ildpw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x8f: sta long ***
|
||||
**********************
|
||||
|
@ -167,8 +157,6 @@ void bCPU::op_sta_longw() {
|
|||
op_write(OPMODE_LONG, aa.d + 1, regs.a.h); //5a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_long() { (regs.p.m)?op_sta_longb():op_sta_longw(); }
|
||||
|
||||
/************************
|
||||
*** 0x9f: sta long,x ***
|
||||
************************
|
||||
|
@ -195,8 +183,6 @@ void bCPU::op_sta_longxw() {
|
|||
op_write(OPMODE_LONG, aa.d + regs.x.w + 1, regs.a.h); //5a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_longx() { (regs.p.m)?op_sta_longxb():op_sta_longxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x99: sta addr,y ***
|
||||
************************
|
||||
|
@ -223,8 +209,6 @@ void bCPU::op_sta_addryw() {
|
|||
op_write(OPMODE_DBR, aa.w + regs.y.w + 1, regs.a.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_addry() { (regs.p.m)?op_sta_addryb():op_sta_addryw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x95: sta dp,x ***
|
||||
**********************
|
||||
|
@ -251,8 +235,6 @@ void bCPU::op_sta_dpxw() {
|
|||
op_write(OPMODE_DP, dp + regs.x.w + 1, regs.a.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_dpx() { (regs.p.m)?op_sta_dpxb():op_sta_dpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x81: sta (dp,x) ***
|
||||
************************
|
||||
|
@ -285,8 +267,6 @@ void bCPU::op_sta_idpxw() {
|
|||
op_write(OPMODE_DBR, aa.w + 1, regs.a.h); //6a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_idpx() { (regs.p.m)?op_sta_idpxb():op_sta_idpxw(); }
|
||||
|
||||
/************************
|
||||
*** 0x91: sta (dp),y ***
|
||||
************************
|
||||
|
@ -319,8 +299,6 @@ void bCPU::op_sta_idpyw() {
|
|||
op_write(OPMODE_DBR, aa.w + regs.y.w + 1, regs.a.h); //5a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_idpy() { (regs.p.m)?op_sta_idpyb():op_sta_idpyw(); }
|
||||
|
||||
/************************
|
||||
*** 0x97: sta [dp],y ***
|
||||
************************
|
||||
|
@ -353,8 +331,6 @@ void bCPU::op_sta_ildpyw() {
|
|||
op_write(OPMODE_LONG, aa.d + regs.y.w + 1, regs.a.h); //6a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_ildpy() { (regs.p.m)?op_sta_ildpyb():op_sta_ildpyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0x83: sta sr,s ***
|
||||
**********************
|
||||
|
@ -378,8 +354,6 @@ void bCPU::op_sta_srw() {
|
|||
op_write(OPMODE_SP, sp + 1, regs.a.h); //4a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_sr() { (regs.p.m)?op_sta_srb():op_sta_srw(); }
|
||||
|
||||
/**************************
|
||||
*** 0x93: sta (sr,s),y ***
|
||||
**************************
|
||||
|
@ -411,5 +385,3 @@ void bCPU::op_sta_isryw() {
|
|||
op_write(OPMODE_DBR, aa.w + regs.y.w, regs.a.l); //7
|
||||
op_write(OPMODE_DBR, aa.w + regs.y.w + 1, regs.a.h); //7a
|
||||
}
|
||||
|
||||
void bCPU::op_sta_isry() { (regs.p.m)?op_sta_isryb():op_sta_isryw(); }
|
||||
|
|
|
@ -18,8 +18,6 @@ void bCPU::op_phaw() {
|
|||
stack_write(regs.a.l); //3
|
||||
}
|
||||
|
||||
void bCPU::op_pha() { (regs.p.m)?op_phab():op_phaw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x8b: phb ***
|
||||
*****************
|
||||
|
@ -94,8 +92,6 @@ void bCPU::op_phxw() {
|
|||
stack_write(regs.x.l); //3
|
||||
}
|
||||
|
||||
void bCPU::op_phx() { (regs.p.x)?op_phxb():op_phxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x5a: phy ***
|
||||
*****************
|
||||
|
@ -116,8 +112,6 @@ void bCPU::op_phyw() {
|
|||
stack_write(regs.y.l); //3
|
||||
}
|
||||
|
||||
void bCPU::op_phy() { (regs.p.x)?op_phyb():op_phyw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x68: pla ***
|
||||
*****************
|
||||
|
@ -145,8 +139,6 @@ void bCPU::op_plaw() {
|
|||
regs.p.z = (regs.a.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_pla() { (regs.p.m)?op_plab():op_plaw(); }
|
||||
|
||||
/*****************
|
||||
*** 0xab: plb ***
|
||||
*****************
|
||||
|
@ -196,7 +188,16 @@ void bCPU::op_plp() {
|
|||
cpu_io(); //2
|
||||
cpu_io(); //3
|
||||
regs.p = stack_read(); //4
|
||||
if(regs.e)regs.p |= 0x30;
|
||||
if(regs.e) {
|
||||
regs.p |= 0x30;
|
||||
} else {
|
||||
switch((regs.p >> 4) & 3) {
|
||||
case 0:optbl = optbl_mx;break;
|
||||
case 1:optbl = optbl_mX;break;
|
||||
case 2:optbl = optbl_Mx;break;
|
||||
case 3:optbl = optbl_MX;break;
|
||||
}
|
||||
}
|
||||
if(regs.p.x) {
|
||||
regs.x.h = 0x00;
|
||||
regs.y.h = 0x00;
|
||||
|
@ -230,8 +231,6 @@ void bCPU::op_plxw() {
|
|||
regs.p.z = (regs.x.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_plx() { (regs.p.x)?op_plxb():op_plxw(); }
|
||||
|
||||
/*****************
|
||||
*** 0x7a: ply ***
|
||||
*****************
|
||||
|
@ -259,8 +258,6 @@ void bCPU::op_plyw() {
|
|||
regs.p.z = (regs.y.w == 0);
|
||||
}
|
||||
|
||||
void bCPU::op_ply() { (regs.p.x)?op_plyb():op_plyw(); }
|
||||
|
||||
/**********************
|
||||
*** 0xf4: pea addr ***
|
||||
**********************
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
libbase : version 0.01 ~byuu
|
||||
*/
|
||||
|
||||
#ifndef __LIBBASE
|
||||
#define __LIBBASE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned long uint32;
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed long int32;
|
||||
|
||||
#ifdef null
|
||||
#undef null
|
||||
#endif
|
||||
#define null 0xffffffff
|
||||
|
||||
#endif
|
|
@ -0,0 +1,304 @@
|
|||
#include "libbase.h"
|
||||
#include "libconfig.h"
|
||||
|
||||
bool config_item::changed() {
|
||||
return (is_string == true) ? (*strsource != strdef) : (*source != def);
|
||||
}
|
||||
|
||||
config_item::config_item() {
|
||||
is_string = false;
|
||||
source = 0;
|
||||
strsource = 0;
|
||||
def = 0;
|
||||
strdef = "";
|
||||
type = 0;
|
||||
name = "";
|
||||
}
|
||||
|
||||
void config::add(uint32 *variable, char *name, uint32 def, uint32 type) {
|
||||
int n;
|
||||
if(item_count >= 4096)return;
|
||||
n = item_count;
|
||||
|
||||
item[n] = new config_item();
|
||||
|
||||
item[n]->is_string = false;
|
||||
item[n]->name = name;
|
||||
item[n]->source = variable;
|
||||
item[n]->def = def;
|
||||
item[n]->type = type;
|
||||
*item[n]->source = item[n]->def;
|
||||
|
||||
item_count++;
|
||||
}
|
||||
|
||||
void config::add(string *variable, char *name, char *def, uint32 type) {
|
||||
int n;
|
||||
if(item_count >= 4096)return;
|
||||
n = item_count;
|
||||
|
||||
item[n] = new config_item();
|
||||
item[n]->is_string = true;
|
||||
item[n]->name = name;
|
||||
item[n]->strsource = variable;
|
||||
item[n]->strdef = def;
|
||||
*item[n]->strsource = item[n]->strdef;
|
||||
|
||||
item_count++;
|
||||
}
|
||||
|
||||
uint32 config::find(char *name) {
|
||||
for(int i=0;i<item_count;i++) {
|
||||
if(item[i]->name == name) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
uint32 config::get(char *name) {
|
||||
int i = find(name);
|
||||
if(i == null)return 0;
|
||||
return *item[i]->source;
|
||||
}
|
||||
|
||||
string &config::strget(char *name) {
|
||||
int i = find(name);
|
||||
if(i == null) {
|
||||
static string not_found;
|
||||
not_found = "";
|
||||
return not_found;
|
||||
}
|
||||
return *item[i]->strsource;
|
||||
}
|
||||
|
||||
void config::set(char *name, uint32 value) {
|
||||
int i = find(name);
|
||||
if(i == null)return;
|
||||
*item[i]->source = value;
|
||||
}
|
||||
|
||||
void config::set(char *name, char *value) {
|
||||
int i = find(name);
|
||||
if(i == null)return;
|
||||
*item[i]->strsource = value;
|
||||
}
|
||||
|
||||
void config::load(char *fn) {
|
||||
FILE *fp;
|
||||
char *buffer;
|
||||
int i, fsize;
|
||||
uint32 l;
|
||||
fp = fopen(fn, "rb");
|
||||
/* file doesn't exist yet, do nothing */
|
||||
if(!fp)return;
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
fsize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
/* blank file, do nothing */
|
||||
if(fsize == 0) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = (char*)malloc(fsize + 1);
|
||||
fread(buffer, 1, fsize, fp);
|
||||
fclose(fp);
|
||||
buffer[fsize] = 0;
|
||||
|
||||
data = buffer;
|
||||
free(buffer);
|
||||
replace(data, "\r\n", "\n");
|
||||
qreplace(data, "\t", " ");
|
||||
|
||||
split(line, "\n", data);
|
||||
|
||||
for(i=0;i<count(line);i++) {
|
||||
qreplace(line[i], " ", "");
|
||||
|
||||
/* remove comment, if it exists */
|
||||
if(strqpos(line[i], "#") != null) {
|
||||
strset(line[i], strqpos(line[i], "#"), 0);
|
||||
}
|
||||
|
||||
/* ignore blank lines */
|
||||
if(strlen(line[i]) == 0)continue;
|
||||
|
||||
qsplit(part, "=", line[i]);
|
||||
|
||||
l = find(*part[0]);
|
||||
if(l != null) {
|
||||
/* if the config item name is valid... update item value */
|
||||
if(item[l]->is_string == true) {
|
||||
strunquote(part[1]);
|
||||
*item[l]->strsource = part[1];
|
||||
} else {
|
||||
if(part[1] == "true" || part[1] == "yes" || part[1] == "on" || part[1] == "enabled") {
|
||||
*item[l]->source = 1;
|
||||
} else if(part[1] == "false" || part[1] == "no" || part[1] == "off" || part[1] == "disabled") {
|
||||
*item[l]->source = 0;
|
||||
} else if(item[l]->type == HEX) {
|
||||
*item[l]->source = strhex(part[1]);
|
||||
} else { /* fall back on DEC */
|
||||
*item[l]->source = strdec(part[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* create a text string from config item[i] to be output via config->save() */
|
||||
void config::set_newline(int i) {
|
||||
char t[16];
|
||||
if(item[i]->is_string == true) {
|
||||
newline = item[i]->name;
|
||||
newline += " = \"";
|
||||
newline += *item[i]->strsource;
|
||||
newline += "\"";
|
||||
} else {
|
||||
newline = item[i]->name;
|
||||
newline += " = ";
|
||||
switch(item[i]->type) {
|
||||
case TRUEFALSE:
|
||||
newline += (*item[i]->source)?"true":"false";
|
||||
break;
|
||||
case YESNO:
|
||||
newline += (*item[i]->source)?"yes":"no";
|
||||
break;
|
||||
case ONOFF:
|
||||
newline += (*item[i]->source)?"on":"off";
|
||||
break;
|
||||
case ENABLED:
|
||||
newline += (*item[i]->source)?"enabled":"disabled";
|
||||
break;
|
||||
case HEX:
|
||||
sprintf(t, "%x", *item[i]->source);
|
||||
newline += t;
|
||||
break;
|
||||
case DEC:
|
||||
default:
|
||||
sprintf(t, "%d", *item[i]->source);
|
||||
newline += t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void config::save(char *fn) {
|
||||
FILE *fp;
|
||||
int i, fsize;
|
||||
uint32 l;
|
||||
char *buffer;
|
||||
uint8 set[4096];
|
||||
bool blank = false;
|
||||
fp = fopen(fn, "rb");
|
||||
if(!fp) {
|
||||
blank = true;
|
||||
} else {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
fsize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
if(fsize == 0) {
|
||||
blank = true;
|
||||
} else {
|
||||
buffer = (char*)malloc(fsize + 1);
|
||||
fread(buffer, 1, fsize, fp);
|
||||
fclose(fp);
|
||||
buffer[fsize] = 0;
|
||||
|
||||
data = buffer;
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
fp = fopen(fn, "wb");
|
||||
/* no write access? */
|
||||
if(!fp)return;
|
||||
|
||||
/* list of config items. if the item is set in the
|
||||
existing config file, then don't test it to see
|
||||
if it needs to be written again later on */
|
||||
memset(set, 0, item_count);
|
||||
|
||||
if(blank == false) {
|
||||
replace(data, "\r\n", "\n");
|
||||
qreplace(data, "\t", " ");
|
||||
|
||||
split(line, "\n", data);
|
||||
split(oldline, "\n", data);
|
||||
|
||||
for(i=0;i<count(line);i++) {
|
||||
qreplace(line[i], " ", "");
|
||||
|
||||
if(strqpos(line[i], "#") != null) {
|
||||
strset(line[i], strqpos(line[i], "#"), 0);
|
||||
}
|
||||
|
||||
/* this line is empty, restore the old line and continue */
|
||||
if(strlen(line[i]) == 0) {
|
||||
line[i] = oldline[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
qsplit(part, "=", line[i]);
|
||||
|
||||
l = find(*part[0]);
|
||||
if(l == null) {
|
||||
/* invalid item name, restore the old line and continue */
|
||||
line[i] = oldline[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
set[l] = 1;
|
||||
set_newline(l);
|
||||
|
||||
/* copy the user comment from the old config file, if it exists */
|
||||
if(strqpos(oldline[i], "#") != null) {
|
||||
newline += " ";
|
||||
newline += *oldline[i] + strqpos(oldline[i], "#");
|
||||
}
|
||||
|
||||
line[i] = newline;
|
||||
}
|
||||
|
||||
/* write out the old config file + changes first */
|
||||
for(i=0;i<count(line);) {
|
||||
fprintf(fp, "%s", *line[i]);
|
||||
|
||||
/* write a line feed on all lines but the last.
|
||||
keeps the file from growing everytime it is saved */
|
||||
if(++i < count(line))fprintf(fp, "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
int lines_written;
|
||||
for(i=lines_written=0;i<item_count;i++) {
|
||||
/* if the item was written to the file above... */
|
||||
if(set[i] == 1)continue;
|
||||
/* ...or if it is still set to the default value,
|
||||
then don't output it to the file here */
|
||||
if(item[i]->changed() == false)continue;
|
||||
|
||||
set_newline(i);
|
||||
/* prevent a newline from appearing at the top of the file
|
||||
when the config file is created for the first time */
|
||||
if(lines_written == 0 && blank == false)fprintf(fp, "\r\n");
|
||||
fprintf(fp, "%s\r\n", *newline);
|
||||
lines_written++;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
config::config() {
|
||||
item_count = 0;
|
||||
}
|
||||
|
||||
config::~config() {
|
||||
for(int i=0;i<item_count;i++) {
|
||||
if(item[i])delete(item[i]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
libconfig : version 0.01 ~byuu
|
||||
*/
|
||||
|
||||
#ifndef __LIBCONFIG
|
||||
#define __LIBCONFIG
|
||||
|
||||
#include "libstring.h"
|
||||
|
||||
class config_item {
|
||||
public:
|
||||
uint32 *source, def, type;
|
||||
string *strsource, strdef;
|
||||
bool is_string;
|
||||
string name;
|
||||
bool changed();
|
||||
config_item();
|
||||
};
|
||||
|
||||
class config {
|
||||
private:
|
||||
uint32 item_count;
|
||||
config_item *item[4096];
|
||||
string data, line, oldline, newline, part;
|
||||
public:
|
||||
enum {
|
||||
TRUEFALSE = 0,
|
||||
YESNO = 1,
|
||||
ONOFF = 2,
|
||||
ENABLED = 3,
|
||||
DEC = 4,
|
||||
HEX = 5,
|
||||
STR = 6
|
||||
};
|
||||
void add(uint32 *variable, char *name, uint32 def, uint32 type = DEC);
|
||||
void add(string *variable, char *name, char *def, uint32 type = STR);
|
||||
uint32 find(char *name);
|
||||
uint32 get(char *name);
|
||||
string &strget(char *name);
|
||||
void set(char *name, uint32 value);
|
||||
void set(char *name, char *value);
|
||||
|
||||
void load(char *fn);
|
||||
void save(char *fn);
|
||||
void set_newline(int i);
|
||||
|
||||
config();
|
||||
~config();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,338 @@
|
|||
#include "libbase.h"
|
||||
#include "libstring.h"
|
||||
|
||||
_string::_string() {
|
||||
size = 16;
|
||||
s = (char*)malloc(size + 1);
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
_string::~_string() {
|
||||
free(s);
|
||||
}
|
||||
|
||||
void string::addto(uint32 num) {
|
||||
while(listcount < (num + 1)) {
|
||||
list[listcount++] = new _string();
|
||||
}
|
||||
}
|
||||
|
||||
_string &string::str(uint32 num) {
|
||||
if(listcount < (num + 1)) { addto(num); }
|
||||
return *list[num];
|
||||
}
|
||||
|
||||
string::string() {
|
||||
count = 0;
|
||||
listcount = 0;
|
||||
addto(0);
|
||||
}
|
||||
|
||||
string::~string() {
|
||||
int i;
|
||||
for(i=listcount-1;i>=0;i--) {
|
||||
delete((_string*)list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 count(string &str) {
|
||||
return str.count;
|
||||
}
|
||||
|
||||
void strresize(_string &str, uint32 size) {
|
||||
char *t;
|
||||
int sl;
|
||||
if(str.size == size)return;
|
||||
sl = strlen(str.s);
|
||||
t = (char*)malloc(size + 1);
|
||||
strcpy(t, str.s);
|
||||
free(str.s);
|
||||
str.s = t;
|
||||
str.size = size;
|
||||
}
|
||||
|
||||
char *strptr(_string &str) {
|
||||
return str.s;
|
||||
}
|
||||
|
||||
void strcpy(_string &dest, char *src) {
|
||||
int srclen = strlen(src);
|
||||
if(srclen > dest.size) { strresize(dest, srclen); }
|
||||
strcpy(dest.s, src);
|
||||
}
|
||||
|
||||
void strset(_string &dest, uint32 pos, uint8 c) {
|
||||
char *s;
|
||||
if(pos > dest.size) { strresize(dest, pos); }
|
||||
dest.s[pos] = c;
|
||||
}
|
||||
|
||||
void strcat(_string &dest, char *src) {
|
||||
int srclen, destlen;
|
||||
srclen = strlen(src);
|
||||
destlen = strlen(dest.s);
|
||||
if(srclen + destlen > dest.size) { strresize(dest, srclen + destlen); }
|
||||
strcat(dest.s, src);
|
||||
}
|
||||
|
||||
void strinsert(_string &dest, char *src, uint32 pos) {
|
||||
_string *s = new _string();
|
||||
strcpy(*s, strptr(dest) + pos);
|
||||
strset(dest, pos, 0);
|
||||
strcat(dest, src);
|
||||
strcat(dest, *s);
|
||||
delete(s);
|
||||
}
|
||||
|
||||
void strremove(_string &dest, uint32 start, uint32 length) {
|
||||
int destlen;
|
||||
char *s;
|
||||
int i, sl = strlen(dest.s);
|
||||
if(start > dest.size) { strresize(dest, start); }
|
||||
if(!length) {
|
||||
strset(dest, start, 0);
|
||||
return;
|
||||
}
|
||||
s = dest.s;
|
||||
for(i=start;i<sl;i++) { s[i] = s[i+length]; }
|
||||
s[i] = 0;
|
||||
}
|
||||
|
||||
bool stricmp(char *dest, char *src) {
|
||||
int i, sl = strlen(dest);
|
||||
if(sl != strlen(src))return false;
|
||||
for(i=0;i<sl;i++) {
|
||||
if(dest[i] >= 'A' && dest[i] <= 'Z') {
|
||||
if(dest[i] != src[i] && dest[i] + 0x20 != src[i])return false;
|
||||
} else if(dest[i] >='a' && dest[i] <= 'z') {
|
||||
if(dest[i] != src[i] && dest[i] - 0x20 != src[i])return false;
|
||||
} else {
|
||||
if(dest[i] != src[i])return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void strlower(char *str) {
|
||||
int i, sl = strlen(str);
|
||||
for(i=0;i<sl;i++) {
|
||||
if(str[i] >= 'A' && str[i] <= 'Z')str[i] += 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
void strupper(char *str) {
|
||||
int i, sl = strlen(str);
|
||||
for(i=0;i<sl;i++) {
|
||||
if(str[i] >= 'a' && str[i] <= 'z')str[i] -= 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 strpos(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return null;
|
||||
for(i=0;i<=ssl-ksl;i++) {
|
||||
if(!memcmp(str+i, key, ksl))return i;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
uint32 strqpos(char *str, char *key) {
|
||||
int i, z, ssl = strlen(str), ksl = strlen(key);
|
||||
uint8 x;
|
||||
if(ksl > ssl)return null;
|
||||
for(i=0;i<=ssl-ksl;) {
|
||||
x = str[i];
|
||||
if(x == '\"' || x == '\'') {
|
||||
z = i++;
|
||||
while(str[i] != x && i < ssl)i++;
|
||||
if(i >= ssl)i = z;
|
||||
}
|
||||
if(!memcmp(str+i, key, ksl)) {
|
||||
return i;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void strtr(char *dest, char *before, char *after) {
|
||||
int i, l, sl = strlen(dest), bsl = strlen(before), asl = strlen(after);
|
||||
if((bsl != asl) || bsl == 0)return;
|
||||
for(i=0;i<sl;i++) {
|
||||
for(l=0;l<bsl;l++) {
|
||||
if(dest[i] == before[l])dest[i] = after[l];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32 strbegin(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return 1;
|
||||
if(!memcmp(str, key, ksl))return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 stribegin(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return 1;
|
||||
for(i=0;i<ksl;i++) {
|
||||
if(str[i] >= 'A' && str[i] <= 'Z') {
|
||||
if(str[i] != key[i] && str[i]+0x20 != key[i])return 1;
|
||||
} else if(str[i] >= 'a' && str[i] <= 'z') {
|
||||
if(str[i] != key[i] && str[i]-0x20 != key[i])return 1;
|
||||
} else {
|
||||
if(str[i] != key[i])return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 strend(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return 1;
|
||||
if(!memcmp(str + ssl - ksl, key, ksl))return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 striend(char *str, char *key) {
|
||||
int i, z, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return 1;
|
||||
for(i=ssl-ksl, z=0;i<ssl;i++, z++) {
|
||||
if(str[i] >= 'A' && str[i] <= 'Z') {
|
||||
if(str[i] != key[z] && str[i]+0x20 != key[z])return 1;
|
||||
} else if(str[i] >= 'a' && str[i] <= 'z') {
|
||||
if(str[i] != key[z] && str[i]-0x20 != key[z])return 1;
|
||||
} else {
|
||||
if(str[i] != key[z])return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void strltrim(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return;
|
||||
if(!strbegin(str, key)) {
|
||||
for(i=0;i<ssl-ksl;i++)str[i] = str[i + ksl];
|
||||
str[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void striltrim(char *str, char *key) {
|
||||
int i, ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return;
|
||||
if(!stribegin(str, key)) {
|
||||
for(i=0;i<ssl-ksl;i++)str[i] = str[i + ksl];
|
||||
str[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void strrtrim(char *str, char *key) {
|
||||
int ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return;
|
||||
if(!strend(str, key)) {
|
||||
str[ssl - ksl] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void strirtrim(char *str, char *key) {
|
||||
int ssl = strlen(str), ksl = strlen(key);
|
||||
if(ksl > ssl)return;
|
||||
if(!striend(str, key)) {
|
||||
str[ssl - ksl] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* does not work on type char* because function increases string length */
|
||||
void strquote(_string &str) {
|
||||
static string t;
|
||||
t = "\"";
|
||||
t += str;
|
||||
t += "\"";
|
||||
str = t;
|
||||
}
|
||||
|
||||
bool strunquote(char *str) {
|
||||
int i, ssl = strlen(str);
|
||||
/* make sure string is long enough to have quotes */
|
||||
if(ssl < 2)return false;
|
||||
|
||||
/* make sure string actually has quotes */
|
||||
if(str[0] == '\"' && str[ssl - 1] == '\"');
|
||||
else if(str[0] == '\'' && str[ssl - 1] == '\'');
|
||||
else return false;
|
||||
|
||||
/* now remove them */
|
||||
for(i=0;i<ssl;i++) {
|
||||
str[i] = str[i + 1];
|
||||
}
|
||||
str[i - 2] = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 strhex(char *str) {
|
||||
uint32 r = 0, m = 0;
|
||||
int i, ssl = strlen(str);
|
||||
uint8 x;
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] >= '0' && str[i] <= '9');
|
||||
else if(str[i] >= 'A' && str[i] <= 'F');
|
||||
else if(str[i] >= 'a' && str[i] <= 'f');
|
||||
else break;
|
||||
}
|
||||
for(--i;i>=0;i--, m+=4) {
|
||||
x = str[i];
|
||||
if(x >= '0' && x <= '9')x -= '0';
|
||||
else if(x >= 'A' && x <= 'F')x -= 'A' - 0x0a;
|
||||
else if(x >= 'a' && x <= 'f')x -= 'a' - 0x0a;
|
||||
else return r;
|
||||
r |= x << m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int strdec(char *str) {
|
||||
uint32 m = 1;
|
||||
int i, r = 0, ssl = strlen(str);
|
||||
uint8 x;
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] >= '0' && str[i] <= '9');
|
||||
else if(str[i] == '-' && i == 0);
|
||||
else break;
|
||||
}
|
||||
for(--i;i>=0;i--, m*=10) {
|
||||
x = str[i];
|
||||
if(x >= '0' && x <= '9')x -= '0';
|
||||
else if(i == 0 && str[i] == '-') {
|
||||
r *= -1;
|
||||
return r;
|
||||
}
|
||||
else return r;
|
||||
r += x * m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32 strbin(char *str) {
|
||||
uint32 r = 0, m = 0;
|
||||
int i, ssl = strlen(str);
|
||||
uint8 x;
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] == '0' || str[i] == '1');
|
||||
else break;
|
||||
}
|
||||
for(--i;i>=0;i--, m++) {
|
||||
x = str[i];
|
||||
if(str[i] == '0' || str[i] == '1')x -= '0';
|
||||
else return r;
|
||||
r |= x << m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#include "libstring_math.cpp"
|
||||
#include "libstring_split.cpp"
|
||||
#include "libstring_replace.cpp"
|
||||
#include "libstring_sprintf.cpp"
|
|
@ -0,0 +1,276 @@
|
|||
/*
|
||||
libstring : version 0.04 ~byuu
|
||||
*/
|
||||
|
||||
#ifndef __LIBSTRING
|
||||
#define __LIBSTRING
|
||||
|
||||
#include "libvector.h"
|
||||
|
||||
class string;
|
||||
class _string;
|
||||
|
||||
uint32 count(string &str);
|
||||
void strresize(_string &str, uint32 size);
|
||||
char* strptr(_string &str);
|
||||
void strcpy(_string &dest, char *src);
|
||||
void strset(_string &dest, uint32 pos, uint8 c);
|
||||
void strcat(_string &dest, char *src);
|
||||
void strinsert(_string &dest, char *src, uint32 pos);
|
||||
void strremove(_string &dest, uint32 start, uint32 length = 0);
|
||||
bool stricmp(char *dest, char *src);
|
||||
void strlower(char *str);
|
||||
void strupper(char *str);
|
||||
uint32 strpos(char *str, char *key);
|
||||
uint32 strqpos(char *str, char *key);
|
||||
void strtr(char *dest, char *before, char *after);
|
||||
uint32 strbegin(char *str, char *key);
|
||||
uint32 stribegin(char *str, char *key);
|
||||
uint32 strend(char *str, char *key);
|
||||
uint32 striend(char *str, char *key);
|
||||
void strltrim(char *str, char *key);
|
||||
void striltrim(char *str, char *key);
|
||||
void strrtrim(char *str, char *key);
|
||||
void strirtrim(char *str, char *key);
|
||||
void strquote(_string &str);
|
||||
bool strunquote(char *str);
|
||||
uint32 strhex(char *str);
|
||||
int strdec(char *str);
|
||||
uint32 strbin(char *str);
|
||||
uint32 strmath(char *in_str);
|
||||
uint32 strmathentity(char *str);
|
||||
void replace (_string &str, char *key, char *token);
|
||||
void qreplace(_string &str, char *key, char *token);
|
||||
void split (string &dest, char *key, char *src);
|
||||
void qsplit(string &dest, char *key, char *src);
|
||||
void sprintf(_string &str, char *s, ...);
|
||||
|
||||
class _string {
|
||||
public:
|
||||
char *s;
|
||||
uint32 size;
|
||||
|
||||
/* * */
|
||||
inline char* operator*() { return s; }
|
||||
|
||||
/* = */
|
||||
inline _string& operator=(char *cpy);
|
||||
inline _string& operator=(_string &cpy);
|
||||
inline _string& operator=(string &cpy);
|
||||
|
||||
/* += */
|
||||
inline _string& operator+=(char *cat);
|
||||
inline _string& operator+=(_string &cat);
|
||||
inline _string& operator+=(string &cat);
|
||||
|
||||
/* -= */
|
||||
inline _string& operator-=(char *cut);
|
||||
inline _string& operator-=(_string &cut);
|
||||
inline _string& operator-=(string &cut);
|
||||
|
||||
/* == */
|
||||
inline bool operator==(char *cmp);
|
||||
inline bool operator==(_string &cmp);
|
||||
inline bool operator==(string &cmp);
|
||||
|
||||
/* != */
|
||||
inline bool operator!=(char *cmp);
|
||||
inline bool operator!=(_string &cmp);
|
||||
inline bool operator!=(string &cmp);
|
||||
|
||||
inline operator char*() { return s; }
|
||||
|
||||
_string();
|
||||
~_string();
|
||||
};
|
||||
|
||||
class string {
|
||||
public:
|
||||
vector<_string*> list;
|
||||
uint32 count, listcount;
|
||||
void addto(uint32 num); //creates all needed strings to make list[num] valid
|
||||
_string &str(uint32 num); //gets a _string reference, creating it + new strings if needed
|
||||
|
||||
/* * */
|
||||
inline char* operator*() { return strptr(str(0)); }
|
||||
|
||||
/* = */
|
||||
inline string& operator=(char *cpy);
|
||||
inline string& operator=(_string &cpy);
|
||||
inline string& operator=(string &cpy);
|
||||
|
||||
/* += */
|
||||
inline string& operator+=(char *cat);
|
||||
inline string& operator+=(_string &cat);
|
||||
inline string& operator+=(string &cat);
|
||||
|
||||
/* -= */
|
||||
inline string& operator-=(char *cut);
|
||||
inline string& operator-=(_string &cut);
|
||||
inline string& operator-=(string &cut);
|
||||
|
||||
/* == */
|
||||
inline bool operator==(char *cmp);
|
||||
inline bool operator==(_string &cmp);
|
||||
inline bool operator==(string &cmp);
|
||||
|
||||
/* != */
|
||||
inline bool operator!=(char *cmp);
|
||||
inline bool operator!=(_string &cmp);
|
||||
inline bool operator!=(string &cmp);
|
||||
|
||||
inline operator char*() { return str(0).s; }
|
||||
inline operator _string&() { return str(0); }
|
||||
inline _string& operator[](uint32 i) { return str(i); }
|
||||
inline _string& operator[](int i) { return str(i); }
|
||||
|
||||
string();
|
||||
~string();
|
||||
};
|
||||
|
||||
//
|
||||
// =
|
||||
//
|
||||
inline _string& _string::operator=(char *cpy) {
|
||||
strcpy(*this, cpy);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator=(_string &cpy) {
|
||||
strcpy(*this, cpy);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator=(string &cpy) {
|
||||
strcpy(*this, cpy.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline string& string::operator=(char *cpy) {
|
||||
strcpy(str(0), cpy);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator=(_string &cpy) {
|
||||
strcpy(str(0), cpy);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator=(string &cpy) {
|
||||
strcpy(str(0), cpy.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// +=
|
||||
//
|
||||
inline _string& _string::operator+=(char *cat) {
|
||||
strcat(*this, cat);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator+=(_string &cat) {
|
||||
strcat(*this, cat);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator+=(string &cat) {
|
||||
strcat(*this, cat.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline string& string::operator+=(char *cat) {
|
||||
strcat(str(0), cat);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator+=(_string &cat) {
|
||||
strcat(str(0), cat);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator+=(string &cat) {
|
||||
strcat(str(0), cat.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// -=
|
||||
//
|
||||
inline _string& _string::operator-=(char *cut) {
|
||||
strrtrim(*this, cut);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator-=(_string &cut) {
|
||||
strrtrim(*this, cut);
|
||||
return *this;
|
||||
}
|
||||
inline _string& _string::operator-=(string &cut) {
|
||||
strrtrim(*this, cut.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline string& string::operator-=(char *cut) {
|
||||
strrtrim(str(0), cut);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator-=(_string &cut) {
|
||||
strrtrim(str(0), cut);
|
||||
return *this;
|
||||
}
|
||||
inline string& string::operator-=(string &cut) {
|
||||
strrtrim(str(0), cut.str(0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// ==
|
||||
//
|
||||
inline bool _string::operator==(char *cmp) {
|
||||
if(!strcmp(*this, cmp))return true;
|
||||
return false;
|
||||
}
|
||||
inline bool _string::operator==(_string &cmp) {
|
||||
if(!strcmp(*this, cmp))return true;
|
||||
return false;
|
||||
}
|
||||
inline bool _string::operator==(string &cmp) {
|
||||
if(!strcmp(*this, cmp.str(0)))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool string::operator==(char *cmp) {
|
||||
if(!strcmp(str(0), cmp))return true;
|
||||
return false;
|
||||
}
|
||||
inline bool string::operator==(_string &cmp) {
|
||||
if(!strcmp(str(0), cmp))return true;
|
||||
return false;
|
||||
}
|
||||
inline bool string::operator==(string &cmp) {
|
||||
if(!strcmp(str(0), cmp.str(0)))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// !=
|
||||
//
|
||||
inline bool _string::operator!=(char *cmp) {
|
||||
if(!strcmp(*this, cmp))return false;
|
||||
return true;
|
||||
}
|
||||
inline bool _string::operator!=(_string &cmp) {
|
||||
if(!strcmp(*this, cmp))return false;
|
||||
return true;
|
||||
}
|
||||
inline bool _string::operator!=(string &cmp) {
|
||||
if(!strcmp(*this, cmp.str(0)))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool string::operator!=(char *cmp) {
|
||||
if(!strcmp(str(0), cmp))return false;
|
||||
return true;
|
||||
}
|
||||
inline bool string::operator!=(_string &cmp) {
|
||||
if(!strcmp(str(0), cmp))return false;
|
||||
return true;
|
||||
}
|
||||
inline bool string::operator!=(string &cmp) {
|
||||
if(!strcmp(str(0), cmp.str(0)))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,177 @@
|
|||
#define STRMATH_ADD 1
|
||||
#define STRMATH_SUB 2
|
||||
#define STRMATH_MUL 3
|
||||
#define STRMATH_DIV 4
|
||||
#define STRMATH_MOD 5
|
||||
#define STRMATH_AND 6
|
||||
#define STRMATH_OR 7
|
||||
#define STRMATH_XOR 8
|
||||
#define STRMATH_SHL 9
|
||||
#define STRMATH_SHR 10
|
||||
|
||||
#define STRMATH_LINKED 64
|
||||
|
||||
#define STRMATHMODE_NEG 1
|
||||
#define STRMATHMODE_NOT 2
|
||||
|
||||
#define __strunktonum() \
|
||||
if (s1[0] == '0' && s1[1] == 'x')r = strhex(s1 + 2); \
|
||||
else if(s1[0] == '0' && s1[1] == 'b')r = strbin(s1 + 2); \
|
||||
else r = strdec(s1)
|
||||
|
||||
#define __strmath_setmode() \
|
||||
if (str[i] == '-') { mode = STRMATHMODE_NEG; i++; } \
|
||||
else if(str[i] == '~') { mode = STRMATHMODE_NOT; i++; } \
|
||||
else if(str[i] == '+') { i++; } \
|
||||
else mode=0
|
||||
|
||||
#define __strmath_modeset() \
|
||||
if (mode == STRMATHMODE_NEG)r *= -1; \
|
||||
else if(mode == STRMATHMODE_NOT)r =~ r
|
||||
|
||||
#define __strmath_set(__x) \
|
||||
s1[z] = 0; \
|
||||
z = 0; \
|
||||
__strunktonum(); \
|
||||
__strmath_modeset(); \
|
||||
array[array_size++] = r; \
|
||||
array_gate[array_size] = __x
|
||||
|
||||
/***************************************
|
||||
strmath(str)
|
||||
resolves all math entities from within
|
||||
str, and returns numerical result
|
||||
example: strmath("5+5")=10
|
||||
***************************************/
|
||||
uint32 p_strmath(char *str) {
|
||||
int i = 0, ssl = strlen(str);
|
||||
uint8 x, mode = 0;
|
||||
uint32 r, array[128], array_size = 0, z = 0;
|
||||
uint8 array_gate[128];
|
||||
char *s1;
|
||||
if(!ssl)return 0;
|
||||
s1 = (char*)malloc(ssl + 1);
|
||||
__strmath_setmode();
|
||||
while(i < ssl) {
|
||||
x = str[i++];
|
||||
if (x == '+') { __strmath_set(STRMATH_ADD); __strmath_setmode(); }
|
||||
else if(x == '-') { __strmath_set(STRMATH_SUB); __strmath_setmode(); }
|
||||
else if(x == '*') { __strmath_set(STRMATH_MUL); __strmath_setmode(); }
|
||||
else if(x == '/') { __strmath_set(STRMATH_DIV); __strmath_setmode(); }
|
||||
else if(x == '%') { __strmath_set(STRMATH_MOD); __strmath_setmode(); }
|
||||
else if(x == '&') { __strmath_set(STRMATH_AND); __strmath_setmode(); }
|
||||
else if(x == '|') { __strmath_set(STRMATH_OR ); __strmath_setmode(); }
|
||||
else if(x == '^') { __strmath_set(STRMATH_XOR); __strmath_setmode(); }
|
||||
else if(x == '<' && str[i] == '<') { __strmath_set(STRMATH_SHL); i++; __strmath_setmode(); }
|
||||
else if(x == '>' && str[i] == '>') { __strmath_set(STRMATH_SHR); i++; __strmath_setmode(); }
|
||||
else s1[z++] = x;
|
||||
}
|
||||
s1[z] = 0;
|
||||
__strunktonum();
|
||||
__strmath_modeset();
|
||||
array[array_size++] = r;
|
||||
free(s1);
|
||||
|
||||
for(i=1;i<array_size;i++) {
|
||||
if (array_gate[i] == STRMATH_SHL) { array[i-1] <<= array[i]; array_gate[i] = STRMATH_LINKED; }
|
||||
else if(array_gate[i] == STRMATH_SHR) { array[i-1] >>= array[i]; array_gate[i] = STRMATH_LINKED; }
|
||||
}
|
||||
|
||||
for(i=1;i<array_size;i++) {
|
||||
if (array_gate[i] == STRMATH_MUL) { array[i-1] *= array[i]; array_gate[i] = STRMATH_LINKED; }
|
||||
else if(array_gate[i] == STRMATH_DIV) { array[i-1] /= array[i]; array_gate[i] = STRMATH_LINKED; }
|
||||
}
|
||||
|
||||
r = array[0];
|
||||
for(i=1;i<array_size;i++) {
|
||||
if (array_gate[i] == STRMATH_ADD)r += array[i];
|
||||
else if(array_gate[i] == STRMATH_SUB)r -= array[i];
|
||||
else if(array_gate[i] == STRMATH_MOD)r %= array[i];
|
||||
else if(array_gate[i] == STRMATH_AND)r &= array[i];
|
||||
else if(array_gate[i] == STRMATH_OR )r |= array[i];
|
||||
else if(array_gate[i] == STRMATH_XOR)r ^= array[i];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32 strmath(char *in_str) {
|
||||
uint32 r = 0;
|
||||
uint32 pdepth = 0, cpdepth, maxpdepth = 0;
|
||||
uint32 pstart, pend, spos;
|
||||
int i, sc, sl = strlen(in_str);
|
||||
char *str = (char*)malloc(sl + 1), *str0;
|
||||
char *pstr;
|
||||
char num[64];
|
||||
strcpy(str, in_str);
|
||||
|
||||
for(i=0;i<sl;i++) {
|
||||
if(str[i]=='(') {
|
||||
pdepth++;
|
||||
if(pdepth > maxpdepth)maxpdepth = pdepth;
|
||||
} else if(str[i]==')') {
|
||||
if(pdepth == 0) {
|
||||
free(str);
|
||||
return null; //error! too many )'s
|
||||
}
|
||||
pdepth --;
|
||||
}
|
||||
}
|
||||
|
||||
if(pdepth != 0) {
|
||||
free(str);
|
||||
return null; //error! unequal ('s to )'s
|
||||
}
|
||||
|
||||
pdepth = maxpdepth;
|
||||
while(pdepth) {
|
||||
cpdepth = 0;
|
||||
for(i=0;i<sl;) {
|
||||
if(str[i] == '(')cpdepth++;
|
||||
if(str[i] == ')')cpdepth--;
|
||||
i++;
|
||||
if(cpdepth == pdepth) {
|
||||
pstart = i;
|
||||
while(str[i] != ')')i++;
|
||||
pend = i;
|
||||
|
||||
pstr = (char*)malloc(pend-pstart+1);
|
||||
memcpy(pstr, str+pstart, pend-pstart);
|
||||
pstr[pend-pstart]=0;
|
||||
r = p_strmath(pstr);
|
||||
free(pstr);
|
||||
sprintf(num, "%d", r);
|
||||
str0 = (char*)malloc(sl + strlen(num) + 1);
|
||||
memcpy(str0, str, pstart - 1);
|
||||
spos = pstart - 1;
|
||||
memcpy(str0+spos, num, strlen(num));
|
||||
spos += strlen(num);
|
||||
sc = spos;
|
||||
memcpy(str0+spos, str+pend+1, sl-pend-1);
|
||||
spos += sl - pend - 1;
|
||||
sl = spos;
|
||||
str0[sl] = 0;
|
||||
free(str);
|
||||
str = str0;
|
||||
cpdepth--;
|
||||
i = sc;
|
||||
}
|
||||
}
|
||||
pdepth--;
|
||||
}
|
||||
|
||||
r = p_strmath(str);
|
||||
|
||||
free(str);
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32 strmathentity(char *str) {
|
||||
int i, ssl = strlen(str);
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/' ||
|
||||
str[i] == '%' || str[i] == '&' || str[i] == '|' || str[i] == '^' ||
|
||||
(str[i] == '<' && str[i+1] == '<') || (str[i] == '>' && str[i+1] == '>'))return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
void replace(_string &str, char *key, char *token) {
|
||||
int i, z, ksl = strlen(key), tsl = strlen(token), ssl = strlen(str);
|
||||
uint32 replace_count = 0, size = ssl;
|
||||
char *data;
|
||||
if(ksl > ssl)return;
|
||||
if(tsl > ksl) { //the new string may be longer than the old string...
|
||||
for(i=0;i<=ssl-ksl;) { //so let's find out how big of a string we'll need...
|
||||
if(!memcmp(str.s + i, key, ksl)) {
|
||||
replace_count++;
|
||||
i += ksl;
|
||||
} else i++;
|
||||
}
|
||||
size = ssl + ((tsl - ksl) * replace_count);
|
||||
if(size > str.size)strresize(str, size);
|
||||
}
|
||||
data = (char*)malloc(size + 1);
|
||||
for(i=z=0;i<ssl;) {
|
||||
if(i <= ssl - ksl) {
|
||||
if(!memcmp(str.s + i, key, ksl)) {
|
||||
memcpy(data + z, token, tsl);
|
||||
z += tsl;
|
||||
i += ksl;
|
||||
} else data[z++] = str.s[i++];
|
||||
} else data[z++] = str.s[i++];
|
||||
}
|
||||
data[z] = 0;
|
||||
strcpy(str, data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void qreplace(_string &str, char *key, char *token) {
|
||||
int i, l, z, ksl = strlen(key), tsl = strlen(token), ssl = strlen(str);
|
||||
uint8 x;
|
||||
uint32 replace_count = 0, size = ssl;
|
||||
char *data;
|
||||
if(ksl > ssl)return;
|
||||
if(tsl > ksl) {
|
||||
for(i=0;i<=ssl-ksl;) {
|
||||
x = str.s[i];
|
||||
if(x == '\"' || x == '\'') {
|
||||
l = i;
|
||||
i++;
|
||||
while(str.s[i++] != x) {
|
||||
if(i == ssl) {
|
||||
i = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!memcmp(str.s + i, key, ksl)) {
|
||||
replace_count++;
|
||||
i += ksl;
|
||||
} else i++;
|
||||
}
|
||||
size = ssl + ((tsl - ksl) * replace_count);
|
||||
if(size > str.size)strresize(str, size);
|
||||
}
|
||||
data = (char*)malloc(size + 1);
|
||||
for(i=z=0;i<ssl;) {
|
||||
x = str.s[i];
|
||||
if(x == '\"' || x == '\'') {
|
||||
l = i++;
|
||||
while(str.s[i] != x && i < ssl)i++;
|
||||
if(i >= ssl)i = l;
|
||||
else {
|
||||
memcpy(data + z, str.s + l, i - l);
|
||||
z += i - l;
|
||||
}
|
||||
}
|
||||
if(i <= ssl - ksl) {
|
||||
if(!memcmp(str.s + i, key, ksl)) {
|
||||
memcpy(data + z, token, tsl);
|
||||
z += tsl;
|
||||
i += ksl;
|
||||
replace_count++;
|
||||
} else data[z++] = str.s[i++];
|
||||
} else data[z++] = str.s[i++];
|
||||
}
|
||||
data[z] = 0;
|
||||
strcpy(str, data);
|
||||
free(data);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
void split(string &dest, char *key, char *src) {
|
||||
int i, ssl = strlen(src), ksl = strlen(key);
|
||||
uint8 x;
|
||||
uint32 lp = 0, split_count = 0;
|
||||
for(i=0;i<=ssl-ksl;) {
|
||||
if(!memcmp(src + i, key, ksl)) {
|
||||
x = src[i];
|
||||
src[i] = 0;
|
||||
strcpy(dest[split_count++], src + lp);
|
||||
src[i] = x;
|
||||
i += ksl;
|
||||
lp = i;
|
||||
} else i++;
|
||||
}
|
||||
strcpy(dest[split_count++], src + lp);
|
||||
dest.count = split_count;
|
||||
}
|
||||
|
||||
void qsplit(string &dest, char *key, char *src) {
|
||||
int i, z, ssl = strlen(src), ksl = strlen(key);
|
||||
uint8 x;
|
||||
uint32 lp = 0, split_count = 0;
|
||||
for(i=0;i<=ssl-ksl;) {
|
||||
x = src[i];
|
||||
if(x=='\"' || x=='\'') {
|
||||
z = i++;
|
||||
while(src[i] != x && i < ssl)i++;
|
||||
if(i >= ssl)i = z;
|
||||
}
|
||||
if(!memcmp(src + i, key, ksl)) {
|
||||
x = src[i];
|
||||
src[i] = 0;
|
||||
strcpy(dest[split_count++], src + lp);
|
||||
src[i] = x;
|
||||
i += ksl;
|
||||
lp = i;
|
||||
} else i++;
|
||||
}
|
||||
strcpy(dest[split_count++], src + lp);
|
||||
dest.count = split_count;
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
void numtobin(char *s, uint32 num) {
|
||||
uint32 mask = 0x80000000, len = 0, z = 0;
|
||||
for(;mask;mask>>=1,len++) { if(num&mask)break; }
|
||||
len = 32 - len;
|
||||
do {
|
||||
if(num&(1<<(len-1)))s[z++] = '1';
|
||||
else s[z++] = '0';
|
||||
}while(--len);
|
||||
s[z] = 0;
|
||||
}
|
||||
|
||||
void sprintf(_string &str, char *s, ...) {
|
||||
va_list args;
|
||||
char t[2], n[256];
|
||||
int i, l, sl, z;
|
||||
uint8 pad_type, pad_len;
|
||||
uint32 num;
|
||||
char *r;
|
||||
va_start(args, s);
|
||||
strcpy(str, "");
|
||||
for(i=0;i<strlen(s);i++) {
|
||||
if(s[i] == '%') {
|
||||
i++;
|
||||
if(s[i] == '0' && s[i+1] == '.' && (s[i+2] >= '0' && s[i+2] <= '9')) {
|
||||
pad_type = 1;
|
||||
if(s[i+3] >= '0' && s[i+3] <= '9') { pad_len = (s[i+2]-'0')*10 + (s[i+3]-'0'); i+=4; }
|
||||
else { pad_len = (s[i+2]-'0'); i+=3; }
|
||||
}
|
||||
else if(s[i] >= '0' && s[i] <= '9') {
|
||||
pad_type = 2;
|
||||
if(s[i+1] >= '0' && s[i+1] <= '9') { pad_len = (s[i]-'0')*10 + (s[i+1]-'0'); i+=2; }
|
||||
else { pad_len = (s[i]-'0'); i+=1; }
|
||||
}
|
||||
else { pad_type = 0; }
|
||||
|
||||
if(s[i] == 'd') {
|
||||
num = va_arg(args, uint32);
|
||||
sprintf(n, "%d", num);
|
||||
} else if(s[i] == 'x') {
|
||||
num = va_arg(args, uint32);
|
||||
sprintf(n, "%x", num);
|
||||
} else if(s[i] == 'b') {
|
||||
num = va_arg(args, uint32);
|
||||
numtobin(n, num);
|
||||
} else if(s[i] == 's') {
|
||||
r = va_arg(args, char*);
|
||||
}
|
||||
|
||||
if(pad_type != 0) {
|
||||
if(s[i] == 's')sl = strlen(r);
|
||||
else sl = strlen(n);
|
||||
if(sl < pad_len) {
|
||||
while(sl < pad_len) {
|
||||
strcat(str, (pad_type == 1)?"0":" ");
|
||||
sl++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(s[i] == 's')strcat(str, r);
|
||||
else strcat(str, n);
|
||||
} else {
|
||||
t[0] = s[i];
|
||||
t[1] = 0;
|
||||
strcat(str, t);
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
libvector : version 0.01 ~byuu
|
||||
*/
|
||||
|
||||
#ifndef __LIBVECTOR
|
||||
#define __LIBVECTOR
|
||||
|
||||
template<typename T> class vector {
|
||||
public:
|
||||
T *array;
|
||||
int size, sizelimit;
|
||||
int findsize(int newsize) {
|
||||
int r = 1;
|
||||
while(r >= 1) {
|
||||
r <<= 1;
|
||||
if(r > sizelimit)return sizelimit;
|
||||
if(r >= newsize)return r;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void resize(int newsize) {
|
||||
T *newarray;
|
||||
newsize = findsize(newsize);
|
||||
|
||||
if(newsize > sizelimit)newsize = sizelimit;
|
||||
if(newsize == size)return;
|
||||
|
||||
newarray = (T*)malloc(sizeof(T) * newsize);
|
||||
if(newsize >= size) {
|
||||
memcpy(newarray, array, sizeof(T) * size);
|
||||
} else {
|
||||
memcpy(newarray, array, sizeof(T) * newsize);
|
||||
}
|
||||
free(array);
|
||||
|
||||
array = newarray;
|
||||
size = newsize;
|
||||
}
|
||||
|
||||
vector(int newsize, int newsizelimit) {
|
||||
size = newsize;
|
||||
sizelimit = newsizelimit;
|
||||
array = (T*)malloc(sizeof(T) * size);
|
||||
}
|
||||
|
||||
vector(int newsize) {
|
||||
size = newsize;
|
||||
sizelimit = 1 << 24;
|
||||
array = (T*)malloc(sizeof(T) * size);
|
||||
}
|
||||
|
||||
vector() {
|
||||
size = 16;
|
||||
sizelimit = 1 << 24;
|
||||
array = (T*)malloc(sizeof(T) * size);
|
||||
}
|
||||
|
||||
~vector() {
|
||||
if(array)free(array);
|
||||
}
|
||||
|
||||
inline T &operator[](int index) {
|
||||
static T __null = (T)0;
|
||||
if(index >= size)resize(index + 1);
|
||||
if(index > sizelimit)return __null;
|
||||
return array[index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -307,6 +307,15 @@ uint32 b, w;
|
|||
snes->notify(SNES::MEM_WRITE, addr, value);
|
||||
}
|
||||
|
||||
void bMemBus::power() {
|
||||
memset(wram, 0, 0x020000);
|
||||
reset();
|
||||
}
|
||||
|
||||
void bMemBus::reset() {
|
||||
fastROM = false;
|
||||
}
|
||||
|
||||
bMemBus::bMemBus() {
|
||||
rom = new bROM();
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ byte *wram;
|
|||
uint8 read (uint32 addr);
|
||||
void write(uint32 addr, byte value);
|
||||
|
||||
void power();
|
||||
void reset();
|
||||
|
||||
bMemBus();
|
||||
~bMemBus();
|
||||
};
|
||||
|
|
|
@ -33,6 +33,9 @@ bool fastROM;
|
|||
virtual bool set_mmio_mapper(uint16 addr, MMIO *mapper);
|
||||
virtual uint8 speed(uint32 addr);
|
||||
|
||||
virtual void power() = 0;
|
||||
virtual void reset() = 0;
|
||||
|
||||
MemBus();
|
||||
~MemBus();
|
||||
};
|
||||
|
|
|
@ -7,11 +7,25 @@ void bPPU::run() {}
|
|||
void bPPU::scanline() {
|
||||
uint16 v = clock->vcounter();
|
||||
if(v > 0 && v < clock->visible_scanlines()) {
|
||||
if(clock->interlace() || regs.oam_halve == true) {
|
||||
output->frame_mode |= PPUOutput::INTERLACE;
|
||||
output->scanline_mode[v] |= PPUOutput::INTERLACE;
|
||||
}
|
||||
if(regs.bg_mode == 5 || regs.bg_mode == 6) {
|
||||
output->frame_mode |= PPUOutput::DOUBLEWIDTH;
|
||||
output->scanline_mode[v] |= PPUOutput::DOUBLEWIDTH;
|
||||
}
|
||||
render_line(v);
|
||||
}
|
||||
}
|
||||
|
||||
void bPPU::frame() {}
|
||||
void bPPU::frame() {
|
||||
snes->notify(SNES::RENDER_FRAME);
|
||||
output->frame_mode = PPUOutput::NORMAL;
|
||||
for(int i=0;i<239;i++) {
|
||||
output->scanline_mode[i] = PPUOutput::NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
void bPPU::power() {
|
||||
memset(vram, 0, 65536);
|
||||
|
@ -21,7 +35,8 @@ void bPPU::power() {
|
|||
}
|
||||
|
||||
void bPPU::reset() {
|
||||
memset(output, 0, 512 * 478 * 2);
|
||||
memset(output->buffer, 0, 512 * 478 * 2);
|
||||
frame();
|
||||
|
||||
//$2100
|
||||
regs.display_disabled = 0;
|
||||
|
|
|
@ -487,13 +487,6 @@ uint16 r = regs.vcounter;
|
|||
//STAT77
|
||||
uint8 bPPU::mmio_r213e() {
|
||||
uint8 r = 0x00;
|
||||
r |= clock->interlace_field() << 7;
|
||||
if(!(cpu->pio_status() & 0x80)) {
|
||||
r |= 1 << 6;
|
||||
} else if(regs.counters_latched == true) {
|
||||
r |= 1 << 6;
|
||||
regs.counters_latched = false;
|
||||
}
|
||||
r |= 0x01; //PPU1 version number
|
||||
return r;
|
||||
}
|
||||
|
@ -503,6 +496,14 @@ uint8 bPPU::mmio_r213f() {
|
|||
uint8 r = 0x00;
|
||||
regs.latch_hcounter = 0;
|
||||
regs.latch_vcounter = 0;
|
||||
|
||||
r |= clock->interlace_field() << 7;
|
||||
if(!(cpu->pio_status() & 0x80)) {
|
||||
r |= 1 << 6;
|
||||
} else if(regs.counters_latched == true) {
|
||||
r |= 1 << 6;
|
||||
regs.counters_latched = false;
|
||||
}
|
||||
r |= (1 << 5);
|
||||
r |= 0x03; //PPU2 version number
|
||||
return r;
|
||||
|
|
|
@ -113,7 +113,7 @@ void bPPU::render_line_mode7() {
|
|||
|
||||
void bPPU::render_line(uint16 line) {
|
||||
if(regs.display_disabled == true) {
|
||||
memset(output + (line << 1) * 512, 0, 2048);
|
||||
memset(output->buffer + (line << 1) * 512, 0, 2048);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ struct {
|
|||
}current_sprite;
|
||||
|
||||
void render_line_to_output();
|
||||
uint16 addsub_pixels(uint8 x, uint8 cdest_index, uint8 cdest_bg, uint8 csrc_index, uint8 csrc_bg);
|
||||
uint16 addsub_pixel(uint8 x, uint8 cdest_index, uint8 cdest_bg);
|
||||
inline uint16 addsub_pixels(uint8 x, uint8 cdest_index, uint8 cdest_bg, uint8 csrc_index, uint8 csrc_bg);
|
||||
inline uint16 addsub_pixel(uint8 x, uint8 cdest_index, uint8 cdest_bg);
|
||||
void render_bg_tile(uint8 color_depth, uint8 bg, uint16 tile_num);
|
||||
void set_pixel(uint8 bg, uint16 x, uint8 pal_index);
|
||||
void set_layer_pixels(uint8 layer_count, uint8 *layer_bg_lookup);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace bPPUAddSubTables {
|
|||
};
|
||||
};
|
||||
|
||||
uint16 bPPU::addsub_pixels(uint8 x, uint8 cdest_index, uint8 cdest_bg, uint8 csrc_index, uint8 csrc_bg) {
|
||||
inline uint16 bPPU::addsub_pixels(uint8 x, uint8 cdest_index, uint8 cdest_bg, uint8 csrc_index, uint8 csrc_bg) {
|
||||
int r, g, b;
|
||||
uint16 cdest = pal_pixel(cdest_index);
|
||||
uint16 csrc = pal_pixel(csrc_index);
|
||||
|
@ -52,7 +52,7 @@ uint16 res;
|
|||
return ((r) | (g << 5) | (b << 10));
|
||||
}
|
||||
|
||||
uint16 bPPU::addsub_pixel(uint8 x, uint8 cdest_index, uint8 cdest_bg) {
|
||||
inline uint16 bPPU::addsub_pixel(uint8 x, uint8 cdest_index, uint8 cdest_bg) {
|
||||
int r, g, b;
|
||||
uint16 cdest = pal_pixel(cdest_index);
|
||||
uint16 csrc = (regs.color_r) | (regs.color_g << 5) | (regs.color_b << 10);
|
||||
|
@ -190,16 +190,17 @@ uint8 *dest;
|
|||
|
||||
void bPPU::render_line_to_output() {
|
||||
int x, x1;
|
||||
uint16 *ptr, *ptri, *ltable;
|
||||
uint16 *ptr, *ltable;
|
||||
uint16 c, cx, cy;
|
||||
uint16 screen_width = (regs.bg_mode == 5 || regs.bg_mode == 6)?512:256;
|
||||
uint16 vline_pos = clock->vcounter();
|
||||
uint16 screen_width;
|
||||
uint16 v, vline_pos = clock->vcounter();
|
||||
v = vline_pos;
|
||||
screen_width = (output->scanline_mode[v] & PPUOutput::DOUBLEWIDTH)?512:256;
|
||||
|
||||
if(clock->interlace() == false) {
|
||||
ptr = (uint16*)output + ((vline_pos << 1) ) * 512;
|
||||
ptri = (uint16*)output + ((vline_pos << 1) + 1) * 512;
|
||||
if(!(output->scanline_mode[v] & PPUOutput::INTERLACE)) {
|
||||
ptr = (uint16*)output->buffer + ((vline_pos << 1)) * 512;
|
||||
} else {
|
||||
ptr = (uint16*)output + ((vline_pos << 1) + clock->interlace_field()) * 512;
|
||||
ptr = (uint16*)output->buffer + ((vline_pos << 1) + clock->interlace_field()) * 512;
|
||||
}
|
||||
ltable = (uint16*)light_table + (regs.display_brightness * 65536);
|
||||
|
||||
|
@ -244,16 +245,12 @@ uint16 vline_pos = clock->vcounter();
|
|||
break;
|
||||
}
|
||||
|
||||
if(clock->interlace() == false) {
|
||||
*(ptr + (x1 )) = *(ltable + cx);
|
||||
*(ptri + (x1++)) = *(ltable + cx);
|
||||
if(screen_width != 256)continue;
|
||||
*(ptr + (x1 )) = *(ltable + cx);
|
||||
*(ptri + (x1++)) = *(ltable + cx);
|
||||
if(screen_width == 256) {
|
||||
*(ptr + (x1)) = *(ltable + cx);
|
||||
x1 += 2;
|
||||
} else {
|
||||
*(ptr + (x1++)) = *(ltable + cx);
|
||||
if(screen_width != 256)continue;
|
||||
*(ptr + (x1++)) = *(ltable + cx);
|
||||
*(ptr + (x1)) = *(ltable + cx);
|
||||
x1 += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
#include "../base.h"
|
||||
|
||||
PPUOutput::PPUOutput() {
|
||||
buffer = (uint16*)memalloc(512 * 478 * 2, "PPUOutput::buffer");
|
||||
memset(buffer, 0, 512 * 478 * 2);
|
||||
frame_mode = NORMAL;
|
||||
for(int i=0;i<239;i++) {
|
||||
scanline_mode[i] = NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
PPUOutput::~PPUOutput() {
|
||||
if(buffer)memfree(buffer, "PPUOutput::buffer");
|
||||
}
|
||||
|
||||
PPU::PPU() {
|
||||
mmio = &mmio_unmapped;
|
||||
output = (uint16*)memalloc(512 * 478 * 2, "PPU::output");
|
||||
memset(output, 0, 512 * 478 * 2);
|
||||
output = new PPUOutput();
|
||||
}
|
||||
|
||||
PPU::~PPU() {
|
||||
if(output)memfree(output, "PPU::output");
|
||||
if(output)delete(output);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
class PPUOutput {
|
||||
public:
|
||||
enum {
|
||||
NORMAL = 0,
|
||||
INTERLACE = 1,
|
||||
DOUBLEWIDTH = 2
|
||||
};
|
||||
uint8 frame_mode;
|
||||
uint8 scanline_mode[239];
|
||||
uint16 *buffer;
|
||||
PPUOutput();
|
||||
~PPUOutput();
|
||||
};
|
||||
|
||||
class PPU {
|
||||
public:
|
||||
uint16 *output;
|
||||
MMIO *mmio;
|
||||
PPUOutput *output;
|
||||
MMIO *mmio;
|
||||
virtual uint8 vram_read (uint16 addr) = 0;
|
||||
virtual void vram_write (uint16 addr, uint8 value) = 0;
|
||||
virtual uint8 oam_read (uint16 addr) = 0;
|
||||
|
|
|
@ -12,7 +12,12 @@ int i;
|
|||
|
||||
char *filetype = fn + i;
|
||||
/* make sure we support this file format before loading it */
|
||||
if(strcmp(filetype, ".smc"))return false;
|
||||
if(stricmp(filetype, ".smc") &&
|
||||
stricmp(filetype, ".swc") &&
|
||||
stricmp(filetype, ".fig") &&
|
||||
stricmp(filetype, ".ufo") &&
|
||||
stricmp(filetype, ".gd3") &&
|
||||
stricmp(filetype, ".078"))return false;
|
||||
|
||||
fp = fopen(fn, "rb");
|
||||
if(!fp)return false;
|
||||
|
@ -21,7 +26,12 @@ char *filetype = fn + i;
|
|||
fsize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
if(!strcmp(filetype, ".smc")) {
|
||||
if(!stricmp(filetype, ".smc") ||
|
||||
!stricmp(filetype, ".swc") ||
|
||||
!stricmp(filetype, ".fig") ||
|
||||
!stricmp(filetype, ".ufo") ||
|
||||
!stricmp(filetype, ".gd3") ||
|
||||
!stricmp(filetype, ".078")) {
|
||||
/* remove header if it exists */
|
||||
if((fsize & 0xfff) == 0x200) {
|
||||
fsize -= 0x200;
|
||||
|
|
|
@ -8,7 +8,7 @@ void SNES::power() {
|
|||
clock->power();
|
||||
cpu->power();
|
||||
ppu->power();
|
||||
mem_bus->fastROM = false;
|
||||
mem_bus->power();
|
||||
|
||||
int i;
|
||||
mem_bus->flush_mmio_mappers();
|
||||
|
@ -17,6 +17,8 @@ int i;
|
|||
for(i=0x2180;i<=0x2183;i++)mem_bus->set_mmio_mapper(i, cpu->mmio);
|
||||
mem_bus->set_mmio_mapper(0x21c2, cpu->mmio);
|
||||
mem_bus->set_mmio_mapper(0x21c3, cpu->mmio);
|
||||
mem_bus->set_mmio_mapper(0x4016, cpu->mmio);
|
||||
mem_bus->set_mmio_mapper(0x4017, cpu->mmio);
|
||||
for(i=0x4200;i<=0x421f;i++)mem_bus->set_mmio_mapper(i, cpu->mmio);
|
||||
for(i=0x4300;i<=0x437f;i++)mem_bus->set_mmio_mapper(i, cpu->mmio);
|
||||
}
|
||||
|
@ -25,7 +27,7 @@ void SNES::reset() {
|
|||
clock->reset();
|
||||
cpu->reset();
|
||||
ppu->reset();
|
||||
mem_bus->fastROM = false;
|
||||
mem_bus->reset();
|
||||
}
|
||||
|
||||
/***************************
|
||||
|
|
|
@ -28,6 +28,7 @@ enum {
|
|||
//debugging functions
|
||||
enum {
|
||||
NO_ACTION = 0,
|
||||
RENDER_FRAME,
|
||||
CPU_EXEC_OPCODE,
|
||||
MEM_READ, MEM_WRITE,
|
||||
VRAM_READ, VRAM_WRITE,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CC = cl
|
||||
CFLAGS = /nologo /O2 /Ob2
|
||||
OBJS = winmain.obj \
|
||||
libstring.obj libconfig.obj \
|
||||
clock.obj bclock.obj \
|
||||
memory.obj bmemory.obj \
|
||||
reader.obj \
|
||||
|
@ -21,6 +22,14 @@ clean:
|
|||
winmain.obj: *.cpp *.h
|
||||
$(CC) $(CFLAGS) /c winmain.cpp
|
||||
|
||||
#################
|
||||
### libraries ###
|
||||
#################
|
||||
libstring.obj: ../lib/*.cpp ../lib/*.h
|
||||
$(CC) $(CFLAGS) /c ../lib/libstring.cpp
|
||||
libconfig.obj: ../lib/*.cpp ../lib/*.h
|
||||
$(CC) $(CFLAGS) /c ../lib/libconfig.cpp
|
||||
|
||||
#############
|
||||
### clock ###
|
||||
#############
|
||||
|
|
|
@ -33,10 +33,10 @@ void bSNES::run() {
|
|||
|
||||
switch(run_status) {
|
||||
case RUN:
|
||||
while(clock->update_frame() == false) {
|
||||
while(update_frame == false) {
|
||||
clock->run();
|
||||
}
|
||||
render_frame();
|
||||
update_frame = false;
|
||||
return;
|
||||
case STOP:
|
||||
break;
|
||||
|
@ -53,8 +53,8 @@ void bSNES::run() {
|
|||
break;
|
||||
case RUNTOFRAME:
|
||||
clock->run();
|
||||
if(clock->update_frame() == true) {
|
||||
render_frame();
|
||||
if(update_frame == true) {
|
||||
update_frame = false;
|
||||
set_status(STOP);
|
||||
disassemble_cpu_op();
|
||||
} else if(w_bp->hit() == true) {
|
||||
|
@ -83,14 +83,10 @@ void bSNES::run() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(clock->update_frame() == true) {
|
||||
render_frame();
|
||||
}
|
||||
}
|
||||
|
||||
void bSNES::render_frame() {
|
||||
renderer.update();
|
||||
renderer->update();
|
||||
}
|
||||
|
||||
/***********************
|
||||
|
@ -229,6 +225,15 @@ void bSNES::write(uint8 type, uint32 addr, uint8 value) {
|
|||
}
|
||||
|
||||
void bSNES::notify(uint32 message, uint32 param1, uint32 param2) {
|
||||
/* system messages */
|
||||
switch(message) {
|
||||
case RENDER_FRAME:
|
||||
update_frame = true;
|
||||
render_frame();
|
||||
break;
|
||||
}
|
||||
|
||||
/* debugging messages */
|
||||
if(is_debugger_enabled == false)return;
|
||||
|
||||
switch(message) {
|
||||
|
@ -262,6 +267,9 @@ void bSNES::notify(uint32 message, uint32 param1, uint32 param2) {
|
|||
|
||||
void bSNES::disassemble_cpu_op() {
|
||||
char t[512];
|
||||
/* don't disassemble opcodes when no ROM is loaded */
|
||||
if(is_debugger_activated == false)return;
|
||||
|
||||
/* don't disassemble opcodes that won't be printed to console/traced to log anyway */
|
||||
if(!w_console->can_write(Console::CPU_MESSAGE) && !w_console->tracing_enabled)return;
|
||||
|
||||
|
@ -311,6 +319,10 @@ void bSNES::debugger_update() {
|
|||
disassemble_cpu_op();
|
||||
}
|
||||
|
||||
bool bSNES::debugger_activated() {
|
||||
return is_debugger_activated;
|
||||
}
|
||||
|
||||
void bSNES::debugger_activate() {
|
||||
HWND hwnd;
|
||||
uint32 i, style;
|
||||
|
@ -343,6 +355,8 @@ uint32 i, style;
|
|||
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||
}
|
||||
InvalidateRect(w_memory->hwnd, 0, TRUE);
|
||||
|
||||
is_debugger_activated = true;
|
||||
}
|
||||
|
||||
void bSNES::debugger_deactivate() {
|
||||
|
@ -378,11 +392,14 @@ uint32 i, style;
|
|||
}
|
||||
w_memory->clear();
|
||||
InvalidateRect(w_memory->hwnd, 0, TRUE);
|
||||
|
||||
is_debugger_activated = false;
|
||||
}
|
||||
|
||||
bSNES::bSNES() {
|
||||
run_status = STOP;
|
||||
run_status = STOP;
|
||||
debug_command = false;
|
||||
update_frame = false;
|
||||
|
||||
debugger_disable();
|
||||
}
|
||||
|
|
|
@ -8,12 +8,18 @@ bool l, r, select, start;
|
|||
|
||||
class bSNES : public SNES {
|
||||
private:
|
||||
//If true, indicates a ROM is loaded and debugger output
|
||||
//is possible.
|
||||
bool is_debugger_activated;
|
||||
|
||||
//When true, notify() ignores read/write requests, as they
|
||||
//have been generated by the debugging interface and not by
|
||||
//the emulator.
|
||||
bool debug_command;
|
||||
uint32 run_status;
|
||||
|
||||
bool update_frame;
|
||||
|
||||
bJoypad joypad1, joypad2;
|
||||
|
||||
public:
|
||||
|
@ -56,6 +62,7 @@ struct {
|
|||
|
||||
//whether or not the debugger *can* be used
|
||||
//e.g., debugger cannot be used without ROM loaded
|
||||
bool debugger_activated();
|
||||
void debugger_activate();
|
||||
void debugger_deactivate();
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#define __config_add(name, def, type) add(&name, #name, def, type)
|
||||
|
||||
class Config : public config {
|
||||
public:
|
||||
|
||||
struct {
|
||||
uint32 mode;
|
||||
uint32 use_vram;
|
||||
}video;
|
||||
|
||||
Config() {
|
||||
__config_add(video.mode, 1, DEC);
|
||||
__config_add(video.use_vram, true, TRUEFALSE);
|
||||
}
|
||||
}cfg;
|
|
@ -68,44 +68,6 @@ va_list args;
|
|||
}
|
||||
}
|
||||
|
||||
uint32 strhex(char *str) {
|
||||
uint32 r = 0, m = 0;
|
||||
int i, ssl = strlen(str);
|
||||
uint8 x;
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] >= '0' && str[i] <= '9');
|
||||
else if(str[i] >= 'A' && str[i] <= 'F');
|
||||
else if(str[i] >= 'a' && str[i] <= 'f');
|
||||
else break;
|
||||
}
|
||||
for(--i;i>=0;i--, m+=4) {
|
||||
x = str[i];
|
||||
if(x >= '0' && x <= '9')x -= '0';
|
||||
else if(x >= 'A' && x <= 'F')x -= 'A' - 0x0a;
|
||||
else if(x >= 'a' && x <= 'f')x -= 'a' - 0x0a;
|
||||
else return r;
|
||||
r |= x << m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32 strdec(char *str) {
|
||||
uint32 m = 1;
|
||||
int i, r = 0, ssl = strlen(str);
|
||||
uint8 x;
|
||||
for(i=0;i<ssl;i++) {
|
||||
if(str[i] >= '0' && str[i] <= '9');
|
||||
else break;
|
||||
}
|
||||
for(--i;i>=0;i--, m*=10) {
|
||||
x = str[i];
|
||||
if(x >= '0' && x <= '9')x -= '0';
|
||||
else return r;
|
||||
r += x * m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
uint32 load_file(char *fn, uint8 **buffer) {
|
||||
FILE *fp;
|
||||
uint8 *data;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
class fpstimer {
|
||||
private:
|
||||
SYSTEMTIME st;
|
||||
int second, ticks;
|
||||
public:
|
||||
void start();
|
||||
void tick();
|
||||
int get_ticks();
|
||||
void reset();
|
||||
bool second_passed();
|
||||
|
||||
fpstimer();
|
||||
};
|
||||
|
||||
void fpstimer::start() {
|
||||
GetSystemTime(&st);
|
||||
second = st.wSecond;
|
||||
}
|
||||
|
||||
void fpstimer::tick() {
|
||||
ticks++;
|
||||
}
|
||||
|
||||
int fpstimer::get_ticks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
void fpstimer::reset() {
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
bool fpstimer::second_passed() {
|
||||
GetSystemTime(&st);
|
||||
if(st.wSecond != second) {
|
||||
second = st.wSecond;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fpstimer::fpstimer() {
|
||||
second = ticks = 0;
|
||||
}
|
|
@ -29,6 +29,7 @@ void CreateWindows() {
|
|||
}
|
||||
|
||||
void init_ui0() {
|
||||
renderer = new Render();
|
||||
w_main = new MainWindow();
|
||||
w_console = new Console();
|
||||
w_bp = new BreakpointEditor();
|
||||
|
@ -39,7 +40,7 @@ void init_ui1() {
|
|||
CreateFonts();
|
||||
CreateWindows();
|
||||
SetFocus(w_main->hwnd);
|
||||
renderer.set_window(w_main->hwnd);
|
||||
renderer.to_windowed();
|
||||
renderer->set_window(w_main->hwnd);
|
||||
renderer->to_windowed();
|
||||
bsnes->debugger_deactivate();
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ bool visible, menu_visible;
|
|||
|
||||
class MainWindow : public Window {
|
||||
public:
|
||||
uint8 video_mode, frameskip;
|
||||
uint8 frameskip;
|
||||
void set_frameskip(uint8 fs);
|
||||
void set_video_mode(uint8 mode);
|
||||
void menu_load();
|
||||
|
@ -227,7 +227,7 @@ uint32 edit_mode, edit_addr, edit_mask;
|
|||
MemoryEditor *w_memory;
|
||||
|
||||
#include <ddraw.h>
|
||||
class render {
|
||||
class Render {
|
||||
public:
|
||||
LPDIRECTDRAW lpdd;
|
||||
LPDIRECTDRAWSURFACE lpdds, lpddsb;
|
||||
|
@ -239,13 +239,14 @@ uint8 color_depth;
|
|||
void set_window(HWND hwnd_handle);
|
||||
void to_windowed();
|
||||
void to_fullscreen();
|
||||
void set_source_window(RECT *rs);
|
||||
void redraw();
|
||||
void update16();
|
||||
void update32();
|
||||
void update();
|
||||
void destroy();
|
||||
void update_color_lookup_table();
|
||||
render();
|
||||
Render();
|
||||
};
|
||||
|
||||
render renderer;
|
||||
Render *renderer;
|
||||
|
|
|
@ -12,35 +12,37 @@ void MainWindow::set_frameskip(uint8 fs) {
|
|||
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_FRAMESKIP_OFF + fs, MF_CHECKED);
|
||||
clock->set_frameskip(fs);
|
||||
w_main->frameskip = fs;
|
||||
}
|
||||
|
||||
void MainWindow::set_video_mode(uint8 mode) {
|
||||
hide();
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_256x224w, MF_UNCHECKED);
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_512x448w, MF_UNCHECKED);
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_960x720w, MF_UNCHECKED);
|
||||
switch(mode) {
|
||||
case VIDEOMODE_256x224w:
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_256x224w, MF_CHECKED);
|
||||
w_main->resize(256, 223);
|
||||
resize(256, 223);
|
||||
break;
|
||||
case VIDEOMODE_512x448w:
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_512x448w, MF_CHECKED);
|
||||
w_main->resize(512, 446);
|
||||
resize(512, 446);
|
||||
break;
|
||||
case VIDEOMODE_960x720w:
|
||||
CheckMenuItem(w_main->hmenu, MENU_SETTINGS_VIDEOMODE_960x720w, MF_CHECKED);
|
||||
w_main->resize(960, 720);
|
||||
resize(960, 720);
|
||||
break;
|
||||
}
|
||||
if(bsnes->debugger_enabled() == true) {
|
||||
w_main->to_bottom();
|
||||
w_main->to_right();
|
||||
to_bottom();
|
||||
to_right();
|
||||
} else {
|
||||
w_main->to_middle();
|
||||
w_main->to_center();
|
||||
to_middle();
|
||||
to_center();
|
||||
}
|
||||
video_mode = mode;
|
||||
w_main->show();
|
||||
cfg.video.mode = mode;
|
||||
show();
|
||||
}
|
||||
|
||||
void MainWindow::menu_load() {
|
||||
|
@ -135,7 +137,7 @@ long __stdcall wndproc_main(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_PAINT:
|
||||
renderer.redraw();
|
||||
renderer->redraw();
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
@ -199,11 +201,10 @@ HMENU hsubmenu, hbranchmenu;
|
|||
AppendMenu(hsubmenu, MF_STRING, MENU_SETTINGS_DEBUGGER, "&Debugger");
|
||||
AppendMenu(w_main->hmenu, MF_STRING | MF_POPUP, (unsigned int)hsubmenu, "&Settings");
|
||||
|
||||
w_main->set_video_mode(w_main->video_mode);
|
||||
w_main->set_frameskip(0);
|
||||
w_main->show_menu();
|
||||
w_main->set_video_mode(cfg.video.mode);
|
||||
w_main->set_frameskip(0);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow() {
|
||||
video_mode = VIDEOMODE_512x448w;
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
//mov eax,[array+eax*4] -> lea ebx,[parray] ; mov ebx,[ebx+eax*4]
|
||||
uint32 color_lookup_table[65536];
|
||||
|
||||
render::render() {
|
||||
Render::Render() {
|
||||
lpdd = 0;
|
||||
lpdds = 0;
|
||||
lpddsb = 0;
|
||||
lpddc = 0;
|
||||
}
|
||||
|
||||
void render::update_color_lookup_table() {
|
||||
void Render::update_color_lookup_table() {
|
||||
int i, r, g, b;
|
||||
lpdds->GetSurfaceDesc(&ddsd);
|
||||
color_depth = ddsd.ddpfPixelFormat.dwRGBBitCount;
|
||||
|
@ -45,9 +45,9 @@ int i, r, g, b;
|
|||
}
|
||||
}
|
||||
|
||||
void render::set_window(HWND hwnd_handle) { hwnd = hwnd_handle; }
|
||||
void Render::set_window(HWND hwnd_handle) { hwnd = hwnd_handle; }
|
||||
|
||||
void render::to_windowed() {
|
||||
void Render::to_windowed() {
|
||||
destroy();
|
||||
DirectDrawCreate(0, &lpdd, 0);
|
||||
lpdd->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
|
||||
|
@ -65,7 +65,12 @@ void render::to_windowed() {
|
|||
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
|
||||
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
if(cfg.video.use_vram) {
|
||||
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
|
||||
} else {
|
||||
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
}
|
||||
ddsd.dwWidth = 512;
|
||||
ddsd.dwHeight = 478;
|
||||
lpdd->CreateSurface(&ddsd, &lpddsb, 0);
|
||||
|
@ -74,7 +79,7 @@ void render::to_windowed() {
|
|||
update();
|
||||
}
|
||||
|
||||
void render::to_fullscreen() {
|
||||
void Render::to_fullscreen() {
|
||||
destroy();
|
||||
DirectDrawCreate(0, &lpdd, 0);
|
||||
lpdd->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
|
||||
|
@ -93,7 +98,12 @@ void render::to_fullscreen() {
|
|||
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
|
||||
ddsd.dwSize = sizeof(DDSURFACEDESC);
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
if(cfg.video.use_vram) {
|
||||
ddsd.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
|
||||
} else {
|
||||
ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
}
|
||||
ddsd.dwWidth = 512;
|
||||
ddsd.dwHeight = 478;
|
||||
lpdd->CreateSurface(&ddsd, &lpddsb, 0);
|
||||
|
@ -102,7 +112,16 @@ void render::to_fullscreen() {
|
|||
update();
|
||||
}
|
||||
|
||||
void render::redraw() {
|
||||
void Render::set_source_window(RECT *rs) {
|
||||
switch(ppu->output->frame_mode) {
|
||||
case 0:SetRect(rs, 0, 0, 256, 223);break;
|
||||
case 1:SetRect(rs, 0, 0, 256, 446);break;
|
||||
case 2:SetRect(rs, 0, 0, 512, 223);break;
|
||||
case 3:SetRect(rs, 0, 0, 512, 446);break;
|
||||
}
|
||||
}
|
||||
|
||||
void Render::redraw() {
|
||||
RECT rd, rs;
|
||||
POINT p;
|
||||
HRESULT hr;
|
||||
|
@ -110,87 +129,177 @@ HRESULT hr;
|
|||
ClientToScreen(hwnd, &p);
|
||||
GetClientRect(hwnd, &rd);
|
||||
OffsetRect(&rd, p.x, p.y);
|
||||
if(clock->overscan() == false) {
|
||||
SetRect(&rs, 0, 2, 512, 448);
|
||||
} else {
|
||||
SetRect(&rs, 0, 2 + 15, 512, 448 + 15);
|
||||
}
|
||||
set_source_window(&rs);
|
||||
hr = lpdds->Blt(&rd, lpddsb, &rs, DDBLT_WAIT, 0);
|
||||
if(hr == DDERR_SURFACELOST) {
|
||||
lpdds->Restore();
|
||||
lpddsb->Restore();
|
||||
}
|
||||
|
||||
uint32 fps;
|
||||
char s[256], t[256];
|
||||
fps_timer->tick();
|
||||
if(fps_timer->second_passed() == true) {
|
||||
sprintf(s, "bsnes v" BSNES_VERSION " ~byuu");
|
||||
if(rom_image->loaded() == true) {
|
||||
fps = fps_timer->get_ticks();
|
||||
if(w_main->frameskip == 0) {
|
||||
sprintf(t, " : %d fps", fps);
|
||||
} else {
|
||||
sprintf(t, " : %d fps [fs: %d]", fps * (1 + w_main->frameskip), w_main->frameskip);
|
||||
}
|
||||
strcat(s, t);
|
||||
}
|
||||
SetWindowText(w_main->hwnd, s);
|
||||
fps_timer->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void render::update16() {
|
||||
void Render::update16() {
|
||||
HRESULT hr;
|
||||
hr = lpddsb->Lock(0, &ddsd, DDLOCK_WAIT, 0);
|
||||
if(hr != DD_OK)return;
|
||||
|
||||
uint16 *_src_data = (uint16*)ppu->output;
|
||||
uint16 *_dest_data = (uint16*)ddsd.lpSurface;
|
||||
uint32 _pitch = ddsd.lPitch;
|
||||
__asm {
|
||||
mov edi,_dest_data
|
||||
mov edx,_pitch
|
||||
add edi,edx
|
||||
add edi,edx
|
||||
sub edx,1024
|
||||
mov esi,_src_data
|
||||
add esi,2048
|
||||
mov ebx,478-2
|
||||
xor eax,eax
|
||||
loop_y:
|
||||
mov ecx,512
|
||||
loop_x:
|
||||
lodsw
|
||||
mov eax,dword ptr[color_lookup_table+eax*4]
|
||||
stosw
|
||||
dec ecx
|
||||
jnz loop_x
|
||||
add edi,edx
|
||||
dec ebx
|
||||
jnz loop_y
|
||||
uint16 *src = (uint16*)ppu->output->buffer;
|
||||
uint16 *dest = (uint16*)ddsd.lpSurface;
|
||||
uint32 pitch;
|
||||
int x, y;
|
||||
/* skip first scanline */
|
||||
src += 1024;
|
||||
|
||||
if(clock->overscan() == true) {
|
||||
if(ppu->output->frame_mode & PPUOutput::INTERLACE) {
|
||||
src += 1024 * 16;
|
||||
} else {
|
||||
src += 1024 * 8;
|
||||
}
|
||||
}
|
||||
|
||||
if(ppu->output->frame_mode == PPUOutput::NORMAL) {
|
||||
/* 256x223 */
|
||||
pitch = (ddsd.lPitch >> 1) - 256;
|
||||
y = 223;
|
||||
while(y--) {
|
||||
x = 256;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src];
|
||||
src += 2;
|
||||
}
|
||||
dest += pitch;
|
||||
src += 512;
|
||||
}
|
||||
} else if(ppu->output->frame_mode == PPUOutput::INTERLACE) {
|
||||
/* 256x446 */
|
||||
pitch = (ddsd.lPitch >> 1) - 256;
|
||||
y = 446;
|
||||
while(y--) {
|
||||
x = 256;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src];
|
||||
src += 2;
|
||||
}
|
||||
dest += pitch;
|
||||
}
|
||||
} else if(ppu->output->frame_mode == PPUOutput::DOUBLEWIDTH) {
|
||||
/* 512x223 */
|
||||
pitch = (ddsd.lPitch >> 1) - 512;
|
||||
y = 223;
|
||||
while(y--) {
|
||||
x = 512;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src++];
|
||||
}
|
||||
dest += pitch;
|
||||
src += 512;
|
||||
}
|
||||
} else {
|
||||
/* 512x446 */
|
||||
pitch = (ddsd.lPitch >> 1) - 512;
|
||||
y = 446;
|
||||
while(y--) {
|
||||
x = 512;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src++];
|
||||
}
|
||||
dest += pitch;
|
||||
}
|
||||
}
|
||||
lpddsb->Unlock(0);
|
||||
}
|
||||
|
||||
void render::update32() {
|
||||
void Render::update32() {
|
||||
HRESULT hr;
|
||||
hr = lpddsb->Lock(0, &ddsd, DDLOCK_WAIT, 0);
|
||||
if(hr != DD_OK)return;
|
||||
|
||||
uint16 *_src_data = (uint16*)ppu->output;
|
||||
uint32 *_dest_data = (uint32*)ddsd.lpSurface;
|
||||
uint32 _pitch = ddsd.lPitch;
|
||||
__asm {
|
||||
mov edi,_dest_data
|
||||
mov edx,_pitch
|
||||
add edi,edx
|
||||
add edi,edx
|
||||
sub edx,2048
|
||||
mov esi,_src_data
|
||||
add esi,2048
|
||||
mov ebx,478-2
|
||||
loop_y:
|
||||
mov ecx,512
|
||||
loop_x:
|
||||
lodsw
|
||||
and eax,0xffff
|
||||
mov eax,dword ptr[color_lookup_table+eax*4]
|
||||
stosd
|
||||
dec ecx
|
||||
jnz loop_x
|
||||
add edi,edx
|
||||
dec ebx
|
||||
jnz loop_y
|
||||
uint16 *src = (uint16*)ppu->output->buffer;
|
||||
uint32 *dest = (uint32*)ddsd.lpSurface;
|
||||
uint32 pitch;
|
||||
int x, y;
|
||||
/* skip first scanline */
|
||||
src += 1024;
|
||||
|
||||
if(clock->overscan() == true) {
|
||||
if(ppu->output->frame_mode & PPUOutput::INTERLACE) {
|
||||
src += 1024 * 16;
|
||||
} else {
|
||||
src += 1024 * 8;
|
||||
}
|
||||
}
|
||||
|
||||
if(ppu->output->frame_mode == PPUOutput::NORMAL) {
|
||||
/* 256x223 */
|
||||
pitch = (ddsd.lPitch >> 2) - 256;
|
||||
y = 223;
|
||||
while(y--) {
|
||||
x = 256;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src];
|
||||
src += 2;
|
||||
}
|
||||
dest += pitch;
|
||||
src += 512;
|
||||
}
|
||||
} else if(ppu->output->frame_mode == PPUOutput::INTERLACE) {
|
||||
/* 256x446 */
|
||||
pitch = (ddsd.lPitch >> 2) - 256;
|
||||
y = 446;
|
||||
while(y--) {
|
||||
x = 256;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src];
|
||||
src += 2;
|
||||
}
|
||||
dest += pitch;
|
||||
}
|
||||
} else if(ppu->output->frame_mode == PPUOutput::DOUBLEWIDTH) {
|
||||
/* 512x223 */
|
||||
pitch = (ddsd.lPitch >> 2) - 512;
|
||||
y = 223;
|
||||
while(y--) {
|
||||
x = 512;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src++];
|
||||
}
|
||||
dest += pitch;
|
||||
src += 512;
|
||||
}
|
||||
} else {
|
||||
/* 512x446 */
|
||||
pitch = (ddsd.lPitch >> 2) - 512;
|
||||
y = 446;
|
||||
while(y--) {
|
||||
x = 512;
|
||||
while(x--) {
|
||||
*dest++ = color_lookup_table[*src++];
|
||||
}
|
||||
dest += pitch;
|
||||
}
|
||||
}
|
||||
lpddsb->Unlock(0);
|
||||
}
|
||||
|
||||
void render::update() {
|
||||
void Render::update() {
|
||||
switch(color_depth) {
|
||||
case 15:
|
||||
case 16:
|
||||
|
@ -203,7 +312,7 @@ void render::update() {
|
|||
redraw();
|
||||
}
|
||||
|
||||
void render::destroy() {
|
||||
void Render::destroy() {
|
||||
if(lpddc) {
|
||||
lpddc->Release();
|
||||
lpddc = 0;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#define INTERFACE_MAIN
|
||||
#define BSNES_VERSION "0.006"
|
||||
#define BSNES_VERSION "0.007"
|
||||
#include "winmain.h"
|
||||
#include "../base.h"
|
||||
|
||||
#include "config.cpp"
|
||||
|
||||
#include "bsnes.h"
|
||||
#include "ui.h"
|
||||
|
||||
#include "timer.cpp"
|
||||
fpstimer *fps_timer;
|
||||
|
||||
#include "lib.cpp"
|
||||
#include "rom.cpp"
|
||||
|
||||
|
@ -31,7 +36,13 @@ void term_snes() {
|
|||
|
||||
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
MSG msg;
|
||||
string cfg_fn;
|
||||
_getcwd(cfg_fn, 4096);
|
||||
cfg_fn += "\\bsnes.cfg";
|
||||
cfg.load(cfg_fn);
|
||||
meminit();
|
||||
fps_timer = new fpstimer();
|
||||
fps_timer->start();
|
||||
rom_image = new ROMImage();
|
||||
|
||||
init_ui0();
|
||||
|
@ -56,6 +67,8 @@ MSG msg;
|
|||
bsnes->run();
|
||||
}
|
||||
|
||||
cfg.save(cfg_fn);
|
||||
delete(rom_image);
|
||||
term_snes();
|
||||
memterm();
|
||||
return 0;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
//can't use common dialogs with this defined...
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#include "../lib/libbase.h"
|
||||
#include "../lib/libvector.h"
|
||||
#include "../lib/libstring.h"
|
||||
#include "../lib/libconfig.h"
|
||||
|
|
Loading…
Reference in New Issue