mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-10 21:29:33 +00:00
build segment table; download all has local/ prefix; NES: use CHR ROM for C
This commit is contained in:
parent
e9d207fa84
commit
806600994f
|
@ -95,7 +95,6 @@ TODO:
|
||||||
- show .map file in listings? memory map view?
|
- show .map file in listings? memory map view?
|
||||||
- open ROM from URL?
|
- open ROM from URL?
|
||||||
- NES: disassembly not aligned on PC
|
- NES: disassembly not aligned on PC
|
||||||
- NES: listing for .s files
|
|
||||||
|
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
|
|
@ -3,25 +3,20 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// include NESLIB header
|
// include NESLIB header
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
// include CC65 NES Header (PPU)
|
// include CC65 NES Header (PPU)
|
||||||
|
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
|
||||||
|
// link the pattern table into CHR ROM
|
||||||
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
// define basic types
|
// define basic types
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef signed char sbyte;
|
typedef signed char sbyte;
|
||||||
typedef unsigned short word;
|
typedef unsigned short word;
|
||||||
typedef enum { false, true } bool;
|
typedef enum { false, true } bool;
|
||||||
|
|
||||||
///// PATTERN TABLE
|
|
||||||
|
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
///// DEFINES
|
///// DEFINES
|
||||||
|
|
||||||
#define COLS 30 // floor width in tiles
|
#define COLS 30 // floor width in tiles
|
||||||
|
@ -766,9 +761,7 @@ const char PALETTE[32] = {
|
||||||
|
|
||||||
void setup_graphics() {
|
void setup_graphics() {
|
||||||
ppu_off();
|
ppu_off();
|
||||||
oam_hide_rest(0);
|
oam_clear();
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
pal_all(PALETTE);
|
pal_all(PALETTE);
|
||||||
vram_adr(0x2000);
|
vram_adr(0x2000);
|
||||||
vram_fill(CH_BLANK, 0x1000);
|
vram_fill(CH_BLANK, 0x1000);
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
|
#pragma data-name (push,"CHARS")
|
||||||
|
#pragma data-name (pop)
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
#define HAS_DEBUGGER
|
#define HAS_DEBUGGER
|
||||||
|
|
||||||
#define PLAYER_1 0
|
#define PLAYER_1 0
|
||||||
#define PLAYER_2 1
|
#define PLAYER_2 1
|
||||||
|
|
||||||
|
void sfx_play(char a, char b) {
|
||||||
|
a=a;
|
||||||
|
b=b;
|
||||||
|
}
|
||||||
|
|
||||||
static const unsigned char palette[]={
|
static const unsigned char palette[]={
|
||||||
0xD, 0x00, 0x3D, 0x3c,
|
0xD, 0x00, 0x3D, 0x3c,
|
||||||
0xD, 0x09, 0x1B, 0x3c,
|
0xD, 0x09, 0x1B, 0x3c,
|
||||||
|
@ -34,6 +42,8 @@ static const unsigned char paused_palette[]={
|
||||||
#pragma bss-name(push,"ZEROPAGE")
|
#pragma bss-name(push,"ZEROPAGE")
|
||||||
#pragma data-name(push,"ZEROPAGE")
|
#pragma data-name(push,"ZEROPAGE")
|
||||||
|
|
||||||
|
unsigned char oam_off;
|
||||||
|
|
||||||
static unsigned char i, j;
|
static unsigned char i, j;
|
||||||
|
|
||||||
static unsigned char player_dir[2];
|
static unsigned char player_dir[2];
|
||||||
|
@ -2823,7 +2833,7 @@ void __fastcall__ reset(void){
|
||||||
void main(void){
|
void main(void){
|
||||||
init();
|
init();
|
||||||
|
|
||||||
music_play(0);
|
// music_play(0);
|
||||||
oam_clear();
|
oam_clear();
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
;;;;; NES CARTRIDGE HEADER
|
;;;;; NES CARTRIDGE HEADER
|
||||||
|
|
||||||
NES_HEADER 0,2,1,0 ; mapper 0, 2 PRGs, 1 CHR, vertical
|
NES_HEADER 0,2,1,0 ; mapper 0, 2 PRGs, 1 CHR, horiz. mirror
|
||||||
|
|
||||||
;;;;; START OF CODE
|
;;;;; START OF CODE
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ HelloVRAM: subroutine
|
||||||
bne .loop ; loop
|
bne .loop ; loop
|
||||||
.end
|
.end
|
||||||
rts ; return to caller
|
rts ; return to caller
|
||||||
|
3
|
||||||
; ASCII message to display on screen
|
; ASCII message to display on screen
|
||||||
HelloMsg:
|
HelloMsg:
|
||||||
.byte "Hello, World!"
|
.byte "Hello, World!"
|
||||||
|
|
|
@ -6,11 +6,8 @@
|
||||||
seg.u RAM
|
seg.u RAM
|
||||||
org $0
|
org $0
|
||||||
|
|
||||||
ScrollPos byte ; used during NMI
|
ScrollX byte ; used during NMI
|
||||||
Rand byte
|
ScrollY byte ; used during NMI
|
||||||
Temp1 byte
|
|
||||||
|
|
||||||
SpriteBuf equ $200
|
|
||||||
|
|
||||||
;;;;; NES CARTRIDGE HEADER
|
;;;;; NES CARTRIDGE HEADER
|
||||||
|
|
||||||
|
@ -27,7 +24,6 @@ Start:
|
||||||
jsr SetPalette ;set colors
|
jsr SetPalette ;set colors
|
||||||
jsr FillVRAM ;set PPU RAM
|
jsr FillVRAM ;set PPU RAM
|
||||||
jsr WaitSync ;wait for VSYNC (and PPU warmup)
|
jsr WaitSync ;wait for VSYNC (and PPU warmup)
|
||||||
jsr InitSprites
|
|
||||||
lda #0
|
lda #0
|
||||||
sta PPU_ADDR
|
sta PPU_ADDR
|
||||||
sta PPU_ADDR ;PPU addr = 0
|
sta PPU_ADDR ;PPU addr = 0
|
||||||
|
@ -55,33 +51,6 @@ FillVRAM: subroutine
|
||||||
bne .loop
|
bne .loop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;
|
|
||||||
InitSprites: subroutine
|
|
||||||
lda #1
|
|
||||||
ldx #0
|
|
||||||
.loop
|
|
||||||
sta SpriteBuf,x
|
|
||||||
jsr NextRandom
|
|
||||||
inx
|
|
||||||
bne .loop
|
|
||||||
rts
|
|
||||||
|
|
||||||
;
|
|
||||||
MoveSprites: subroutine
|
|
||||||
lda #1
|
|
||||||
ldx #0
|
|
||||||
.loop
|
|
||||||
sta Temp1
|
|
||||||
and #3
|
|
||||||
clc
|
|
||||||
adc SpriteBuf,x
|
|
||||||
sta SpriteBuf,x
|
|
||||||
lda Temp1
|
|
||||||
jsr NextRandom
|
|
||||||
inx
|
|
||||||
bne .loop
|
|
||||||
rts
|
|
||||||
|
|
||||||
; set palette colors
|
; set palette colors
|
||||||
|
|
||||||
SetPalette: subroutine
|
SetPalette: subroutine
|
||||||
|
@ -107,21 +76,34 @@ SetPalette: subroutine
|
||||||
|
|
||||||
NMIHandler:
|
NMIHandler:
|
||||||
SAVE_REGS
|
SAVE_REGS
|
||||||
; load sprites
|
|
||||||
lda #$02
|
|
||||||
sta PPU_OAM_DMA
|
|
||||||
; update scroll position (must be done after VRAM updates)
|
; update scroll position (must be done after VRAM updates)
|
||||||
inc ScrollPos
|
jsr ReadJoypad
|
||||||
lda ScrollPos
|
pha
|
||||||
|
and #$03
|
||||||
|
tay
|
||||||
|
lda ScrollDirTab,y
|
||||||
|
clc
|
||||||
|
adc ScrollX
|
||||||
|
sta ScrollX
|
||||||
sta PPU_SCROLL
|
sta PPU_SCROLL
|
||||||
lda #0
|
pla
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
and #$03
|
||||||
|
tay
|
||||||
|
lda ScrollDirTab,y
|
||||||
|
clc
|
||||||
|
adc ScrollY
|
||||||
|
sta ScrollY
|
||||||
sta PPU_SCROLL
|
sta PPU_SCROLL
|
||||||
; move sprites
|
|
||||||
jsr MoveSprites
|
|
||||||
; reload registers
|
; reload registers
|
||||||
RESTORE_REGS
|
RESTORE_REGS
|
||||||
rti
|
rti
|
||||||
|
|
||||||
|
; Scroll direction lookup table
|
||||||
|
ScrollDirTab:
|
||||||
|
hex 00 01 ff 00
|
||||||
|
|
||||||
;;;;; CONSTANT DATA
|
;;;;; CONSTANT DATA
|
||||||
|
|
||||||
align $100
|
align $100
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
//#link "jroatch.c"
|
// link the pattern table into CHR ROM
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
//#link "chr_generic.s"
|
||||||
#define TILESET jroatch_chr
|
|
||||||
|
|
||||||
//#link "famitone2.s"
|
//#link "famitone2.s"
|
||||||
void __fastcall__ famitone_update(void);
|
void __fastcall__ famitone_update(void);
|
||||||
|
@ -16,9 +15,6 @@ extern char demo_sounds[];
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
//copy tileset to RAM
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)TILESET, sizeof(TILESET));
|
|
||||||
pal_col(1,0x04);
|
pal_col(1,0x04);
|
||||||
pal_col(2,0x20);
|
pal_col(2,0x20);
|
||||||
pal_col(3,0x30);
|
pal_col(3,0x30);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,18 +3,13 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// include NESLIB header
|
// include NESLIB header
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
// include CC65 NES Header (PPU)
|
// include CC65 NES Header (PPU)
|
||||||
|
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
|
||||||
///// PATTERN TABLE
|
// link the pattern table into CHR ROM
|
||||||
|
//#link "chr_generic.s"
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
///// METASPRITES
|
///// METASPRITES
|
||||||
|
|
||||||
|
@ -79,9 +74,6 @@ const char PALETTE[32] = {
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
void setup_graphics() {
|
void setup_graphics() {
|
||||||
// set pattern table
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
// clear sprites
|
// clear sprites
|
||||||
oam_hide_rest(0);
|
oam_hide_rest(0);
|
||||||
// set palette colors
|
// set palette colors
|
||||||
|
|
|
@ -3,18 +3,13 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// include NESLIB header
|
// include NESLIB header
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
// include CC65 NES Header (PPU)
|
// include CC65 NES Header (PPU)
|
||||||
|
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
|
||||||
///// PATTERN TABLE
|
// link the pattern table into CHR ROM
|
||||||
|
//#link "chr_generic.s"
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
///// METASPRITES
|
///// METASPRITES
|
||||||
|
|
||||||
|
@ -79,9 +74,6 @@ const char PALETTE[32] = {
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
void setup_graphics() {
|
void setup_graphics() {
|
||||||
// set pattern table
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
// clear sprites
|
// clear sprites
|
||||||
oam_clear();
|
oam_clear();
|
||||||
// set palette colors
|
// set palette colors
|
||||||
|
|
|
@ -12,10 +12,10 @@ FT_TEMP ds 3 ;3 bytes in zeropage used by the library as a scratchpad
|
||||||
FT_BASE_ADR = $0500 ;page in the RAM used for FT2 variables, should be $xx00
|
FT_BASE_ADR = $0500 ;page in the RAM used for FT2 variables, should be $xx00
|
||||||
FT_DPCM_OFF = DMCSamples ;$c000..$ffc0, 64-byte steps
|
FT_DPCM_OFF = DMCSamples ;$c000..$ffc0, 64-byte steps
|
||||||
FT_SFX_STREAMS = 4 ;number of sound effects played at once, 1..4
|
FT_SFX_STREAMS = 4 ;number of sound effects played at once, 1..4
|
||||||
FT_DPCM_ENABLE = 1 ;undefine to exclude all DMC code
|
;FT_DPCM_ENABLE = 1 ;undefine to exclude all DMC code
|
||||||
FT_SFX_ENABLE = 1 ;undefine to exclude all sound effects code
|
FT_SFX_ENABLE = 1 ;undefine to exclude all sound effects code
|
||||||
;FT_THREAD = 1 ;undefine if you are calling sound effects from the same thread as the sound update call
|
;FT_THREAD = 1 ;undefine if you are calling sound effects from the same thread as the sound update call
|
||||||
;FT_PAL_SUPPORT = 1 ;undefine to exclude PAL support
|
FT_PAL_SUPPORT = 1 ;undefine to exclude PAL support
|
||||||
FT_NTSC_SUPPORT = 1 ;undefine to exclude NTSC support
|
FT_NTSC_SUPPORT = 1 ;undefine to exclude NTSC support
|
||||||
|
|
||||||
;;;;; NES CARTRIDGE HEADER
|
;;;;; NES CARTRIDGE HEADER
|
||||||
|
@ -52,6 +52,7 @@ Start:
|
||||||
ldy #>music_data
|
ldy #>music_data
|
||||||
lda PPU_STATUS
|
lda PPU_STATUS
|
||||||
and #$80 ;NTSC_MODE
|
and #$80 ;NTSC_MODE
|
||||||
|
eor #$80
|
||||||
jsr FamiToneInit
|
jsr FamiToneInit
|
||||||
lda #0
|
lda #0
|
||||||
jsr FamiToneMusicPlay
|
jsr FamiToneMusicPlay
|
||||||
|
|
|
@ -22,6 +22,9 @@ APU_DMC_CTRL = $4010
|
||||||
APU_CHAN_CTRL = $4015
|
APU_CHAN_CTRL = $4015
|
||||||
APU_FRAME = $4017
|
APU_FRAME = $4017
|
||||||
|
|
||||||
|
JOYPAD1 = $4016
|
||||||
|
JOYPAD2 = $4017
|
||||||
|
|
||||||
; NOTE: I've put this outside of the PPU & APU, because it is a feature
|
; NOTE: I've put this outside of the PPU & APU, because it is a feature
|
||||||
; of the APU that is primarily of use to the PPU.
|
; of the APU that is primarily of use to the PPU.
|
||||||
OAM_DMA = $4014
|
OAM_DMA = $4014
|
||||||
|
@ -139,7 +142,7 @@ NES_MIRR_QUAD = 8
|
||||||
pha
|
pha
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
;;;;; SAVE_REGS - restore Y/X/A registers
|
;;;;; RESTORE_REGS - restore Y/X/A registers
|
||||||
|
|
||||||
MAC RESTORE_REGS
|
MAC RESTORE_REGS
|
||||||
pla
|
pla
|
||||||
|
|
|
@ -2,12 +2,8 @@
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// link the pattern table into PRG ROM
|
// link the pattern table into CHR ROM
|
||||||
// we'll write it into CHR RAM on startup
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
// function to write a string into the name table
|
// function to write a string into the name table
|
||||||
// adr = start address in name table
|
// adr = start address in name table
|
||||||
|
@ -19,10 +15,6 @@ void put_str(unsigned int adr, const char *str) {
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// copy pattern table to PRG RAM
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
|
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(1,0x04);
|
pal_col(1,0x04);
|
||||||
pal_col(2,0x20);
|
pal_col(2,0x20);
|
||||||
|
|
|
@ -42,3 +42,20 @@ PrevRandom subroutine
|
||||||
.NoEor:
|
.NoEor:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;;;;; CONTROLLER READING
|
||||||
|
|
||||||
|
ReadJoypad subroutine
|
||||||
|
lda #$01
|
||||||
|
sta JOYPAD1 ; set strobe bit
|
||||||
|
tax ; X = 1
|
||||||
|
lsr ; now A is 0
|
||||||
|
sta JOYPAD1 ; clear strobe bit
|
||||||
|
.loop:
|
||||||
|
lda JOYPAD1 ; load controller state
|
||||||
|
lsr ; bit 0 -> carry
|
||||||
|
txa ; X -> A
|
||||||
|
rol ; carry -> bit 0 of result, bit 7 -> carry
|
||||||
|
tax ; A -> X
|
||||||
|
bcc .loop ; repeat until 1 shifted out
|
||||||
|
rts ; controller bits returned in A
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
include "nesdefs.asm"
|
include "nesdefs.asm"
|
||||||
|
|
||||||
;;;;; ZERO-PAGE VARIABLES
|
;;;;; ZERO-PAGE VARIABLES
|
||||||
|
|
|
@ -2,12 +2,8 @@
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// link the pattern table into PRG ROM
|
// link the pattern table into CHR ROM
|
||||||
// we'll write it into CHR RAM on startup
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
// function to write a string into the name table
|
// function to write a string into the name table
|
||||||
// adr = start address in name table
|
// adr = start address in name table
|
||||||
|
@ -38,10 +34,6 @@ void scroll_demo() {
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// copy pattern table to PRG RAM
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
|
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(1,0x04);
|
pal_col(1,0x04);
|
||||||
pal_col(2,0x20);
|
pal_col(2,0x20);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
//#link "jroatch.c"
|
// link the pattern table into CHR ROM
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
//#link "chr_generic.s"
|
||||||
#define TILESET jroatch_chr
|
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
//copy tileset to RAM
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)TILESET, sizeof(TILESET));
|
|
||||||
pal_col(1,0x04);
|
pal_col(1,0x04);
|
||||||
pal_col(2,0x20);
|
pal_col(2,0x20);
|
||||||
pal_col(3,0x30);
|
pal_col(3,0x30);
|
||||||
|
|
|
@ -3,18 +3,13 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// include NESLIB header
|
// include NESLIB header
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
// include CC65 NES Header (PPU)
|
// include CC65 NES Header (PPU)
|
||||||
|
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
|
||||||
///// PATTERN TABLE
|
// link the pattern table into CHR ROM
|
||||||
|
//#link "chr_generic.s"
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
|
|
||||||
const char PALETTE[32] = {
|
const char PALETTE[32] = {
|
||||||
|
@ -33,9 +28,6 @@ const char PALETTE[32] = {
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
void setup_graphics() {
|
void setup_graphics() {
|
||||||
// set pattern table
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
// clear sprites
|
// clear sprites
|
||||||
oam_clear();
|
oam_clear();
|
||||||
// set palette colors
|
// set palette colors
|
||||||
|
|
|
@ -5,12 +5,8 @@
|
||||||
// vertical mirroring (horizontal scroling)
|
// vertical mirroring (horizontal scroling)
|
||||||
#define NES_MIRRORING 1
|
#define NES_MIRRORING 1
|
||||||
|
|
||||||
// link the pattern table into PRG ROM
|
// link the pattern table into CHR ROM
|
||||||
// we'll write it into CHR RAM on startup
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
//#link "jroatch.c"
|
|
||||||
extern unsigned char jroatch_chr[0x1000];
|
|
||||||
#define PATTERN_TABLE jroatch_chr
|
|
||||||
|
|
||||||
// function to write a string into the name table
|
// function to write a string into the name table
|
||||||
// adr = start address in name table
|
// adr = start address in name table
|
||||||
|
@ -40,10 +36,6 @@ void scroll_demo() {
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// copy pattern table to PRG RAM
|
|
||||||
vram_adr(0x0);
|
|
||||||
vram_write((unsigned char*)PATTERN_TABLE, sizeof(PATTERN_TABLE));
|
|
||||||
|
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(0,0x00);
|
pal_col(0,0x00);
|
||||||
pal_col(1,0x04);
|
pal_col(1,0x04);
|
||||||
|
|
|
@ -7,7 +7,8 @@ const unsigned char palSprites[16]={/*{pal:"nes",n:4,sets:4}*/
|
||||||
0x0f,0x19,0x29,0x39
|
0x0f,0x19,0x29,0x39
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char TILESET[8*256] = {/*{w:8,h:8,bpp:1,count:256,brev:1,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}*/
|
const unsigned char TILESET[8*256] = {
|
||||||
|
/*{w:8,h:8,bpp:1,count:256,brev:1,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}*/
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x7c,0x7c,0x7c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x6c,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0xfe,0x6c,0xfe,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xfe,0xd0,0xfe,0x16,0xfe,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xdc,0x38,0x76,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6c,0x7c,0xec,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x70,0x70,0x70,0x70,0x70,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x38,0x38,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x38,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0xfe,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x1e,0x3c,0x78,0xf0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x7c,0x7c,0x7c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x6c,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0xfe,0x6c,0xfe,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xfe,0xd0,0xfe,0x16,0xfe,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xdc,0x38,0x76,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6c,0x7c,0xec,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x70,0x70,0x70,0x70,0x70,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x38,0x38,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x38,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0xfe,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x1e,0x3c,0x78,0xf0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x78,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x0e,0x7c,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x0e,0x3c,0x0e,0x0e,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x7e,0xee,0xee,0xfe,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xe0,0xfc,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xfc,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xee,0x1c,0x1c,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x7c,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0x7e,0x0e,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x38,0x70,0x70,0x38,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x1c,0x1c,0x38,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x1c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x78,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x0e,0x7c,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x0e,0x3c,0x0e,0x0e,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x7e,0xee,0xee,0xfe,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xe0,0xfc,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xfc,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xee,0x1c,0x1c,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x7c,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0x7e,0x0e,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x38,0x70,0x70,0x38,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x1c,0x1c,0x38,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x1c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x7c,0xee,0xee,0xee,0xe0,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xfe,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xee,0xfc,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xe0,0xe0,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xec,0xee,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf0,0xe0,0xe0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf8,0xe0,0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xee,0xee,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xfe,0xee,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x38,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x0e,0x0e,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xfc,0xf8,0xec,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,0xee,0xfe,0xfe,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xee,0xfe,0xfe,0xee,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x7c,0xee,0xee,0xee,0xe0,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xfe,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xee,0xfc,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xe0,0xe0,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xec,0xee,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf0,0xe0,0xe0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf8,0xe0,0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xee,0xee,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xfe,0xee,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x38,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x0e,0x0e,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xfc,0xf8,0xec,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,0xee,0xfe,0xfe,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xee,0xfe,0xfe,0xee,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
|
|
||||||
//this example code shows how to put some text in nametable
|
//this example code shows how to put some text in nametable
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#pragma data-name (push,"CHARS")
|
||||||
|
#pragma data-name(pop)
|
||||||
|
|
||||||
const unsigned char TILESET[48*16] = {/*{w:8,h:8,bpp:1,count:48,brev:1,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}*/
|
const unsigned char TILESET[48*16] = {/*{w:8,h:8,bpp:1,count:48,brev:1,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]}*/
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x7e,0x42,0x42,0x46,0x46,0x46,0x7e,0x00,0x7e,0x42,0x42,0x46,0x46,0x46,0x7e,0x00,
|
0x7e,0x42,0x42,0x46,0x46,0x46,0x7e,0x00,0x7e,0x42,0x42,0x46,0x46,0x46,0x7e,0x00,
|
||||||
|
|
|
@ -538,7 +538,7 @@ function _downloadAllFilesZipFile(e) {
|
||||||
// TODO: handle binary files
|
// TODO: handle binary files
|
||||||
store.getItem(path, (err, text) => {
|
store.getItem(path, (err, text) => {
|
||||||
if (text) {
|
if (text) {
|
||||||
zip.file(fixFilename(getFilenameForPath(path)), text);
|
zip.file(fixFilename(path), text);
|
||||||
}
|
}
|
||||||
if (++count == keys.length) {
|
if (++count == keys.length) {
|
||||||
zip.generateAsync({type:"blob"}).then( (content) => {
|
zip.generateAsync({type:"blob"}).then( (content) => {
|
||||||
|
|
|
@ -126,9 +126,9 @@ var PLATFORM_PARAMS = {
|
||||||
define: '__NES__',
|
define: '__NES__',
|
||||||
cfgfile: 'neslib.cfg',
|
cfgfile: 'neslib.cfg',
|
||||||
libargs: ['crt0.o', 'nes.lib',
|
libargs: ['crt0.o', 'nes.lib',
|
||||||
'-D', 'NES_MAPPER=2', // UxROM
|
'-D', 'NES_MAPPER=0', // UxROM
|
||||||
'-D', 'NES_PRG_BANKS=2', // 2 PRG banks
|
'-D', 'NES_PRG_BANKS=2', // 2 PRG banks
|
||||||
'-D', 'NES_CHR_BANKS=0', // TODO: >0 doesn't seem to work
|
'-D', 'NES_CHR_BANKS=1', // 1 CHR bank
|
||||||
'-D', 'NES_MIRRORING=0', // horizontal mirroring
|
'-D', 'NES_MIRRORING=0', // horizontal mirroring
|
||||||
],
|
],
|
||||||
extra_link_files: ['crt0.o'],
|
extra_link_files: ['crt0.o'],
|
||||||
|
@ -876,13 +876,30 @@ function linkLD65(step:BuildStep) {
|
||||||
return;
|
return;
|
||||||
// parse symbol map (TODO: omit segments, constants)
|
// parse symbol map (TODO: omit segments, constants)
|
||||||
var symbolmap = {};
|
var symbolmap = {};
|
||||||
|
var seg_re = /^__(\w+)_SIZE__$/;
|
||||||
for (var s of viceout.split("\n")) {
|
for (var s of viceout.split("\n")) {
|
||||||
var toks = s.split(" ");
|
var toks = s.split(" ");
|
||||||
if (toks[0] == 'al') {
|
if (toks[0] == 'al') {
|
||||||
symbolmap[toks[2].substr(1)] = parseInt(toks[1], 16);
|
let ident = toks[2].substr(1);
|
||||||
|
let ofs = parseInt(toks[1], 16);
|
||||||
|
symbolmap[ident] = ofs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: "of" in IE?
|
// build segment map
|
||||||
|
var segments = {};
|
||||||
|
for (let ident in symbolmap) {
|
||||||
|
let m = seg_re.exec(ident);
|
||||||
|
if (m) {
|
||||||
|
let seg = m[1];
|
||||||
|
let segstart = symbolmap['__'+seg+'_RUN__'] || symbolmap['__'+seg+'_START__'];
|
||||||
|
let segsize = symbolmap['__'+seg+'_SIZE__'];
|
||||||
|
let seglast = symbolmap['__'+seg+'_LAST__'];
|
||||||
|
if (segstart >= 0 && segsize > 0) {
|
||||||
|
segments[seg] = {start:segstart, size:segsize, last:seglast};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// build listings
|
||||||
var listings = {};
|
var listings = {};
|
||||||
for (var fn of step.files) {
|
for (var fn of step.files) {
|
||||||
if (fn.endsWith('.lst')) {
|
if (fn.endsWith('.lst')) {
|
||||||
|
@ -902,6 +919,7 @@ function linkLD65(step:BuildStep) {
|
||||||
listings:listings,
|
listings:listings,
|
||||||
errors:errors,
|
errors:errors,
|
||||||
symbolmap:symbolmap,
|
symbolmap:symbolmap,
|
||||||
|
segments:segments
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user