Category Archives: Uncategorized

Model, View, Controller (MVC)

I’ve spent a few days from the past couple weeks refactoring SNES Tracker Debugger (STD), and I quickly learned that my GUI code was bit tied in with the application logic. I came across a real winner, as far as an architecture – MVC. My implementation of MVC is custom in that it may vary from “official” descriptions. There may even be a different name for paradigm I have created from MVC. Offhand, here are some distinctions of my impl of MVC from the “traditional” description

  • No intent to connect models to views (but I may contradict if sensical to do so)
  • Views have their own GUI Logic (since this is not a webpage but a desktop app)

so let’s focus on what I imagine.

Model

This simply refers to the “data.” This is the least well-defined of the three entities. It is also intended (in my implementation) to be out of direct-contact with the View. However, I have given myself permission to make exception(s) if necessary, based on the on-going experience of creating this architecture in practice. (1)

View

The GUI components are now designed completely independent of the internal logic/data. They access the “internal” data and logic through controllers which expose APIs.

Controller

This is where the API functions and control logic reside. The core idea is that a controller will present an API to the View, typically representing one or many CRUD-like operations.


OK, that was a very vague description though (perhaps we could call it language-agnostic). So let’s start imagining the components in the language of CPP

CPP MVC Paradigm

There are some potential helper “things” I can use to spur development of this kind. These ideas were extrapolated from http://stackoverflow.com/questions/6929957/mvc-approach-with-c

  • boost state machines for the logic and boost signals to connect things together.
  • CPPInject

I am rather unclear on what I might use. So, let’s just talk conceptually.

Views

I plan on all GUI code to be a part of this “VIEW” sub-component .. There are different types of Views (not exhaustive)

  • One that will need data from a controller
  • One that will need data from a controller, and will update new data to the controller
  • One that needs no connection to a controller (unlikely?)

Of course, views can have their own internal logic to manage themselves. I anticipate a view that updates another part of itself based on certain internal state. This is normal, any GUI logic is simply part of the View.

It is here that a part of me wonders whether that kind of logic should be outside of View … But for my purposes I think it’s a good architecture to have all GUI logic separate, in what I will call the “View” or GUI code, and I think it’s OK for them to maintain their own state.

Controllers

I don’t understand yet how I will be connecting views to controllers in a CPP manner, but a View class might be able to “target” or “include” any number of specific controllers from its class definition. This might be from reference(s) passed to the View’s constructor, or via composition.

Models

This might best be considered as a mixture of data structures and “internal API.” Generally speaking, I intend on seeing only the controllers acting on this data.


Now I want to encapsulate this entire MVC paradigm within an Abstraction Layer for Video / Audio / Input (Keyboard, MIDI, ?)

Footnotes

(1) I initially thought “Direct” memory access could be beneficial for APU RAM access, for instance — but even so, I imagine an API will be better simply because different APU functions are necessary to modify different portions of the RAM … We’ll see…

 

 

 

Advertisements

What is NALL [bsnes] ✔ [byuu.org] – ?

|
-> What is the least instrusive solution?

  • Use Nall w/ “Ruby”
  • “Do what you’re doing now”

Remember, the “Audio” class in STD is/should be for/assoc. with Audio Drivers, I think. I have Music_Player class in my head also, and how it relates to “Audio.” That is confusing me. I just want “Audio” to wrap Driver Selection, and involve the following routines:

  1. “Output Device” query – incl. supported samples rates and other assoc. subroutines
  2. Select Output Device
  3. Select Audio Format

2/3 could be one function as well, with persistent settings.

But I really did want to talk about Nall. And ruby. These are “things” made by byuu and co. that I love. Ruby really inspired to write wrappers for my code. It all started when I was about to modify STD to incorporate the newest feature Time_Scrub and it’s been awhile since I’ve been in the project. I realized how convoluted everything was and really deeply involved with the methods the library at hand called for (SDL). And I was writing all the GUI widgets from scratch.. After analyzing Ruby [in fact, I will publish the analysis in my next blog post], I discovered the beauty of the hardware abstraction layer. And now, I aim to find a way to describe STD in a library agnostic manner, accompanied by drivers for some libraries (partially SDL and wholly QT is my aim).

