Skip to content

Commit

Permalink
Prepare NES machine type
Browse files Browse the repository at this point in the history
  • Loading branch information
drmortalwombat committed Mar 4, 2023
1 parent f34aa2d commit 6189e0c
Show file tree
Hide file tree
Showing 13 changed files with 1,951 additions and 67 deletions.
6 changes: 6 additions & 0 deletions include/crt.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ lx1: lda (addr), y

#elif defined(OSCAR_TARGET_BIN)

#elif defined(OSCAR_TARGET_NES)
sei
cld
#else
byt 0x0b
byt 0x08
Expand All @@ -153,6 +156,7 @@ lx1: lda (addr), y
stx spentry

#endif

// Clear BSS Segment

lda #<BSSStart
Expand Down Expand Up @@ -239,6 +243,7 @@ l2: dey
#endif

spexit:
#if !defined(OSCAR_TARGET_NES)
lda #$4c
sta $54
lda #0
Expand All @@ -248,6 +253,7 @@ l2: dey
#if defined(__C128__)
lda #0
sta 0xff00
#endif
#endif
rts
}
Expand Down
2 changes: 2 additions & 0 deletions include/nes/nes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "nes.h"

76 changes: 76 additions & 0 deletions include/nes/nes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#ifndef NES_NES_H
#define NES_NES_H

#include <c64/types.h>

#define PPU_CTRL_NT_2000 0b00000000
#define PPU_CTRL_NT_2400 0b00000001
#define PPU_CTRL_NT_2800 0b00000010
#define PPU_CTRL_NT_2C00 0b00000011
#define PPU_CTRL_INC_1 0b00000000
#define PPU_CTRL_INC_32 0b00000100
#define PPU_CTRL_SPR_0000 0b00000000
#define PPU_CTRL_SPR_1000 0b00001000
#define PPU_CTRL_BG_0000 0b00000000
#define PPU_CTRL_BG_1000 0b00010000
#define PPU_CTRL_SPR_8X8 0b00000000
#define PPU_CTRL_SPR_8X16 0b00100000
#define PPU_CTRL_NMI 0b10000000

#define PPU_MASK_GREYSCALE 0b00000001
#define PPU_MASK_BG8 0b00000010
#define PPU_MASK_SPR8 0b00000100
#define PPU_MASK_BG_ON 0b00001000
#define PPU_MASK_SPR_ON 0b00010000
#define PPU_MASK_EM_RED 0b00100000
#define PPU_MASK_EM_GREEN 0b01000000
#define PPU_MASK_EM_BLUE 0b10000000

struct PPU
{
volatile byte control;
volatile byte mask;
volatile byte status;
volatile byte oamaddr;
volatile byte oamdata;
volatile byte scroll;
volatile byte addr;
volatile byte data;
};

#define ppu (*((struct PPU *)0x2000))

struct NESIO
{
volatile byte sq1_volume;
volatile byte sq1_sweep;
volatile word sq1_freq;

volatile byte sq2_volume;
volatile byte sq2_sweep;
volatile word sq2_freq;

volatile byte tri_volume;
volatile byte tri_pad;
volatile word tri_freq;

volatile byte noise_volume;
volatile byte noise_pad;
volatile word noise_freq;

volatile byte dmc_freq;
volatile byte dmc_raw;
volatile byte dmc_start;
volatile byte dmc_length;

volatile byte oamdma;
volatile byte channels;
volatile byte input[2];
};

#define nesio (*((struct NESIO *)0x4000))

#pragma compile("nes.c")

#endif

Loading

0 comments on commit 6189e0c

Please sign in to comment.