Debug Messages in no$gmb and BGB

I've recently started working on a little side project, involving Gameboy development. While reading through the docs of BGB1, I noticed it supports printing debug messages to a debug console, I, however, couldn't get it working, since it was using the syntax of the no$gmb2 assembler. Thanks to the people of #gbdev on EFnet, especially beware, I've eventually got it working, and made an rgbds3 macro out of it.
Without further ado, here is a gist of the it:

IF !DEF(DEBUG_INC)  
DEBUG_INC SET 1

; Prints a message to the no$gmb / bgb debugger
; Accepts a string as input, see emulator doc for support
DBGMSG: MACRO  
        ld  d, d
        jr .end\@
        DW $6464
        DW $0000
        DB \1
.end\@:
        ENDM

ENDC ; DEBUG_INC  

Comments

SysInfo - Beautiful System Diagnosis

screen

I've recently been reminded of a tool called Archey1, it's used to display system specs in a delightful manner. You often see it in screenshots of some other people desktops of the Arch Linux community.

I missed such a tool on OS X, and that's why I wrote SysInfo. It's available on Github2.

Comments

Fixing Slow Vim in Tmux and iTerm2

I've noticed my Vim got horribly slow once I had multiple panes in tmux open.
My initial investigation led to the fact, that tmux is slowing Vim down, and a quick Google search confirmed that.
After removing all plugins in Vim/tmux, I dug through the iTerm2 settings and found this:

screen

Removing the tick at "Save lines to scrollback in alternate screen mode" and setting the scrollback to a reasonable amount (I chose 1000), the lag was nearly gone. I'll continue investigating, to improve the Vim performance.

Comments

Resurrected

I've resurrected my blog, and put my .io domain to a good use, and set-up a ghost blog.
So far, I've always had my personal websites cluttered on many domains, but this came to an end, everything is now on arvid.io.

You can expect new posts in the next few weeks, I already have something prepared.

Comments

Automatically exporting assets from Sketch into Android Studio

Matt Zanchelli wrote a blog post about automatically exporting assets from Sketch into Xcode, unfortunately this method can only be used with Xcode projects, but fortunately we have Gradle.

I ported this technique to use Gradle an achieve the same for Android Studio projects.

Installing Sketchtool

You have to install sketchtool first, it’s a tool by Bohemian Coding (the makers of Sketch), to work with .sketch tools on the command line.
Download the Sketchtool and move the content of the directory into /usr/bin.

Alternatively, you can use this shell script, which basically does the same for you:

curl -O http://sketchtool.bohemiancoding.com/sketchtool-latest.zip;\  
unzip sketchtool-latest.zip;\  
sudo cp sketchtool/sketchtool /usr/bin/sketchtool;\  
sudo cp -R sketchtool/sketchtool\ resources.bundle/ /usr/bin/sketchtool\ resources.bundle/;\  
rm -r sketchtool/;\  
rm sketchtool-latest.zip;  

Screencast

Setting up the project

To organize the Sketch files, I created a subfolder in the root directory of the project and moved the AppIcon.sketch file into it. To create the image files of from the artboards in the file, we need a shell script. Create a AppIcon.sh file and copy the code below into the file.

#!/bin/sh

/usr/bin/sketchtool export artboards AppIcon.sketch

mv HDPI.png ../app/src/main/res/drawable-hdpi/ic_launcher.png  
mv XHDPI.png ../app/src/main/res/drawable-xhdpi/ic_launcher.png  
mv XXHDPI.png ../app/src/main/res/drawable-xxhdpi/ic_launcher.png  
mv XXXHDPI.png ../app/src/main/res/drawable-xxxhdpi/ic_launcher.png  

Modifying the build.gradle

This script has to be executed before every compilation of the project, to achieve this we have to modify our build.gradle file, by appending the following:

task copySketch(type:Exec) {  
    workingDir '../Graphics Resources'
    commandLine './AppIcon.sh'
}
preBuild.dependsOn copySketch  

It assumes, you use the same structure as described above. If you don't, adjust the paths accordingly (the default directory, is the directory where the build.gradle lives in).

Sample Project

You can download the sample project, or visit the Github repository.

Comments

[Android 4] ActionBar with Tabs example

Example Application & Code for ActionBar with Tabs Layout optimized for Android 4.0.
I’am slowly optimizing my apps for Android 4.0 and because there aren’t much Example / Resources I thought I publish my own code as example. It is a simple Layout. Code and anything else after break

First of all we need our MainActivity.java which contain the Initializing for our ActionBar Layout:

public class StartActivity extends Activity {  
public static Context appContext;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    //ActionBar gets initiated
    ActionBar actionbar = getActionBar();

    //Tell the ActionBar we want to use Tabs.
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    //initiating both tabs and set text to it.
    ActionBar.Tab PlayerTab = actionbar.newTab().setText("Fragment A");
    ActionBar.Tab StationsTab = actionbar.newTab().setText("Fragment B");

    //create the two fragments we want to use for display content
    Fragment PlayerFragment = new AFragment();
    Fragment StationsFragment = new BFragment();

    //set the Tab listener. Now we can listen for clicks.
    PlayerTab.setTabListener(new MyTabsListener(PlayerFragment));
    StationsTab.setTabListener(new MyTabsListener(StationsFragment));

    //add the two tabs to the actionbar
    actionbar.addTab(PlayerTab);
    actionbar.addTab(StationsTab);
  }
}

I think the comments explain everything. Next step. The TabListener.

class MyTabsListener implements ActionBar.TabListener {  
    public Fragment fragment;

    public MyTabsListener(Fragment fragment) {
        this.fragment = fragment;
    }

    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft) {
        Toast.makeText(StartActivity.appContext, "Reselected!", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
        ft.replace(R.id.fragment_container, fragment);
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        ft.remove(fragment);
    }
}

The method names explain it, onTabSelected we replace our current Fragment with the new Fragment.The Container is fragment_container and a simple LinearLayout.
The Fragments look like this:

public class AFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.afragment, container, false);
    }

}

This Fragment simple inflate the Layout afragment.xml in the container (defined above)
afragment.xml can be anything, in my example its a simple textview.

The main layout should look like this:

<LinearLayout  
xmlns:android="http://schemas.android.com/apk/res/android"  
android:orientation="vertical"  
android:layout_width="fill_parent"  
android:layout_height="fill_parent" android:layout_gravity="center">  
    <LinearLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

</LinearLayout>  
</LinearLayout>  

You can find the full source code on Github.

Comments