There’s something about Nall – what is it -since byuu is working on his new website, the page for nall is down. We must peruse the web archive of it, thankfully which includes a download. https://web.archive.org/web/20140710210208/http://byuu.org/files/nall_20140107.tar.xz

https://web.archive.org/web/20140108065451/http://byuu.org/programming/nall/

Here is a relevant complete snippet for archival purposes:

nall is a C++11 header library that implements a large number of containers
and classes. Although at times it does reimplement containers that exist in the
C++ standard library, it primarily only does so to offer greater consistency and
enhanced yet simplified functionality.

For instance, nall/string supports tokenization, string-replace, math
parsing via recursive descent, small-string optimization, a customized string
container with string-group-specific functions, and so on. It provides type-safe
string building and printing functions, can store binary data and transparently
be passed to functions requiring C-style null-terminated strings, and uses a
more intelligent composition method than overriding the shift operators.

nall/vector allows O(1) amortized insert and remove at both the beginning and
end of the queue. Resizing the queue does not always require copying or moving
all objects through placement-new syntax and realloc (yet it still supports
non-POD objects and properly invokes constructors and destructors.) It also has
functions to optionally auto-resize an array when accessing an element out of
bounds, or to return a stock object if the array index is out of bounds.

nall also provides dozens of additional small libraries that do not exist in
the C++ standard library. For instance, rather than needing a 300KB dependency
on zlib or a 400KB dependency on libpng, nall/zip and nall/png provide simple
decompression support for these formats in a mere 10KB of code each.

As a header library, no separate object compilation is necessary. Simply
include the header(s) you want, and you can use it right away.

Some of the primary supported concepts implemented in nall are:

  • string
  • vector
  • set
  • hashset
  • map
  • sort
  • thread
  • unzip
  • png
  • image
  • config
  • markup/bml
  • markup/xml
  • varint
  • sha256
  • crc
  • dsp
  • stream
  • optional
  • file
  • filemap
  • directory
  • dl
  • endian
  • http
  • smtp
  • odbc

License

nall is available under the ISC license.

I had no prior experience with the ISC license but I was pleasantified to see this text template, nice and simple – https://en.wikipedia.org/wiki/ISC_license

So we might be overwhelmed at all the cool things that nall has to offer, and I would be foolish to not take time to learn it. I’m mostly interested in maintaining its use in Ruby, the hardware abstraction layer, where the nall::any type is used.. I like it’s light-weight flauntiness. I’m going to try it out. 🙂 Nall is also really useful for its “config” capability as I’ve become well accustomed with in my hacking of bsnes-classic – it makes it super easy to have a config file for various features, and extending the configuration is easy. I will make a tutorial on this.

There are some other questions I have on byuu’s libraries .. Such as Phoenix / Hiro and the difference between the two. I have the instinct that Hiro picks up a dead Phoenix. But I’m not sure. For some reason I’m not too interested in the GUI abstraction provided by Phoenix and possibly Hiro(?) .. This may be of use to someone who is : https://github.com/apollolux/hello-phoenix

7z support

Zophar’s Domain is one such popular SPC site that distributes its SPC packages in 7z archives. I love the support I’ve added into SPC Tracker that can load RSN/RAR files, so I would love to go all the way with 7z support. I’ve looked into and made some discoveries quickly:

can use http://www.7-zip.org/sdk.html 15.05 beta package’s 7zDec, a simplified 7z extractor and file lister.

To compile
There are some additions needed to be made to the lzma1505/C/Util/7z/makefile.gcc
I am unsure whether these changes are necessary because I run OS X Yosemite.

makefile.gcc.patch

--- makefile.gcc.old	2015-07-16 18:18:19.000000000 -0400
+++ makefile.gcc	2015-07-16 18:18:27.000000000 -0400
@@ -4,13 +4,17 @@ LIB =
 RM = rm -f
 CFLAGS = -c -O2 -Wall
 
-OBJS = 7zMain.o 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o CpuArch.o LzmaDec.o Lzma2Dec.o Bra.o Bra86.o Bcj2.o Ppmd7.o Ppmd7Dec.o 7zFile.o 7zStream.o
+OBJS = BraIA64.o Delta.o 7zMain.o 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o CpuArch.o LzmaDec.o Lzma2Dec.o Bra.o Bra86.o Bcj2.o Ppmd7.o Ppmd7Dec.o 7zFile.o 7zStream.o
 
 all: $(PROG)
 
 $(PROG): $(OBJS)
 	$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
 
