Author Topic: A simple SNES libary.  (Read 8442 times)

0 Members and 1 Guest are viewing this topic.

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
A simple SNES libary.
« on: November 12, 2011, 09:15:39 PM »
I have always used neviksti's starterkit for making SNES games but I don't understand how everything works and ASM is just so hard that I can't see what any of the code is doing unless it has a comment explaining it; I hardly do anything without having to ask you lot for help.

There is one SNES compiler I belive that doesn't use ASM called snesc but it's not really that efficient and I can't find any tutorials or examples for it.


That's why I'm asking if we could just completely sc.rap everything and start again fresh. Make a new SNES libary with a bunch of easy to use functions such as "CreateSprite" and "SetSpriteX" and "LoadBackground" and "ScrollBackgroundX" just like PAlib but for SNES, and we could use wla as the compiler.

The SNES homebrew scene is so small since it's so hard to make games for SNES but it we could build a small basic libary without any fancy FX chip support but just the bare essentials then we could change this.


As I already mentioned I'm not the best ASM coder out there; and I hardly know any of the SNES hardware adress's and such. But if we all worked together and helped each other out then it will work.


Who else is interested in making something like this?
« Last Edit: November 12, 2011, 09:18:22 PM by YoshiInAVoid »

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: A simple SNES libary.
« Reply #1 on: November 12, 2011, 09:40:08 PM »
I don't have any such libraries or plans to write one. But here's some code for stuff I've written for the SNES in asm and C. Some of it has a decent amount of comments, some doesn't.

http://code.google.com/p/neo-myth-menu/source/browse/#svn%2Ftrunk%2FSNES%2FNeoMythMenu
http://jiggawatt.org/badc0de/t700c-src.zip
http://jiggawatt.org/badc0de/spcplayer-1.4.zip


And here are some docs:
http://fdwr.tripod.com/docs/snesmap.txt
http://ekid.nintendev.com/snes/spctech.htm

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #2 on: November 12, 2011, 11:19:31 PM »
Thanks alot! That really will come in handy later.

About your SPC player, you have this line:

.define SPC_FILE "spctestset/so-01.spc"

Does the file "so-01.spc" get included in the actuall ROM file; if so, what changes did you have to do in order to get the compiler to do so.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: A simple SNES libary.
« Reply #3 on: November 12, 2011, 11:34:36 PM »
No, the DEFINE is just for the filename.

The actual data gets included here:

Code: [Select]
; SPC-700 register values
 .bank 1 slot 0
 .org $0000
 .incbin SPC_FILE skip $00025 read $0008
 ; DSP register values
 .org $4000
 .incbin SPC_FILE skip $10100 read $0080


 ; The actual 64k SPC RAM dump
 .bank 2
 .section "musicDataLow"
 .incbin SPC_FILE skip $0100 read $8000
 .ends
 .bank 3
 .section "musicDataHigh"
 .incbin SPC_FILE skip $8100 read $8000
 .ends

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #4 on: November 13, 2011, 12:41:23 AM »
When I include loadspc.asm with my project I get an error saying "Unknown directive ".equ"." so I changed all the equs to defines and now it gives me some errors about sta and various other functions requiring a direct value.

How can I fix this?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: A simple SNES libary.
« Reply #5 on: November 13, 2011, 01:46:57 AM »
Does it work if you just try to build the project as it is? I.e. if you run make_player.bat?

And keep in mind that loadspc.asm relies on stuff from snes.inc.

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #6 on: November 13, 2011, 01:53:00 AM »
No. But your zip didn't include the wla compiler so I had to add the one that I use, and I get this error:

Unknown directive ".SNESHEADER"

It is also missing SNES_Init.asm

Can I just have your whole project folder?

Also, do you have google talk or msn; it would be alot quicker and easier to talk to you.
« Last Edit: November 13, 2011, 02:02:21 AM by YoshiInAVoid »

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #7 on: November 13, 2011, 04:20:58 AM »
Ok so I managed to get your program to compile! Now I'll try and use it.

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #8 on: November 16, 2011, 01:28:09 AM »
It only works with a certain version of WLA DX, and the rest of the libary doesn't work with that version of WLA DX. This is hard! I'm going to have to edit your whole libary in order to get it to work.

