|
;[FC][忍者神龟3代标题选关程序]( e# x" T/ H* y8 ]; c* W
;作者:FlameCyclone 2017.4.1# E) ]: t+ q0 k: G
% T6 J1 `& i/ J0 g+ g
, @# S0 t3 w3 x- n- D
;配置数据
- {% i+ M$ g6 k0 [' L1 m" sKEY_ADDR = $F8 ;按键地址! \4 x# e& Z8 X) s: {
STAGE_TEMP = $6010 ;关卡临时地址1 y1 |5 B+ L# ?2 s( e1 L4 V0 H7 B
STAGE_MAX = $0E ;最大关卡数) r$ x9 R, F6 ~2 ?
TITLE_A = $20 ;标题条件A
0 S2 Y+ D U1 f$ D( HTITLE_A_ON = $02 ;标题条件A有效状态判定
# _% ]8 A p5 H( i) n6 H) ^# RTITLE_B = $21 ;标题条件B
! `, L k D# u5 O2 u- X5 [TITLE_B_ON = $03 ;标题条件B有效状态判定) r( F% o4 L/ O+ }& c3 j
PPU_END = $FF ;PPU结束符
( M( | c4 _5 ~$ b3 T+ aTIME_LAY = $4A ;标题显示延时地址
/ b: y4 e) [7 R3 [/ U0 k6 ~ ~BUTTON_DEC = $42 ;关卡减少按键2 z1 N2 W' t5 F
BUTTON_INC = $81 ;关卡增加按键% U" ]2 r' p* `% [5 p8 e
NUMBER_A = $06 ;数字A距离STAGE偏移量
& i, h: ^( s" G& w( j5 zNUMBER_B = $08 ;数字B距离STAGE偏移量
. J" |, u4 \' C" e% QPPU_ADDR_H = $23 ;STAGE写入地址高位2 b* z/ r, Z# f5 V) s( r9 r
PPU_ADDR_L = $8C ;STAGE写入地址低位
! h, |1 E7 h( o# z1 D! XCHAR_S = $A2 ;字符'S'3 X, o, {) U9 p! t$ S7 [- B
CHAR_T = $A3 ;字符'T'
; [4 r* ^# c+ X3 h- v0 n$ zCHAR_A = $90 ;字符'A'
6 }2 g f, ]( D* H) y( B) {$ C" o1 |CHAR_G = $96 ;字符'G'# |' P7 O" q4 D9 _3 n
CHAR_E = $94 ;字符'E'
" j6 }( k# c+ k7 u$ I0 ^$ i) pCHAR_SPA = $00 ;字符空格
. s: G# u8 P3 V# C5 m9 wCHAR_LIN = $AE ;字符'-'2 _+ K$ s7 y" I6 A( y+ s4 A
CHAR_O = $9E ;字符'o'
: [) Q+ U% d) ~, Z4 o2 mNUM_1 = $81 ;数字'1'
1 U. ?/ s) [+ @NUM_2 = $82 ;数字'2'
Q2 o. k2 V( G' e3 uNUM_3 = $83 ;数字'3' ^+ h5 K* c' O9 P* I
NUM_4 = $84 ;数字'4'1 j0 \. z0 M" ~
NUM_5 = $85 ;数字'5'
! q v2 K1 Z6 r! L8 e# Q1 o& ^NUM_6 = $86 ;数字'6'
$ c; K: o A: Q# ?: p; n; YNUM_7 = $87 ;数字'7'
/ D& c1 N5 _4 rNUM_8 = $88 ;数字'8'
/ k0 N9 V, W1 _% ]% I. fNUM_9 = $89 ;数字'9'
! l/ V1 l6 ?# d) n# Z" R. {' |NUM_0 = $80 ;数字'0'
/ d2 e/ f0 Q# }: r) g. f5 R" W* ]) N, n
.ORG $F82A
Z2 |& r+ k+ {1 | D7 s. ~ W JSR $E700
- h6 O1 j2 |9 [% \2 S# O1 Q
1 V ]+ ?1 K) `( W4 H: c
+ n& E. r* y) E5 n. r .ORG $E700, N0 u- E0 k+ F
6 M5 I0 s, Y1 u8 C8 q! c1 l* f STY $4014 ;补上覆盖的精灵写入指令
. {' p7 W; {8 Q" N, G4 i2 L) `PROTECT_DATA: ;数据保护; N2 V) `; k" I0 R' K& n
PHA ;数据保护开始
" }" r7 F, C% O" n TXA- ^# L7 w; J- r' T
PHA* L5 `) N7 M$ z$ y
TYA
& R0 R5 A; y6 J$ ^% ? G PHA ;数据保护结束+ c0 X: a6 N) P! P' ~. V6 a" V1 q
LDA TITLE_A
2 F" x+ A; W' c& z CMP #TITLE_A_ON ;比较是否为标题画面- E A% `0 X6 M+ ]2 M
BNE RET
( O$ d" X4 ^3 n& h LDA TITLE_B" n; A+ r- ]6 m( k; c+ M# r
CMP #TITLE_B_ON ;比较是否为标题画面 W" P2 i4 ?" _
BEQ PPU_STAGE
5 l; W" @& w1 Y- ?/ e4 KRET: ;恢复数据
. }6 |, w* a/ x, ]$ h PLA ;恢复数据开始
1 H7 R; p; _1 n& A0 N( d& l }2 T& z TAY h) \, M2 k6 T( W
PLA% Q L! E" |2 r4 B
TAX
+ C9 ~0 u4 Y; u PLA ;恢复数据结束
9 L3 e" H0 t7 X! h/ C# @ RTS ;返回4 k, L) [' V) i" e" ]* \+ S2 X
PPU_STAGE: ;字符STAGE写入程序 S! s4 M. d6 o/ q0 x
LDA #PPU_ADDR_H
6 T# L: f0 Z9 f5 d$ d# u; s STA $2006 ;设置PPU字符写入高位地址
$ @9 Z7 N$ N& J6 U. }" @: d LDA #PPU_ADDR_L
/ U C8 n, f- b% s STA $2006 ;设置PPU字符写入低位地址! \2 K# h6 ~7 k( k& z* g- `
LDX #$001 @5 J i+ b6 B5 i% F
PPU_STAGE_WROTE: ;写入STAGE字模
8 X1 X- ]9 j1 \" q$ A LDA STAGE_DATA,X, a P) \9 x! O1 `* i
CMP #PPU_END ;判断是否写入结束
* z! C# Z- z, X BEQ STAGE_CMP9 {2 ?4 q, d0 g& P! P
STA $2007
. M3 V8 X; }0 K, K+ k- ^" ]. L* s2 T7 j7 ? INX: ?( z% V% ?) w/ N% Z+ b2 P
BCC PPU_STAGE_WROTE
4 v- _ u8 L; M! g0 O7 zSTAGE_CMP: ;选关操作: r# I: h# t5 D( u3 Z: u {, N
LDA STAGE_TEMP
: c. ?9 W, D9 A4 {; E CMP #$FF ;关卡数据初始化条件判断
( `# m& t! R5 H+ ]- E4 G0 t2 B9 t BNE KEY_B
( a* Q3 v' U1 a3 y LDA #$006 N/ j/ T8 X1 i& n e% Z; ]
STA STAGE_TEMP ;关卡数据初始化
" A* X: }; K# ^# s7 Z/ b) gKEY_B: ;关卡减少( p9 C; P3 j& H3 N% [$ ~0 A
LDA KEY_ADDR$ b& {, R6 m9 ^+ H2 D
AND #BUTTON_DEC ;按键B或左减关
) F0 [, m/ ]+ s; N) ^' R BEQ KEY_A
* l' a/ U3 c* x0 d; w. M, L; E8 @ LDA #$FF9 I; p* ^3 t" c# E& G
STA TIME_LAY ;重设标题延时
9 ?$ _. L, R9 S7 ]7 r! x LDA STAGE_TEMP
( d4 v' ^, `8 Y CMP #$00 ;关卡比较" n/ i d; e, ~7 _6 S
BEQ KEY_A# y$ {/ m: F4 P. N6 l
DEC STAGE_TEMP ;减关
& f! D. I j% J" {5 } JSR MUSIC ;按键音效
$ b7 X( I L( PKEY_A: ;关卡增加1 ~4 j; e9 W2 w" \
LDA KEY_ADDR
# ]4 L& u# a T' W. m5 e AND #BUTTON_INC ;按键A或右加关0 M% e! Q5 j. v$ b# F
BEQ PPU_NUM_WRITE
+ r5 ]$ E& B0 M! H2 ]0 q# A4 H LDA #$FF
; c6 d x; i3 x* ?& A STA TIME_LAY ;重设标题延时
2 q/ n( V+ t! G e8 ?, b8 B5 a3 g LDA STAGE_TEMP
, L8 W: ^0 g' k0 X# j3 x) m1 e CMP #STAGE_MAX ;关卡比较
0 Z& b' q3 J5 }" b, h- f5 M BEQ PPU_NUM_WRITE
" K1 o. w* s) E! Y, A- @8 ~ INC STAGE_TEMP ;加关
) X3 f. {' |( g/ s JSR MUSIC ;按键音效/ J& ]- a# f' r% W; f7 \9 \
PPU_NUM_WRITE: ;关卡数字写入地址; S8 v* o& u% T/ d
LDA #PPU_ADDR_H
: y4 m% o" c* Z7 l( h STA $2006 ;设置PPU数字写入高位地址
9 L; @6 w3 N1 l( R7 v8 j; ~9 Y LDA #PPU_ADDR_L
+ r& f1 M. k; f/ o: j9 L CLC$ e* q& T0 U( @! N, u7 o9 t
ADC #NUMBER_A6 `; D( Q' F! A! ^9 p' F% r# p
STA $2006 ;设置PPU字符写入低位地址: a8 ^' g$ x' t @5 g3 s2 d
LDA STAGE_TEMP' N0 A* c. x; _5 J" O2 U2 H
TAX
* j% V/ z+ C' V6 C LDA STAGE_D1,X ;写入数字
, x, R; _1 x, B% V x2 K8 K STA $20074 O4 d0 {6 p6 L" |0 y3 r
LDA #PPU_ADDR_H5 ~$ \. T, t7 K
STA $2006 ;设置PPU数字写入高位地址
+ Y+ i6 x4 H( F& }# @ f" Y8 J LDA #PPU_ADDR_L7 T7 K; ?# ]" S" r/ ]0 O4 o
CLC3 h6 f- v2 ]/ w
ADC #NUMBER_B
* h6 Q+ |/ W& o. n$ e7 { STA $2006 ;设置PPU字符写入低位地址" ?& {6 t A( C3 y' c
LDA STAGE_TEMP
" c; A! {9 n+ m' _ TAX, u# l8 s4 t4 B7 Y
LDA STAGE_D2,X ;写入数字
* @) z: j$ ^. R STA $20079 v/ x, n8 K V' B4 m! \
STAHE_WRITE:
! W- c" r3 D5 `2 z LDA STAGE_TEMP
, q7 B$ M, ]. U3 R2 ~; T5 O STA $2D ;初始关卡写入
E; B- z' r: V: CPPU_RTS: ;恢复数据$ Y& u- \$ R) w# P* {& y9 r. E5 M
PLA m' `- Q1 S5 K$ x; u6 U7 l! O# N+ |
TAY
' j# ?( N2 x/ m, F* R/ Q$ ]* O% v' z# E PLA
7 n$ N3 t7 {7 I# X, V TAX- y% \# a; b2 I# d7 L+ P" f3 f+ Q
PLA
* t h' ?3 r+ V9 R RTS
5 o2 s( `9 h1 K2 A- Y4 P) _* b
1 j" M5 h2 Y; W: }STAGE_DATA: ;关卡文字S,T,A,G,E,X,-,X字模数据
( g* {; D, S' ^; F& M) a .BYTE CHAR_S,CHAR_T,CHAR_A,CHAR_G,CHAR_E,CHAR_SPA,CHAR_SPA,CHAR_LIN,CHAR_SPA,CHAR_SPA,PPU_END
8 {" t7 U( T. H$ T! s/ S0 {" p/ j
: V' m" W" @$ L/ k' R1 P6 N' F. MSTAGE_D1: ;关卡数字: j' E* q+ i G- `/ B7 z6 B
.BYTE NUM_1,NUM_2,NUM_2,NUM_3,NUM_4,NUM_4,NUM_5,NUM_5,NUM_6,NUM_6,NUM_7,NUM_7,NUM_8,NUM_8,NUM_8
! f7 D. u$ a2 L- V M$ x p1 ^' j7 q
STAGE_D2: ;场景数字
9 c7 V7 K+ `5 w6 y9 p .BYTE NUM_1,NUM_1,NUM_2,NUM_1,NUM_1,NUM_2,NUM_1,NUM_2,NUM_1,NUM_2,NUM_1,NUM_2,NUM_1,NUM_2,NUM_36 p( r$ i+ M3 g+ b$ b. N7 X
* p' y, }! y# c0 y
: @: l( E0 L3 A5 c: i
MUSIC: ;按键音效+ }* c& v7 I/ `+ E
LDA #$3B ;音乐号
) }8 F+ I6 O8 U+ T+ G JSR $919E ;系统音乐调用9 o, O1 G0 ^8 d& N! Y1 R
RTS |
|