Update to my tutorial in C
Moderator: Moderators
Re: Update to my tutorial in C
Does anyone think I should increase the # of metatiles? Currently my code can use up to 51 (5 bytes each). But with a slight modification, that could be 102.
In my mind (before) you could swap metatile definitions for each type of level. I thought 51 should be enough.
Just wondering what other people think.
In my mind (before) you could swap metatile definitions for each type of level. I thought 51 should be enough.
Just wondering what other people think.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
Since it's a tutorial for learning about the nes, yes, it should be fine. Once the user know enough to do things on their own, they can update the code and add those extra metatile they are missing. It should be part of the learning process anyway, to extend to make it work the way you want
Re: Update to my tutorial in C
Most of my games use 16 or 32 as per "section", I think it's more than enough.
Re: Update to my tutorial in C
Agreed. It's a tutorial, not an all-purpose framework. Arbitrary limitations are fine. People following your tutorials are eventually going to have to learn to do things themselves.Banshaku wrote:Since it's a tutorial for learning about the nes, yes, it should be fine. Once the user know enough to do things on their own, they can update the code and add those extra metatile they are missing. It should be part of the learning process anyway, to extend to make it work the way you want
My games: http://www.bitethechili.com
Re: Update to my tutorial in C
True. Just trying to anticipate "how do I expand your code to do X" questions.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
I wrote a function for changing song speed manually (a while back).
It occurred to me today, as I was working on music code, that you could have greater flexibility over song speed, AND not interfere with Fxx effects if you instead adjusted the FT_TEMPO_STEP_L and FT_TEMPO_STEP_H.
Bigger for faster.
I might edit my code... later (I'm busy).
It occurred to me today, as I was working on music code, that you could have greater flexibility over song speed, AND not interfere with Fxx effects if you instead adjusted the FT_TEMPO_STEP_L and FT_TEMPO_STEP_H.
Bigger for faster.
I might edit my code... later (I'm busy).
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
Updated the neslib Sprite functions to remove the "sprid" parts. one sprite is 11% faster, metasprite is 5% faster. fewer passed arguments = faster.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
Hi! Thanks for the update!
I've been trying to "load" it into 8bitworkshop, but without success yet.
No matter what I do, a reference to the "old" neslib is probably hardcoded somewhere in their IDE.
I'll keep trying, nevertheless.
@Doug, is neslib.h and neslib.s independent from nesdoug.h and nesdoug.s?
I've been trying to "load" it into 8bitworkshop, but without success yet.
No matter what I do, a reference to the "old" neslib is probably hardcoded somewhere in their IDE.
I'll keep trying, nevertheless.
@Doug, is neslib.h and neslib.s independent from nesdoug.h and nesdoug.s?
Re: Update to my tutorial in C
You could try the LIBARGS special command, put it in the comments like here (but add in crt0, that's for an assembly example):wonder wrote: I've been trying to "load" it into 8bitworkshop, but without success yet.
No matter what I do, a reference to the "old" neslib is probably hardcoded somewhere in their IDE.
https://forums.nesdev.com/viewtopic.php ... 15#p242505
It implies that crt0 and neslib are linked by default.
Re: Update to my tutorial in C
Correct. neslib was written by Shiru 6 years. The version in 8bitworkshop is a more recent fork. The version that I use is also an unrelated fork, which I modified yesterday.is neslib.h and neslib.s independent from nesdoug.h and nesdoug.s?
nesdoug is code specific to my tutorial, and meant to be a companion library to neslib, which I felt was not complete.
But you can make a complete game without the nesdoug files, you will just not be able to follow my tutorial.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
I've started to setup an NES development environment on my Ubuntu VM.
I can compile and run 01_Hello without problems.
Instructions:
Now you can git clone the 01_Hello repository.
The windows file 'compile.bat' won't work here,
so I created a new file named 'compile.sh':
When done, don't forget to
Now it's simple:
I'll convert the bash script to a Makefile when I have some time.
I can compile and run 01_Hello without problems.
Instructions:
Code: Select all
# Install an emulator (eg. Nestopia)
sudo apt install nestopia
# Install CC55
cd $HOME
mkdir -p nes && cd nes
git clone https://github.com/cc65/cc65.git
make
# Add CC65 to your path environment variable
echo '# NesDev' >> $HOME/.bashrc
echo 'export CC65_HOME="$HOME/nes/cc65"' >> $HOME/.bashrc
echo 'export PATH="$PATH:$CC65_HOME/bin"' >> $HOME/.bashrc
The windows file 'compile.bat' won't work here,
so I created a new file named 'compile.sh':
Code: Select all
#!/bin/bash
name="$1"
cc65 -Oirs "$name.c" --add-source
ca65 crt0.s
ca65 "$name.s" -g
ld65 -C nrom_32k_vert.cfg -o "$name.nes" crt0.o "$name.o" nes.lib -Ln labels.txt
rm *.o
mv labels.txt BUILD/
mv "$name.s" BUILD/
mv "$name.nes" BUILD/
nestopia "BUILD/$name.nes"
Code: Select all
chmod +x compile.sh
Code: Select all
# Assuming 01_Hello exists in 'projects'
cd $HOME/nes/projects
cd 01_Hello
./compile.sh hello
Re: Update to my tutorial in C
Where I download it? I've looked at your github but I don't see it.dougeff wrote:Updated the neslib Sprite functions to remove the "sprid" parts. one sprite is 11% faster, metasprite is 5% faster. fewer passed arguments = faster.
Projects:
Shadow of the Beast (port)
The Sword of Ianna
The Banketh - The Video Game
My website: RetroNES
Shadow of the Beast (port)
The Sword of Ianna
The Banketh - The Video Game
My website: RetroNES
Re: Update to my tutorial in C
Every tutorial, from 01_Hello to 29_Powerpad.
In main folders, crt0.s changed to include SPRID as an internal variable.
In LIB folders, neslib.h and neslib.s updated. oam_spr() and oam_meta_spr() specifically.
In main folders, crt0.s changed to include SPRID as an internal variable.
In LIB folders, neslib.h and neslib.s updated. oam_spr() and oam_meta_spr() specifically.
nesdoug.com -- blog/tutorial on programming for the NES
Re: Update to my tutorial in C
@Dougeff, in neslib.h you have the following declaration:
The docstring says it returns something, but the return type is void. I would suggest:
Code: Select all
//set sprite in OAM buffer, chrnum is tile, attr is attribute, sprid is offset in OAM in bytes
//returns sprid+4, which is offset for a next sprite
// Note: sprid removed for speed
void __fastcall__ oam_spr(unsigned char x,unsigned char y,unsigned char chrnum,unsigned char attr);
Code: Select all
//set sprite in OAM buffer, chrnum is tile, attr is attribute, sprid is offset in OAM in bytes
//increments the sprid by 4 bytes, which is the offset for the next sprite
// Note: sprid removed for speed
void __fastcall__ oam_spr(unsigned char x,unsigned char y,unsigned char chrnum,unsigned char attr);
Re: Update to my tutorial in C
Fixed. Removed old comments about return values.
nesdoug.com -- blog/tutorial on programming for the NES