+BraIA64.o: ../../BraIA64.c
+	$(CXX) $(CFLAGS) ../../BraIA64.c
+Delta.o: ../../Delta.c
+	$(CXX) $(CFLAGS) ../../Delta.c
 7zMain.o: 7zMain.c
 	$(CXX) $(CFLAGS) 7zMain.c

We can first inspect the archive for SPC files. If there’s none, don’t load. Then perform similar RSN/RAR duties. (RSN/RAR should perform similar safety check).

Part II

OK 7z support is implemented. In hindsight, additional functionality to 7zDec was required — ability to specify an output directory — and also NFD (NativeFileDialog) had a bug where file extensions < 3 chars were not parsing correctly. That was fixed 🙂 , although no pull request was submitted, I did submit an issue with an explanation and clear solution. Relevant links:

NFD < 3 char file extension bugfix:

Add ability for 7zDec to output extraction to a separate directory

[debugger] Add support for 7z archives loading

I am alive!

Hey yall,

I am alive and well 😀 I just needed some time off the SNES Tracker wagonwheel. ???? Don’t know what’s in store! But I’m hoping to incorporate some GUI libraries or find some help on this project.. There’s a large intimidation factor, plus I don’t have a job, living with fam and hanging with friends. We’ll see where it all goes!!

I’ve been learning about VJing thru my VJ friends and have started maintaining a private wiki for my own knowledge base it’s really useful! I highly recommend you do the same, if you’re like me.. Always working and learning new things, and building new ideas.

….

Can’t wait to show y’all what I’ve been working on in 2.5 weeks 🙂 It’s actually not SNES Tracker related, but it is SPC related somewhat.. sort of.. a little bit.

Oh, I’m also thinking of keeping SNES Tracker all to myself..

MSU-1 && Get SuperRoadBlaster working on Higan / Bsnes > v0.87

This has nothing to do with SNES Tracker.. Well it might.. If for some reason SNES Tracker supports MSU-1 .. which it has no reason to.. they’re unrelated and operate independently of each other.. But anyways it was hard to figure out how to get this thing working correctly on new Higan..

Keep everything the same but add this SuperRoadBlaster.bml file to the SuperRoadBlaster.sfc directory.

SuperRoadBlaster.bml

