Skip to content

Commit 2cbbbe1

Browse files
committed
* Move postcard data to the PRG_XTRA bank.
This frees up title screen data for an eventual options menu.
1 parent 7ee43da commit 2cbbbe1

File tree

11 files changed

+134
-42
lines changed

11 files changed

+134
-42
lines changed
Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
; This module implements the Postcard at the beginning of each stage.
44
.include "lettersfx.asm"
5-
.include "lettergfx.asm"
5+
;.include "lettergfx.asm"
66

77
postcard_palette_black:
88
.byte $0f,$0f,$0f,$0f
@@ -73,13 +73,13 @@ postcard_setup_palette_request:
7373

7474
postcard_bitset: .byte $FF, $01, $02, $04, $08, $10, $20, $40, $80
7575

76-
; ** SUBROUTINE: postcard
76+
; ** SUBROUTINE: postcard_XTRA
7777
; desc: Initializes, shows the postcard screen, then fades out. The game fadein will be handled by the caller.
7878
; parameters:
7979
; levelnumber - The destination level number
80-
.proc postcard
80+
.proc postcard_XTRA
8181
ldy levelnumber
82-
lda postcard_lo, y
82+
lda postcard_hi, y
8383
bne @continue
8484
@returnEarly:
8585
rts
@@ -91,6 +91,10 @@ postcard_bitset: .byte $FF, $01, $02, $04, $08, $10, $20, $40, $80
9191
and sf_completed
9292
bne @returnEarly
9393

94+
; set the music bank to this one
95+
lda #prgb_xtra
96+
sta musicbank
97+
9498
; well, there is a postcard defined here, and we didn't yet finish the level, so do it
9599
lda #$FF
96100
sta p1_cont
@@ -111,31 +115,8 @@ postcard_bitset: .byte $FF, $01, $02, $04, $08, $10, $20, $40, $80
111115
; since we might have interrupted rendering, wait for vblank to prevent tearing
112116
jsr vblank_wait
113117

114-
; start loading screen data
115-
lda #$20
116-
sta ppu_addr
117-
lda #$00
118-
sta ppu_addr
119-
120-
;ldy levelnumber
121-
lda postcard_hi, y
122-
tax
123-
lda postcard_lo, y
124-
125-
jsr nexxt_rle_decompress
126-
127-
; clear the attribute table bytes as it seems that the RLE data doesn't do that
128-
lda #$23
129-
sta ppu_addr
130-
lda #$C0
131-
sta ppu_addr
132-
133-
ldy #64
134-
lda #0
135-
: sta ppu_data
136-
dey
137-
bne :-
138-
sty ow_slidetmr
118+
; load the post card graphics.
119+
jsr load_postcard_graphics
139120

140121
; also switch banks
141122
ldx #chrb_pcard
@@ -349,8 +330,39 @@ postcard_bitset: .byte $FF, $01, $02, $04, $08, $10, $20, $40, $80
349330
.endproc
350331

351332
; NOTE: The Prologue doesn't use a postcard.
352-
postcard_lo: .byte 0, <postcard_ch1, <postcard_ch2
353-
postcard_hi: .byte 0, >postcard_ch1, >postcard_ch2
333+
postcard_lo: .byte 0, <postcard_ch1, <postcard_ch2
334+
postcard_hi: .byte 0, >postcard_ch1, >postcard_ch2
354335
postcard_sfx_in: .byte 0, 9, 11
355336
postcard_sfx_out: .byte 0, 10, 12
356-
postcard_yp: .byte 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,4,4,5,6,7,8,9,10,12,13,15,16,18,20,22,24,26,29
337+
postcard_yp: .byte 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,4,4,5,6,7,8,9,10,12,13,15,16,18,20,22,24,26,29
338+
339+
; ** SUBROUTINE: load_postcard_graphics
340+
; desc: Loads the postcard graphics for the current level number (in 'levelnumber').
341+
.proc load_postcard_graphics
342+
; start loading screen data
343+
lda #$20
344+
sta ppu_addr
345+
lda #$00
346+
sta ppu_addr
347+
348+
ldy levelnumber
349+
lda postcard_hi, y
350+
tax
351+
lda postcard_lo, y
352+
jsr nexxt_rle_decompress_XTRA
353+
354+
; clear the attribute table bytes as it seems that the RLE data doesn't do that
355+
lda #$23
356+
sta ppu_addr
357+
lda #$C0
358+
sta ppu_addr
359+
360+
ldy #64
361+
lda #0
362+
: sta ppu_data
363+
dey
364+
bne :-
365+
sty ow_slidetmr
366+
367+
rts
368+
.endproc
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ speeds: .byte 12, 20
7373
; prepare the graphics and init the fade
7474
jsr soft_nmi_off
7575

