Skip to content

Commit

Permalink
Menu tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
kandowontu committed Jan 15, 2025
1 parent 7433a98 commit f71356b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 72 deletions.
2 changes: 1 addition & 1 deletion LIB/asm/nesdash.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.importzp _gamemode
.importzp _tmp1, _tmp2, _tmp3, _tmp4, _tmp5, _tmp6, _tmp7, _tmp8, _tmp9, _temptemp5 ; C-safe temp storage
.import pusha, pushax, callptr4
.import _scroll_x, _cursedmusic
.import _scroll_x, _cursedmusic, _draw_arrow

.macpack longbranch

Expand Down
81 changes: 18 additions & 63 deletions LIB/asm/neslib.s
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.export __memcpy,__memfill,_delay

.export _flush_vram_update2, _oam_set, _oam_get
.import _disco_sprites, _slowmode, _kandoframecnt, _kandokidshack4, _pauseStatus,_coins_inserted, _CREDITS1_PREV, _CREDITS2_PREV
.import _disco_sprites, _slowmode, _kandoframecnt, _kandokidshack4, _pauseStatus,_coins_inserted, _CREDITS1_PREV, _CREDITS2_PREV, _showarrownow
.segment "NESLIB"

;NMI handler
Expand Down Expand Up @@ -125,16 +125,16 @@ nmi:
bne @skipAll

@calc:
lda noMouse
bne @SkipMouse
; lda noMouse
; bne @SkipMouse
; Read the raw controller data synced with OAM DMA to prevent
; DMC DMA bugs
;jsr oam_and_readjoypad

lda <(mouse + kMouseButtons)
and #$0f
cmp #$01
beq :+
; lda <(mouse + kMouseButtons)
; and #$0f
; cmp #$01
; beq :+
@SkipMouse:
LDA #>OAM_BUF
STA PPU_OAM_DMA
Expand Down Expand Up @@ -163,6 +163,11 @@ nmi:
lda _coins_inserted
cmp #$FF
beq @skip1
cmp #0
bne @justinc
lda #1
sta _showarrownow
@justinc:
inc _coins_inserted
@skip1:
lda #sfx_coin
Expand All @@ -182,6 +187,11 @@ nmi:
lda _coins_inserted
cmp #$FF
beq @skip2
cmp #0
bne @justinc2
lda #1
sta _showarrownow
@justinc2:
inc _coins_inserted
@skip2:
lda #sfx_coin
Expand Down Expand Up @@ -1623,62 +1633,7 @@ CONTROLLER_PORT = CTRL_PORT1
rts
snes_mouse_detected:

; convert the X/Y displacement into X/Y positions on the screen
ldx #1
loop:
lda mouse + kMouseY,x
bpl :+
; subtract the negative number instead
and #$7f
sta mouse + kMouseZero ; reuse this value as a temp value
lda TEMP,x
sec
sbc mouse + kMouseZero
; check if we underflowed
bcc wrappednegative
; check the lower bounds
cmp MouseBoundsMin,x
bcs setvalue ; didn't wrap so set the value now
wrappednegative:
lda MouseBoundsMin,x
jmp setvalue
:
; add the positive number
clc
adc TEMP,x
; check if we wrapped, set to the max bounds if we did
bcs wrapped
; check the upper bounds
cmp MouseBoundsMax,x
bcc setvalue ; didn't wrap so set the value
wrapped:
lda MouseBoundsMax,x
setvalue:
sta mouse + kMouseY,x
dex
bpl loop
; calculate newly pressed buttons and shift it into byte zero
lda TEMP+2
eor #%11000000
and mouse + kMouseButtons
rol
ror mouse + kMouseZero
rol
ror mouse + kMouseZero

; calculate newly released buttons
lda mouse + kMouseButtons
eor #%11000000
and TEMP+2
rol
ror mouse + kMouseZero
rol
ror mouse + kMouseZero

; Set the connected bit
sec
ror mouse + kMouseZero


rts

MOUSE_Y_MINIMUM = 1
Expand Down
1 change: 1 addition & 0 deletions SAUCE/famidash.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ uint8_t normalorcommlevels;
uint8_t mouse_timer;
uint8_t prev_mouse_x;
uint8_t prev_mouse_y;
uint8_t showarrownow;

extern uint8_t parallax_scroll_column;
extern uint8_t parallax_scroll_column_start;
Expand Down
29 changes: 21 additions & 8 deletions SAUCE/gamestates/state_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ const unsigned char vstext[] = "VS";

void state_menu() {
poweroffcheck = 0xff;
menuselection = 0;
if (exitingLevelSelect) {
draw_both_progress_bars();
pal_fade_to_withmusic(4,0);
Expand Down Expand Up @@ -844,10 +845,10 @@ void state_menu() {
//POKE(0x203, 0x00);

// Expand the data for the menu nametable while the PPU is still off
vram_adr(NAMETABLE_A);
vram_unrle(game_start_screen);
vram_adr(NAMETABLE_A);
vram_unrle(game_start_screen);
vram_adr(NAMETABLE_B);
vram_unrle(game_start_screen);
vram_unrle(game_start_screen);

set_scroll_x(0);

Expand All @@ -857,8 +858,10 @@ void state_menu() {
pal_fade_to_withmusic(0,4);
tmp4 = menuselection; ++tmp4;
tmp5 = loNTAddrTableTitleScreen[tmp4]|(hiNTAddrTableTitleScreen[tmp4]<<8);
one_vram_buffer('a', tmp5);
one_vram_buffer('b', addloNOC(tmp5, 1));
if (coins_inserted) {
one_vram_buffer('a', tmp5);
one_vram_buffer('b', addloNOC(tmp5, 1));
}
roll_new_mode();
kandoframecnt = 0;
teleport_output = 0Xff;
Expand All @@ -882,6 +885,16 @@ void state_menu() {
*/
while (!(joypad1.press & (PAD_START | PAD_A)) || !coins_inserted){


if (showarrownow == 1) {
tmp4 = menuselection; ++tmp4;
tmp5 = loNTAddrTableTitleScreen[tmp4]|(hiNTAddrTableTitleScreen[tmp4]<<8);
one_vram_buffer('a', tmp5);
one_vram_buffer('b', addloNOC(tmp5, 1));
showarrownow = 0;
}


if (joypad1.press & PAD_SELECT && coins_inserted != 255) {
for (tmp2 = 0; tmp2 < 255; tmp2++) {

Expand Down Expand Up @@ -1343,22 +1356,22 @@ void state_menu() {
dec_mouse_timer();
tmp3 = 0;

if (joypad1.press_right) {
if (joypad1.press_right && coins_inserted) {
if (menuselection == 5) menuselection = 0;
else if (menuselection == 1) { menuselection = 5; tmp3--; tmp3--; tmp3--; }
else menuselection++;
tmp3--;
menutimer = 0;
}
if (joypad1.press_left) {
if (joypad1.press_left && coins_inserted) {
if (menuselection == 0) menuselection = 5;
else if (menuselection == 5) { menuselection = 1; tmp3++; tmp3++; tmp3++; }
else menuselection--;
tmp3++;
menutimer = 0;
}

if (tmp3 ) { // menu selection incremented
if (tmp3 && coins_inserted) { // menu selection incremented
tmp4 = menuselection; ++tmp4;
tmp5 = loNTAddrTableTitleScreen[tmp4]|(hiNTAddrTableTitleScreen[tmp4]<<8);
if (menuselection != 4) {
Expand Down

0 comments on commit f71356b

Please sign in to comment.