Skip to content

Commit

Permalink
show ROM size in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed Dec 24, 2017
1 parent 85c14e3 commit 504401a
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 55 deletions.
4 changes: 2 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* pentlyas.py: output lists each song's total size in comments
* Add "Isometry" song demonstrating attack track more thoroughly
* makefile: change score filename
* NES shell: move credit line to status bar
* NES shell: profiler shows current and peak CPU usage
* NES shell: move copyright notice to status bar
* NES shell: status shows ROM size and current and peak CPU usage
* NES/NSF executables no longer in Git; will be in releases instead

0.05wip7 (2017-09)
Expand Down
123 changes: 71 additions & 52 deletions src/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
.import getTVSystem
.importzp NUM_SONGS

; Size diagnostics
.import periodTableHi, periodTableLo
PERIOD_SIZE = (periodTableHi - periodTableLo) * 2
PENTLY_SIZE = PENTLYMUSIC_SIZE + PENTLYSOUND_SIZE + PERIOD_SIZE

.segment "ZEROPAGE"
nmis: .res 1
oam_used: .res 1
Expand All @@ -47,6 +52,7 @@ STATUS_BAR_TOP = 24
STATUS_BAR_ADDR = $2000 + 32 * STATUS_BAR_TOP
BEAT_POS_ADDR = STATUS_BAR_ADDR + 32 * 1 + 2
CYCLES_ADDR = STATUS_BAR_ADDR + 32 * 1 + 25
ROM_SIZE_ADDR = STATUS_BAR_ADDR + 32 * 2 + 2
WORD_PEAK_ADDR = STATUS_BAR_ADDR + 32 * 2 + 21
PEAK_ADDR = WORD_PEAK_ADDR + 4

Expand Down Expand Up @@ -126,20 +132,6 @@ PEAK_ADDR = WORD_PEAK_ADDR + 4
sta cyclespeaklo

; Present one frame with only sprite 0 to prime the profiler

lda #>WORD_PEAK_ADDR
sta PPUADDR
lda #<WORD_PEAK_ADDR
sta PPUADDR
lda #'P'
sta PPUDATA
lda #'e'
sta PPUDATA
lda #'a'
sta PPUDATA
lda #'k'
sta PPUDATA

lda #4
sta oam_used

Expand Down Expand Up @@ -274,6 +266,54 @@ forever:
jmp forever
.endproc


.proc puts_multiline_ay
src = $00
dst = $02
sta src+1
sty src+0
lineloop:
ldy dst+1
sty PPUADDR
ldy dst+0
sty PPUADDR
ldy #0
charloop:
lda (src),y
beq done
cmp #$0A
beq is_newline
sta PPUDATA
iny
bne charloop
is_newline:

; Add Y (length before newline) plus 1 to text pointer
;sec ; CMP already set carry
tya
adc src
sta src
lda src+1
adc #0
sta src+1
lda dst
adc #32
sta dst
lda dst+1
adc #0
sta dst+1

; crop to the status bar top
; (things below it are limited to 1 line tall)
lda dst+0
cmp #<STATUS_BAR_ADDR
lda dst+1
sbc #>STATUS_BAR_ADDR
bcc lineloop
done:
rts
.endproc

.proc display_todo
lda #VBLANK_NMI
ldx #$00
Expand All @@ -300,47 +340,17 @@ dst = $02
sta dst+0
lda #>TRACKNAMES_ADDR
sta dst+1
lda #<tracknames_txt
sta src+0
ldy #<tracknames_txt
lda #>tracknames_txt
sta src+1
todo_rowloop:
ldy dst+1
sty PPUADDR
ldy dst+0
sty PPUADDR
ldy #0
todo_charloop:
lda (src),y
beq todo_done
cmp #$0A
beq is_newline
sta PPUDATA
iny
bne todo_charloop
is_newline:
jsr puts_multiline_ay

sec
tya
adc src
sta src
lda src+1
adc #0
sta src+1
lda dst
adc #32
sta dst
lda dst+1
adc #0
lda #<ROM_SIZE_ADDR
sta dst+0
lda #>ROM_SIZE_ADDR
sta dst+1

; crop to the status bar top
lda dst+0
cmp #<STATUS_BAR_ADDR
lda dst+1
sbc #>STATUS_BAR_ADDR
bcc todo_rowloop
todo_done:
ldy #<bytes_txt
lda #>bytes_txt
jsr puts_multiline_ay

; Draw top of status bar
lda #>STATUS_BAR_ADDR
Expand Down Expand Up @@ -410,6 +420,15 @@ tracknames_txt:
.incbin "tracknames.txt"
.byt 0

bytes_txt:
.byt "ROM:"
.byt '0'|<((PENTLY_SIZE / 1000) .MOD 10)
.byt '0'|<((PENTLY_SIZE / 100) .MOD 10)
.byt '0'|<((PENTLY_SIZE / 10) .MOD 10)
.byt '0'|<((PENTLY_SIZE / 1) .MOD 10)
.byt " bytes Peak",0


main_palette:
.byt $0F,$00,$10,$30, $0F,$00,$10,$30, $0F,$00,$10,$30, $0F,$00,$10,$30
.byt $0F,$00,$10,$30, $0F,$00,$10,$30, $0F,$00,$10,$30, $0F,$00,$10,$30
Expand Down
3 changes: 3 additions & 0 deletions src/pently.inc
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,6 @@ PENTLY_USE_BPMMATH = 1
.globalzp pently_tempoCounterLo, pently_tempoCounterHi

.global pently_fpmLo, pently_fpmHi

; Size (for debugging) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.global PENTLYSOUND_SIZE, PENTLYMUSIC_SIZE
13 changes: 12 additions & 1 deletion src/pentlymusic.s
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ pentlymusicbase: .res pentlymusicbase_size
.endif

.segment PENTLY_RODATA
pentlymusic_rodata_start = *

FRAMES_PER_MINUTE_PAL = 3000
FRAMES_PER_MINUTE_NTSC = 3606
pently_fpmLo:
Expand All @@ -154,6 +156,8 @@ porta1x_rates_hi:
.endif

.segment PENTLY_CODE
pentlymusic_code_start = *

.proc pently_start_music
asl a
tax
Expand Down Expand Up @@ -1321,4 +1325,11 @@ is_decrease:
bcc at_target
.endproc

.endif
.endif


.segment PENTLY_RODATA
pentlymusic_rodata_size = * - pentlymusic_rodata_start
.segment PENTLY_CODE
pentlymusic_code_size = * - pentlymusic_code_start
PENTLYMUSIC_SIZE = pentlymusic_rodata_size + pentlymusic_code_size
2 changes: 2 additions & 0 deletions src/pentlysound.s
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ch_lastfreqhi = pentlyBSS + 2
sfx_remainlen = pentlyBSS + 3

.segment PENTLY_CODE
pentlysound_code_start = *

;;
; Initializes all sound channels.
Expand Down Expand Up @@ -294,3 +295,4 @@ no_change_to_hi_period:
rts
.endproc

PENTLYSOUND_SIZE = * - pentlysound_code_start

0 comments on commit 504401a

Please sign in to comment.