76+
lda #prgb_xtra
77+
sta musicbank
78+
7679
ldx #<music_data_chapter_complete
7780
ldy #>music_data_chapter_complete
7881
lda #1 ; NTSC
@@ -107,7 +110,7 @@ speeds: .byte 12, 20
107110
lda level_end_gfx_hi, y
108111
tax
109112
lda level_end_gfx_lo, y
110-
jsr nexxt_rle_decompress
113+
jsr nexxt_rle_decompress_XTRA
111114

112115
; clear the other nametable to black, we'll need it that way.
113116
lda #$24

src/prg_ttle.asm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@
88
.include "title/prologue.asm"
99
.include "title/titlescr.asm"
1010
.include "title/mountain.asm"
11-
.include "title/letter.asm"
12-
.include "title/levelend.asm"
13-
.include "title/chcomp.asm"
11+
.include "title/helper.asm"

src/prg_xtra.asm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
.segment "PRG_XTRA"
44

5+
.include "extra/lettergfx.asm"
6+
.include "extra/levelend.asm"
7+
.include "extra/letter.asm"
8+
.include "extra/chcomp.asm"
59
.include "x_rmtran.asm"
6-
;.include "x_physic.asm"
7-
;.include "x_scroll.asm"
8-
;.include "x_entity.asm"
9-
10+
.include "x_rle.asm"

src/title/helper.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; Copyright (C) 2025 iProgramInCpp
2+
3+
.proc postcard
4+
ldx #<postcard_XTRA
5+
ldy #>postcard_XTRA
6+
lda #prgb_xtra
7+
jmp far_call2
8+
.endproc

src/x_rle.asm

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
; Copyright (C) 2025 iProgramInCpp
2+
3+
; This belongs in the PRG_XTRA bank. It deals with outputting the
4+
; postcard and level end graphics.
5+
6+
; ** SUBROUTINE: nexxt_rle_decompress_XTRA
7+
; desc: Decompresses the NEXXT RLE format.
8+
; assumes: rendering is disabled
9+
; NOTE: EXACT copy of src/title/rle.asm! Must be synched at all times!
10+
; parameters:
11+
; X - high byte of data
12+
; A - low byte of data
13+
.proc nexxt_rle_decompress_XTRA
14+
_RLE_LOW = temp1
15+
_RLE_HIGH = temp2
16+
_RLE_TAG = temp3
17+
_RLE_BYTE = temp4
18+
19+
; Set up
20+
tay
21+
stx <_RLE_HIGH
22+
lda #0
23+
sta <_RLE_LOW
24+
; Read byte that does not appear in data, used to signal a run
25+
lda (_RLE_LOW),y
26+
sta <_RLE_TAG
27+
iny
28+
bne @tag_nowrap
29+
inc <_RLE_HIGH
30+
@tag_nowrap:
31+
@decodeloop:
32+
; Read a byte from the stream
33+
lda (_RLE_LOW),y
34+
iny
35+
bne @main_nowrap
36+
inc <_RLE_HIGH
37+
@main_nowrap:
38+
; If it doesn't match the run marker, output it
39+
cmp <_RLE_TAG
40+
beq @is_rle
41+
@is_literal:
42+
sta ppu_data
43+
sta <_RLE_BYTE
44+
bne @decodeloop
45+
@is_rle:
46+
; We just saw a run marker. Load the length, stopping if zero
47+
lda (_RLE_LOW),y
48+
beq @done
49+
iny
50+
bne @len_nowrap
51+
inc <_RLE_HIGH
52+
@len_nowrap:
53+
; The run marker followed by $01 means itself
54+
cmp #$01
55+
bcs @is_run
56+
lda <_RLE_TAG
57+
bcc @is_literal
58+
@is_run:
59+
tax ; X = length of run
60+
; Output the most recent byte X times
61+
lda <_RLE_BYTE
62+
@runloop:
63+
sta ppu_data
64+
dex
65+
bne @runloop
66+
beq @decodeloop
67+
@done:
68+
rts
69+
.endproc
70+

0 commit comments

Comments
 (0)