1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00

nes: updates

This commit is contained in:
Steven Hugg 2019-05-13 18:36:25 -04:00
parent e5c50d2a9e
commit 070a67a917
6 changed files with 52 additions and 49 deletions

View File

@ -138,6 +138,7 @@ TODO:
- target ES6 - target ES6
- don't have to include bootstrap-tourist each time? - don't have to include bootstrap-tourist each time?
- don't have to include firebase always? - don't have to include firebase always?
- build ca65 projects w/ no crt0? https://github.com/pinobatch/thwaite-nes/blob/master/makefile
- Github - Github
- gh-pages branch with embedded - gh-pages branch with embedded
- handle overwrite logic - handle overwrite logic
@ -152,8 +153,6 @@ TODO:
- don't import useless files - don't import useless files
- support projects with subdirectories, file list? - support projects with subdirectories, file list?
- emulator needs reset shortcut for nes - emulator needs reset shortcut for nes
- local/ files in repository?
- build ca65 projects w/ no crt0? https://github.com/pinobatch/thwaite-nes/blob/master/makefile
- switching platform of a repo? - switching platform of a repo?

View File

@ -369,12 +369,8 @@ typedef struct Actor {
int pal:2; // palette color (2 bits) int pal:2; // palette color (2 bits)
int dir:1; // direction (0=right, 1=left) int dir:1; // direction (0=right, 1=left)
int onscreen:1; // is actor onscreen? int onscreen:1; // is actor onscreen?
union { sbyte yvel; // Y velocity (when jumping)
struct { // when jumping... sbyte xvel; // X velocity (when jumping)
sbyte yvel; // Y velocity
sbyte xvel; // X velocity
} jumping;
} u;
} Actor; } Actor;
Actor actors[MAX_ACTORS]; Actor actors[MAX_ACTORS];
@ -509,8 +505,8 @@ void check_scroll_down() {
void fall_down(struct Actor* actor) { void fall_down(struct Actor* actor) {
actor->floor--; actor->floor--;
actor->state = FALLING; actor->state = FALLING;
actor->u.jumping.xvel = 0; actor->xvel = 0;
actor->u.jumping.yvel = 0; actor->yvel = 0;
} }
void move_actor(struct Actor* actor, byte joystick, bool scroll) { void move_actor(struct Actor* actor, byte joystick, bool scroll) {
@ -521,10 +517,10 @@ void move_actor(struct Actor* actor, byte joystick, bool scroll) {
// left/right has priority over climbing // left/right has priority over climbing
if (joystick & PAD_A) { if (joystick & PAD_A) {
actor->state = JUMPING; actor->state = JUMPING;
actor->u.jumping.xvel = 0; actor->xvel = 0;
actor->u.jumping.yvel = JUMP_VELOCITY; actor->yvel = JUMP_VELOCITY;
if (joystick & PAD_LEFT) actor->u.jumping.xvel = -1; if (joystick & PAD_LEFT) actor->xvel = -1;
if (joystick & PAD_RIGHT) actor->u.jumping.xvel = 1; if (joystick & PAD_RIGHT) actor->xvel = 1;
// play sound for player // play sound for player
if (scroll) sfx_play(SND_JUMP,0); if (scroll) sfx_play(SND_JUMP,0);
} else if (joystick & PAD_LEFT) { } else if (joystick & PAD_LEFT) {
@ -575,9 +571,9 @@ void move_actor(struct Actor* actor, byte joystick, bool scroll) {
check_scroll_down(); check_scroll_down();
} }
case JUMPING: case JUMPING:
actor->x += actor->u.jumping.xvel; actor->x += actor->xvel;
actor->yy += actor->u.jumping.yvel/4; actor->yy += actor->yvel/4;
actor->u.jumping.yvel -= 1; actor->yvel -= 1;
if (actor->yy <= get_floor_yy(actor->floor)) { if (actor->yy <= get_floor_yy(actor->floor)) {
actor->yy = get_floor_yy(actor->floor); actor->yy = get_floor_yy(actor->floor);
actor->state = STANDING; actor->state = STANDING;

View File

@ -278,7 +278,7 @@ SetPalette: subroutine
bne .loop bne .loop
rts rts
; set sprite 0 ; set sprite 0 (A = top scanline)
SetSprite0: subroutine SetSprite0: subroutine
sta $200 ;ypos sta $200 ;ypos
lda #$00 ;code lda #$00 ;code
@ -313,6 +313,10 @@ SetSprite0: subroutine
REPEND REPEND
ENDM ENDM
;;;
;;; NMI HANDLER
;;;
NMIHandler: subroutine NMIHandler: subroutine
; save registers ; save registers
SAVE_REGS SAVE_REGS
@ -325,11 +329,11 @@ NMIHandler: subroutine
PPU_SETADDR $2000 ; reset PPU address PPU_SETADDR $2000 ; reset PPU address
; load sprite zero ; load sprite zero
lda #109 lda #109
jsr SetSprite0 jsr SetSprite0 ; set sprite 0 position
lda #$02 lda #$02
sta PPU_OAM_DMA sta PPU_OAM_DMA ; send sprites to PPU
; setup sky scroll ; setup sky scroll
lda Heading+1 lda Heading+1 ; heading scroll pos.
sta PPU_SCROLL ; X scroll sta PPU_SCROLL ; X scroll
lda #0 lda #0
sta PPU_SCROLL ; Y scroll = 0 sta PPU_SCROLL ; Y scroll = 0
@ -339,27 +343,26 @@ NMIHandler: subroutine
jsr RoadPostFrame jsr RoadPostFrame
; wait for sprite 0 ; wait for sprite 0
.wait0 bit PPU_STATUS .wait0 bit PPU_STATUS
bvs .wait0 bvs .wait0 ; until bit 6 set
.wait1 bit PPU_STATUS .wait1 bit PPU_STATUS
bvc .wait1 bvc .wait1 ; until bit 6 clear
; alter horiz. scroll position for each scanline ; alter horiz. scroll position for each scanline
ldy #0 ldy #0
.loop .loop
; pad out rest of scanline ; pad out rest of scanline
SLEEP 78 SLEEP 80
; change scroll register ; change scroll register
tya tya ; Y -> A
lsr ; / 2 lsr ; A / 2
tax tax ; A -> X
lda RoadX0,x ; get X offset of scanline lda RoadX0,x ; get X offset of scanline
eor #$80 ; + 128 eor #$80 ; + 128
sta PPU_SCROLL ; horiz byte sta PPU_SCROLL ; horiz byte
lda #0 sta PPU_SCROLL ; vert byte (ignored)
sta PPU_SCROLL ; vert byte = 0 ; take back 1 cycle every 4th line
; take extra cycle every 4th line tya ; Y -> A
tya and #3 ; mask first 2 bits
and #3 bne .skipcyc ; -1 cycle every 4 lines
bne .skipcyc
.skipcyc .skipcyc
; next loop iteration ; next loop iteration
iny iny

View File

@ -6,8 +6,6 @@
seg.u ZEROPAGE seg.u ZEROPAGE
org $0 org $0
SkipY ds 1
;;;;; OTHER VARIABLES ;;;;; OTHER VARIABLES
seg.u RAM seg.u RAM
@ -97,21 +95,21 @@ NMIHandler: subroutine
sta PPU_OAM_DMA sta PPU_OAM_DMA
; wait for sprite 0 ; wait for sprite 0
.wait0 bit PPU_STATUS .wait0 bit PPU_STATUS
bvs .wait0 bvs .wait0 ; until bit 6 set
.wait1 bit PPU_STATUS .wait1 bit PPU_STATUS
bvc .wait1 bvc .wait1 ; until bit 6 clear
SLEEP 14
ldy #0 ldy #0
.loop .loop
; take out cycle every 4th line ; add two cycles every 6th line
tya lda Div3Table,y ; is non-zero?
and #3 bne .skipcyc ; branch adds +1 cycle
bne .skipcyc ; clks = 2/3/3/3
.skipcyc .skipcyc
; pad out rest of scanline ; pad out rest of scanline
SLEEP 65 SLEEP 66
; alter horiz. scroll position for each scanline ; alter horiz. scroll position for each scanline
tya tya
sec clc
adc LineXLo,y adc LineXLo,y
sta LineXLo,y sta LineXLo,y
lda LineXHi,y lda LineXHi,y
@ -122,14 +120,19 @@ NMIHandler: subroutine
sta PPU_SCROLL ; vert byte sta PPU_SCROLL ; vert byte
; next iteration of loop ; next iteration of loop
iny iny
cpy #112 cpy #112 ; out of lines?
bne .loop bne .loop ; no, repeat
RESTORE_REGS RESTORE_REGS
rti rti
;;;;; CONSTANT DATA ;;;;; CONSTANT DATA
align $100 align $100 ; align to page boundary
Div3Table:
REPEAT 38 ; repeat 3*38 times
.byte 0,1,1 ; repeating 0-1-1 bytes
REPEND ; end of repeat block
Palette: Palette:
hex 1f ;background hex 1f ;background
hex 09092c00 ;bg0 hex 09092c00 ;bg0

View File

@ -36,7 +36,7 @@ const JSNES_PRESETS = [
{id:'ex4.dasm', name:'Controller Demo (ASM)'}, {id:'ex4.dasm', name:'Controller Demo (ASM)'},
{id:'musicdemo.dasm', name:'Famitone Demo (ASM)'}, {id:'musicdemo.dasm', name:'Famitone Demo (ASM)'},
{id:'xyscroll.dasm', name:'XY Split Scrolling (ASM)'}, {id:'xyscroll.dasm', name:'XY Split Scrolling (ASM)'},
{id:'scrollrt.dasm', name:'Line-by-line Scrolling (ASM)'}, // {id:'scrollrt.dasm', name:'Line-by-line Scrolling (ASM)'},
{id:'road.dasm', name:'3-D Road Demo (ASM)'}, {id:'road.dasm', name:'3-D Road Demo (ASM)'},
{id:'chase/game.c', name:'Shiru\'s Chase Game'}, {id:'chase/game.c', name:'Shiru\'s Chase Game'},
]; ];

View File

@ -234,6 +234,8 @@ export class GithubService {
publish(reponame:string, desc:string, license:string, isprivate:boolean) : Promise<GHSession> { publish(reponame:string, desc:string, license:string, isprivate:boolean) : Promise<GHSession> {
var repo; var repo;
var platform_id = this.project.platform_id;
var mainPath = this.project.stripLocalPath(this.project.mainPath);
return this.github.user.repos.create({ return this.github.user.repos.create({
name: reponame, name: reponame,
description: desc, description: desc,
@ -246,9 +248,9 @@ export class GithubService {
// create README.md // create README.md
var s = README_md_template; var s = README_md_template;
s = s.replace(/\$NAME/g, encodeURIComponent(reponame)); s = s.replace(/\$NAME/g, encodeURIComponent(reponame));
s = s.replace(/\$PLATFORM/g, encodeURIComponent(this.project.platform_id)); s = s.replace(/\$PLATFORM/g, encodeURIComponent(platform_id));
s = s.replace(/\$GITHUBURL/g, encodeURIComponent(repo.html_url)); s = s.replace(/\$GITHUBURL/g, encodeURIComponent(repo.html_url));
s = s.replace(/\$MAINFILE/g, encodeURIComponent(this.project.stripLocalPath(this.project.mainPath))); s = s.replace(/\$MAINFILE/g, encodeURIComponent(mainPath));
var config = { var config = {
message: '8bitworkshop: updated metadata in README.md', message: '8bitworkshop: updated metadata in README.md',
content: btoa(s) content: btoa(s)