Skip to content

Commit

Permalink
NES Emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
zardam committed Jan 21, 2019
0 parents commit 4c145f0
Show file tree
Hide file tree
Showing 116 changed files with 25,126 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.d
*.o
nes_icon.cpp
nes_icon.h
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include apps/nes/nofrendo/Makefile

apps += NES::App
app_headers += apps/nes/app.h

app_objs += $(addprefix apps/nes/,\
app.o\
nes_controller.o\
nes_view.o\
)

app_images += apps/nes/nes_icon.png

i18n_files += $(addprefix apps/nes/,\
base.de.i18n\
base.en.i18n\
base.es.i18n\
base.fr.i18n\
base.pt.i18n\
)
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# numworks-nofrendo

A NES emulator for the NumWorks calculator

## Easy Installation

See here : https://zardam.github.io/webnofrendo/

## How to build

```bash
git clone https://github.com/numworks/epsilon.git
cd epsilon
git clone https://github.com/zardam/numworks-nofrendo.git apps/nes
make EPSILON_APPS='calculation graph code statistics probability solver sequence regression settings nes' epsilon.bin
cat your_nes_rom.nes >> epsilon.bin
make EPSILON_APPS='calculation graph code statistics probability solver sequence regression settings nes' epsilon_flash
```

## Controls

| Calculator | NES |
|------------|--------|
| Up | Up |
| Down | Down |
| Left | Left |
| Right | Right |
| Back | A |
| OK | B |
| Up | Start |
| OnOff | Select |
| BackSpace | Reset |
| Any other | Exit |
56 changes: 56 additions & 0 deletions app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "app.h"
#include "../i18n.h"
#include "../apps_container.h"
#include "nes_icon.h"

extern "C" {
#include <assert.h>
#include <epsilon/nofrendo_wrapper.h>
}

namespace NES {

I18n::Message App::Descriptor::name() {
return I18n::Message::NES;
}

I18n::Message App::Descriptor::upperName() {
return I18n::Message::NESCapital;
}

const Image * App::Descriptor::icon() {
return ImageStore::NesIcon;
}

App::Descriptor * App::Snapshot::descriptor() {
static Descriptor descriptor;
return &descriptor;
}

App * App::Snapshot::unpack(Container * container) {
return new (container->currentAppBuffer()) App(container, this);
}

App::Snapshot::Snapshot(){
}

void App::didBecomeActive(Window * window) {
::App::didBecomeActive(window);

NofrendoWrapper nofrendoWrapper;
nofrendoWrapper.run();

m_appsContainer->switchTo(m_appsContainer->appSnapshotAtIndex(0));
}

void App::willBecomeInactive() {
::App::willBecomeInactive();
}

App::App(Container * container, Snapshot * snapshot) :
::App(container, snapshot, &m_nesController),
m_appsContainer((AppsContainer*) container)
{
}

}
35 changes: 35 additions & 0 deletions app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef NES_APP_H
#define NES_APP_H

#include <escher.h>
#include "nes_controller.h"

class AppsContainer;

namespace NES {

class App : public ::App {
public:
class Descriptor : public ::App::Descriptor {
public:
I18n::Message name() override;
I18n::Message upperName() override;
const Image * icon() override;
};
class Snapshot : public ::App::Snapshot {
public:
Snapshot();
App * unpack(Container * container) override;
Descriptor * descriptor() override;
};
virtual void didBecomeActive(Window * window);
virtual void willBecomeInactive();
private:
App(Container * container, Snapshot * snapshot);
NesController m_nesController;
AppsContainer * m_appsContainer;
};

}

#endif
2 changes: 2 additions & 0 deletions base.de.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NES = "NES"
NESCapital = "NES"
2 changes: 2 additions & 0 deletions base.en.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NES = "NES"
NESCapital = "NES"
2 changes: 2 additions & 0 deletions base.es.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NES = "NES"
NESCapital = "NES"
2 changes: 2 additions & 0 deletions base.fr.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NES = "NES"
NESCapital = "NES"
2 changes: 2 additions & 0 deletions base.pt.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NES = "NES"
NESCapital = "NES"
15 changes: 15 additions & 0 deletions nes_controller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "nes_controller.h"