cartridge region=NTSC
  rom name=SuperRoadBlaster.sfc size=0x40000
  map id=rom address=00-3f,80-bf:8000-ffff
  map id=rom address=40-7d,c0-ff:0000-ffff

  ram name=SuperRoadBlaster.srm size=0x800
  map id=ram address=20-3f,a0-bf:6000-7fff
  map id=ram address=70-7d:0000-ffff

  msu1
    map id=io address=00-3f,80-bf:2000-2007
    rom name=SuperRoadBlaster.msu size=0x1eb60169
    track number=0 name=SuperRoadBlaster-0.pcm
    track number=1 name=SuperRoadBlaster-1.pcm
    track number=2 name=SuperRoadBlaster-2.pcm
    track number=3 name=SuperRoadBlaster-3.pcm
    track number=4 name=SuperRoadBlaster-4.pcm
    track number=5 name=SuperRoadBlaster-5.pcm
    track number=6 name=SuperRoadBlaster-6.pcm
    track number=7 name=SuperRoadBlaster-7.pcm
    track number=8 name=SuperRoadBlaster-8.pcm
    track number=9 name=SuperRoadBlaster-9.pcm
    track number=10 name=SuperRoadBlaster-10.pcm
    track number=11 name=SuperRoadBlaster-11.pcm
    track number=12 name=SuperRoadBlaster-12.pcm
    track number=13 name=SuperRoadBlaster-13.pcm
    track number=14 name=SuperRoadBlaster-14.pcm
    track number=15 name=SuperRoadBlaster-15.pcm
    track number=16 name=SuperRoadBlaster-16.pcm
    track number=17 name=SuperRoadBlaster-17.pcm
    track number=18 name=SuperRoadBlaster-18.pcm
    track number=19 name=SuperRoadBlaster-19.pcm
    track number=20 name=SuperRoadBlaster-20.pcm
    track number=21 name=SuperRoadBlaster-21.pcm
    track number=22 name=SuperRoadBlaster-22.pcm
    track number=23 name=SuperRoadBlaster-23.pcm
    track number=24 name=SuperRoadBlaster-24.pcm
    track number=25 name=SuperRoadBlaster-25.pcm
    track number=26 name=SuperRoadBlaster-26.pcm
    track number=27 name=SuperRoadBlaster-27.pcm
    track number=28 name=SuperRoadBlaster-28.pcm
    track number=29 name=SuperRoadBlaster-29.pcm
    track number=30 name=SuperRoadBlaster-30.pcm
    track number=31 name=SuperRoadBlaster-31.pcm
    track number=32 name=SuperRoadBlaster-32.pcm
    track number=33 name=SuperRoadBlaster-33.pcm
    track number=34 name=SuperRoadBlaster-34.pcm
    track number=35 name=SuperRoadBlaster-35.pcm
    track number=36 name=SuperRoadBlaster-36.pcm
    track number=37 name=SuperRoadBlaster-37.pcm
    track number=38 name=SuperRoadBlaster-38.pcm
    track number=39 name=SuperRoadBlaster-39.pcm
    track number=40 name=SuperRoadBlaster-40.pcm
    track number=41 name=SuperRoadBlaster-41.pcm
    track number=42 name=SuperRoadBlaster-42.pcm
    track number=43 name=SuperRoadBlaster-43.pcm
    track number=44 name=SuperRoadBlaster-44.pcm
    track number=45 name=SuperRoadBlaster-45.pcm
    track number=46 name=SuperRoadBlaster-46.pcm
    track number=47 name=SuperRoadBlaster-47.pcm
    track number=48 name=SuperRoadBlaster-48.pcm
    track number=49 name=SuperRoadBlaster-49.pcm
    track number=50 name=SuperRoadBlaster-50.pcm
    track number=51 name=SuperRoadBlaster-51.pcm
    track number=52 name=SuperRoadBlaster-52.pcm
    track number=53 name=SuperRoadBlaster-53.pcm
    track number=54 name=SuperRoadBlaster-54.pcm
    track number=55 name=SuperRoadBlaster-55.pcm
    track number=56 name=SuperRoadBlaster-56.pcm
    track number=57 name=SuperRoadBlaster-57.pcm
    track number=58 name=SuperRoadBlaster-58.pcm
    track number=59 name=SuperRoadBlaster-59.pcm
    track number=60 name=SuperRoadBlaster-60.pcm
    track number=61 name=SuperRoadBlaster-61.pcm
    track number=62 name=SuperRoadBlaster-62.pcm
    track number=63 name=SuperRoadBlaster-63.pcm
    track number=64 name=SuperRoadBlaster-64.pcm
    track number=65 name=SuperRoadBlaster-65.pcm
    track number=66 name=SuperRoadBlaster-66.pcm
    track number=67 name=SuperRoadBlaster-67.pcm
    track number=68 name=SuperRoadBlaster-68.pcm
    track number=69 name=SuperRoadBlaster-69.pcm
    track number=70 name=SuperRoadBlaster-70.pcm
    track number=71 name=SuperRoadBlaster-71.pcm
    track number=72 name=SuperRoadBlaster-72.pcm
    track number=73 name=SuperRoadBlaster-73.pcm
    track number=74 name=SuperRoadBlaster-74.pcm
    track number=75 name=SuperRoadBlaster-75.pcm
    track number=76 name=SuperRoadBlaster-76.pcm
    track number=77 name=SuperRoadBlaster-77.pcm
    track number=78 name=SuperRoadBlaster-78.pcm
    track number=79 name=SuperRoadBlaster-79.pcm
    track number=80 name=SuperRoadBlaster-80.pcm
    track number=81 name=SuperRoadBlaster-81.pcm
    track number=82 name=SuperRoadBlaster-82.pcm
    track number=83 name=SuperRoadBlaster-83.pcm
    track number=84 name=SuperRoadBlaster-84.pcm
    track number=85 name=SuperRoadBlaster-85.pcm
    track number=86 name=SuperRoadBlaster-86.pcm
    track number=87 name=SuperRoadBlaster-87.pcm
    track number=88 name=SuperRoadBlaster-88.pcm
    track number=89 name=SuperRoadBlaster-89.pcm
    track number=90 name=SuperRoadBlaster-90.pcm
    track number=91 name=SuperRoadBlaster-91.pcm
    track number=92 name=SuperRoadBlaster-92.pcm
    track number=93 name=SuperRoadBlaster-93.pcm
    track number=94 name=SuperRoadBlaster-94.pcm
    track number=95 name=SuperRoadBlaster-95.pcm
    track number=96 name=SuperRoadBlaster-96.pcm
    track number=97 name=SuperRoadBlaster-97.pcm
    track number=98 name=SuperRoadBlaster-98.pcm
    track number=99 name=SuperRoadBlaster-99.pcm
    track number=100 name=SuperRoadBlaster-100.pcm
    track number=101 name=SuperRoadBlaster-101.pcm
    track number=102 name=SuperRoadBlaster-102.pcm
    track number=103 name=SuperRoadBlaster-103.pcm
    track number=104 name=SuperRoadBlaster-104.pcm
    track number=105 name=SuperRoadBlaster-105.pcm
    track number=106 name=SuperRoadBlaster-106.pcm
    track number=107 name=SuperRoadBlaster-107.pcm
    track number=108 name=SuperRoadBlaster-108.pcm
    track number=109 name=SuperRoadBlaster-109.pcm
    track number=110 name=SuperRoadBlaster-110.pcm
    track number=111 name=SuperRoadBlaster-111.pcm
    track number=112 name=SuperRoadBlaster-112.pcm
    track number=113 name=SuperRoadBlaster-113.pcm
    track number=114 name=SuperRoadBlaster-114.pcm
    track number=115 name=SuperRoadBlaster-115.pcm
    track number=116 name=SuperRoadBlaster-116.pcm
    track number=117 name=SuperRoadBlaster-117.pcm
    track number=118 name=SuperRoadBlaster-118.pcm
    track number=119 name=SuperRoadBlaster-119.pcm
    track number=120 name=SuperRoadBlaster-120.pcm
    track number=121 name=SuperRoadBlaster-121.pcm

