|
本帖最后由 yandagui 于 2017-3-30 21:03 编辑
+ m7 O' z: W: v. J* |2 z
) E% {9 f# Y) H6 T得益于修改思路的进一步优化,原本是通过文件的Trainer在7000-71FF固化程序,让程序的精灵端口跳转到7000执行关卡选择的程序(包括显示STAGE),Trainer在ROM载入时就把Trainer的512字节载入到7000-71FF了,本来想通过按键跳转的切BANK程序里面把原本Trainer的数据复制到7000-71FF,这样ROM就不需要Trainer就可以让7000-71FF充满我写的选关程序了,然而,ROM运行时首先运行的是精灵写入程序,那时候按键程序都还没有开始执行,此时7000-71FF一片空白,跳转到7000只能死机喽.
' N" ?" D4 R& g* u* S; o7 f1 j然而,今天想到一个思路.
3 W# R8 }" j* F1 Q1.找一个大约20字节的空间A,把精灵写入指令改为跳转到A写上: 7000-71FF是否已经写有数据(71FF为FE即可),有的话跳转到7000执行,否则执行原来的精灵写入程序后回去.
% n) c) N% `+ e" W2.按键部分加上数据复制功能: 判断71FF是否为FE(是的话数据写完了,跳过写入程序,不是就复制数据块)没有复制完数据的话就把Trainer数据块复制到7000-71FE,复制完将71FF写入FE
5 y7 }' z+ v6 z3 J, u( B3.这样一来就可以完美地使用空间6000-7FFF来写更多程序了(数据可以写入到6000-7FFF).
& }, K3 p; P. ?: k1 T" w+ U4 t7 L& L) S! c' {8 ^
1 D& J3 g; t r9 n2 |;[FC][最终任务KEY][END]
' \. c# A( ?& Q+ g! @3 cbutton = $04 ;单次按键; g1 P9 S5 t* j' O; S" q, t
flag = $6000 ;功能开关标志6 e, F" Z% u9 D
pause = $000E ;暂停地址: E- \9 X& G% K$ M" N6 K
2 X4 x9 P5 ^1 K0 Q' x: C: G
.ORG $8000
5 N5 I; G% Q# i- O) V LDY #$08 ;自带的按键程序
. K5 k' M, d/ X0 AADDR8002:
& a J; \' j, f0 b' @1 l LDA $4016,X
# ` A+ ] ^& K+ [ LSR9 m) K! p H! g( o! X
ROL $0021
+ j# X9 ?+ H" |4 r4 K) X0 z LSR
8 [$ e. T7 |% X" U X ROL $00291 ~# T- F' k/ S; r5 N7 H7 J( y
DEY
+ C! g8 }2 X, l; G& X o# T BNE $80028 L6 N2 P1 z3 K
LDA $0021- s/ @! w" j- k7 Q3 K/ l
ORA $00298 @+ g. m& x- `8 U0 c5 B
STA $0021
: L o1 o# H. i( v LDA $0020
' A9 `, M x6 ]9 E( S1 Y AND $0021
7 G: [5 K$ S, m: E1 E V) H STA $0020
+ r6 L+ X/ W0 G7 w: w# R/ |" R$ D; q LDA $06,X# D# t! q/ j. a7 |3 A9 F% K
EOR $0020! ~3 o. U# z) p5 I
AND $0020
( u; Y) E. ^+ q6 ] STA $04,X
2 Q9 C. ^) N% M+ I5 F LDA $00205 ?3 @6 \( ?3 ?, ^6 B# s2 c
STA $06,X
) F& T! w7 j: Z, E' @. o1 m6 ~ JSR KEY_OPERATE$ Y" N' _5 S) `9 x: p1 z
JSR Function ;功能调用
: L. ^4 i' E3 G JSR Weapon ;武器切换调用* U$ k7 B6 ?; ?
JSR Power ;威力调用
9 l$ ^1 K5 n: f; b JSR BULLET_NUM ;子弹数目
* O/ p3 D) `; S1 H4 k% {& h, K JSR BULLET ;副武器类型
) r5 ~$ g( i2 ?# o RTS
9 ~9 k1 T* o& U1 l
( l9 f& V1 T" X
, k/ i }: J5 A3 P9 }: n
0 c8 w5 x; U* M: W .ORG $80502 p% M6 g/ U; C8 n9 q) `/ s" P
Function: ;功能
( o1 { O! g2 m! c; pWUDI: ;无敌
/ _* r( |7 t, m: C% G& s LDA $6000,X9 b* S& o" ?; F5 O
AND #$08 ;开关判断
: s' a) ^, O; O BEQ LIFE) ]# x$ N$ S3 |6 o& A8 a
LDA #$056 w* R7 F9 s/ i" v1 n, `
STA $05DC,X ;无敌锁定
% ?3 a9 |* ]/ R+ l E2 \LIFE: ;生命; M! D0 Z4 N: x# g* X: W
LDA $6000,X
, f: [" B+ N' W5 j/ a* p0 H8 u7 c AND #$04 ;开关判断
! ]: \ ^+ ?& A% u$ u% H: V BEQ FUNRTS
: J' n% J: N$ U3 x |& D7 h5 W( J LDA #$057 y( P/ q' d! b( I! R
STA $1C,X ;生命赋值& S! z; R3 Z/ Q6 U- M4 x4 m( J
FUNRTS:/ i" _ r; O/ `1 n( [* v
RTS
" Q. i$ ]7 @ H3 c/ [9 F
9 |7 R/ e( t5 R" \Weapon: ;武器切换) ^7 |# J+ n* n/ `8 i
LDA pause ;暂停状态判断* O. c4 r+ I- _, P- j8 g4 f
BNE WEARTS
# G2 @ @; g8 R" P1 ~ LDA $04,X$ n: ~9 @1 X3 b6 G- \
CMP #$20 ;选择键判断
0 ?5 o3 p S6 l% O4 L/ e9 y/ w. c BNE WEARTS
: i! v1 [- R& K; Q5 G- O LDA $12,X2 Q, G+ f2 w8 r! w o
CMP #$03 ;武器值判断
. W. @; W7 r. ], i4 r, N' K BCC WEAINC
" m1 W$ P. ]5 K8 o- B LDA #$FF# k" I! a/ |1 p% ]2 a# Z
STA $12,X ;武器重置
1 c* B% u4 _. Y/ @) iWEAINC:+ ^8 [9 J+ |+ P' e
INC $12,X ;武器增加% y T7 z3 ^, q( `8 ]
1 ?7 G3 j; e, q7 o
WEARTS:
1 a8 y0 q, i$ w) D RTS7 s j. Y- M: Z0 o+ E ]
- c% U; V% N8 ZPower: ;威力% l5 X/ q6 I/ D- q! Z# _
LDA pause ;暂停状态判断
6 v n0 K+ I* }8 v( k BEQ SPERTS0 H8 r' u8 K0 d" A0 ~& V
BUT_LEFT:
1 j# Y+ |; @2 Q# q/ W6 N* M* ^" b LDA $04,X! f8 n% I- _' p
CMP #$02 ;左按键判断2 t5 ], @7 G Q4 @+ ]
BNE BUT_RIGHT. i( m* [6 ]# x. c& j) L) y ]6 c8 E
LDA $88,X
" f* y) R. I& @; A0 m' b) y9 O CMP #$00 ;威力判断
2 w- T9 [* S0 W BEQ SPERTS6 H5 E7 P2 f, V6 y1 s. W1 d' N1 t
SPEDEC
) A8 _& w* m' ?% x T+ O) v) X/ D x! { LDA $88,X ;读取武器值
) g C% {8 S { SEC+ f1 ~) {$ `6 ]* @- p+ f
SBC #$08; Z/ q& I7 ]2 Z) D9 R1 n0 a ?4 a Y2 K
STA $88,X ;威力减小' u2 h7 W% g& ?5 A" z7 X: Q# p, W
BUT_RIGHT:& j- q! D9 z1 @/ n
LDA $04,X7 n2 y; u1 z; m# B7 W+ n. D
CMP #$01 ;右按键判断2 z5 x8 R' i7 ?
BNE SPERTS
# S- k- H9 }+ T1 @7 C LDA $88,X
4 k3 ]6 r/ }, V CMP #$10 ;威力判断5 O9 Z2 i. T/ v6 D+ p# y; Q
BEQ SPERTS
! a4 e) k/ I8 s- U6 u* I; kSPEINC:
+ A8 x/ a7 k# i5 o8 r LDA $88,X ;读取武器值
: ^6 V- m1 c0 p! X CLC/ w ? p( j- Y& v, C: C
ADC #$08
: ~$ w3 g1 Z5 @# A! c STA $88,X ;威力增大
2 S* Z* l) j/ S; }& w' Z- l3 D$ V! U
) J' J4 ~1 z: N9 f! L( Z0 pSPERTS:
+ O* N- F! F# I, Q4 \ i2 Y RTS# t" o" m9 w0 z& t2 s7 V
* h; u. A& G3 \! T3 n' y# a4 v9 @7 D
BULLET_NUM: ;子弹数目# X5 g9 U7 W2 J" M$ p- G
LDA pause ;暂停状态判断! S$ e! x8 ~& D/ @) B5 P3 V
BEQ BULRTS
) e7 Y0 Y3 [* N$ P4 w# ]" M CPX #$00 ;主机玩家判断
5 F- H* Y9 d8 f0 x" U d BNE BULRTS
: h! q- x. C* U; _ LDA $04,X ;主机玩家判断3 v! E8 M% z' N1 [
AND #$80 ;按键A比较
! l. n6 F t; ^) L; M h) p' C+ T! \ BEQ BULRTS8 f' U: f* ~6 q2 B' p o6 X
LDA $87 ;状态判断
) R9 \9 [. A- ?" ^ BEQ BUL_2
$ i! R, d- A/ r# e9 h0 K9 r! B0 qBUL_1:
' F' t( z; ?2 T4 W LDA #$002 C3 L% u; ]( ~- Z
STA $87 ;1发子弹
- m: ~( x/ W+ q, U* ?4 t BEQ BULRTS) u; p$ u; y0 S3 W
BUL_2:6 |2 a! `7 z0 V% P
LDA #$01
* u, z. o* b$ U" C3 |. ^ STA $87 ;2发子弹3 X3 @5 c( C/ V% z- \( ^
, A3 [# E" }! C; C9 I
BULRTS:
8 F8 f6 Y) ^$ q# A RTS
" i. z/ X! f! u8 |7 R/ y 1 {3 I: v; X$ y% M. B( G
; Z l6 U6 S% Z7 m8 A% c4 D
BULLET:0 z) q! b6 R7 B- q% A* G7 u5 X
LDA pause ;判断暂停状态
M/ m" k- Y( E: A, u BEQ BULLETRTS) o7 d) l' r: ?( Z' R% J5 f
LDA $04,X( m W3 S7 o5 H( W! F/ j1 M
CMP #$40 ;按键B比较; A2 | ~+ O v. _8 t
BNE BULLETRTS
* a2 ~& T" U, Z8 q% C" c LDA $6002,X ;读取副武器4 `7 E" P+ Q! `5 z3 G& N
CMP #$032 D* P4 D) H. \9 T, r" ^, W
BCC BULLETADD. p7 l7 F8 B5 i4 L
LDA #$FF
& f; V- i1 f+ L6 d u0 k STA $6002,X
( n# \' V* e8 B. WBULLETADD:
; `9 G. @, J9 x1 U7 y e+ k INC $6002,X' Q+ n/ m# K, F/ P" ?% x2 u, e
' d$ |3 J. e$ e8 o6 `6 ~
BULLETRTS:: c% Y/ g+ o3 I1 I K
LDA $6002,X5 m$ B$ A6 n5 e2 q3 s2 ^7 F6 s
TAY
: Q+ F8 O4 x4 v' G# J( e1 L LDA BULLET_DATA,Y9 c- T! q$ ]; B {# r9 a' r
STA $6004,X ;写入副武器数据
: U6 f5 D( `6 ^) U& y RTS
* X% b- Z+ m* M) Q- R1 O" _ 4 V9 V: w. O* ~; W, K. g
0 H* B& k d& Q! oBULLET_DATA:
% ~6 K& ^2 q: G1 s, a .BYTE $06,$02,$03,$04
+ g9 w2 Z$ g1 s }# G i9 e4 y1 V4 j2 Q
0 p7 O2 \; t- m; R* T
7 C. H* U; }- i' n1 U7 u. ?
KEY_OPERATE: ;按键开关操作" s# k9 X2 b0 i; d( Y
data_protect: ;数据保护0 m8 a9 x+ a( V+ O o2 C
PHA
0 ^+ U9 [0 T- X/ T- e) K TXA, I6 l0 \( K. w. L- D8 u- J
PHA
# ~, L+ Z; s" q4 m l TYA
9 P0 m8 b7 A' }3 ` PHA
8 U6 @& O# F9 u/ d4 y' l' Z/ w* C3 c8 e2 r1 W( C1 o' C
FLAG_INI: ;开关标志初始化. K' [7 y: ~ D$ ?3 Y2 F( N" _
: C% Z m& N7 Q! J8 Z3 S! S
LDA $600F
5 @8 O: m3 o& ] y9 P8 A/ t/ J CMP #$01
+ @9 H- l0 M+ C* y BEQ pause_cmp7 V. _1 x! Z5 o: a# l
LDA #$00
$ v, s$ N3 ^; m$ |' @6 C# ` STA $6000% z( k& f6 ~: ^7 h/ v
STA $6001
$ r- |- C" K- s" T( P STA $60029 [" P* ]9 _0 I8 K9 f
STA $6003
# @2 M6 d; a8 m STA $6004/ P5 d% ^- \* J3 O
STA $6005
) y" I% S! W6 O4 ]) r LDA #$017 @% C4 S, l# G* ^( M& S
STA $600F
3 h- s. g* A6 N! M5 @
, }0 ^( G1 K2 P2 x# Opause_cmp: ;判断暂停状态
* `+ a. s) q( f) n: `! Q0 _* Y! Z LDA pause
) l4 O, l9 a- R4 L6 Q2 E' |: u CMP #$01 ;判断暂停状态
0 y3 \% T, s3 n BEQ button_press! I# r8 T- k0 @9 L/ O2 A' H: s
PLA
1 n7 Y }9 z0 y- f5 V$ k ?& D TAY
/ J6 ^6 ?! Y. M7 _: l5 u PLA
) C' n1 P% ?# ?. E% q* y TAX
- u5 u6 ~2 }! v' n( g" H PLA& g9 n, l j+ ?7 ? O
RTS
+ X6 h' b# s* O% {8 j
; ~; I- @9 D$ A. H+ }) Mbutton_press: ;按压操作
: k5 g T5 g: f9 gini_Y:& A# W) A: [0 V. x" U% ^; S: J& y4 F
LDY #$00, q5 K6 L6 R6 I) ~, j
button_cmp:
' ^$ N- B* c$ ~$ Y4 s7 t5 e LDA button,X
- ~1 A& w+ y" C5 E CMP ora_data,Y3 M7 o+ \; p5 k
BNE count_Y_cmp
4 s8 b% F! S0 mflag_cmp:9 E8 |$ i, X9 E. ~5 [" G
LDA flag,X+ Y5 n- H/ {0 J+ `
AND ora_data,Y/ R( n' v+ Q- E( |; j/ g; Y
BNE flag_and
( e5 F/ l; l8 M# z1 I& bflag_ora:
- j0 h9 M6 F; X& ?# Q6 D LDA flag,X
4 W8 V4 R" ~* z" i* u1 x8 t, U ORA ora_data,Y
1 t1 Z* a2 F9 v" P4 k STA flag,X
$ v2 Z% u3 f# v/ }8 w, v/ |. O BNE count_Y_cmp
8 T4 |( Q4 o3 t5 Iflag_and:
2 P* u `. i: c' G& p LDA flag,X# Q6 X9 y; K! o
AND and_data,Y! a2 _+ [8 s' `- Z' Z4 z, C
STA flag,X
7 u7 S& ?4 x. m) v; C3 R3 ] }) xcount_Y_cmp:" V! H2 C3 G& d3 N- O7 g9 r
INY+ F# f% F( o6 C9 ^4 T8 @
CPY #$08, H" l" M. m8 W
BCC button_cmp
, l% W% c2 l) Y2 x7 C u/ U9 ^ 7 r+ P/ U% |7 \% g" F
data_extract: ;数据恢复% I' T, B$ C& }
PLA x$ l; t& I: F
TAY
( W1 j! A, l) t' u5 _; c9 Z PLA9 Y* N( |0 B/ O1 d3 g" C( \
TAX
2 {0 N/ G' v# } t# {3 u9 J PLA
8 R X1 j/ B4 H# ~
# g0 O& o) n* p, E1 Wreturn:1 `, v8 q% N( Z; K. D6 L
RTS. ]. L- B+ p4 J( J Y+ s) T/ x# ^
* X# w1 Y; Q! @, A# r; X3 U" Q# J# j
ora_data: ;按键相或数据
" n$ b' j5 T9 f- D2 F# b" z .BYTE $08,$04,$02,$01,$80,$40,$20,$10! _( H, Q# ~0 F6 { m
and_data: ;按键相与数据) [7 H) b3 I; u+ \
.BYTE $F7,$FB,$FD,$FE,$7F,$BF,$DF,$EF
$ e. L+ |' }* F3 \5 a7 W( _ 0 d( C0 t* e' ~- s9 u9 C N5 m
" w) y H# Q5 N6 d- u4 z# R$ E) U3 x
3 D$ z. B. L* h8 c3 H2 | ;FC数据搬移程序 BY FlameCyclone3 e$ J* j* y) |; p# j0 y
.ORG $8200/ _ A, S0 X; c* u
JMP DATA_COPY_PROTECT
2 o; M( h2 C, Y/ R$ U/ Y7 Z- g2 o( }6 V( K5 Q
ADDR_DATA_TO = $40 ;目的地址: x1 y+ q2 a: _
ADDR_FROM_START = $42 ;源开始地址1 P3 M9 U# P4 f! L
ADDR_FROM_END = $44 ;源结束地址: @" M' y; h' E* S
4 \0 f. x T4 o+ N2 ?9 t$ a+ \ADDR_TO: ;目的地址
0 g4 S2 y! C" ]3 M. Q# [ .BYTE $00,$70! J. b; c& g, |: \
ADDR_BEGIN: ;源开始地址: b8 Z0 ^+ E& D) v% n
.BYTE $00,$83
& u1 }# P- x. F7 |ADDR_END: ;源结束地址( T4 C$ i. e) A4 L" v. g4 e" Q
.BYTE $FE,$84( Y. V- L- e8 U2 a3 |7 ]- r
& R, k* P( h6 f: Z+ v
INT_ADDR = $08 ;中断地址
9 f* l+ c6 d! ~ _$ r/ q6 J+ h# ?FLAG_OVER = $71FF ;完成标志7 U8 Z8 g+ Y6 ^8 p" T# m- G4 H
6 G( x' q# J/ v2 F' b
. ^+ f- d+ x4 o8 C: T% |2 pDATA_COPY_PROTECT: ;保护数据
# ?3 S1 f; S! y: u' x. U1 V- D PHP
" X/ b! }7 b- }7 E6 j PHA5 [( k! x$ d) O0 x: k+ m: |) P2 b
TXA
' V! b9 c% t4 \+ J5 ^) n! n7 m5 z PHA# h( Q9 T. W; ~) e3 z
TYA6 S2 b5 q1 L! l
PHA$ J' }/ F0 Z8 o& B9 u: J, {# \
LDA ADDR_DATA_TO
1 D& I% N% w3 l S PHA6 [, L- t4 m _1 G% u G
LDA ADDR_DATA_TO+1+ B: A/ E. J- i* Q4 j' c+ a! U _" Y
PHA m! y0 y7 r/ U% S8 F
LDA ADDR_FROM_START; J3 o( x3 D" b' t c, B. l
PHA
: N, C: C/ t- S LDA ADDR_FROM_START+1- u: ?6 o3 N& o- F0 S, D
PHA
# M9 m. d- b* V! r6 M# l9 Z5 T+ b: q LDA ADDR_FROM_END2 z. [( |, q# J: s( p" s, D+ P
PHA# {8 I9 c9 D6 |$ ^$ F, z4 m1 S
LDA ADDR_FROM_END+1! E6 W7 i+ S8 L; l: e! h1 l
PHA B! V) Z4 `% @) R
) ?6 v. L' e9 K" x/ [) s9 R# U
OFF_INT: ;屏蔽中断1 l6 e6 _! a, H/ ?. w
LDA INT_ADDR
S& D! f! d& {8 m AND #$7F
: H# w7 u; Q) ]8 p9 [ STA $2000 ;屏蔽中断
b1 q$ [; {4 Z$ O2 C) d# o0 K' H8 @- o) q' s. V
3 ]- }& p$ ]1 U5 r9 a
SET_DATA_ADDR_START: ;设置复制起始地址: P) P4 W! {. R; D8 W
LDA ADDR_BEGIN# r3 D% {8 `: |" y& S; O$ [3 Z
STA ADDR_FROM_START ;设置复制起始地址低位
6 Z- y J# r v* L LDA ADDR_BEGIN+1" T, i0 H9 V2 G6 n5 s2 v
STA ADDR_FROM_START+1 ;设置复制起始地址高位 j4 `, `$ I, S
8 X: X2 i0 I0 {9 j
SET_DATA_ADDR_END: ;设置复制结束地址' O4 F4 ^1 B8 ^0 q# @+ G
LDA ADDR_END) _. z& y3 A) H, I4 D% y0 f- @. U: G
STA ADDR_FROM_END ;设置复制结束地址低位4 `- L* q% Z! X& c6 q
LDA ADDR_END+1
+ i3 k$ J. M+ U STA ADDR_FROM_END+1 ;设置复制结束地址高位
V6 ^+ T" [$ E) n9 ~ K/ n2 D% J ' C% X4 `6 c" F+ g* V
SET_DATA_COPY_START: ;设置目的起始地址
9 u) |7 L1 N& M3 m: y LDA ADDR_TO( |+ F" d+ J- y. q" f6 [- t1 B# V
STA ADDR_DATA_TO ;设置目的起始地址低位3 r" A V) e% ^; n
LDA ADDR_TO+10 F! d1 x- e. r" X+ j# O
STA ADDR_DATA_TO+1 ;设置目的起始地址高位
7 Y% G- `$ T; n: _9 p% ^( t) i0 Y
2 l5 R' ~7 n: r, h* ?OVER_COPY_CMP: ;复制完成比较
- W7 r0 \6 D. R6 q: [+ D/ [ LDA FLAG_OVER2 o' \, s+ `- D. @/ O3 }* U
CMP #$FE ;复制完成标志比较7 o4 G) w9 p- x8 C. V _
BEQ DATA_COPY_EXACT% U& S ?8 w) \, z' w
; B/ l& c @- P* g, A7 j: tINI_XY_COUNT: ;计数器初始化
" j$ x3 H* t: g+ @$ i* G, D LDX #$007 a+ q+ I8 R0 z0 f2 y( h$ F* N- j
LDY #$00
4 M( K9 w7 H" l; ]0 y- x4 @
; w, r: Z8 n+ P5 M4 LCOPY_OVER_CMP: ;地址比较/ H+ A) E) t9 _
LDA ADDR_FROM_START
+ R/ A/ U7 u' V5 K CMP ADDR_FROM_END3 j3 e% g, H3 u' h5 C
BNE COPY_START
5 }0 c$ S( D8 B/ A5 N; ]! E. Y/ T LDA ADDR_FROM_START+1
6 d, N1 G4 ?0 z2 I- J; W$ O+ l CMP ADDR_FROM_END+1
% G) d4 ~. Y% R9 U' C8 C BEQ COPY_OVER
e# z' U" [" v1 v+ K& d! u
* H) g x# D) H+ C# X* HCOPY_START: ;数据复制开始4 W# f$ b& I) Z8 q; t" n$ g6 C
LDA (ADDR_FROM_START),Y ;读取源地址
9 O; k8 q8 D3 X( ?6 Z) U- G J STA (ADDR_DATA_TO),Y ;写入目的地址
5 l4 F$ i) q- S& A7 f$ S INC ADDR_FROM_START ;源地址低位递增+ z" j# L9 @/ }( L. D# p. B
INC ADDR_DATA_TO ;目的地址低位递增
) B4 ~. ^, ], v' N: v% ^% s BNE COPY_JMP- ?& g9 B* c# S
INC ADDR_FROM_START+1 ;源地址高位递增
+ d! }; }3 r6 J, G INC ADDR_DATA_TO+1 ;目的地址高位递增+ v: }. D" a' J" y) @9 F2 z0 e
$ I* D0 [' G9 E/ ?* k( }5 D
COPY_JMP: # w% u. G3 g' g
JMP COPY_OVER_CMP Y" o% n1 `8 E2 `* {' L* Y# L
3 ]0 @. d5 A0 B0 R: C$ d
COPY_OVER: ;复制完成- C8 U, c& @; q# m( U
LDA #$FE
# w, r6 \: X7 b8 l8 U8 [ STA FLAG_OVER ;写入完成标志
: B8 E/ c2 H6 I& k2 KFINAL_BYTE:
7 O# N3 W; X3 U/ V' v/ e4 m+ m LDA (ADDR_FROM_START),Y ;读取最后一个字节2 A; l0 n. D+ _1 C" V: `
STA (ADDR_DATA_TO),Y ;写入最后一个字节4 q; ~$ P8 e; O, V- Y. _" s
. K2 G( x- L4 y5 p
DATA_COPY_EXACT: ;恢复数据2 z% T) O( ]7 x& k
LDA INT_ADDR" P, z* K5 r/ F9 L; d5 Y: Z! G
STA $2000 ;恢复中断
. o8 Q" h; ^7 N PLA
- h; F, @6 u6 }1 T' H STA ADDR_FROM_END+1
- p0 _6 [' {1 g PLA
7 X: r1 J3 M) @/ a. k/ } STA ADDR_FROM_END5 q+ ? @' z1 X+ [
PLA
) u& W" h/ `- t& b. d- G: }( _ STA ADDR_FROM_START+19 M' W9 S; A: f4 ]# d2 N2 b& x
PLA
" N g% A3 O& Z2 A t# I+ l' L2 d STA ADDR_FROM_START% V v, V- f) ~! a* z
PLA
7 q( r5 v0 w+ \4 }. B' J2 B+ ~! P- e- k STA ADDR_DATA_TO+1
8 q8 q1 ? ]. Q1 y PLA
/ Z2 ~/ y) x. L8 C8 d) B* u3 E* b1 D6 F: D STA ADDR_DATA_TO
* t! f5 P; v6 T7 V- i; p PLA
7 J# k# r U( }; }; B5 k* | TAY
/ j+ }+ F( z+ g" Z6 L/ ` PLA
5 u6 p9 V3 _ T; ^; } U8 [ TAX/ M$ L H- R+ n7 J# ?* A
PLA; g9 n$ [) w# P$ \' r8 }
PLP
# X" W5 N" c; g& ^
( d' }( X# p0 Y0 F 6 J( C& `) C: C% d+ p* }& t
( Y$ t9 U. ?, n q( @% v
DATA_COPY_RETURN:0 X# t1 ^/ O3 v; s9 f7 P5 f
RTS
) u+ H: Q3 i" q2 O! C ' u% G+ x$ c4 w% ^( D
.ORG $C056 ;精灵指令覆盖8 m j! T& d8 N6 P4 J" N) A9 Q
JSR $FFB5
9 Z$ T2 J9 ?8 K# O3 V / I, Y# x6 n+ p3 Y( m3 C" ?
.ORG $FFB5 ;
. \- x: t+ K4 t! w$ p4 c PHA
' b& X- }: N6 d( v: E/ n0 h TXA
# S* \/ A. a `( d f' h PHA _/ y( W2 a P4 [3 k2 T
TYA
+ [6 F6 Q. S" p. F9 F PHA8 D4 i A& ]: V9 H+ p
LDA $71FF ;比较7000-71FE数据是否完成复制
& b$ c) a3 C1 d! e' N CMP #$FE
/ H' }9 r2 h6 r+ O BNE ADDR_FFCA
; C7 E5 g" f; d( I PLA4 X1 I7 p# @* X v( P$ h
TAY
* j. E, v* X' x, L0 e! p' x PLA; l8 y' m/ e- v/ s+ K- ]
TAX1 [) f, k" ~" ?- `" s
PLA
5 \1 s+ s, E* w# t, f) \! I I! [/ Q3 T JSR $7000 ;跳转到自写程序
# V" a2 b& l! j RTS7 b _! |) B1 u0 h b% U
ADDR_FFCA:
6 _5 _" U- `9 B3 M PLA" S. y4 w! N) z$ O! a
TAY
2 m: c; {; U& s$ m" [ PLA% l2 r; F2 k8 b4 S7 `
TAX
, ]! {5 J8 s/ C+ q- Z PLA& ?( Y1 R$ z1 Z* k, H8 o/ e& n! G
RTS8 Z7 ]( ?3 X& u) ^* j9 F: s8 C
- i& p# Y: q @2 \9 \, b
8 q% p2 \$ f0 F( a4 ?: f- J6 A# Q7 K# B! M
.ORG $C264 ;自定义的MAPPER2切页程序2 h+ b5 w- D5 V! H
PHA
P2 J! _/ U! y TXA
% X X3 c2 f- V* P0 r! h PHA- {) ]0 a" B/ z8 B' L8 d
LDA $0066. g4 p0 @9 }- a/ }: O, P
BNE ADDRC280
: h9 I! d$ v5 @( ^8 c LDA #$07: }/ V4 A* a/ X. [
LDX #$038 f/ L1 h- W5 R# Y$ k
JSR $CD9B ;自带的切bank方法* c- S2 ?5 r/ s7 v7 ^
PLA* O( u6 _. Q' M+ d7 y
TAX
- G+ Y! w% v1 D3 u/ c PLA
) c& Y7 i3 A) h& }& L' C JSR $8000% ], {' N9 T a+ _
LDA #$06, a1 g* R$ d: B- C" u2 L' z
LDX #$03
h* P M# r( n# j9 h6 T" V4 E. e JSR $CD9B ;切回原该切得bank(可以不用)3 }9 u# r" m( L7 U! F, m6 j
RTS* @9 ]- E4 E& A! q
ADDRC280:! X7 q; z9 k) v2 v5 h: b" y% {
PLA
9 G$ X4 D) a! a, ^, ] TAX, U/ X5 i/ e3 U
PLA
2 E0 n; P7 ?# U( Z, R$ p RTS. U2 ~' h5 Y* z+ V, D
+ i- j; K8 F4 |' H # Y, w3 l, W% J0 T7 G$ \0 K1 o+ Y
;[FC][最终任务PPU][END]2 b( K2 w+ n* C, Z. |6 W
.ORG $C056 ;跳转到PPU重写程序
) N o7 O9 o* e8 N! A JSR $70004 }: V; z/ q2 C
+ z2 h: K2 z1 k .ORG $CEBF
( `5 S$ K6 q" u$ O7 ]+ X& S JSR STAGE_DATA_WRITE ;跳转到关卡数据写入; d1 ?) g0 ^3 W7 I; ^
" C" h4 @. d" m1 u
.ORG $E460
- J" a' r- V3 O' F" e8 Z* ^ JSR BULLET_DATA_WRITE ;跳转到副武器数据写入1 H" B) m% ^. v2 O6 m2 N
5 M" ]) X0 r4 j/ E/ H* Q0 {
.ORG $71F0, @) Y; W ]+ ~; J# f
STAGE_DATA_WRITE:; i! k! I* O/ s- h2 j. |9 l
LDA $6010+ n0 r: i7 {+ G4 {1 e! A
STA $1E ;关卡写入
- t& t" H$ z- H6 }8 j6 k; V LDA #$00; v' t/ U% e3 I, D7 x2 W
RTS
' l! b+ ?' F+ t* z' Y7 U& i* o @ .ORG $71C0
A% \, ` [5 Z# TBULLET_DATA_WRITE: ;副武器数据写入 L; n+ X% v% ?3 H+ O
CPX #$0E
1 U4 J& q0 t+ G7 s3 `1 J) U BCS P2_BUL! \- u' F5 n9 e) w' L
P1_BUL:. X% x. g; t4 s, k
LDA $6004
+ H' o- G- X& Z$ @# @ JSR $D7D0 ;P1副武器数据写入
1 G7 b b- L- W; | RTS1 P) w; b% B [. l- P: z4 x
P2_BUL:3 X2 F6 m* O% u: R4 ~6 _
LDA $6005
: T* G3 U' l+ }! W JSR $D7D0 ;P2副武器数据写入
1 k; G, ^0 t! W) O; U' c" Z' ^, q RTS
, x* n9 `" ?' x1 P7 M8 \6 @7 v8 w0 j, k7 w( x& k A' l
) ]) F! I/ B! D: _2 _ .ORG $70001 P+ K- H& P3 `, h+ h& P9 D4 ]
. m: L: }2 r& P6 n6 J3 q) J STY $4014 ;补上覆盖的精灵写入指令
2 @' c% x' R( g! T$ z PHA' g$ G! Y/ |1 o& P1 b
TXA7 u3 S( a. C) v2 o+ ]+ b1 l: h
PHA
5 l: k$ S$ {, Y+ c TYA
* p3 t& N/ [* k( J+ S- V' B PHA8 M+ L/ s8 p5 C, _" |
LDA $0C
* J0 R& O X3 k CMP #$01 ;比较是否为标题画面6 ]$ H" ~2 _" P" ~2 o# \
BEQ PPU_STAGE
3 j* g4 K/ t6 x) X PLA, Q2 P/ C' ?0 l1 J6 Z: g& j
TAY, B* a9 | [# ]$ ~. P7 B ?' h
PLA
+ L( ]* M' J8 P$ `7 c0 d- n- _ TAX
' X7 c7 k( R$ s/ B PLA
9 F' I2 M5 A+ [- y+ B5 X4 L7 H RTS1 `2 |! U: y0 S7 S3 W
PPU_STAGE: ;STAGE显示程序" a% r# z, i4 x& F: E
LDA PPU_ADDR_DATA
5 n+ N {$ }3 G+ }( G" i: Z" d STA $2006! k0 `( a4 @* o
LDA PPU_ADDR_DATA+10 Z/ x6 d' D$ u+ Q
STA $2006 ;坐标设置/ z3 Y/ ~' T5 W. \/ @# E# `+ x4 z
LDX #$00
/ Y7 l9 N! Y) Y: U, n& e8 `PPU_STAGE_WROTE: ;写入STAGE字模
7 b7 \) S# h: t0 q LDA STAGE_DATA,X$ h, u0 H! T1 e7 Y& I5 o7 \
STA $2007
7 @' {) ~ v' o& y. u4 i INX
+ R: }7 E) s% ^! g, S+ L CPX #$06: o: s" ^- G( o3 r0 b! N, l
BCC PPU_STAGE_WROTE) z0 C( g# D# S
LDA $6010- A4 q. k6 P2 H% `5 R/ o2 |
CMP #$FF ;关卡数据初始化条件判断% x# F: j2 S0 J8 p* U9 w4 {& V
BNE KEY_B
3 h, ?6 S9 c9 @3 g( [" E3 q) x LDA #$00& {; q: O7 l @7 t0 ]1 L; H$ z
STA $6010 ;关卡数据初始化/ }" b5 Y. }# P) o; s0 w& q
KEY_B: ;关卡减少- l. R, c0 x$ O! K! z" k& s6 A
LDA $04+ T' q4 r( r* @6 a5 z3 X# M9 u
AND #$42 ;按键B或左减关
( M" ]+ o* J% H( N6 _/ J BEQ KEY_A1 T5 M# l \& U6 `, f, z2 u3 ?
LDA $6010
1 R$ r1 _* E( h# j9 f* u CMP #$00 ;关卡比较2 a# @/ {) R0 t' Q( Y
BEQ KEY_A) p. ]( E2 [/ U2 N9 _
DEC $6010 ;减关
. Z* f. @' A# QKEY_A: ;关卡增加+ V* k$ U2 @' g6 y1 b
LDA $04
( I7 h* d) {8 Y AND #$81 ;按键A或右加关
. ~$ Q/ h/ ?+ u5 o$ T5 E5 e BEQ PPU_NUM_WRITE, @8 Q9 o0 H+ u- a* B6 u
LDA $6010
" j, n4 M) N. _2 v CMP #$04 ;关卡比较
( X+ n0 n6 M! s- p BEQ PPU_NUM_WRITE1 H1 Z5 m7 b* r B) |8 S' Q0 O) D
INC $6010 ;加关
4 _7 ~- }. c% C6 Y. ePPU_NUM_WRITE:7 y9 `& c+ E$ g
LDA $6010% z/ z8 @8 o7 A7 y9 F
TAX4 _3 V7 p5 B$ Q% |' _% P% I% Z+ Z
LDA STAGE_NUM,X ;写入数字
% s" Q8 B! v/ n; I2 r STA $2007' h' X9 d. G3 H. f5 e
PPU_RTS:
- a, y5 S- e! I0 Q/ t3 ~8 | PLA
- N" D6 n$ h" | TAY
. v4 z8 S, k) L) n, E: C* L2 U PLA* c# G) N1 | x
TAX& |7 ~) f) F# H! ]
PLA
' _! }" a$ B( ~- @) @8 s* w* |$ p RTS
$ c" F8 u2 t4 j/ ^5 U7 w7 ^; p " C; J! p2 e* I5 X
3 w: i ]4 N# w& w. K8 C
STAGE_DATA: ;关卡文字S,T,A,G,E,字模数据
F7 F5 C5 C0 ~' I2 [ .BYTE $EC,$ED,$DA,$E0,$DE,00) [* d5 g0 t% v" H/ s+ E0 x
STAGE_NUM: ;关卡数字1,2,3,4,5字模数据
, y) W; l- |; H3 F .BYTE $D1,$D2,$D3,$D4,$D5
5 O b; A% x& Q0 r
, B7 P( N# X: m" q0 P iPPU_ADDR_DATA:. A7 U2 |$ h8 Q2 M7 a4 b# V
.BYTE $23,$0C
' Y# V3 \5 p- ?1 A8 k 8 p# B) B0 F" w. G
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|