Skip to content

Commit

Permalink
Game improvements (#23)
Browse files Browse the repository at this point in the history
* add music menu

* add battle music

* do not restart music anytime

* add zip's to clean in Makefile

* colorfull game

* fixed: reset behavior npc #17

* improve gamepads & support 4 players #11

* randomization adjustment to standardize US/JAP

* fix color order

* attack with button A or B

* pallete bg & fixes

* BR_BL_TR_TL

* optimize put_logo

* organize logo, players & score

* small optmizations

* tileset characters adjustments

* add badges
  • Loading branch information
RodrigoDornelles authored Jul 5, 2022
1 parent 06bc8b5 commit 30e0fba
Show file tree
Hide file tree
Showing 13 changed files with 630 additions and 886 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cc65
*.o
*.s
*.nes
*.nes.zip
./*.s
./bin/*
!asm/*.s
!bin/.gitkeep
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ clean:
@rm -fv $(TARGETS)
@rm -fv $(OBJECTS)
@rm -fv $(ASSEMBLY_SOURCES)
@rm -fv *.zip
@rm -fv asm/crt0.o

%.s: %.c
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# coco-battle-royale-2
# `Coco Battle Royale II`<br/>`ココバトル (kokobatoru) 2`

[![version](https://img.shields.io/github/v/release/psywave-games/coco-battle-royale-2?sort=semver&label=download)](https://github.com/psywave-games/coco-battle-royale-2/releases)
[![license](https://img.shields.io/github/license/psywave-games/coco-battle-royale-2)](https://github.com/psywave-games/coco-battle-royale-2/blob/master/LICENSE)
[![status](https://img.shields.io/github/checks-status/psywave-games/coco-battle-royale-2/master)](https://github.com/psywave-games/coco-battle-royale-2/actions)
[![size](https://img.shields.io/github/repo-size/psywave-games/coco-battle-royale-2)](https://github.com/psywave-games/coco-battle-royale-2/archive/refs/heads/master.zip)
[![Engine:CC65](https://img.shields.io/badge/Engine-CC65-red)](https://cc65.github.io/)

> homebrew game for nintendo years 80 console, distributed as free software.

## How to build

```SHELL
$ git clone --recurse-submodules https://github.com/psywave-games/coco-battle-royale-2
$ make
```

## Gameplay

| :us: :eu: Nintendo Entertainment System | :jp: Famicom |
| :-------------------------------------: | :-----------:|
| ![coco battle royale 2 gameplay](https://raw.githubusercontent.com/psywave-games/gifs/main/cocobattleroyale2.gif) | ![kokobatoru 2 gameplay](https://raw.githubusercontent.com/psywave-games/gifs/main/kokobatoru2.gif) |

| move | attack | main player restart or insert coin | main player pause |
| :--: | :----: | :--------------------------------: | :---------------: |
| <kbd>&uarr;</kbd> <kbd>&larr;</kbd> <kbd>&darr;</kbd> <kbd>&rarr;</kbd>| <kbd>A</kbd> <kbd>B</kbd> | <kbd>start</kbd> | <kbd>select</kbd> |
3 changes: 2 additions & 1 deletion asm/crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ RLE_HIGH =TEMP+1
RLE_TAG =TEMP+2
RLE_BYTE =TEMP+3


.include "micromages.s"

.segment "HEADER"

Expand Down Expand Up @@ -237,6 +237,7 @@ detectNTSC:
jmp _main ;no parameters

.include "neslib.s"
.include "micromages2.s"

.segment "RODATA"

Expand Down
37 changes: 37 additions & 0 deletions asm/micromages.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;NES 4-player controller reading - written for the ca65 assembler
;- works with FourScore on NES (and AV Famicom afaik)
;- works with Hori adapter on Famicom (up to 4 players)
;- works with expansion port controllers on Famicom (3 players)
;- should work with dual expansion port controllers on Famicom (4 players)
;- has checks in place to allow worn out standard controllers to be replaced by
; expansion controllers on Famicom (depending on state of playerActive array);
; This is good behavior for Famicom, a lot of commercially released Famicom
; games do the same!

.export _playerActive,_joy1,_joy2,_joy3,_joy4

;joypad button constants
JOY_RIGHT = $01
JOY_LEFT = $02
JOY_DOWN = $04
JOY_UP = $08
JOY_START = $10
JOY_SELECT = $20
JOY_B = $40
JOY_A = $80

;you'll need to initialize this when the user selects the number of players.
;zero for active players, non-zero for inactive players
_playerActive: .res 4

;will hold state of joypads after call to updateInput (use bitwise ops with
;button constants above)
_joy1: .res 1
_joy2: .res 1
_joy3: .res 1
_joy4: .res 1

buf4016_0: .res 3
buf4016_1: .res 3
buf4017_0: .res 3
buf4017_1: .res 3
121 changes: 121 additions & 0 deletions asm/micromages2.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
;NES 4-player controller reading - written for the ca65 assembler
;- works with FourScore on NES (and AV Famicom afaik)
;- works with Hori adapter on Famicom (up to 4 players)
;- works with expansion port controllers on Famicom (3 players)
;- should work with dual expansion port controllers on Famicom (4 players)
;- has checks in place to allow worn out standard controllers to be replaced by
; expansion controllers on Famicom (depending on state of _playerActive array);
; This is good behavior for Famicom, a lot of commercially released Famicom
; games do the same!

.export _updateInput

;call this at the beginning of a frame
.proc _updateInput ;a,x,y

;not 100% sure anymore why I wrote these out
;most likely had to do with some zeropage reuse/optimization thing in Micro Mages
byte2_4016_0 = buf4016_0 + 0
byte1_4016_0 = buf4016_0 + 1
byte0_4016_0 = buf4016_0 + 2
byte2_4017_0 = buf4017_0 + 0
byte1_4017_0 = buf4017_0 + 1
byte0_4017_0 = buf4017_0 + 2

byte2_4016_1 = buf4016_1 + 0
byte1_4016_1 = buf4016_1 + 1
byte0_4016_1 = buf4016_1 + 2
byte2_4017_1 = buf4017_1 + 0
byte1_4017_1 = buf4017_1 + 1
byte0_4017_1 = buf4017_1 + 2

;reset strobe bit
ldy #$01
sty $4016
dey
sty $4016

;read joypad and famicom expansion pads as well as multitap adapters
ldx #3-1
@byteLoop:
ldy #8
@readLoop:
lda $4016
lsr a ; bit0 -> Carry
rol buf4016_0,x
lsr a ; bit1 -> Carry
rol buf4016_1,x
lda $4017
lsr a ; bit0 -> Carry
rol buf4017_0,x
lsr a ; bit1 -> Carry
rol buf4017_1,x
dey
bne @readLoop
dex
bpl @byteLoop

lda byte0_4016_1
sta _joy3
lda byte0_4017_1
sta _joy4

;on Famicom, it is expected that the expansion port controller
;can be used to replace a worn-out standard controller #1
;Let's do that unless a third player joins the party
lda byte0_4016_0
ldy _playerActive+2 ;player 3
beq :+
ora _joy3
:
sta _joy1

;also allow second expansion controller to replace standard controller #2
lda byte0_4017_0
ldy _playerActive+3 ;player 4
beq :+
ora _joy4
:
sta _joy2

@detectMultitap:
;check 3rd bytes from bit0 reads
lda byte2_4016_0
cmp #%00010000 ;$10
bne @skipFourScore
lda byte2_4017_0 ;$20
cmp #%00100000
bne @skipFourScore
;FourScore detected
;2nd bytes hold controller #3/#4 data
lda byte1_4016_0
ora _joy3
sta _joy3
lda byte1_4017_0
ora _joy4
sta _joy4
jmp @skipDetectMultitap
@skipFourScore:

;check 3rd bytes from bit1 reads
lda byte2_4016_1
cmp #%00100000 ;$20
bne @skipHori
lda byte2_4017_1
cmp #%00010000 ;$10
bne @skipHori
;hori adapter detected
;2nd bytes hold controller #3/#4 data
;allow to replace worn out standard famicom controllers with these as well (4p mode)
lda byte1_4016_1
ora _joy1
sta _joy1
lda byte1_4017_1
ora _joy2
sta _joy2
@skipHori:

@skipDetectMultitap:

rts
.endproc
Loading

0 comments on commit 30e0fba

Please sign in to comment.