Talk:Super NES Programming/Initialization Tutorial

The SNES Central development page bonked. Uploading new files. Snargle 21:16, 28 July 2005 (UTC)

it is still black!! :((

How should the file system look like?(where should each and every file go?)

What do all the flags in the status register do?
About this section:

"In the header file, the label "Start" is declared as the reset vector, so that is where the program shall begin executing:"

sep    #$20        ; Set the A register to 8-bit.

It would help me wrap my head around this, If I could look at a list of flags in the status register and a description of what they all do. If there's already a page for this, then maybe we should link it here? 98.212.132.99 (discuss) 01:38, 21 March 2019 (UTC)

assembler link dead
permission denied

Need explanation of code
This code: lda    #%11100000  ; Load the low byte of the green color. sta    $2122 lda    #%00000000  ; Load the high byte of the green color. sta    $2122

It loads something to A, then stores it. Then it does it again. Its exactly the same code (except for the value assigned to A), so how come the first half sets the low byte of $2122 and the other half sets the high byte? Magic? --Profetylen (discuss • contribs) 23:23, 22 March 2011 (UTC)


 * I'm not an expert but apparently the SNES hardware has an automatic address increment function which mean that successive writes to $2122 write to successive memory localtions in the color palette. Recent Runes (discuss • contribs) 00:19, 24 March 2011 (UTC)


 * Okay! Thanks for clearing that up! :D --Profetylen (discuss • contribs) 23:31, 24 March 2011 (UTC)

I'm using Windows 7 and the SNES assemlber doesn't seem to work :(

I open it, and then it closes automatically :( Please send me an E-Mail (felixlukas@hotmail.com) and post the solution here. 88.69.130.203 (discuss) 10:22, 22 June 2011 (UTC)

NEW EDIT: I am also having the issue of trying to run the assembler. It may only be usable on linux, but I'm hoping for a response as well. cerd@rockets.utoledo.edu

Code example doesn't work right in bsnes
i tried this tutorial code, and was able to set the color just fine when loading the rom in zsnes, but in bsnes, the screen just spazzes out with random blocks. I can confirm this Subcogitate (discuss • contribs) 18:44, 8 February 2013 (UTC)

I've never used ZSNES personally, but I know it takes shortcuts. The provided ROM DOES work on power-on in bsnes, but will give a garbage pattern on reset that matches the pattern from a ROM assembled from the source code, except possibly for the color.

It does NOT appear that the provided ROM was assembled using the same assembler as the provided source code, based on where the RESET vector points to in the "given ROM" compared to the "assembled source code ROM". I'm looking at both the provided ROM and my own assembled ROM using a disassembler and seeing if I can't get the assembled source code to work.

Update: Changing "sta    $212C" to "stz     $212C" in the snes initialization code fixes the demo for BSNES. This prevents objects and the background from being initialized, and the PPU reading garbage. The provided ROM demo works on Power-on, but not on reset because I guess bsnes stores '0' in the accumulator on power-on, and retains the value on reset (the accumulator IS given values in the provided ROM before jumping into an infinite loop).

Opening/using the assembler
Is the assembler provided by the referenced website in the wiki page( http//www.villehelin.com/wla.html) only usable in unix/linux and not windows? I'm to the point where I'm trying to compile the code and I'm at a loss.

Something isn't right.
I followed the steps of the guide exactly, and yet the .smc file does not appear to do anything. The "greenspace.asm" contents are as follows:

.include "Header.inc" .include "Snes_Init.asm"

VBlank:   ; Needed to satisfy interrupt definition in "Header.inc" RTI

.bank 0 .section "MainCode" Start: ; Initialize the SNES Snes_Init sep    #$20         ; Set the A register to 8-bit. lda    #%10000000  ; Force VBlank by turning off screen. sta    $2100 lda    #%11100000  ; Load the low byte of the green color. sta    $2122 lda    #%00000000  ; Load the high byte of the green color. lda    #%00001111  ; End VBlank, setting brightness to 15 (100%). sta    $2100 ; Loop forever. Forever: jmp Forever

.ends

The "greenspace.link" file:

[objects] Greenspace.obj

SD2SNES Problem
I tried to test my ROM on a real SD2SNES cart, and the source code was almost the same as the one in the article, only without the , without the, and the initialisation code as well as the header are included within the main file.

When I tested it on SNES9X, it ran perfectly fine, but when I ran it on SD2SNES, there were a few garbage Japanese characters on the bottom left.

Here's the entire source code: https://pastebin.com/eW1LXdZp -Nikku4211

the forever loop
How does the loop work here? I saw some examples about looping but the loop was trapped inside a subroutine unlike here:

Forever: jmp Forever It jumps to forever, does it pass to the code above or something? Lakhdar Lakhdari (discuss • contribs)
 * Loop forever.