Minor fixes and cleanups

This commit is contained in:
Sean Maas 2022-03-26 19:23:39 -04:00
parent 51bcf8ab8c
commit 50844e8fa8
13 changed files with 94 additions and 113 deletions

View file

@ -44,9 +44,9 @@ bool Cartridge::loadRom(std::string path)
romSize = ftell(romFile); romSize = ftell(romFile);
fseek(romFile, 0, SEEK_SET); fseek(romFile, 0, SEEK_SET);
// Choose the save extension based on the instance number // Choose the save extension based on the instance ID
// This ensures multiple instances don't write over the same file // This ensures multiple instances don't write over the same file
std::string ext = number ? (".sv" + std::to_string(number + 1)) : ".sav"; std::string ext = core->getId() ? (".sv" + std::to_string(core->getId() + 1)) : ".sav";
// Attempt to load the ROM's save into memory // Attempt to load the ROM's save into memory
saveName = path.substr(0, path.rfind(".")) + ext; saveName = path.substr(0, path.rfind(".")) + ext;

View file

@ -38,7 +38,7 @@ enum NdsCmdMode
class Cartridge class Cartridge
{ {
public: public:
Cartridge(Core *core, int number): core(core), number(number) {} Cartridge(Core *core): core(core) {}
~Cartridge(); ~Cartridge();
virtual bool loadRom(std::string path); virtual bool loadRom(std::string path);
@ -52,7 +52,6 @@ class Cartridge
protected: protected:
Core *core; Core *core;
int number;
FILE *romFile = nullptr; FILE *romFile = nullptr;
uint8_t *rom = nullptr, *save = nullptr; uint8_t *rom = nullptr, *save = nullptr;
@ -69,7 +68,7 @@ class Cartridge
class CartridgeNds: public Cartridge class CartridgeNds: public Cartridge
{ {
public: public:
CartridgeNds(Core *core, int number): Cartridge(core, number) {} CartridgeNds(Core *core): Cartridge(core) {}
bool loadRom(std::string path); bool loadRom(std::string path);
void directBoot(); void directBoot();
@ -115,7 +114,7 @@ class CartridgeNds: public Cartridge
class CartridgeGba: public Cartridge class CartridgeGba: public Cartridge
{ {
public: public:
CartridgeGba(Core *core, int number): Cartridge(core, number) {} CartridgeGba(Core *core): Cartridge(core) {}
bool loadRom(std::string path); bool loadRom(std::string path);

View file

@ -24,9 +24,10 @@
#include "core.h" #include "core.h"
#include "settings.h" #include "settings.h"
Core::Core(std::string ndsPath, std::string gbaPath, int number): Core::Core(std::string ndsPath, std::string gbaPath, int id):
cartridgeNds(this, number), id(id),
cartridgeGba(this, number), cartridgeNds(this),
cartridgeGba(this),
cp15(this), cp15(this),
divSqrt(this), divSqrt(this),
dldi(this), dldi(this),
@ -40,7 +41,7 @@ Core::Core(std::string ndsPath, std::string gbaPath, int number):
ipc(this), ipc(this),
memory(this), memory(this),
rtc(this), rtc(this),
spi(this, number), spi(this),
spu(this), spu(this),
timers { Timers(this, 0), Timers(this, 1) }, timers { Timers(this, 0), Timers(this, 1) },
wifi(this) wifi(this)

View file

@ -66,11 +66,12 @@ struct Task
class Core class Core
{ {
public: public:
Core(std::string ndsPath = "", std::string gbaPath = "", int number = 0); Core(std::string ndsPath = "", std::string gbaPath = "", int id = 0);
void runFrame() { (this->*runFunc)(); } void runFrame() { (this->*runFunc)(); }
bool isGbaMode() { return gbaMode; } bool isGbaMode() { return gbaMode; }
int getId() { return id; }
int getFps() { return fps; } int getFps() { return fps; }
uint32_t getGlobalCycles() { return globalCycles; } uint32_t getGlobalCycles() { return globalCycles; }
@ -100,8 +101,9 @@ class Core
Wifi wifi; Wifi wifi;
private: private:
bool gbaMode = false;
void (Core::*runFunc)() = &Core::runNdsFrame; void (Core::*runFunc)() = &Core::runNdsFrame;
bool gbaMode = false;
int id = 0;
std::vector<Task> tasks; std::vector<Task> tasks;
uint32_t globalCycles = 0; uint32_t globalCycles = 0;

View file

@ -63,7 +63,7 @@ EVT_BUTTON(wxID_CANCEL, LayoutDialog::cancel)
EVT_BUTTON(wxID_OK, LayoutDialog::confirm) EVT_BUTTON(wxID_OK, LayoutDialog::confirm)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
LayoutDialog::LayoutDialog(NooFrame *frame): wxDialog(nullptr, wxID_ANY, "Screen Layout"), frame(frame) LayoutDialog::LayoutDialog(NooApp *app): wxDialog(nullptr, wxID_ANY, "Screen Layout"), app(app)
{ {
// Remember the previous settings in case the changes are discarded // Remember the previous settings in case the changes are discarded
prevSettings[0] = ScreenLayout::getScreenRotation(); prevSettings[0] = ScreenLayout::getScreenRotation();
@ -173,144 +173,112 @@ void LayoutDialog::rotateNone(wxCommandEvent &event)
{ {
// Set the screen rotation setting to none // Set the screen rotation setting to none
ScreenLayout::setScreenRotation(0); ScreenLayout::setScreenRotation(0);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::rotateCw(wxCommandEvent &event) void LayoutDialog::rotateCw(wxCommandEvent &event)
{ {
// Set the screen rotation setting to clockwise // Set the screen rotation setting to clockwise
ScreenLayout::setScreenRotation(1); ScreenLayout::setScreenRotation(1);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::rotateCcw(wxCommandEvent &event) void LayoutDialog::rotateCcw(wxCommandEvent &event)
{ {
// Set the screen rotation setting to counter-clockwise // Set the screen rotation setting to counter-clockwise
ScreenLayout::setScreenRotation(2); ScreenLayout::setScreenRotation(2);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::arrangeAuto(wxCommandEvent &event) void LayoutDialog::arrangeAuto(wxCommandEvent &event)
{ {
// Set the screen arrangement setting to automatic // Set the screen arrangement setting to automatic
ScreenLayout::setScreenArrangement(0); ScreenLayout::setScreenArrangement(0);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::arrangeVert(wxCommandEvent &event) void LayoutDialog::arrangeVert(wxCommandEvent &event)
{ {
// Set the screen arrangement setting to vertical // Set the screen arrangement setting to vertical
ScreenLayout::setScreenArrangement(1); ScreenLayout::setScreenArrangement(1);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::arrangeHori(wxCommandEvent &event) void LayoutDialog::arrangeHori(wxCommandEvent &event)
{ {
// Set the screen arrangement setting to horizontal // Set the screen arrangement setting to horizontal
ScreenLayout::setScreenArrangement(2); ScreenLayout::setScreenArrangement(2);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::sizeEven(wxCommandEvent &event) void LayoutDialog::sizeEven(wxCommandEvent &event)
{ {
// Set the screen sizing setting to even // Set the screen sizing setting to even
ScreenLayout::setScreenSizing(0); ScreenLayout::setScreenSizing(0);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::sizeTop(wxCommandEvent &event) void LayoutDialog::sizeTop(wxCommandEvent &event)
{ {
// Set the screen sizing setting to enlarge top // Set the screen sizing setting to enlarge top
ScreenLayout::setScreenSizing(1); ScreenLayout::setScreenSizing(1);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::sizeBot(wxCommandEvent &event) void LayoutDialog::sizeBot(wxCommandEvent &event)
{ {
// Set the screen sizing setting to enlarge bottom // Set the screen sizing setting to enlarge bottom
ScreenLayout::setScreenSizing(2); ScreenLayout::setScreenSizing(2);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::gapNone(wxCommandEvent &event) void LayoutDialog::gapNone(wxCommandEvent &event)
{ {
// Set the screen gap setting to none // Set the screen gap setting to none
ScreenLayout::setScreenGap(0); ScreenLayout::setScreenGap(0);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::gapQuart(wxCommandEvent &event) void LayoutDialog::gapQuart(wxCommandEvent &event)
{ {
// Set the screen gap setting to quarter // Set the screen gap setting to quarter
ScreenLayout::setScreenGap(1); ScreenLayout::setScreenGap(1);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::gapHalf(wxCommandEvent &event) void LayoutDialog::gapHalf(wxCommandEvent &event)
{ {
// Set the screen gap setting to half // Set the screen gap setting to half
ScreenLayout::setScreenGap(2); ScreenLayout::setScreenGap(2);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::gapFull(wxCommandEvent &event) void LayoutDialog::gapFull(wxCommandEvent &event)
{ {
// Set the screen gap setting to full // Set the screen gap setting to full
ScreenLayout::setScreenGap(3); ScreenLayout::setScreenGap(3);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::intScale(wxCommandEvent &event) void LayoutDialog::intScale(wxCommandEvent &event)
{ {
// Toggle the integer scale setting // Toggle the integer scale setting
ScreenLayout::setIntegerScale(!ScreenLayout::getIntegerScale()); ScreenLayout::setIntegerScale(!ScreenLayout::getIntegerScale());
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::gbaCrop(wxCommandEvent &event) void LayoutDialog::gbaCrop(wxCommandEvent &event)
{ {
// Toggle the GBA crop setting // Toggle the GBA crop setting
ScreenLayout::setGbaCrop(!ScreenLayout::getGbaCrop()); ScreenLayout::setGbaCrop(!ScreenLayout::getGbaCrop());
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::filter(wxCommandEvent &event) void LayoutDialog::filter(wxCommandEvent &event)
{ {
// Toggle the screen filter setting // Toggle the screen filter setting
NooApp::setScreenFilter(!NooApp::getScreenFilter()); NooApp::setScreenFilter(!NooApp::getScreenFilter());
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
} }
void LayoutDialog::cancel(wxCommandEvent &event) void LayoutDialog::cancel(wxCommandEvent &event)
@ -323,9 +291,7 @@ void LayoutDialog::cancel(wxCommandEvent &event)
ScreenLayout::setIntegerScale(prevSettings[4]); ScreenLayout::setIntegerScale(prevSettings[4]);
ScreenLayout::setGbaCrop(prevSettings[5]); ScreenLayout::setGbaCrop(prevSettings[5]);
NooApp::setScreenFilter(prevSettings[6]); NooApp::setScreenFilter(prevSettings[6]);
app->updateLayouts();
// Trigger a resize to update the screen layout
frame->SendSizeEvent();
event.Skip(true); event.Skip(true);
} }

View file

@ -22,15 +22,15 @@
#include <wx/wx.h> #include <wx/wx.h>
#include "noo_frame.h" class NooApp;
class LayoutDialog: public wxDialog class LayoutDialog: public wxDialog
{ {
public: public:
LayoutDialog(NooFrame *frame); LayoutDialog(NooApp *app);
private: private:
NooFrame *frame; NooApp *app;
int prevSettings[7]; int prevSettings[7];

View file

@ -106,7 +106,7 @@ bool NooApp::OnInit()
void NooApp::createFrame() void NooApp::createFrame()
{ {
// Create a new frame using the lowest free instance number // Create a new frame using the lowest free instance ID
for (int i = 0; i < MAX_FRAMES; i++) for (int i = 0; i < MAX_FRAMES; i++)
{ {
if (!frames[i]) if (!frames[i])
@ -117,31 +117,41 @@ void NooApp::createFrame()
} }
} }
void NooApp::removeFrame(int number) void NooApp::removeFrame(int id)
{ {
// Free an instance number; this should be done on frame destruction // Free an instance ID; this should be done on frame destruction
frames[number] = nullptr; frames[id] = nullptr;
} }
void NooApp::connectCore(int number) void NooApp::connectCore(int id)
{ {
// Connect a frame's core to all other active cores // Connect a frame's core to all other active cores
for (int i = 0; i < MAX_FRAMES; i++) for (int i = 0; i < MAX_FRAMES; i++)
{ {
if (!frames[i] || i == number) continue; if (!frames[i] || i == id) continue;
if (Core *core = frames[i]->getCore()) if (Core *core = frames[i]->getCore())
core->wifi.addConnection(frames[number]->getCore()); core->wifi.addConnection(frames[id]->getCore());
} }
} }
void NooApp::disconnCore(int number) void NooApp::disconnCore(int id)
{ {
// Disconnect a frame's core from all other active cores // Disconnect a frame's core from all other active cores
for (int i = 0; i < MAX_FRAMES; i++) for (int i = 0; i < MAX_FRAMES; i++)
{ {
if (!frames[i] || i == number) continue; if (!frames[i] || i == id) continue;
if (Core *core = frames[i]->getCore()) if (Core *core = frames[i]->getCore())
core->wifi.remConnection(frames[number]->getCore()); core->wifi.remConnection(frames[id]->getCore());
}
}
void NooApp::updateLayouts()
{
// Trigger resize events for frames to update screen layouts
for (size_t i = 0; i < MAX_FRAMES; i++)
{
if (frames[i])
frames[i]->SendSizeEvent();
} }
} }
@ -163,7 +173,7 @@ int NooApp::audioCallback(const void *in, void *out, unsigned long count,
uint32_t *original = nullptr; uint32_t *original = nullptr;
// Get samples from each instance so frame limiting is enforced // Get samples from each instance so frame limiting is enforced
// Only the lowest instance number's samples are played; the rest are discarded // Only the lowest instance ID's samples are played; the rest are discarded
for (size_t i = 0; i < MAX_FRAMES; i++) for (size_t i = 0; i < MAX_FRAMES; i++)
{ {
if (!frames[i]) continue; if (!frames[i]) continue;

View file

@ -31,10 +31,12 @@ class NooApp: public wxApp
{ {
public: public:
void createFrame(); void createFrame();
void removeFrame(int number); void removeFrame(int id);
void connectCore(int number); void connectCore(int id);
void disconnCore(int number); void disconnCore(int id);
void updateLayouts();
static int getScreenFilter() { return screenFilter; } static int getScreenFilter() { return screenFilter; }
static int getKeyBind(int index) { return keyBinds[index]; } static int getKeyBind(int index) { return keyBinds[index]; }

View file

@ -81,8 +81,8 @@ EVT_DROP_FILES(NooFrame::dropFiles)
EVT_CLOSE(NooFrame::close) EVT_CLOSE(NooFrame::close)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
NooFrame::NooFrame(NooApp *app, int number, std::string path): NooFrame::NooFrame(NooApp *app, int id, std::string path):
wxFrame(nullptr, wxID_ANY, "NooDS"), app(app), number(number) wxFrame(nullptr, wxID_ANY, "NooDS"), app(app), id(id)
{ {
// Set the icon // Set the icon
wxIcon icon(icon_xpm); wxIcon icon(icon_xpm);
@ -163,7 +163,7 @@ NooFrame::NooFrame(NooApp *app, int number, std::string path):
wxMenuBar *menuBar = new wxMenuBar(); wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, "&File"); menuBar->Append(fileMenu, "&File");
menuBar->Append(systemMenu, "&System"); menuBar->Append(systemMenu, "&System");
if (number == 0) // Only show settings in the main instance if (id == 0) // Only show settings in the main instance
menuBar->Append(settingsMenu, "&Settings"); menuBar->Append(settingsMenu, "&Settings");
SetMenuBar(menuBar); SetMenuBar(menuBar);
@ -216,7 +216,7 @@ void NooFrame::Refresh()
// Override the refresh function to also update the FPS counter // Override the refresh function to also update the FPS counter
wxString label = "NooDS"; wxString label = "NooDS";
if (number) label += wxString::Format(" (%d)", number + 1); if (id > 0) label += wxString::Format(" (%d)", id + 1);
if (running) label += wxString::Format(" - %d FPS", core->getFps()); if (running) label += wxString::Format(" - %d FPS", core->getFps());
SetLabel(label); SetLabel(label);
} }
@ -250,8 +250,8 @@ void NooFrame::startCore(bool full)
try try
{ {
// Attempt to boot the core // Attempt to boot the core
core = new Core(ndsPath, gbaPath, number); core = new Core(ndsPath, gbaPath, id);
app->connectCore(number); app->connectCore(id);
} }
catch (CoreError e) catch (CoreError e)
{ {
@ -336,7 +336,7 @@ void NooFrame::stopCore(bool full)
// Shut down the core // Shut down the core
if (core) if (core)
{ {
app->disconnCore(number); app->disconnCore(id);
delete core; delete core;
core = nullptr; core = nullptr;
} }
@ -537,7 +537,7 @@ void NooFrame::inputSettings(wxCommandEvent &event)
void NooFrame::layoutSettings(wxCommandEvent &event) void NooFrame::layoutSettings(wxCommandEvent &event)
{ {
// Show the layout settings dialog // Show the layout settings dialog
LayoutDialog layoutDialog(this); LayoutDialog layoutDialog(app);
layoutDialog.ShowModal(); layoutDialog.ShowModal();
} }
@ -646,6 +646,6 @@ void NooFrame::close(wxCloseEvent &event)
{ {
// Properly shut down the emulator // Properly shut down the emulator
stopCore(true); stopCore(true);
app->removeFrame(number); app->removeFrame(id);
event.Skip(true); event.Skip(true);
} }

View file

@ -31,7 +31,7 @@ class NooCanvas;
class NooFrame: public wxFrame class NooFrame: public wxFrame
{ {
public: public:
NooFrame(NooApp *app, int number = 0, std::string path = ""); NooFrame(NooApp *app, int id = 0, std::string path = "");
void Refresh(); void Refresh();
@ -51,7 +51,7 @@ class NooFrame: public wxFrame
wxJoystick *joystick; wxJoystick *joystick;
wxTimer *timer; wxTimer *timer;
int number = 0; int id = 0;
Core *core = nullptr; Core *core = nullptr;
bool running = false; bool running = false;

View file

@ -61,11 +61,11 @@ bool Spi::loadFirmware()
fread(firmware, sizeof(uint8_t), firmSize, file); fread(firmware, sizeof(uint8_t), firmSize, file);
fclose(file); fclose(file);
if (number > 0) if (core->getId() > 0)
{ {
// Increment the MAC address based on the instance number // Increment the MAC address based on the instance ID
// This allows instances to be detected as separate systems // This allows instances to be detected as separate systems
firmware[0x36] += number; firmware[0x36] += core->getId();
// Recalculate the WiFi config CRC // Recalculate the WiFi config CRC
uint16_t crc = crc16(0, &firmware[0x2C], 0x138); uint16_t crc = crc16(0, &firmware[0x2C], 0x138);
@ -86,16 +86,16 @@ bool Spi::loadFirmware()
firmware[0x21] = 0x3F; // User settings offset / 8, byte 2 firmware[0x21] = 0x3F; // User settings offset / 8, byte 2
// Set some WiFi config data // Set some WiFi config data
firmware[0x2C] = 0x38; // Config length, byte 1 firmware[0x2C] = 0x38; // Config length, byte 1
firmware[0x2D] = 0x01; // Config length, byte 2 firmware[0x2D] = 0x01; // Config length, byte 2
firmware[0x36] = number; // MAC address, byte 1 firmware[0x36] = core->getId(); // MAC address, byte 1
firmware[0x37] = 0x09; // MAC address, byte 2 firmware[0x37] = 0x09; // MAC address, byte 2
firmware[0x38] = 0xBF; // MAC address, byte 3 firmware[0x38] = 0xBF; // MAC address, byte 3
firmware[0x39] = 0x12; // MAC address, byte 4 firmware[0x39] = 0x12; // MAC address, byte 4
firmware[0x3A] = 0x34; // MAC address, byte 5 firmware[0x3A] = 0x34; // MAC address, byte 5
firmware[0x3B] = 0x56; // MAC address, byte 6 firmware[0x3B] = 0x56; // MAC address, byte 6
firmware[0x3C] = 0xFE; // Enabled channels, byte 1 firmware[0x3C] = 0xFE; // Enabled channels, byte 1
firmware[0x3D] = 0x3F; // Enabled channels, byte 2 firmware[0x3D] = 0x3F; // Enabled channels, byte 2
// Calculate the WiFi config CRC // Calculate the WiFi config CRC
uint16_t crc = crc16(0, &firmware[0x2C], 0x138); uint16_t crc = crc16(0, &firmware[0x2C], 0x138);

View file

@ -27,7 +27,7 @@ class Core;
class Spi class Spi
{ {
public: public:
Spi(Core *core, int number): core(core), number(number) {} Spi(Core *core): core(core) {}
~Spi(); ~Spi();
bool loadFirmware(); bool loadFirmware();
@ -44,7 +44,6 @@ class Spi
private: private:
Core *core; Core *core;
int number;
uint8_t *firmware = nullptr; uint8_t *firmware = nullptr;
size_t firmSize = 0; size_t firmSize = 0;

View file

@ -143,7 +143,7 @@ void Wifi::processPackets()
{ {
wRxbufWrcsr++; wRxbufWrcsr++;
wRxbufWrcsr = (wRxbufBegin & 0x1FFE) + (wRxbufWrcsr - (wRxbufBegin & 0x1FFE)) % ((wRxbufEnd & 0x1FFE) - (wRxbufBegin & 0x1FFE)); wRxbufWrcsr = (wRxbufBegin & 0x1FFE) + (wRxbufWrcsr - (wRxbufBegin & 0x1FFE)) % ((wRxbufEnd & 0x1FFE) - (wRxbufBegin & 0x1FFE));
wRxbufWrcsr &= 0x1FFF; wRxbufWrcsr &= 0xFFF;
} }
} }
@ -344,7 +344,7 @@ void Wifi::writeWTxbufWrData(uint16_t mask, uint16_t value)
wTxbufWrAddr += 2; wTxbufWrAddr += 2;
if (wTxbufWrAddr == wTxbufGap) if (wTxbufWrAddr == wTxbufGap)
wTxbufWrAddr += wTxbufGapdisp << 1; wTxbufWrAddr += wTxbufGapdisp << 1;
wTxbufWrAddr %= 0x2000; wTxbufWrAddr &= 0x1FFF;
// Decrement the write counter and trigger an interrupt at the end // Decrement the write counter and trigger an interrupt at the end
if (wTxbufCount > 0 && --wTxbufCount == 0) if (wTxbufCount > 0 && --wTxbufCount == 0)
@ -503,12 +503,14 @@ uint16_t Wifi::readWRxbufRdData()
uint16_t value = core->memory.read<uint16_t>(1, 0x4804000 + wRxbufRdAddr); uint16_t value = core->memory.read<uint16_t>(1, 0x4804000 + wRxbufRdAddr);
// Increment the read address // Increment the read address
wRxbufRdAddr += 2;
if (wRxbufRdAddr == wRxbufGap)
wRxbufRdAddr += wRxbufGapdisp << 1;
if ((wRxbufBegin & 0x1FFE) != (wRxbufEnd & 0x1FFE)) if ((wRxbufBegin & 0x1FFE) != (wRxbufEnd & 0x1FFE))
{
wRxbufRdAddr += 2;
if (wRxbufRdAddr == wRxbufGap)
wRxbufRdAddr += wRxbufGapdisp << 1;
wRxbufRdAddr = (wRxbufBegin & 0x1FFE) + (wRxbufRdAddr - (wRxbufBegin & 0x1FFE)) % ((wRxbufEnd & 0x1FFE) - (wRxbufBegin & 0x1FFE)); wRxbufRdAddr = (wRxbufBegin & 0x1FFE) + (wRxbufRdAddr - (wRxbufBegin & 0x1FFE)) % ((wRxbufEnd & 0x1FFE) - (wRxbufBegin & 0x1FFE));
wRxbufRdAddr %= 0x2000; wRxbufRdAddr &= 0x1FFF;
}
// Decrement the read counter and trigger an interrupt at the end // Decrement the read counter and trigger an interrupt at the end
if (wRxbufCount > 0 && --wRxbufCount == 0) if (wRxbufCount > 0 && --wRxbufCount == 0)