Alright, so I've done a bit of searching for this, and I've come to the conclusion that no libraries for the NES C compiler have been made.
Compiler can be found here: http://www.cc65.org/
So I'm going to take it upon myself to build my own libraries that will allow:
* Joypad Input
* Sprite Drawing
* Pallette Loading
and much more.
The only problem is, I am not fluent in NES asm and am just beginning, so I will be following the basic NES asm tutorials here: http://patater.com/gbaguy/nesasm.htm
Here is a little bit of test code you folks can try out at home, I've already made the keyboard input part.
Oh and here is the batch file I use to compile (assuming the C file is named test.c):
Compiler can be found here: http://www.cc65.org/
So I'm going to take it upon myself to build my own libraries that will allow:
* Joypad Input
* Sprite Drawing
* Pallette Loading
and much more.
The only problem is, I am not fluent in NES asm and am just beginning, so I will be following the basic NES asm tutorials here: http://patater.com/gbaguy/nesasm.htm
Here is a little bit of test code you folks can try out at home, I've already made the keyboard input part.
Code:
#include <conio.h>
#include <peekpoke.h>
#include <6502.h>
typedef struct joypad
{
unsigned char a;
unsigned char b;
unsigned char select;
unsigned char start;
unsigned char up;
unsigned char down;
unsigned char left;
unsigned char right;
} joypad;
void keyprocess(joypad* joy1)
{
// Reset the Pad
asm("lda #$01");
asm("sta $4016");
asm("lda #$00");
asm("sta $4016");
// Read Keys
joy1->a = PEEK(16406) & 1;
joy1->b = PEEK(16406) & 1;
joy1->select = PEEK(16406) & 1;
joy1->start = PEEK(16406) & 1;
joy1->up = PEEK(16406) & 1;
joy1->down = PEEK(16406) & 1;
joy1->left = PEEK(16406) & 1;
joy1->right = PEEK(16406) & 1;
}
joypad joy;
void main (void)
{
clrscr();
cprintf("hello world");
while(1)
{
clrscr();
gotoxy(0,0);
keyprocess(&joy);
if (joy.a)
{
cprintf("win");
}
else
{
cprintf("fail");
}
}
}
#include <peekpoke.h>
#include <6502.h>
typedef struct joypad
{
unsigned char a;
unsigned char b;
unsigned char select;
unsigned char start;
unsigned char up;
unsigned char down;
unsigned char left;
unsigned char right;
} joypad;
void keyprocess(joypad* joy1)
{
// Reset the Pad
asm("lda #$01");
asm("sta $4016");
asm("lda #$00");
asm("sta $4016");
// Read Keys
joy1->a = PEEK(16406) & 1;
joy1->b = PEEK(16406) & 1;
joy1->select = PEEK(16406) & 1;
joy1->start = PEEK(16406) & 1;
joy1->up = PEEK(16406) & 1;
joy1->down = PEEK(16406) & 1;
joy1->left = PEEK(16406) & 1;
joy1->right = PEEK(16406) & 1;
}
joypad joy;
void main (void)
{
clrscr();
cprintf("hello world");
while(1)
{
clrscr();
gotoxy(0,0);
keyprocess(&joy);
if (joy.a)
{
cprintf("win");
}
else
{
cprintf("fail");
}
}
}
Oh and here is the batch file I use to compile (assuming the C file is named test.c):
Code:
SET CC65_INC=\nesC\include
SET CC65_LIB=\nesC\lib
SET PATH=\nesC\bin
cc65.exe -t nes test.c
ca65.exe -t nes test.s
ld65.exe -t nes test.o nes.lib -o test.nes
pause
SET CC65_LIB=\nesC\lib
SET PATH=\nesC\bin
cc65.exe -t nes test.c
ca65.exe -t nes test.s
ld65.exe -t nes test.o nes.lib -o test.nes
pause