With the WLA DX that the rest of the libary is using, doesn't support the .equ is there a way of removing the equs and replacing them with something else.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: A simple SNES libary.
« Reply #9 on: November 16, 2011, 01:56:08 AM »
Can't you just use the latest version of WLA-DX? 9.5 or whatever it is.


Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: A simple SNES libary.
« Reply #10 on: November 16, 2011, 02:20:05 AM »
Oh, and a late answer to your question: 

Quote
Also, do you have google talk or msn; it would be alot quicker and easier to talk to you.

I do have gtalk. It should be possible to find the address by clicking on the email icon next to my username (the one that looks like an envelope).

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #11 on: November 23, 2011, 12:36:51 AM »
I haven't really got any progress at all yet. I'll buckle down and make sure that there is something available by the end of the week. But it's really hard for me, even the most simple thing such printing a line of text I wouldn't be able to do without using neviksti's starterkit as a template or something to copy.

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #12 on: December 30, 2011, 05:03:04 AM »
I finally got snesc to work and compile for me so I shall make the libary with that! I've actually already started it, it will be called the "YIAV_Lib" and is designed to be simple and clean so that anyone can use it.

EDIT: See the next post for the code.
« Last Edit: December 31, 2011, 03:36:36 AM by YoshiInAVoid »

Offline YoshiInAVoid

  • Newbie
  • *
  • Posts: 44
  • NEO newbie
Re: A simple SNES libary.
« Reply #13 on: December 31, 2011, 03:32:49 AM »
I have finally managed to get a very simple "Hello World!" demo working with my libary :D it should give you a good idea of what the libary will look like in the future.

Put the file "YIAV_Lib.h" in your includes folder, for me it's:

C:\MinGW\msys\1.0\local\snes-sdk\include\YIAV_Lib.h

But it might be different depending on your set up.

Then put this code in it:

Code: [Select]
#include <string.h>

#define YIAV_LinkTiles(Tiles) extern unsigned char Tiles[]

extern unsigned char palette[];
unsigned int pal[0x100];

unsigned int Layer0[0x400];
unsigned int Layer1[0x400];
unsigned int Layer2[0x400];
unsigned int Layer3[0x400];

void YIAV_SetupLayers(void) {
setmap(0, (unsigned char*)Layer0);
setmap(1, (unsigned char*)Layer1);
setmap(2, (unsigned char*)Layer2);
setmap(3, (unsigned char*)Layer3);
}

void YIAV_SetupPalette(void) {
memcpy(pal, palette, 0x200);
setpalette((unsigned char*)pal);
}

void YIAV_LoadTilesToLayer(unsigned char* Tiles, unsigned int LayerNo) {
settiles(LayerNo, Tiles, 0xF00);
}

void YIAV_Init(void) {
snesc_init();
enablescreen();
YIAV_SetupLayers();
YIAV_SetupPalette();
}

void YIAV_Update(void) {
resettimer();
sync(1);
}

void YIAV_OutputText(unsigned char* Text, unsigned int* Layer, unsigned int X, unsigned int Y) {
writestring(Text, Layer, X + Y * 32, 0x3F6);
}

Copy "tiles1" from your "snesc" folder and put it in your "HelloWorld" folder. Rename it to "Font". In "data.asm" in your "HelloWorld" folder replace:

Code: [Select]
tiles1:
  .incbin "tiles1.dat"

With:

Code: [Select]
Font:
  .incbin "Font.dat"

Then put this in your "HelloWorld.c" file:

Code: [Select]
//Just include your header file and the header file for YIAV_Lib:

#include "HelloWorld.h"
#include <YIAV_Lib.h>


//Link to your tiles:

YIAV_LinkTiles(Font);


//The main function:

int main() {


//Initialize the YIAV_Lib:

YIAV_Init();


//Load your tiles into layer 0 - Must be a number not "Layer0"

YIAV_LoadTilesToLayer(Font, 0);


//Output some text on the screen:

YIAV_OutputText("Hello World!", Layer0, 10, 1);


//Loop the game:

while(1) {


//Sync the screen, reset the timer and have a short delay:

YIAV_Update();
}

}

