Skip to content

Commit

Permalink
nullbios: credits management for 2 players
Browse files Browse the repository at this point in the history
  • Loading branch information
dciabrin committed Aug 19, 2021
1 parent db347cc commit abfc1b4
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions nullbios/biosstart.S
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ RESET:
/* Set initial system information in RAM */
#if BIOS_ROM_HARDWARE != 0
move.b #0x80, BIOS_MVS_FLAG
/* Init credits information, and assume credits
* are always stored in P1_CREDITS_BCD
*/
move.b #0, BIOS_STATCURNT
move.b #0, BIOS_STATCURNT_RAW
move.b #0, P1_CREDITS_BCD
jsr load_soft_dip
#else
Expand Down Expand Up @@ -208,7 +213,17 @@ NO_OP:


SYSTEM_IO:
/* player 1 */
/* check player 1 coin button */
move.b BIOS_P1CURRENT, %d1
move.b %d1, BIOS_P1PREVIOUS
move.b REG_P1CNT, %d0
not.b %d0
move.b %d0, BIOS_P1CURRENT
eor.b %d0, %d1
and.b %d1, %d0
move.b %d0, BIOS_P1CHANGE

/* check player 2 coin button */
move.b BIOS_P1CURRENT, %d1
move.b %d1, BIOS_P1PREVIOUS
move.b REG_P1CNT, %d0
Expand Down Expand Up @@ -273,11 +288,18 @@ SYSTEM_IO:

.Lstart_status:
/* start status */
move.b BIOS_STATCURNT, %d1
move.b %d1, BIOS_STATCURNT_RAW
move.b REG_STATUS_B, %d0
not.b %d0
andi.b #0xf, %d0
/* bits 1 and 3 from reg_status_b (start buttons)
* to bit 1 and 2 in %d0 (for bios_start_flag)
*/
move.b %d0, %d1
andi.b #0x4, %d1
lsr #1, %d1
andi.b #0x1, %d0
or.b %d1, %d0
move.b BIOS_STATCURNT, %d1
move.b %d1, BIOS_STATCURNT_RAW
move.b %d0, BIOS_STATCURNT
eor.b %d0, %d1
and.b %d1, %d0
Expand All @@ -286,12 +308,30 @@ SYSTEM_IO:
beq .Lnostart
.Lstart_pressed:
/* when start is pressed and credits are available:
* . game's "plater_start" callback is executed
* . game's "player_start" callback is executed
* . the callback sees which player wants to start
* via bits set in bios_start_flag
* . the callback engages "game mode" by
* setting bios_user_mode set to 2.
* [only when game mode is engaged]
* . credits are decremented
* . credits are decremented for each bit still set
* in bios_start_flag when the callback exits
* [before the game is started]
* . hitting 2UP start means that two players want
* to start, and it only runs the callback if
* enough credits are available
*/
cmp.b #2, BIOS_USER_MODE
beq .Lend_of_coin_prechecks
btst #1, %d0
beq .L2up_no_pressed
bset #0, %d0
cmp.b #2, P1_CREDITS_BCD
blt .Lnostart
.L2up_no_pressed:
cmp.b #1, P1_CREDITS_BCD
blt .Lnostart
.Lend_of_coin_prechecks:
move.b %d0, BIOS_START_FLAG
jsr PLAYER_START.l
cmp.b #2, BIOS_USER_MODE
Expand Down

0 comments on commit abfc1b4

Please sign in to comment.