nes: updated comments in presets

This commit is contained in:
Steven Hugg 2019-05-22 11:45:05 -04:00
parent 9a19531f91
commit 1c192c4105
22 changed files with 147 additions and 3 deletions

View File

@ -1,4 +1,10 @@
/*
Generates random sounds in the APU, printing the parameters
to the screen. Also shows an asterisk while each channel is
playing, i.e. while its length counter is active.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,4 +1,9 @@
/*
Setting the attribute table, which controls palette selection
for the nametable. We copy it from an array in ROM to video RAM.
*/
#include "neslib.h"
#include <string.h>
#include <stdlib.h>

View File

@ -1,4 +1,13 @@
/*
Bank-switching using the MMC3 mapper.
We use a special linker config that sets up
64 KB of PRG ROM and 64 KB of CHR ROM.
Macros are used to set MMC3 registers and switch banks.
CC65 #pragma directives are used to put things in various
PRG ROM segments (CODE0-CODE6, CODE).
*/
// bank-switching configuration
#define NES_MAPPER 4 // Mapper 4 (MMC3)
#define NES_PRG_BANKS 4 // # of 16KB PRG banks

View File

@ -1,4 +1,14 @@
/*
A platform game with a randomly generated stage.
Uses the Famitone2 library for sound and music.
It scrolls vertically (horizontal mirroring) and nametable
updates are performed offscreen one row at a time with the
draw_floor_line() function.
The enemies use the same movement logic as the player, just
with random inputs.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,9 @@
/*
Demonstrates the Famitone2 library for sound and music.
Press controller buttons to hear sound effects.
*/
#include "neslib.h"
// link the pattern table into CHR ROM

View File

@ -1,4 +1,11 @@
/*
If you have more objects than will fit into the 64 hardware
sprites, you can omit some of the sprites each frame.
We also use oam_meta_spr_pal() to change the color of each
metasprite.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,11 @@
/*
A simple "hello world" example.
Set the screen background color and palette colors.
Then write a message to the nametable.
Finally, turn on the PPU to display video.
*/
#include "neslib.h"
// link the pattern table into CHR ROM

View File

@ -1,4 +1,15 @@
/*
We demonstrate horizontal scrolling of two nametables.
Vertical mirroring is set, so nametables A and B are
to the left and right of each other.
New playfield data is randomly generated and updated
offscreen using the vrambuf module.
Every 32 pixels, we also update the attribute table.
We also use the split() function to create a status bar.
*/
#include "neslib.h"
#include <string.h>
@ -29,11 +40,13 @@ byte bldg_attr; // attribute table value
#define PLAYROWS 24
// convert from nametable address to attribute table address
word nt2attraddr(word a) {
return (a & 0x2c00) | 0x3c0 |
((a >> 4) & 0x38) | ((a >> 2) & 0x07);
}
// generate new random building data
void new_building() {
bldg_height = (rand8() & 7) + 2;
bldg_width = (rand8() & 3) * 4 + 4;
@ -41,6 +54,8 @@ void new_building() {
bldg_attr = rand8();
}
// update the nametable offscreen
// called every 8 horizontal pixels
void update_nametable() {
register word addr;
// a buffer drawn to the nametable vertically

View File

@ -1,4 +1,12 @@
/*
Multiple screen splits with the MMC3 mapper using IRQs.
The main loop updates the scroll counters continuously.
When a IRQ fires, we change the X scroll register, setting
it immediately via the PPU struct.
The NMI and IRQ use the same callback function.
*/
// bank-switching configuration
#define NES_MAPPER 4 // Mapper 4 (MMC3)
#define NES_PRG_BANKS 4 // # of 16KB PRG banks

View File

@ -1,4 +1,10 @@
/*
Read from controllers with pad_poll().
We also demonstrate sprite animation by cycling among
several different metasprites, which are defined using macros.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,10 @@
/*
Metasprites combine several hardware sprites to make a larger
sprite. Our demo uses 4 hardware sprites in a 2x2 pattern,
forming 16x16 pixel sprites.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,12 @@
/*
Creates a monochrome frame buffer in video RAM.
We map the pattern tables to CHR RAM, using the UxROM (2) mapper.
By cleverly setting up palettes, and using a split-screen
CHR bank switch, we split the screen into four different regions
that display their own pixels.
*/
#include "neslib.h"
#include "nes.h"
#include <stdlib.h>

View File

@ -1,4 +1,8 @@
/*
A simple music player.
*/
#include <string.h>
#include <nes.h>

View File

@ -1,6 +1,8 @@
// this example code unpacks a RLE'd nametable into the VRAM
// you can create the source data using NES Screen Tool
/*
Unpacks a RLE-compressed nametable+attribute table into VRAM.
Also uses the pal_bright() function to fade in the palette.
*/
#include "neslib.h"

View File

@ -1,4 +1,12 @@
/*
Scrolling demo.
We've selected horizontal mirroring as the default, so
nametables A and C are stacked on top of each other.
The vertical scroll area is 480 pixels high; note how
the nametables wrap around.
*/
#include "neslib.h"
#include <string.h>

View File

@ -1,4 +1,11 @@
/*
A shoot-em-up game.
Uses CHR RAM to draw attacker tiles at 8 different pixels,
then animates them in the nametable.
Sprites are used for the player, missiles, attackers, and stars.
*/
#include <stdlib.h>
#include <string.h>
#include <nes.h>

View File

@ -1,4 +1,10 @@
/*
A character-based surround-the-opponent game.
Reads from nametable RAM to determine collisions, and also
to help the AI avoid walls.
*/
#include <stdlib.h>
#include <string.h>
#include <nes.h>

View File

@ -1,4 +1,9 @@
/*
Sprite demo.
Animate all 64 hardware sprites.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,12 @@
/*
Demo of split screen effect.
We position sprite 0 at the desired scanline, and when it
collides with the background, a flag in the PPU is set.
The split() function waits for this flag, then changes the
X scroll register in the PPU.
*/
#include "neslib.h"
#include <string.h>

View File

@ -1,4 +1,9 @@
/*
Demonstrates the PPU's tint and monochrome bits.
Use the controller to see different combinations.
*/
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,11 @@
/*
On the NES, you can't write to video RAM while the PPU
is active, so you have to do it during the vertical blank.
We have a module (vrambuf) which fills up a buffer with video
data, then NESLib writes it to VRAM during the NMI interrupt.
*/
#include "neslib.h"
#include <string.h>
#include <stdio.h>

View File

@ -24,10 +24,10 @@ const JSNES_PRESETS = [
{id:'monobitmap.c', name:'Monochrome Bitmap'},
{id:'aputest.c', name:'Sound Tester'},
{id:'music.c', name:'Music Player'},
{id:'fami.c', name:'Famitone Demo'},
{id:'siegegame.c', name:'Siege Game'},
{id:'shoot2.c', name:'Solarian Game'},
{id:'climber.c', name:'Platform Game'},
{id:'fami.c', name:'Famitone Demo'},
{id:'bankswitch.c', name:'Bank Switching'},
{id:'irq.c', name:'IRQ Scanline Counter'},
{id:'ex0.dasm', name:'Initialization (ASM)'},