namespace NES {

NesController::NesController() :
ViewController(nullptr),
m_view()
{
}

View * NesController::view() {
return &m_view;
}

}
21 changes: 21 additions & 0 deletions nes_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef NES_CONTROLLER_H
#define NES_CONTROLLER_H

#include <escher.h>
#include "nes_view.h"

class AppsContainer;

namespace NES {

class NesController : public ViewController {
public:
NesController();
View * view() override;
private:
NesView m_view;
};

}

#endif
Binary file added nes_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions nes_view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "nes_view.h"
#include <assert.h>

namespace NES {

NesView::NesView() :
View()
{
}

}
15 changes: 15 additions & 0 deletions nes_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef APPS_NES_VIEW_H
#define APPS_NES_VIEW_H

#include <escher.h>

namespace NES {

class NesView : public View {
public:
NesView();
};

}

#endif
87 changes: 87 additions & 0 deletions nofrendo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
NES_ROM ?= apps/nes/nofrendo/epsilon/2048.nes
SFLAGS += -Iapps/nes/nofrendo -Iapps/nes/nofrendo/nes -Iapps/nes/nofrendo/sndhrdw -Iapps/nes/nofrendo/libsnss -Iapps/nes/nofrendo/cpu
nof_objs = $(addprefix apps/nes/nofrendo/,\
bitmap.o\
config.o\
cpu/dis6502.o\
cpu/nes6502.o\
event.o\
libsnss/libsnss.o\
log.o\
mappers/map000.o\
mappers/map001.o\
mappers/map002.o\
mappers/map003.o\
mappers/map004.o\
mappers/map005.o\
mappers/map007.o\
mappers/map008.o\
mappers/map009.o\
mappers/map011.o\
mappers/map015.o\
mappers/map016.o\
mappers/map018.o\
mappers/map019.o\
mappers/map024.o\
mappers/map032.o\
mappers/map033.o\
mappers/map034.o\
mappers/map040.o\
mappers/map041.o\
mappers/map042.o\
mappers/map046.o\
mappers/map050.o\
mappers/map064.o\
mappers/map065.o\
mappers/map066.o\
mappers/map070.o\
mappers/map073.o\
mappers/map075.o\
mappers/map078.o\
mappers/map079.o\
mappers/map085.o\
mappers/map087.o\
mappers/map093.o\
mappers/map094.o\
mappers/map099.o\
mappers/map160.o\
mappers/map229.o\
mappers/map231.o\
mappers/mapvrc.o\
memguard.o\
nes/mmclist.o\
nes/nes.o\
nes/nesinput.o\
nes/nes_mmc.o\
nes/nes_pal.o\
nes/nes_ppu.o\
nes/nes_rom.o\
nes/nesstate.o\
sndhrdw/fds_snd.o\
sndhrdw/mmc5_snd.o\
sndhrdw/nes_apu.o\
sndhrdw/vrcvisnd.o\
nofrendo.o\
epsilon/nofrendo_wrapper.o\
epsilon/osd_epsilon.o\
epsilon/stubs.o\
)

ifneq ($(PLATFORM),device)
nof_objs += $(addprefix apps/nes/nofrendo/,\
epsilon/rom.o\
)
apps/nes/nofrendo/epsilon/rom.c: FORCE
@echo "BIN $@"
$(Q) echo "const unsigned char _rom_data[] = {" > $@
$(Q) cat "$(NES_ROM)" | xxd -i >> $@
$(Q) echo "};" >> $@

FORCE:

products += apps/nes/nofrendo/epsilon/rom.c
endif

$(nof_objs): SFLAGS := $(subst -Os,-O2,$(SFLAGS))

objs += $(nof_objs)
Loading

0 comments on commit 4c145f0

Please sign in to comment.