Yup, thanks.tepples wrote:Was it called Unofficial MagicKit?
A programming newb wants to start
Moderator: Moderators
Re: UMK
Re: A programming newb wants to start
Update: I decided to take a look at programming the nes in C (as mentioned before,) and it's very weird to look at.
is used to do and in C. Jeez, there really isn't a good way to work at a high level with the nes, is there?
Code: Select all
*((unsigned char*)0x2005) = 0x00;Code: Select all
lda #$00Code: Select all
sta $2005Re: A programming newb wants to start
Yes, there is. You either make a #define macro that wraps away the ugliness, or use #define macros to define the hardware registers you want to access.nicklausw wrote:Jeez, there really isn't a good way to work at a high level with the nes, is there?
For example:
Code: Select all
// Helper for memory accesses:
#define _M(a) ( *( unsigned char* )(a) )
_M(0x2015) = 0;
Code: Select all
struct _PPU {
byte ctrl;
byte mask;
byte const status;
byte oam_addr;
byte oam_data;
byte scroll;
byte addr;
byte data;
};
#define PPU ( *( struct _PPU volatile * )0x2000 )
PPU.scroll = 0;
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
- rainwarrior
- Posts: 8062
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: A programming newb wants to start
In general, anything that writes to registers, and especially PPU interaction like your NMI handler should be written in assembly and buried in a library. This is essentially the same as how you'd do it in C on another platform. Critical hardware stuff is part of libraries, and you write high level code only, for the most part.
If you want a specific assembly, you should write that part of the code in assembly. Write in C the parts of the program where the details of how it gets done don't matter. That's what C is for, to relieve you of those details. You can use both assembly and C in the same program, and it's somewhat counterproductive to jump through hoops to force one to do the other's job.
Code: Select all
// in a header
extern uint8 ppu_ctrl;
extern uint8 ppu_scroll_x;
extern uint8 ppu_scroll_y;
#pragma zpsym("ppu_ctrl")
#pragma zpsym("ppu_scroll_x")
#pragma zpsym("ppu_scroll_y")
; in the NMI handler of the assembly library
; ...
bit $2002
lda _ppu_scroll_x
sta $2005
lda _ppu_scroll_y
sta $2005
lda _ppu_ctrl
ora #%10000000 ; set NMI bit
sta $2000
; ...
// used in high level C code
// ...
unsigned short int scroll = 0;
// ...
++scroll;
ppu_ctrl = (ppu_ctrl & ~0x01) | ((scroll >> 8) & 0x01);
ppu_scroll_x = scroll & 0xFF;
ppu_scroll_y = 0;
// ...Re: A programming newb wants to start
I guess now you all know how much I can work with C. 
-
mikaelmoizt
- Posts: 120
- Joined: Sat Apr 12, 2014 12:11 pm
- Location: Gothenburg, Sweden
Re: A programming newb wants to start
Do you mean this? viewtopic.php?f=10&t=12097nicklausw wrote: Someone really does need to just go through that tutorial and modify everything to be asm6-compatible. I know, someone (you?) converted the actual files to its syntax, but the tutorials themselves...
Its a step in the right direction atleast.
I´ve got %01100011 problems but the BITs aint one.
Re: A programming newb wants to start
Yup. Sorry, couldn't remember for the life of me who did the conversion.mikaelmoizt wrote:Do you mean this? viewtopic.php?f=10&t=12097nicklausw wrote: Someone really does need to just go through that tutorial and modify everything to be asm6-compatible. I know, someone (you?) converted the actual files to its syntax, but the tutorials themselves...
Its a step in the right direction atleast.
-
mikaelmoizt
- Posts: 120
- Joined: Sat Apr 12, 2014 12:11 pm
- Location: Gothenburg, Sweden
Re: A programming newb wants to start
No problem.nicklausw wrote: Yup. Sorry, couldn't remember for the life of me who did the conversion.
I tried for many hours to combine those stupid .bank directives with .org into something useful before I decided I've had enough. Maybe I am just stupid or something, but why should you ever split banks into 8k slots like that (unless you work with something like mmc3)?
Edit: Come to think of it, I actually now remember this assembler was a modified <something> to work with nes, hence the weird way to split banks like that.
I´ve got %01100011 problems but the BITs aint one.
Re: A programming newb wants to start
It's based off a PC Engine assembler. The 8k banks are pretty much useless.mikaelmoizt wrote:No problem.nicklausw wrote: Yup. Sorry, couldn't remember for the life of me who did the conversion.![]()
I tried for many hours to combine those stupid .bank directives with .org into something useful before I decided I've had enough. Maybe I am just stupid or something, but why should you ever split banks into 8k slots like that (unless you work with something like mmc3)?
Edit: Come to think of it, I actually now remember this assembler was a modified <something> to work with nes, hence the weird way to split banks like that.