NESã®ããã°ã©ãã³ã°ãå匷ããããã·ã³ãã«ãªSTGãäœã£ãŠã¿ããã®ã§ãã
ã¿ã€ãã« | ã²ãŒã ç»é¢ |
---|---|
- stg.nesãããŠã³ããŒãããŠãšãã¥ã¬ãŒã¿ã§ãã¬ã€ããŠãã ãã
- Mapper0ã®ã«ãŒããªããžã«çŒãã°æããå®æ©ã§ãåãçã§ãïŒæªç¢ºèªïŒ
- RPGã¢ãããŒã«ïŒãã©ãŠã¶ïŒã§ããã¬ã€ã§ããŸã
å°çããšã€ãªã¢ã³ã®æ€æ°å°ã«ãªã£ãŠããååäžçŽãçµã£ã20xx幎ã人é¡ã¯ç§å¯è£ã«éçºãã察ãšã€ãªã¢ã³é§éè¹ã§æåŸã®æŠéã«èšãããšããŠããããšã€ãªã¢ã³ã¯ç¡éã«å¢æ®ããŠããã®ã§ãã®æŠãã«åå©ã¯ååšããªãããšã€ãªã¢ã³ã«åã®ææ ããããã®ã¯ååšããªããçµ±çãããæèã®å ã§ããã ç Žå£ãšè³æºã®ç¥å¥ªããããªã£ãŠããã圌çã®ç®çã¯äžäœäœãªã®ã ãããããããŠã人é¡ã«æªæ¥ã¯ããã®ããçŽæãããæåãžã®æåŸã®æŠããä»å§ãŸãã
- ã«ãŒãœã«ã§èªæ©ãäžäžå·Šå³ã«ç§»åããŠAãã¿ã³ã§ã·ã§ãããæãŠãŸã
- ã·ã§ããã§æµæ©ãç Žå£ããŠãã ãã
- æµæ©ãç Žå£ãããšããŒãã¹ã¢ã€ãã ãåºãŠããŸã
- ããŒãã¹ã¢ã€ãã ãååŸãããšç²åŸåŸç¹ãäžãããèœãšããšç²åŸåŸç¹ãèœã¡ãŸãïŒ0以äžã«ã¯ãªããŸããïŒ
- èªæ©ãæµæ©ãæµã·ã§ããã«è¡çªãããšã²ãŒã ãªãŒããŒã§ã
以äžã®ããŒã«ãå¿ èŠã§ãã
make
ç§ãæåã«ããã°ã©ãã³ã°ãèŠããã®ã¯ã16bitæ©ã®PC-9801ã®N88æ¥æ¬èªBASICïŒä»¥äžãBASICïŒã§ããã åœæãé»æ³¢æ°è瀟ã®ãã€ã³ã³BASICãã¬ãžã³ïŒããŒãã¬ïŒã«æ²èŒãããŠããã²ãŒã ããã°ã©ã ãæã¡èŸŒãã§éã³ãèšèªä»æ§ãç解ãããèªåã§ã²ãŒã ãäœã£ãŠéãã§ãŸãããBASICã¯ã·ã³ãã«ãªã®ã§ãããŒãã¬ã®èªé¢ãèŠãªããããã°ã©ã ãæã¡èŸŒãã§ããã ãã§ããã°ã©ãã³ã°ã®ããæ¹ãç解ã§ããŸãã ããããããŒãã¬ã®èªé¢ã«ã¯æã ãç解äžèœãªæ°å€ã®çŸ åïŒãã³ããªã¹ãïŒã ãæ²èŒããŠãããªãŒã«ãã·ã³èªã®ã²ãŒã ãæ²èŒãããŠããŠãããã¯BASICã§ã¯å°åºå®çŸäžå¯èœãªã¬ãã«ã®åããå®çŸããŠããŸããã
ãã·ã³èªãç解ããŠã²ãŒã ãäœããããšã¯ãBASICå šçã®ãã®é ã§ããã°å€§ããªã¢ããã³ããŒãžã§ããã çŸåšã§ã¯åãªãéå»ã®éºç©ã§ãããªããããããŸããã ãã ããSwiftãKotlinãPhytonãšãã£ãææ°ã®é«çŽèšèªã§ãã£ãŠãæçµçã«ã¯ãã·ã³èªã«å€æãããŠã³ã³ãã¥ãŒã¿äžã§åããŸãã ãªã®ã§ãé«çŽèšèªã§ããã°ã©ãã³ã°ããå Žåã§ãã£ãŠãããã·ã³èªãå šãç解ããã«çµãããããã·ã³èªãç解ããäžã§çµãã æ¹ãè¯ããããããŸããã ã€ãŸããå®çšé¢ã§ã¯äœ¿ãæããªããã®ã®ç¥èãšããŠã¯å¿ èŠãªããšãããããŸããã
ç§ã¯äžåŠçã®é ãPC-9801ã®Turbo Assemblerã§ãã·ã³èªããã°ã©ãã³ã°ã®åºç€ã身ã«ã€ããã®ã§ãããå®éã®ãšããããªãèŠåŽããŸããããã·ã³èªã身ã«ã€ããã°éæ³ãæãã£ããããªãããã²ãŒã ãç°¡åã«äœãããšããå¹»æ³ãæ±ããŠããã®ã§ãããå šç¶ãããªããšã¯ãããŸãããããããæ¡åŒµã¡ã¢ãªãªã©ã䜿ããŠåŠçæ§èœãè¯ãPC-98ã§ããã°ãCèšèªã§äœã£ãŠããªãŒã«ãã·ã³èªãšãããªã«éè²ããªãã¬ãã«ã®ããã°ã©ã ãäœãããšãã§ããŸãã åœæã¯ç¥ãç±ããªãã£ãã®ã§ããã16bitã®ãã·ã³èªã¯çµæ§é£ããã®ã§ãåœæã®ç§ã®ç°å¢ãPC-98ïŒ16bitïŒã§ã¯ãªãPC-88ïŒ8bitïŒãªããã£ãšç°¡åã«ãã¹ã¿ãŒã§ããçã§ãã çŸä»£ã®ããã°ã©ããèªåã®PCïŒæãã64bit CPUïŒã§ãã·ã³èªãå匷ãããšãç°æ¬¡å ã®ã¬ãã«ã§ïŒ16bitãããé¥ãã«ïŒé£ãããšæãããŸãã
ãã·ã³èªãå匷ããã«ã¯8bit CPUã§åãããã°ã©ã ãæžãããšãäžçªæ¥œãªã®ã§ãæãæ®åãã8bitã³ã³ãã¥ãŒã¿ã§ã¯ãªãããšèãããã任倩å ã®ãã¡ããªãŒã³ã³ãã¥ãŒã¿ãé¡æãšããŠããã·ã³èªã²ãŒã ããã°ã©ãã³ã°ã®è§£èª¬ãããããšæãããã®ãªããžããªãå ¬éããŠã¿ãããšã«ããŸããã
以äžããã¡ãã³ã³ã²ãŒã ããã°ã©ãã³ã°ã®æè¡æ å ±ãæžããŠãããŸããããã¡ãã³ã³ã®å Žåãæ¢ã«è§£æãå°œããããŠããŠãåºç€çãªæè¡æ å ±ã§ããã°Webäžã«æº¢ããŠããã®ã§ãåã ã°ã°ã£ãŠèª¿ã¹ãã°è¯ãããšæããŸããããã§ã¯ãïŒç§ã調ã¹ãéãïŒWebã§ã¯åŸãããªãã£ããã£ãšå®æŠå¯ãã®ç¥èŠãæžããŠããããšæããŸãã
6502ã®å ç®åœä»€ã¯ADDã§ã¯ãªãADCïŒADD WITH CARRYïŒã§ããç¹ã泚æããå¿ çšãããã
äŸãã°,
ADC #$10
ã®æŒç®çµæ㯠A = A + #$10(16)
ã§ã¯ãªã A = A + #$10(16) + C
ã§ããã
ãã£ãªãŒ C
ã¯, çŽåã®æŒç®çµæã§ãã£ãªãŒãç«ã£ãå Žå㯠1
ã§ç«ããªãã£ãå Žå㯠0
ã«ãªãã
LDX #$FF
INX
; ãã®å Žå, C 㯠1 ã«ãªã
LDX #$00
INX
; ãã®å Žå, C 㯠0 ã«ãªã
ãã£ãªãŒã®çµæã«é¢ä¿ãªãåçŽã«å ç®ãããå Žå CLC
åœä»€ (Clear Carry) ãå®è¡ããŠäºããã£ãªãŒããªã»ããããªããã°ãªããªããïŒãããŠã6502ã«ã¯ãã£ãªãŒã䜿ããã«å ç®ããåœä»€ã¯ç¡ãïŒ
ADC #$10 ; ãã®å Žå a ã«ã¯ 16 or 17 ãå ç®ããã
CLC
ADC #$10 ; ãã®å Žå a ã«ã¯ 16 ãå ç®ããã
åœåãADCãåçŽãªå ç®ãšåéãããŠãèšç®çµæãæåŸ å€ãšéããã°ãå€çºããŠèŠåŽããããããïŒãã®commit ã§ADCã®åã«CLCãå®è¡ããä¿®æ£ãå ¥ãããŠããã®ã¯ãã®çºã§ãã...ïŒ
TAX ãš TXA ãåçŽã«ãã¿ãã¯ã¹ïŒâ»çšéã§ã¯ãªãïŒããã¿ã¯ãµãã¿ãããªèªã¿ã§æåèŠããŠããã®ã ãããã®èŠãæ¹ã«ã¯åé¡ãããã
ãããã®åœä»€ã¯Aã¬ãžã¹ã¿ãšXã¬ãžã¹ã¿ã®ä»£å ¥åœä»€ãªã®ã ããã©ã£ã¡æ¹åãªã®ããæ··åããã¡ã§ãããïŒäœåŠãšã¯èšããªãããéã§è§£èª¬ããŠãããŠã§ããµã€ãããã£ããããã®ã§äœèšã«æ··ä¹±ããŠããŸã£ã^^;ïŒ
以äžã®ããã«èŠãããšééããªããªã£ãã®ã§è¯ãæãã§ããã
TAX; Transfer A to X (AãXã«ä»£å
¥)
TXA; Transfer X to A (XãAã«ä»£å
¥)
from
ã§ã¯ãªãto
ã§ãããšèŠããã°ãŸãééããªãã ããŒã¢ããã¯ãA2X
ãX2A
ãªãééããªãã£ãèš³ã ããããŒã¢ããã¯ãã¢ã«ãã¡ãããçžãã«ããŠããã®ã£ãŠäœãçç±ãããã®ã ããã?
èªæ©ã®ã·ã§ãããæµæ©ãæµåŒŸãªã©ã®è€æ°ç»å Žãããªããžã§ã¯ã㯠4byteã®æ§é äœ ã§å®çŸ©ããã®ãæãŸããã4byteã«ããããšã§ åãã€ã³ããã¯ã¹ã»ã¬ãžã¹ã¿(X/Y)ã䜿ã£ãŠã¹ãã©ã€ãDMAã«ãã¢ã¯ã»ã¹ã§ãã ã®ã§åŠçå¹çãè¯ããªãã
é«æ§èœãªCPUã䜿ã£ãããã°ã©ãã³ã°ã«æ £ããŠãããšããã£ã4byteãšãäœãã§ããªããããããšæããããããããªããã8bitã®CPUãªãããã§å²ãšäœãšããªãã
å ·äœçã«ã¯, å šãŠã®æ§é äœã¯ä»¥äžã®ãããªããŒã¿æ§æã«ãªãã®ã§ã¯ãªãããšæãããã
- çåãã©ã°ïŒå Œçš®å¥å€å®ïŒã§1byte
- 座æšã§2byte
- æ±çšå€æ°ã§1byte
ãµãã«ãŒãã³ã®åŒã³åºãã«ããåŠçåå²ã¯ãããžãã¯ãæ§é åããŠèŠãããã§ããåé¢ã¡ãã£ã¯ãã£éãã å ·äœçã«ã¯JSR(åŒã³åºã)ã§6ãµã€ã¯ã«ãRTS(埩垰)ã§6ãµã€ã¯ã«ãªã®ã§åèš12ãµã€ã¯ã«ã䜿ã£ãŠããŸãã
ãã¡ãã³ã³ã®CPU (RP2A03) ã®æ§èœã¯1.7MHzãªã®ã§ã1ç§ã«çŽ170äžãµã€ã¯ã«å®è¡ã§ããã 1ãã¬ãŒã ïŒ1/60ç§ïŒã§ã¯çŽ28333ãµã€ã¯ã«å®è¡ã§ããã ãã®äžã§ã¡ã€ã³ã«ãŒãã®å šãŠã®åŠçãå®è¡ããªããã°ãªããªãã®ã§ããã£ã12ãµã€ã¯ã«ããã©12ãµã€ã¯ã«ã§ããã
ãªã®ã§ããµãã«ãŒãã³åŒã³åºãã§åŠçãæ§é åããããšãããšã€ã¿ã€ç®ãèŠãã ãã¡ãããå®è£ ããã¬ã€ã«æ§é åããªããšåŸããæãå ¥ããã®ãå°é£ãªã¹ãã²ããã£ããã°ã©ã ã«ãªã£ãŠããŸãã®ã§ãããã¯ããã§å°ãã¢ãã§ããããåŠçé床çã«åé¡ãªãå ã¯ãã¬ã€ã«æ§é åããŠãããæ§èœã足ããªããªã£ããæ§é åã厩ããªããæé©åã«åªãããšããæãç¡ãã¯ãªãã
ãªãããããªããªãã¹ã䜿ããªãæ¹ãè¯ããµãã«ãŒãã³ãã ãããã©ã³ãåœä»€ã¯æ倧ã§ã255ãã€ãå ãŸã§ãããžã£ã³ãã§ããªãã®ã§ããã®åé¡ã«åŒã£ãããå Žåã«ã¯äœ¿ããããåŸãªããã€ã³ããã¯ã¹ãè€æ°åãïŒéã«ãŒããšããå®è£ ãããšãå€åŽã®ã«ãŒãããã©ã³ãã§é£ã¹ãªããªãã®ã§å åŽã®ã«ãŒãåŠçããµãã«ãŒãã³åããå¿ çšãåºãŠãããstg.asmã§ã¯ãæµãã£ã©ãšèªæ©ã·ã§ããã®åœããå€å®ããããããæµãã£ã©ã®ç§»åã«ãŒãå ã§èªæ©ã·ã§ãããšã®åœããå€å®åŠçïŒsub_moveEnemy_hitCheckïŒããµãã«ãŒãã³ãšããŠåŒã³åºãããã«ããŠããã
äœè«ã ãã6502ã«ã¯indexã¬ãžã¹ã¿ãxãšyã®ïŒã€ããããã²ãŒã ãäœãäžã§ã¯2ã€ã®indexãããããšãããªã䟿å©ã ãšåœããå€å®ã®ããžãã¯ãçµãã§ã¿ãŠå®æã§ããã
ãã®ãµã³ãã«ã²ãŒã ã®å Žå, èªæ©ãšæµã·ã§ããã®åœããå€å®ãå ¥ãã ãã®commit ã§ã€ãã«ãã¡ãã³ã³ã®æ§èœéçãè¶ ããŠåŠçèœã¡ãçºçããããã«ãªã£ããããã§ã以äž2ç¹ã®ä¿®æ£ãå ¥ããŠäœãšãéçåé¿ããããšã«ããã
- æµã·ã§ããã®äžéæ°ã16â8ã«äžæ¹ä¿®æ£ (commit)
- å€æ°ãå šéšãŒãããŒãžã«ç§»ã (commit)
幞ããã²ãŒã ã®ä»æ§äžæµã·ã§ãããåæžãããŠã鬌çé£åºŠãä¿ãŠãã®ã§ãæµã·ã§ãããåæžãããã16ãããªããŠ10ãšãã§è¯ããããããªããããªããžã§ã¯ãæ°ãåå2ã®nä¹ã«ãããã£ãã®ã§8ã«ããïŒâ»ã³ã¬ã«ã€ããŠã¯å¥ãããã¯ã§åŸè¿°ãããå®çšçãªçç±ã¯ç¹ã«ç¡ã) ã
å€æ°ã«ã€ããŠããå šéšã®å€æ°ã®ç·ãµã€ãºãèšç®ããŠã¿ããšããäœè£ããã£ãŠå šéšãŒãããŒãžã«åãŸãã®ã§ãå šéšãŒãããŒãžã«ç§»ãããïŒãŒãããŒãžã«ç§»ãããšã§load/storeã«èŠãããµã€ã¯ã«ã1ãµã€ã¯ã«åãããšãã§ããïŒ
ãŒãããŒãžã¯WRAMã® $0000ã$00FF ã®ç¯å²ã§ããã®ç¯å²å ãªãä»ïŒ$0100ã$1FFFïŒãšæ¯ã¹ãŠãã§ããæ°ã1åã£ãŠã¢ã¯ã»ã¹ã§ããã®ã§ã¢ã¯ã»ã¹æ§èœãè¯ãåé¢ãæ倧256ãã€ããã䜿ããªãã®ã§ç¡éã«äœ¿ãããšãã§ããªããïŒå šå€æ°ã®ãµã€ãºåèšã256ãã€ã以äžã§ããã°ç¡éã«äœ¿ã£ãŠãè¯ãïŒ
ãã®ã²ãŒã ã§ã¯ãèªæ©ã·ã§ãããæµã·ã§ãããæµæ©ãªã©ã®è€æ°ãªããžã§ã¯ãã®äžéæ°ãå šãŠ2ã®nä¹ã«ããŠããããããã«ã¯å®ã®ãšããå®çšçãªçç±ã¯ãªãã
äŸãã°2ã®nä¹ã§ã¯ãªãå Žåãã¬ãžã¹ã¿ã«äœè£ãããã°ä»¥äžã®ããã«indexã䜿ã£ãŠåãããšãã§ãããã®æã¯ãããã2ã®nä¹ã«ããå¿ èŠã¯ãªãã
ldx #$05 ; x = 5
loop:
(loop procedure)
dex ; x--
bne loop ; branch if x != 0
ãã ããã¬ãžã¹ã¿ã«äœè£ãç¡ãç¶æ³ã§ã¯ãã«ãŒããåãã®ã«äžã€ã®ã¬ãžã¹ã¿ã朰ãã®ãæããã±ãŒã¹ããŸãŸããããã®å Žåãã¬ãžã¹ã¿ã«ã«ãŒããã©ã°ãšæ§é äœã®èŠçŽ æ·»åãå Œçšãããããšã§ã¬ãžã¹ã¿ãç¯çŽã§ããã
ãµã€ãº4 & èŠçŽ æ°16 ã®æ§é äœã§ããã°ä»¥äžã®ããã«å®è£ ã§ããã
ldx #$00 ; x = 0
loop:
(loop procedure)
txa ; a = x
clc ; ãã£ãªãŒãã¯ãªã¢
adc #$04 ; a = a + 4
and #$3f ; a = a and $3f (%00111111)
tax ; x = a
bne loop ; branch if x != 0
ãªããžã§ã¯ãæ°ïŒãšæ§é äœãµã€ãºïŒã2ã®nä¹ã§ããã°, ãªããžã§ã¯ãæ°ïŒÃæ§é äœãµã€ãºïŒ- 1
ã§è«çç©ïŒANDïŒããããšã§ãäžéå€ãè¶
ããæã«0ã«æ»ãã®ã§ bne
ã§ã«ãŒãç¶ç¶å€å®ãã§ããã
ãããä»®ã«ãªããžã§ã¯ãæ°ã®äžéã10ã ãšãããšä»¥äžã®ããã«ãªãã
ldx #$00 ; x = 0
loop:
(loop procedure)
txa ; a = x
clc ; ãã£ãªãŒãã¯ãªã¢
adc #$04 ; a = a + 4
tax ; x = a
cmp #$28 ;
bcc loop ; branch if a < 40 ($28 = 4 * 10)
äžèš2ã€ã®ã³ãŒãã®éã㯠and -> cmp
+ bne -> bcc
ãããªãã
ãããŠãandãcmpãbneãbccã¯å
šãŠ(and+cmpã¯å³å€èšç®ãªã) 2ãµã€ã¯ã«ã®åœä»€ãªã®ã§ãã©ã¡ãã®åŠçãæ§èœé¢ã§ã®éãã¯ç¡ããïŒãªããšãªããcmpãããandã®æ¹ãæ©ãããªæ°ããããïŒ
andãçšããã¡ãªãããšããŠã¯ã
- andã®æ¹ãå®è£ çã«ã¯èŠãããïŒãã£ãªãŒãããŒããã©ã°ã§ã®ãã©ã³ããèŠãããïŒ
- ã«ãŒãåŸã«ã¬ãžã¹ã¿ããªã»ããç¶æ ïŒ0ïŒã«ãªãïŒã«ãŒãåŸã«ã¯ãªã¢ãå¿ èŠãªã±ãŒã¹ã§ã¯åœä»€æ°ãç¯çŽã§ããïŒ
ãããã®ãã®ã§ã¯ãªãã ãããã ãªã®ã§ããã®éšåã¯ã奜ã¿ã§å®è£ ããã°è¯ãã¬ãã«ãšããã®ãç§èŠã
ãã®ãããã¯ã®ã¿ã€ãã«ã¯ã©ã¡ãããšãããšãã1ã€ã®ã¬ãžã¹ã¿ã§ã«ãŒãå€å®ãšãªããžã§ã¯ãèŠçŽ ã®æ·»åãå Œçšããããã¯ããã¯ãã ã£ããããããªãã
åè§åœ¢ã®ãªããžã§ã¯ãå士ã®åœããå€å®ã¯ãäŸãã° 16x16ã®ãªããžã§ã¯ãa
(座æš: v_ax, v_ay) ãš 8x8ã®ãªããžã§ã¯ãb
(座æšå€æ°: v_bx, v_by) ã§ããã°ä»¥äžã®4ã€ã®èšç®åŒãå
šãŠ true ãªãè¡çªãããšèŠåãããšãã§ããŸãã
- checkX1: aã®å³ç«¯ > bã®å·Šç«¯
- checkX2: aã®å·Šç«¯ < bã®å³ç«¯
- checkY1: aã®äžç«¯ > bã®äžç«¯
- checkY2: aã®äžç«¯ < bã®äžç«¯
Cèšèªã§ããã°ä»¥äžã®ããã«èšç®ããŠãããã°è¯ãã§ãã
if (v_ax + 16 >= v_bx && // checkX1 (æ¯èŒæŒç®ã¯ > ã§è¯ãã§ããã³ãŒãããããããããããã >= ã«ããŸã)
v_ax < v_bx + 8 && // checkX2
v_ay + 16 >= v_by && // checkY1 (æ¯èŒæŒç®ã¯ < ã§è¯ãã§ããã³ãŒãããããããããããã <= ã«ããŸã)
v_ay < v_by + 8) { // checkY2
// è¡çªããæã®åŠç
}
Cèšèªã§å€æ°åã®ãã¬ãã£ã¯ã¹ã«
v_
ãªããŠä»ããããšã¯ãªããšæããŸããããã·ã³èªã ãšã¬ãžã¹ã¿çãšæ··åããŠããŸãã®ãé¿ãããããå€æ°åã ãšåããããã«ãã¬ãã£ã¯ã¹ãä»äžããã³ãŒãã£ã³ã°ã«ãŒã«ãšããæ¹ãè¯ãã§ãã
ãããåçŽã«6502ã§æžããšã以äžã®ããã«ãªããŸãã
checkX1:
lda v_ax ; ã¬ãžã¹ã¿a = v_ax
clc
adc #16 ; ã¬ãžã¹ã¿aã«16ãå ç®
cmp v_bx
bcc not_hit ; ã¬ãžã¹ã¿a(v_ax+16) < v_bx ãªãè¡çªããªãã£ããšå€å®
checkX2:
lda v_bx ; ã¬ãžã¹ã¿a = v_bx
clc
adc #8 ; ã¬ãžã¹ã¿aã«8ãå ç®
cmp v_ax
bcc not_hit ; ã¬ãžã¹ã¿a(v_bx+8) < v_ax ãªãè¡çªããªãã£ããšå€å®
checkY1:
lda v_ay ; ã¬ãžã¹ã¿a = v_ay
clc
adc #16 ; ã¬ãžã¹ã¿aã«16ãå ç®
cmp v_by
bcc not_hit ; ã¬ãžã¹ã¿a(v_ay+16) < v_by ãªãè¡çªããªãã£ããšå€å®
checkY2:
lda v_by ; ã¬ãžã¹ã¿a = v_by
clc
adc #8 ; ã¬ãžã¹ã¿aã«8ãå ç®
cmp v_ay
bcc not_hit ; ã¬ãžã¹ã¿a(v_by+8) < v_ay ãªãè¡çªããªãã£ããšå€å®
ãã ããäžèšã®åœããå€å®ãç»é¢å šäœïŒ256x240ïŒã§çºçããå Žåãæ¡ããµãïŒãªãŒããŒãããŒïŒçºçã«æ³šæããªããã°ãªããŸãããå ·äœçã«ã¯ããµã€ãº16ã®ãªããžã§ã¯ãaãç»é¢å³ç«¯240pxã«ããç¶æ ã§å€å®ãããšã以äžã®ããã«æå³ããªãå€å®ããããŠããŸããŸãã
checkX1:
lda v_ax ; ã¬ãžã¹ã¿a = v_ax (240)
clc
adc #16 ; ã¬ãžã¹ã¿aã«16ãå ç® â 240 + 16 = 0 (8bitãªã®ã§)
cmp v_bx
bcc not_hit ; 0 < v_bx ãªãè¡çªããªãã£ããšå€å® (æå³ããªãå€å®)
ããã§ã以äžã«v_axã240以äžã§ãæ£åžžã«å€å®ã§ããå®è£ äŸã瀺ããŸãã
checkX1:
lda v_ax ; ã¬ãžã¹ã¿a = v_ax
cmp #240
bcs x1ov16 ; v_axã240以äžãªãx1ov16ãžåå²ããŠå¥ã®æ¹æ³ã§ãã§ãã¯
clc
adc #16 ; ã¬ãžã¹ã¿aã«16ãå ç®
cmp v_bx
bcc not_hit ; ã¬ãžã¹ã¿a(v_ax+16) < v_bx ãªãè¡çªããªãã£ããšå€å®
checkX2:
lda v_bx ; ã¬ãžã¹ã¿a = v_bx
clc
adc #8 ; ã¬ãžã¹ã¿aã«8ãå ç®
cmp v_ax
bcc not_hit ; ã¬ãžã¹ã¿a(v_bx+8) < v_ax ãªãè¡çªããªãã£ããšå€å®
bcs checkY1 ; x1ov16 ãå®è¡ããªãããã«ãã©ã³ã
x1ov16:
lda v_bx
cmp #232
bcc not_hit ; v_bxã232æªæºãªãè¡çªããªãã£ããšå€å®
checkY1:
æåã«v_axã240以äžããã§ãã¯ããŠã240以äžã§ããã° x1ov16
ãšããå¥ã®å€å®ããžãã¯ã«ãã©ã³ãããŠãããã§v_bxã232ïŒ240-8ïŒæªæºãã©ãããã§ãã¯ããŸããããã«ãããªãŒããŒãããŒãåé¿ãã€ã€å€å®ã§ããããã«ãªããŸããã
ãã ãåœããå€å®ã¯ãã£ã1åã§äžè¿°ã®ããã«ããªã沢山ã®åœä»€ãå®è¡ããå¿ èŠããããæŽã«è€æ°ãªããžã§ã¯ãã察象ã«å®è¡ããå ŽåãåŠçã®å®è¡æ°ãææ°çã«å¢å ããŠããŸããŸãããªã®ã§ãäžèšã®ããã«å³å¯ãªãã§ãã¯ããã¹ããã¯ã±ãŒã¹ãã€ã±ãŒã¹ããšæããŸãã
ãã¡ãã³ã³ã®CPUïŒRP2A03ïŒã«ã¯ãªã³ããã㧠ç©åœ¢æ³¢2chãäžè§æ³¢1chããã€ãº1chãDPCM 1ch ã®AY-3-8910ãæ¡åŒµãããšæããé³æºãå®è£ ããŠããŠãããããæ°ã ã®åæ²ãçãŸããŸãããç§ãçµæ§ããããã¥ãŒã³é³æ¥œã奜ãã§ããããããã¥ãŒã³å¥œããé«ããŠèªäœã®ããããã¥ãŒã³é³æºïŒVGSïŒãäœããæ±æ¹Projectã®é³æ¥œãVGSçšã«ããŠã³ã°ã¬ãŒãã»ã¢ã¬ã³ãžããŠäœã£ã楜æ²ãé ä¿¡ããã¢ããªïŒæ±æ¹BGM on VGSïŒã以åäœã£ãŠãããããã§ãã
èªäœã®ãã¡ãã³ã³ã²ãŒã ã§é³æ¥œãåçããã«ã¯é³æºãã©ã€ããå®è£ ããå¿ èŠããã£ãŠãããã¯çµæ§æ·å± ãé«ãã®ã§ãããä»ãªã pently ãšããçŽ æŽãããã©ã€ãã©ãªãZLIBã©ã€ã»ã³ã¹ã§å ¬éãããŠããã®ã§ãããã䜿ãã°å²ãšç°¡åã«é³æ¥œä»ãã®ã²ãŒã ãäœãããšãã§ããŸãã
ããããä»åã®ç¿äœã§ã¯ãRP2A03ã®é³æºæ©èœãé³æ¥œã§ã¯ãªãå¹æé³ã«å šæ¯ãããŠã¿ãããšã«ããŸãããïŒç¿äœã ãããªãã¹ãå€éšããã°ã©ã ãåæã«ããããªãã£ãäºã«å ãããã©ã€ããèªäœãããšãªããšããã ãã§çµæ§å€§äœã«ãªã£ãŠããŸãããã¡ãã³ã³ã²ãŒã ã®äœãæ¹ã®å匷çšã«ã¯åããªãæ°ããããšããå®çšçãªçç±ããããŸãïŒ
RP2A03æšæºé³æºã¯è²§åŒ±ã ãšèšãããŠããŸãããããšãå¹æé³åçé³æºããšèŠåããæã®RP2A03ã¯å²ãšãŽãŒãžã£ã¹ã§ããåæã«4çš®é¡ã®å¹æé³ãåçã§ããã®ã§ãããŸããå¹æé³ãåçããã®ã«å¿ èŠãªæäœã¯loadãšstoreã4åïŒã€ãŸã4byteã®I/OããŒã転éãïŒå®è¡ããã ããªã®ã§ãåŠçè² è·ãžã®åœ±é¿ã軜埮ã§æžã¿ãŸãã
å¹æé³ã®å®è£ äŸã¯ããã®commitãèŠãã°åããããã«ããŠãããŸããã ç¿äœããããç©åœ¢æ³¢2chãäžè§æ³¢1chããã€ãº1chã®å šãŠã䜿ã£ãŠããŸãããDPCMã¯æ®å¿µãªãã䜿ã£ãŠãŸããã (DPCMã§ããã¹ããã€ã»ãŒã ã»ãªãŒã«!!ããšé³Žããããã£ããã©æ念)
ãã©ãŠã³ç®¡ãã¬ãã¯èµ°æ»ç·ã1ç§éã«60åã®åšæïŒ60HzïŒã§äžããäžã«æµããŠç»é¢ãæç»ããŠãŸãããã¡ãã³ã³ã®ã°ã©ãã£ãã¯ã¯ã瞊240pxãèµ°æ»ç·ã®æµãã«åŸã£ãŠãã¬ãã«è¡šç€ºãããŸããã1åã®æŽæ°åšææã«16pxåã®ç»é¢ãæŽæ°ããªãåšæãããããããvBlankãšåŒãã§ããŸãã
ãã¡ãã³ã³ã®ã°ã©ãã£ãã¯ã®æžãæãåŠçã¯ãã®vBlankæéã«è¡ããªããã°ãªããŸããã
vBlankæéå€ã«æŽæ°ãè¡ãããšã§æå³çã«æç»ãä¹±ããããè¡šçŸææ³ãååšããŸãããã¶ãããã©ãŽã³ã¯ãšã¹ãã®æ ã®æãšãããã®ææ³ã䜿ã£ãŠããã¯ãã
ãã®vBlankæéãšããã®ããšã«ããçãã
ã¹ãã©ã€ãã«é¢ããŠã¯ãDMA転éã䜿ãã®ã§240pxãæŽæ°äžã«ã¡ã¢ãªæŽæ°ãæžãŸããã ãã§è¯ãã®ã§ãããåé¡ã«ãªã£ãŠããã®ã¯BGã§ãããã®ç¿äœã§ã¯ãèæ¯ã®æã®è¡šç€ºãã¹ã³ã¢è¡šç€ºãã¡ãã«è¡šç€ºãã²ãŒã ãªãŒããŒè¡šç€ºã®æŽæ°ãvBlankæéã«å šãŠè¡ãããã®ã§ãããå šéšãåæã«è¡ãããšã¯vBlankã®æéå ã§ã¯ããç¡çããããŸããïŒãããŠããªãã¹ãæŽæ°åŠçãæ©ãåãäžããŠã²ãŒã ã®ã¡ã€ã³åŠçã«å²ããCPUãªãœãŒã¹ã確ä¿ãããïŒ
ããã§ã
- èæ¯ã®æãæç»ïŒ4ãã¬ãŒã ã«ã€ã1åã ãè¡ã£ãŠããïŒããæã¯ãã®ä»ã®æç»ãskip
- ã¹ã³ã¢è¡šç€ºãæŽæ°ããæã¯ãã®ä»ã®æç»ãskip
- ã¡ãã«è¡šç€ºãæŽæ°ããæã¯ãã®ä»ã®æç»ãskip
ãšãã£ã圢ã§æç»åŠçã®skipãè¡ãããšã«ããŸããã skipããããã®ä»ã®æŽæ°åŠçã¯ãå€æ°ãäžæã䜿ã£ãŠæ¬¡åã®vBlankæéã§ãåºæ¥ãããã«ããŠããå¿ èŠããããŸãã
ãã¡ãã³ã³ãšææ°ã®ã²ãŒã æ©ã®æ倧ã®éãã¯ãã¢ã€ãã£ã¢ã圢ã«ãããŸã§ã®ã³ã¹ãã§ãã
ãã¡ãã³ã³ã ãšã¢ã€ãã£ã¢ã®å šãŠã圢ã«ããããšãããšãæ³åããŠããããããã£ãšæ©ãããŒããªãããã®å£ã«ã¶ã€ãããŸããä»åã®ç¿äœã§ãå²ãšæ©ã段éã§éçãèŠããŠããŸããããã¡ãã³ã³ã ãšå šãŠã®ã¢ã€ãã£ã¢ã圢ã«ããããšã¯åºæ¥ãªãã®ã§ãåºæ¥ãç¯å²ã§äœãã§ããããèãããã¢ã€ãã£ã¢ã®ããç¹°ããã¿ãããªããšãããå¿ èŠããããŸãã
ã²ãŒã ãäœãããšãããšæ象ç¡è±¡ãªã¢ã€ãã£ã¢ãçãŸããŠããããšæããŸãããããŒããªããããã»ãŒç¡ãçŸä»£ã®ã³ã³ãã¥ãŒã¿ãªããéãšæéããæããã°ãã®å šãŠãå®çŸã§ããŠããŸãäžæ¹ããã¡ãã³ã³ã ãšã¢ã€ãã£ã¢ã®ããç¹°ãã®éçšã§ããããªããã£ããªãã®ãåªå ããŠãããªããã°ãªããŸããã
ææ°ã®ã²ãŒã æ©ã ãšæ象ç¡è±¡ãªãã®ãåºæ¥ãŠããŸããªã¹ã¯ãé«ãã®ã§ãæããææ°ã®ã²ãŒã éçºã®çŸå Žã§ã¯ã¢ã€ãã£ã¢ãç ®è©°ããããã«å»¶ã ãšäŒè°ãç¹°ãè¿ããŠããã®ã§ã¯ãªãããšæ³åã§ããŸããç§ã¯äŒè°ãå«ããªã®ã§æ³åããã ãã§é£å·æ°å³ã«ãªã£ãŠããŸãã®ã§ãããã¢ã€ãã£ã¢ãšã¯ååºç¹ãç©åãé«ã液äœã¿ãããªãã®ã ãããã£ãšããã¯å¿ èŠçµè²»ãªã®ã ãããšæããŸãã
ããŒããªããããäœãããšã¯ãã¡ãªããã§ãããªããšæãããã¡ã§ãæ¶è²»è èŠç¹ã§ã¯å®éãã®éããªã®ã§ãããã¯ãªãšã€ã¿ãŒèŠç¹ã§ã¯ã¢ã€ãã£ã¢ã®ååºç¹ãäžããŠããããšããããªã倧ããªã¡ãªããããããšãããŸãã
ãã³ãã³åç»ãªã©ã§ã²ãŒã ã®çžããã¬ã€åç»ãçµæ§äººæ°ããããŸããããã¡ãã³ã³ã§ã®ã²ãŒã éçºã¯ã²ãŒã éçºã«ãããçžããã¬ã€ãšããããããããŸããããããã觊ã£ãŠã¿ããšæã£ãŠãããããã²ãŒã ãäœãäžã§å¿ èŠååãªæ©èœãå šãŠæã£ãŠããŠãããã§ãçžããã¬ã€ã§ããããšã«ã¯éããªãã§ããéåæŠããšããçšã®ãã®ã§ããªãã§ãã
ãããã1983幎ã®æç¹ã§æ¢ã«ãã®åã«éããŠããäºã«é©ããŸããç§ã¯1990幎代ã«ãã¡ãã³ã³ã®10å以äžã®æ§èœãæã€PC-98ã§ã²ãŒã ããã°ã©ãã³ã°ãããŠããã®ã§ãããã¢ã¯ã·ã§ã³ã²ãŒã ã®éçºçšéãšããŠã¯ãã¡ãã³ã³ã®æ¹ããã£ãšäžã ã£ããšæèšã§ããŸãã äœããPC-98ã«ã¯ã¹ãã©ã€ããç¡ãã®ã§ã
ã¹ãã©ã€ãã®äºãå·®ãåŒããŠããã²ãŒã éçºã®ãæããšããç¹ã§ã¯PC-8801mkIISRãšãã®æ¹ãäžã ã£ãããããã ããåŸç¶æ©ã§ããPC-88VAïŒ16bitïŒã¯ã¹ãã©ã€ããå ¥ãããã®ã®ç¡æ®ãªçµæã«çµãããŸãããïŒx68kã匷ãããïŒã次äžä»£æ©ïŒ16bitïŒã®åã®æ®µéïŒ8bitïŒã®æç¹ã§ã88ã«ãã¡ãã³ã³çžåœã®ã¹ãã©ã€ãæèŒããŠãããäžçã¯å€§åéã£ããããããªãã98å šçæ代ã§ã8bitã®88ãäŸ¡æ Œåªäœæ§+äž»ã«ã²ãŒã ãäœããã人éåãã«æ²¢å±±å£²ãç¶ããçµæçã«98ããã88ã®æ¹ãé·ãçãæ®ãç¶ãããããããŸããã
ãã¡ãã³ã³ã¯ããœã³ã³ãšéãã²ãŒã ã«ç¹åããã³ã³ãã¥ãŒã¿ã§ããã ãããã²ãŒã ãšããéå®æ¡ä»¶äžãªã10幎è¿ãäžä»£å·®ãããããžãã¹ã³ã³ãã¥ãŒã¿ãšã匵ãåããã®ã ãšæããŸããçŸä»£ã®ã³ã³ãã¥ãŒã¿ã§äŸãããªããUnityã§äœã£ãããã¢ããªããåããªãã³ã³ãã¥ãŒã¿ãã¿ãããªãã®ãšèãããšãããæããããããŸããã Unityã®å Žåãã²ãŒã ãäœãããã«å¿ èŠãªæ©èœããœãããŠã§ã¢ã®ã¬ãã«ã§æœåºããŠã²ãŒã éçºè ãžæäŸããŠããŸããããã¡ãã³ã³ã¯åã«ãããããŒããŠã§ã¢ã«ãªã£ãã ãã§ããæ§èœã¯èããæªãã§ããã
ç¿äœããŠããå ã«æ°ã¥ããTIPSãæžãæºããŠå ¬éããããšæã£ãŠããã®ã§ãããæãã®å€ã玹ä»ã§ãããã¿ãå°ãªããåŸåã¯äž»ã«ç²Ÿç¥è«ã«ãªã£ãŠããŸã£ããããããŸããããã¯ããã²ãŒã éçºã¯ææžãèªãã§åŠã¶ãã®ã§ã¯ãªããå®éã«äœã£ãŠã¿ãããšãäžçªããšæããŸããç§ã¯ã³ãã©ã®ãµã€ãã§ãã¡ãã³ã³äžã§HELLO WORLDã衚瀺ããããã°ã©ã ãããŠã³ããŒãããŠããããcc65ã§ã¢ã»ã³ãã«ããŠåããããšããå§ãã衚瀺äœçœ®ãå€ããŠã¿ãããè²ãå€ããŠã¿ãããã¹ã¯ããŒã«ããŠã¿ãããã¹ãã©ã€ãã衚瀺ããŠã¿ãããã¹ãã©ã€ãããžã§ã€ãããã§åãããŠã¿ãããAãã¿ã³ã§ã¹ãã©ã€ãããã·ã§ãããæãŠãããã«ããŠã¿ãã...ãšãã颚ã«æ¹é ãéããçµæããã®ã²ãŒã ãå®æããŸãããããçšåºŠã®å®æåã¯æããŠããŸãããåºæ¬è¡ãåœããã°ã£ããã§äœããŸãããããããã¡ãã³ã³ã®ã²ãŒã ãäœã£ãŠã¿ãããŠãã®ãªããžããªã«èŸ¿ãçããæ¹ãå± ãã°ãå¿ èŠååãªç°å¢ã¯æ¢ã«æŽã£ãŠããã®ã§ããŸãã¯ãã®ã²ãŒã ã®ããŸãã«ã鬌çãªé£åºŠãäœãšãããããã«æ¹é ããŠã¢ã»ã³ãã«ããŠåãããŠã¿ããšãã£ããšããããå§ããŠã¿ããšè¯ããããããŸããã
æåŸã«ãã®ç¿äœã®ãœãŒã¹ã³ãŒãã®èªãäžã§åèã«ãªããããªæ å ±ãæžããŠãããŸãã
- src/stg.asm
- æåã¯ãã®ãœãŒã¹ããäœãå§ããã®ã§ãããéäžããé·ããœãŒã¹ãæ¹ä¿®ããã®ã倧å€ã«ãªã£ãã®ã§å¹Ÿã€ãã®ãã¡ã€ã«ã«åé¢ã㊠include ããŠèªã¿èŸŒãããã«ããŸãã
- æçµçã«ãã®ãœãŒã¹ã¯ä»¥äžã®ãããã¯ã ããæ®ããŸãã
- iNESãããã®å®çŸ©
- ã¹ã¿ãŒãã¢ããåŠç
- å®æ°å®çŸ©
- 8bitã³ã³ãã¥ãŒã¿ã®ã¡ã¢ãªã¯64KBãããŸããããã¡ãã³ã³ã®ã¡ã¢ãªãããã¯å€§éæã«åãããšãåå32KB($0000ã$7FFF)ãRAMãI/OããŒããåŸå32KB($8000ã$FFFF)ãã³ãŒããšããå ·åã«ãªã£ãŠããŸãã
- ãã®ã²ãŒã ã®ã³ãŒããµã€ãºã¯ãã·ã³èªã«å€æãããš4KBã»ã©ãããŸããããã®å šéšãããã°ã©ã ãšããèš³ã§ã¯ãªãåŸåé åã«æååããã¬ãããšãã£ãåºå®å€ã®ããŒã¿ãçªã£èŸŒãã§ããŸãã
- å€æ°ã©ãã«
- 64KBã®ã¡ã¢ãªã®å ãããã°ã©ã å ã§æžãæãå¯èœãªå€ïŒå€æ°ïŒãã¢ãã¬ã¹ã®äœçªå°ã«å²ãåœãŠããå®çŸ©ããŠããŸã
- Cèšèªãªã©ã®ããã°ã©ã ã§èšããšããã®ã°ããŒãã«å€æ°ã¿ãããªãã®ã§ãïŒã€ãŸããå šéšã®å€æ°ãã°ããŒãã«å€æ°ã§ç®¡çããŠããŸãïŒ
- å€æ°ãšããŠäœ¿ããé åã¯æ±ºãŸã£ãŠ
$0000ã$00FF
(0ããŒãž) ãš$0200ã$07FF
(2ã7ããŒãž) ãŸã§ã®åèš $0700 ãã€ãïŒ1792ãã€ãïŒã§ãïŒMAPPER0ã®å ŽåïŒ - ãã®ã²ãŒã ã®å Žåã0ããŒãžãäžè¬å€æ°çšã3ããŒãžãã¹ãã©ã€ãDMA転éçšã«äœ¿ã£ãŠããŠæ®ã5ããŒãžã¯æªäœ¿çšã ããããŸã ãŸã æŠããŸã
$0100ã$01FF
ã®ç¯å²ã¯ã¹ã¿ãã¯é åã§ãPHA/PLAãªã©ã§ã¬ãžã¹ã¿ã®å€ãäžæçã«ä¿æããããã®ãã®ã§ãïŒCèšèªã§ããã°ã©ã ãäœãå Žåãã£ã256ãã€ãã ãšäœãã§ãªãã¬ãã«ãããããŸãããããªãŒã«ãã·ã³èªã§çµãå Žåã¯256ãã€ããå²ãšæãŠäœãã®ã§ãé åã足ããªããªã£ããåŸå128ãã€ãã朰ãã®ãã¢ãªããïŒ
- CHARSã»ã°ã¡ã³ããžã®ãã€ããªèªã¿èŸŒã¿
- ã¹ãã©ã€ãã®ãã¿ãŒã³ããŒã¿ïŒCHRãã¡ã€ã«ïŒãCHARSã»ã°ã¡ã³ãã«èªã¿èŸŒãããã«ããŠããŸã
- RPGãã¢ã¯ã·ã§ã³ã²ãŒã ã®ããããªã©ã®ã¿ã€ã«ãã¿ãŒã³ããã®
.incbin
ãšããããªããã»ããµã§èªã¿èŸŒãã§ãããã°è¯ãããã§ã
- src/stg-00title.asm
- ã¿ã€ãã«ç»é¢ã§ãïŒäžçªæåŸã®æ¹ã§äœããŸããïŒ
- src/stg-01setup.asm
- ã¿ã€ãã«ã®ã«ãŒããæããåŸã«å®è¡ãããã²ãŒã ã®åæååŠçã§ã
- BGã®æç»ãåçš®å€æ°ã®åæåãè¡ã£ãŠããŸã
- WRAMã®é åã¯åæåããªããšäžå®å€ãå ¥ã£ãŠããŠãã°ãã®ã§WRAMé åã0ã¯ãªã¢ããåŠçãå ¥ããæ¹ãè¯ãã£ãããïŒå®éã0ã¯ãªã¢æŒãã§çµæ§ãã°ã£ããããªïŒ
- src/stg-02mainloop.asm
- ã²ãŒã ã®ã¡ã€ã³ã«ãŒãåŠçã§ã
- ãã®ãœãŒã¹ã®é ããæ«å°ŸãŸã§ã®åŠçã1ç§éã«60åå®è¡ãããŠããŸã
- ç¹ã«éèŠãªã®ãvBlankã®åæãããŠãããã®ããžãã¯ã§ã
lda $2002
ã§PPUã®ç¶æ ãèªã¿èŸŒã¿ negative flag ãã¯ãªã¢ãããŠããéã¯åªç®¡lda $2002
ãç¹°ãè¿ããŠããŸã- ããã«ãããã®ã«ãŒããæããæ = vBlankãçºçäžãšãªããŸãïŒãã®éã«ã°ã©ãã£ãã¯ã®æŽæ°åŠçãã§ããŸãïŒ
- ã¹ãã©ã€ãã«é¢ããŠã¯3ããŒãžã®å 容ãDMA転éããããã«æ瀺ããŠããã ãã§ããã以éã®ããžãã¯ã¯å šãŠBGã®æŽæ°åŠçã§ã
- ãã®ä»ãœãŒã¹: ãµãã«ãŒãã³ã§ãïŒå šãŠã¡ã€ã³ã«ãŒãããè¿œããããããšãã§ããŸãïŒ
- äžè¬åã: GPLv3
- ã«ã¹ã¿ã ã©ã€ã»ã³ã¹ãåžæãããå Žåemailã«ãŠåå¥ã«ãé£çµ¡ãã ãã