From efe497783f2b92ae0058cd10833312f1b7ff757c Mon Sep 17 00:00:00 2001 From: Pecusx Date: Sun, 16 Feb 2025 00:13:55 +0100 Subject: [PATCH] Keyboard/Joy left and right --- lumber.asm | 196 +++++++++++++++++++++++++++++++++++++++++++---------- lumber.xex | Bin 10278 -> 10396 bytes 2 files changed, 161 insertions(+), 35 deletions(-) diff --git a/lumber.asm b/lumber.asm index 55cf9eb..941420d 100644 --- a/lumber.asm +++ b/lumber.asm @@ -25,6 +25,7 @@ display = $a000 .zpvar temp .word = $80 .zpvar temp2 .word .zpvar tempbyte .byte + .zpvar PaddleState .byte .zpvar LowCharsetBase .byte .zpvar displayposition .word .zpvar DLI_A DLI_X dliCount .byte @@ -162,7 +163,7 @@ secondDLI ;-------------------------------------------------- main ;-------------------------------------------------- - jsr wait_for_depress + jsr WaitForKeyRelease jsr MakeDarkScreen jsr initialize RMTsong song_main_menu @@ -251,24 +252,24 @@ EndOfStartScreen */ loop ; PUT GAME HERE - jsr wait_for_press - jsr wait_for_depress + jsr GetKey + cmp #@kbcode._left + beq left_pressed + cmp #@kbcode._right + beq right_pressed + bne loop +right_pressed jsr ScoreUp jsr AnimationR - jsr wait_for_press - jsr wait_for_depress - jsr AnimationR - jsr wait_for_press - jsr wait_for_depress - jsr AnimationL - jsr wait_for_press - jsr wait_for_depress - jsr AnimationL -NoAuto jmp loop +left_pressed + jsr ScoreUp + jsr AnimationL + jmp loop + LevelOver ; level over - jsr wait_for_depress + jsr WaitForKeyRelease rts .endp @@ -424,27 +425,6 @@ noingame mva #0 RMT_blocked */ rts .endp -;-------------------------------------------------- -.proc wait_for_press ; ion -;-------------------------------------------------- - lda TRIG0 - beq press_ok - lda CONSOL - and:cmp #%00000111 - beq wait_for_press -press_ok - rts -.endp -;-------------------------------------------------- -.proc wait_for_depress ; ion -;-------------------------------------------------- - lda CONSOL - and:cmp #%00000111 - bne wait_for_depress - lda TRIG0 - beq wait_for_depress - rts -.endp ;-------------------------------- ; non ZP variables ;-------------------------------- @@ -691,6 +671,134 @@ branch_ready rts .endp ;-------------------------------------------------- +.proc GetKey +; waits for pressing a key and returns pressed value in A +; result: A=keycode +;-------------------------------------------------- + jsr WaitForKeyRelease +getKeyAfterWait + jsr GetKeyFast + cmp #@kbcode._none + beq getKeyAfterWait + ldy #0 + sty ATRACT ; reset atract mode + rts +.endp + +;-------------------------------------------------- +.proc GetKeyFast +; returns pressed value in A - no waits for press +; result: A=keycode ($ff - no key pressed) +;-------------------------------------------------- + .IF TARGET = 800 + lda SKSTAT + and #%00000100 ; any key + bne checkJoyGetKey ; key not pressed, check Joy + .ELIF TARGET = 5200 + lda SkStatSimulator + and #%11111110 + bne checkJoyGetKey ; key not pressed, check Joy + .ENDIF + lda kbcode + cmp #@kbcode._none + bne getkeyend +checkJoyGetKey + ;------------JOY------------- + ;happy happy joy joy + ;check for joystick now + lda STICK0 + and #$0f + cmp #$0f + beq notpressedJoyGetKey + tay + lda joyToKeyTable,y + bne getkeyend + +notpressedJoyGetKey + ;fire + lda STRIG0 + beq JoyButton + .IF TARGET = 800 ; Second joy button , Select and Option key only on A800 + jsr Check2button + bcc SecondButton + bne checkSelectKey +checkSelectKey + lda CONSOL + and #%00000010 ; Select + beq SelectPressed + lda CONSOL + and #%00000100 ; Option + beq OptionPressed + .ENDIF + lda #@kbcode._none + bne getkeyend +OptionPressed + lda #@kbcode._atari ; Option key + bne getkeyend +SecondButton +SelectPressed + lda #@kbcode._tab ; Select key + bne getkeyend +JoyButton + lda #@kbcode._ret ; Return key +getkeyend + rts +; ---- + .IF TARGET = 800 ; Second joy button only on A800 +Check2button + lda PADDL0 + and #$c0 + eor #$C0 + cmp PaddleState + sta PaddleState + rts + .ENDIF +.endp + +;-------------------------------------------------- +.proc getkeynowait +;-------------------------------------------------- + jsr WaitForKeyRelease + lda kbcode + and #$3f ; CTRL and SHIFT ellimination + rts +.endp + + +;-------------------------------------------------- +.proc WaitForKeyRelease +;-------------------------------------------------- +StillWait + lda STICK0 + and #$0f + cmp #$0f + bne StillWait + lda STRIG0 + beq StillWait + .IF TARGET = 800 + lda SKSTAT + and #%00000100 ; any key + beq StillWait + lda CONSOL + and #%00000110 ; Select and Option only + cmp #%00000110 + bne StillWait + .ELIF TARGET = 5200 + lda SkStatSimulator + and #%11111110 + beq StillWait + .ENDIF +KeyReleased + rts +.endp +;-------------------------------------------------- +.proc CheckStartKey +;-------------------------------------------------- + lda CONSOL ; turbo mode + and #%00000001 ; START KEY + rts +.endp +;-------------------------------------------------- branch_addr_tableL .by branch2 ;-------------------------------- +joyToKeyTable + .by $ff ;00 + .by $ff ;01 + .by $ff ;02 + .by $ff ;03 + .by $ff ;04 + .by $ff ;05 + .by $ff ;06 + .by @kbcode._right ;07 + .by $ff ;08 + .by $ff ;09 + .by $ff ;0a + .by @kbcode._left ;0b + .by $ff ;0c + .by @kbcode._down ;0d + .by @kbcode._up ;0e + .by $ff ;0f +;----------------------------------- ; names of RMT instruments (sfx) ;-------------------------------- sfx_ping = $07 diff --git a/lumber.xex b/lumber.xex index 4a5d958c50a65f80a39bf84347166aef749b2211..baf486a6957590c9ee9efa577aa2d63eb4ab43c5 100644 GIT binary patch delta 890 zcmZuv-%Aux6rLaJY>K-xy6alIp*P%J9as~z$m${J$LQHntcQ9?h@po_=pn3!USiE0 zp|(+DUK5su6>oGS>B(Zj2ZhF`VgG`PD56@1dXOTR?$wN7JP-GL=R4o|&b`AdoquxS z#Zg(jqKkH^BWXX6CSG2bYq3ai5b7AsZ)>TN*USlLd? zHmJve#96tImT{=Zz`#mbT#Uh{^2;cT)fg;pe%ohBaGU$c#c2vk8gr>i5nd4Fa4@zk5OlDkD`b~LIvg>w^}dGA>iR+(;<=}KHs z>HJg5dn?gpK-YjemrIW53gsy$L{Iy6ckF-?oLHY>x3EjynL^9nU8CO0+?)niM00sG zNk0Z>QAz=;1&9om0wfBS3?u?p6i8D|71?5{ihx0XEac=J-}_nOW=0Jn*VK?3CXF@6 zcaM=ff+{<*CoQjz=>@lk%n05gB z!!%8{f!e93jK6O5J=Es=_9pKOo0lBPeQz+t8yG$x?(6e+B21Iy%TfQW@JfwY#UnCpQHM8_qc94i!1( z?gP}K?wPPsrL}dkl1jAiGOv{ky;3?WEqbMOmWmt|`S3>pCS-{zWQ8eYjU+Vrl!`WE z>*Q}p<~kusL#=Yg6mr27azzrFJWtgPXzo*0d7iG;?v?*rdlhDRD9oNLpk`9PR^Y-1 z&b9IvG}%wGfB2LDWnK6V691IIz{teN$S42=QqnTgQYwP)>^;}od!CfKpte$=*WUA; zo#$FR5LX$%nz#N_~TZ9U)F07FV(5%XLd&r<@w5*9J%+A(^mD-sMt&Qul415&rf+;b;L-A<6Y1q_%fPr_ANfK^IjC{<|oROt6yYdzUk zT~X2!)3_roAd4rLtE(njVV6yKXARWvd6M-4v%+>Sh1tMBVCV%3S$g(bd9Jna?6ve< qYwp==;knk#v)9~nE!QPY=9A19n1HIxfNDKo>gnr0V0y@8