information:
  title:  Super Road Blaster
  name:   Super Road Blaster
  region: NA

Sources
http://www.smwcentral.net/?p=viewthread&t=71558

Here is some important info I discovered and wrote myself 😛

Super Road Blaster source is obviously a gold mine.

Here's what I discovered tonight.. more details found in Makefile

converting video to png with ffmpeg, snippet from Road Blaster, https://github.com/DocSchoko/SNES-SuperRoadBlaster/blob/master/tools/xmlsceneparser.py: 
os.system("ffmpeg -y -i %s -s 256x192 -pix_fmt rgb8 %s/video_%%06d.gfx_video.png -ss %s -t %s" % (options.get('videofile'), options.get('chapterfolder'), timestart, duration))

Super Blaster has tool to convert png to snes gfx..

this somehow gets compiled in a data file "gamename.msu" by https://github.com/DocSchoko/SNES-SuperRoadBlaster/blob/master/tools/msu1blockwriter.py

now audio
os.system("ffmpeg -y -i %s -acodec pcm_s16le -ar 44100 -ac 2 %s/audio.sfx_video.wav -ss %s -t %s" % (options.get('videofile'), options.get('chapterfolder'), timestart, duration))

https://github.com/DocSchoko/SNES-SuperRoadBlaster/blob/master/tools/msu1blockwriter.py also does the audio pcm file output.. 

it is up to you to follow Super Road Blaster further or create your own file format.. but basically you would be storing sequential frames of tiles, tile map, and color palette data, perhaps along with an audio track



create a skeleton snes program that sets up a BG layer at a certain VRAM address that MSU1 will upload to. and then u learn how to program MSU1 to send the data to VRAM
http://helmet.kafuka.org/msu1.htm

Good luck, cause there's not much doc on MSU1 that I can see...
Perhaps the original source code behind what we just  watched: http://www.dforce3000.de/pub/SuperRoadBlaster.sfc.7z
https://github.com/DocSchoko/SNES-SuperRoadBlaster