Skip to content

Commit

Permalink
Offset APU buffer depending on configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumball2415 committed Dec 3, 2023
1 parent 0df2a35 commit 5b53ab2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nes/src/mdfourier.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ test_subtype = test_state+4
test_lastpulsehi = test_state+5
test_good_phase = test_state+6

apu_addressbuf = $0104
apu_databuf = $0120
.ifdef FDSHEADER
FDS_OFFSET = 4
.else
FDS_OFFSET = 0
.endif

apu_addressbuf = $0100 + FDS_OFFSET
apu_databuf = $0120 + FDS_OFFSET

; FDS code and mapper configuration by Persune 2023
; with code from Brad Smith 2021
Expand Down
7 changes: 7 additions & 0 deletions nes/src/mdfourier4kfe.s
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ test_good_phase := test_state+6
sta $0102
lda #$AC
sta $0103
; we can't use $0103 for cold boot check because this routine clobbers it
lda #1
sta coldboot_check
; reset the FDS to begin our program properly
Expand Down Expand Up @@ -235,10 +236,14 @@ irq_handler:
bit $4015 ; ack some IRQs
lda #$40
sta $4017 ; disable frame counter IRQ

.ifndef FDSHEADER
bit PPUSTATUS ; ack vblank NMI
vwait1:
bit PPUSTATUS ; wait for first warmup vblank
bpl vwait1
.endif

txa
:
sta $00,x ; clear zero page
Expand Down Expand Up @@ -283,9 +288,11 @@ irq_handler:
bne :-
.endif

.ifndef FDSHEADER
vwait2:
bit PPUSTATUS ; wait for second warmup vblank
bpl vwait2
.endif

; due to FDS BIOS using the triangle, the phase is trash on cold boot
.ifdef FDSHEADER
Expand Down

0 comments on commit 5b53ab2

Please sign in to comment.