If you can't get it working then I'll upload a "HelloWorld.zip" with everything inside.

Side note: You might want to create a file called "TestGame.bat" with this code in:

Code: [Select]
REM C -> ASM / S
..\bin\816-tcc.exe -Wall -I../include -o snesc.ps -c HelloWorld.c
..\bin\816-tcc.exe -Wall -I../include -o input.ps -c input.c
..\bin\816-tcc.exe -Wall -I../include -o init.ps -c init.c
..\bin\816-tcc.exe -Wall -I../include -o graph.ps -c graph.c
..\bin\816-tcc.exe -Wall -I../include -o str.ps -c str.c

REM Optimize ASM files
..\bin\816-opt.py snesc.ps > snesc.s
..\bin\816-opt.py input.ps > input.s
..\bin\816-opt.py init.ps > init.s
..\bin\816-opt.py graph.ps > graph.s
..\bin\816-opt.py str.ps > str.s

REM ASM -> OBJ
..\bin\wla-65816.exe -io data.asm data.obj

..\bin\wla-65816.exe -io snesc.s snesc.obj
..\bin\wla-65816.exe -io input.s input.obj
..\bin\wla-65816.exe -io init.s init.obj
..\bin\wla-65816.exe -io graph.s graph.obj
..\bin\wla-65816.exe -io str.s str.obj

REM OBJ -> SMC
..\bin\wlalink.exe -dvSo data.obj snesc.obj input.obj init.obj graph.obj str.obj HelloWorld.smc

REM delete files
del *.ps
del *.s
del *.obj
del *.sym

pause

HelloWorld.smc

del HelloWorld.smc

exit

It compiles your game, then pauses saying "Press any key to continue" so you can read all your errors and warnings or see if it compiled perfectly. Then it runs "HelloWorld.smc" with whatever emulator you have set up, (or an "Open With" dialogue if you haven't set up an emulator for smc files) and when you close the emulator it deletes the file "HelloWorld.smc" and closes itself.

Currently the libary only works with Layer0; if you try and use any other layer it wont display the text, but I'm working on it.
« Last Edit: December 31, 2011, 03:35:02 AM by YoshiInAVoid »

Offline FrankJScott

  • Jr. Member
  • **
  • Posts: 67
  • NEO newbie
    • High Rated Trash Can Blog
Useful Marketing Blog Advice
« Reply #14 on: May 22, 2022, 02:39:32 AM »
To the man asking about marketing help for social media, what schools have good marketing programs, marketing tactics for social media, do you need a blog to be an affiliate marketer, affiliate marketing tips and tricks in hindi, marketing advisor jobs,  I highly recommend this recommended marketing tips link or marketing advisor salary, digital marketing blog examples, marketing advisory accenture, what is the most effective digital marketing strategy, marketing tricks for instagram, marketing blogs ideas, as well as this best marketing advice link not to mention how effective is instagram for marketing, marketing strategies for school district, marketing tips for small companies, great blog names, marketing campaign advisor job description, marketing blog topics 2021, on top of this high rated marketing blog site which is also great. Also have a look at this updated marketing tips info alongside all content marketing blog topics, share market guide for beginners pdf in hindi, where can i market my business for free, what are simple marketing tips, social media marketing blogs 2021, affiliate marketing tips and tricks in hindi, and don't forget this high rated marketing tips advice and don't forget how do i promote my artwork, marketing blogs india, is digital marketing a good business to start, best marketing tips for 2022, which app is best for marketing, best headlines for email marketing, as well as updated marketing tips forum which is also worth a look. I also recommend this updated marketing tips tips alongside all digital marketing solutions examples, marketing tips for real estate agents 2021, instagram marketing tips and tricks, examples of marketing boards, marketing solutions examples, best strategy for marketing small business, as well as this cool marketing tips details as well as examples of a blog post, content of blog examples, marketing for social media strategies, online marketing strategies for small business pdf, sales marketing tips in hindi, marketing ideas for cooking school, alongside all top rated marketing advice blog which is also great. Finally, have a look at this best marketing blog advice for good measure. Check more Awesome Body Link 6bab266