diff --git a/Atari/inputs.asm b/Atari/inputs.asm new file mode 100644 index 0000000..44ca61d --- /dev/null +++ b/Atari/inputs.asm @@ -0,0 +1,206 @@ +;-------------------------------------------------- +.proc GetKey +; waits for pressing a key and returns pressed value in A +; when [ESC] is pressed, escFlag is set +; result: A=keycode +;-------------------------------------------------- + jsr WaitForKeyRelease +getKeyAfterWait + jsr GetKeyFast + cmp #@kbcode._none + beq getKeyAfterWait + ldy #0 + sty ATRACT ; reset atract mode + mvy #sfx_keyclick sfx_effect + rts +.endp + +;-------------------------------------------------- +.proc GetKeyFast +; returns pressed value in A - no waits for press +; when [ESC] is pressed, escFlag is set +; result: A=keycode ($ff - no key pressed) +;-------------------------------------------------- + .IF TARGET = 800 + lda SKSTAT + cmp #$ff + beq checkJoyGetKey ; key not pressed, check Joy + cmp #$f7 ; SHIFT + beq checkJoyGetKey + .ELIF TARGET = 5200 + lda SkStatSimulator + and #%11111110 + bne checkJoyGetKey ; key not pressed, check Joy + .ENDIF + lda kbcode + cmp #@kbcode._none + beq checkJoyGetKey + pha + and #$3f ; CTRL and SHIFT ellimination + cmp #@kbcode._esc ; 28 ; ESC + beq EscPressed + pla + jmp getkeyend +EscPressed + pla + mvy #$80 escFlag + 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 +;-------------------------------------------------- + lda #128-KeyRepeatSpeed ; tricky + sec + sbc FirstKeypressDelay ; tricky 2 :) + sta pressTimer +StillWait + bit pressTimer + bmi KeyAutoReleased + lda STICK0 + and #$0f + cmp #$0f + bne StillWait + lda STRIG0 + beq StillWait + .IF TARGET = 800 + lda SKSTAT + cmp #$ff + bne StillWait + lda CONSOL + and #%00000110 ; Select and Option only + cmp #%00000110 + bne StillWait + .ELIF TARGET = 5200 + lda SkStatSimulator + and #%11111110 + beq StillWait + .ENDIF +KeyReleased + mva #FirstKeySpeed FirstKeypressDelay + rts +KeyAutoReleased ; autorepeat + mva #0 FirstKeypressDelay + rts +.endp +;-------------------------------------------------- +.proc IsKeyPressed +; result: A=0 - yes , A>0 - no +;-------------------------------------------------- + lda SKSTAT + and #%00000100 + beq @+ + lda #1 +@ and STRIG0 + rts +.endp +;-------------------------------------------------- +.proc CheckStartKey +;-------------------------------------------------- + lda CONSOL ; turbo mode + and #%00000001 ; START KEY + rts +.endp +;-------------------------------------------------- +.proc CheckExitKeys +;-------------------------------------------------- +; Checks keyboard and sets appropriate flags for exit procedures +; If START+OPTION is pressed - exit to GameOver screen +; If 'O' key is pressed - displays "Are you sure?" and - exit to GameOver screen +; If 'Esc' key is pressed - displays "Are you sure?" and - exit to Menu screen +; Just setting the right flags!!! + + ; Select and Option + lda CONSOL + and #%00000101 ; Start + Option + beq QuitToGameover + lda SKSTAT + cmp #$ff + jeq nokeys + cmp #$f7 ; SHIFT + jeq nokeys + + lda kbcode + and #%10111111 ; SHIFT elimination + + cmp #@kbcode._O ; $08 ; O + bne CheckEsc + jsr AreYouSure + bit escFlag + bpl nokeys + ;---O pressed-quit game to game over screen--- +QuitToGameover + mva #$C0 escFlag ; bits 7 and 6 set + rts +CheckEsc + cmp #@kbcode._esc ; 28 ; ESC + bne nokeys +DisplayAreYouSure + jsr AreYouSure + ;---esc pressed-quit game--- +nokeys + bit escFlag + rts +; +.endp diff --git a/C64/inputs.asm b/C64/inputs.asm new file mode 100644 index 0000000..7d31a89 --- /dev/null +++ b/C64/inputs.asm @@ -0,0 +1,63 @@ +;-------------------------------------------------- +.proc GetKey +; waits for pressing a key and returns pressed value in A +; when [ESC] is pressed, escFlag is set +; result: A=keycode +;-------------------------------------------------- + jsr WaitForKeyRelease + jsr GetKeyFast + ldy #0 + sty escFlag + rts +.endp + +;-------------------------------------------------- +.proc GetKeyFast +; returns pressed value in A - no wait for press +; when [ESC] is pressed, escFlag is set +; result: A=keycode +;-------------------------------------------------- + lda #$ff + rts +.endp + +;-------------------------------------------------- +.proc getkeynowait +;-------------------------------------------------- + jsr WaitForKeyRelease + lda kbcode + and #$3f ;CTRL and SHIFT ellimination + rts +.endp + +;-------------------------------------------------- +.proc WaitForKeyRelease +;-------------------------------------------------- +StillWait + rts +.endp +;-------------------------------------------------- +.proc IsKeyPressed +; result: A=0 - yes , A>0 - no +;-------------------------------------------------- + lda #1 + rts +.endp +;-------------------------------------------------- +.proc CheckStartKey +;-------------------------------------------------- + lda #%00000001 ; START KEY not pressed + rts +.endp +;-------------------------------------------------- +.proc CheckExitKeys +;-------------------------------------------------- +; Checks keyboard and sets appropriate flags for exit procedures +; If START+OPTION is pressed - exit to GameOver screen +; If 'O' key is pressed - displays "Are you sure?" and - exit to GameOver screen +; If 'Esc' key is pressed - displays "Are you sure?" and - exit to Menu screen +; Just setting the right flags!!! + + rts +; +.endp diff --git a/game.asm b/game.asm index 860330a..1d19485 100644 --- a/game.asm +++ b/game.asm @@ -1070,6 +1070,27 @@ BarrelPositionIsFine .endp +;-------------------------------------------------- +.proc DemoModeOrKey +; Waits for the key pressed if at least one human is playing. +; Otherwise, waits 3 seconds (demo mode). +;-------------------------------------------------- + ;check demo mode + ldx numberOfPlayers + dex +checkForHuman ; if all in skillTable other than 0 then switch to DEMO MODE + lda skillTable,x + beq peopleAreHere + dex + bpl checkForHuman + ; no people, just wait a bit + ldy #75 + jmp PauseYFrames + ; rts +peopleAreHere + jmp getkey ; jsr:rts +.endp + ;---------------------------------------------- .proc SortSequence ; ;---------------------------------------------- diff --git a/scorch.asm b/scorch.asm index cf58e0f..e760d74 100644 --- a/scorch.asm +++ b/scorch.asm @@ -410,183 +410,6 @@ NoRMT_PALchange .ENDIF .endp -;-------------------------------------------------- -.proc GetKey -; waits for pressing a key and returns pressed value in A -; when [ESC] is pressed, escFlag is set -; result: A=keycode -;-------------------------------------------------- - jsr WaitForKeyRelease -getKeyAfterWait - jsr GetKeyFast - cmp #@kbcode._none - beq getKeyAfterWait - ldy #0 - sty ATRACT ; reset atract mode - mvy #sfx_keyclick sfx_effect - rts -.endp - -;-------------------------------------------------- -.proc GetKeyFast -; returns pressed value in A - no waits for press -; when [ESC] is pressed, escFlag is set -; result: A=keycode ($ff - no key pressed) -;-------------------------------------------------- - .IF TARGET = 800 - lda SKSTAT - cmp #$ff - beq checkJoyGetKey ; key not pressed, check Joy - cmp #$f7 ; SHIFT - beq checkJoyGetKey - .ELIF TARGET = 5200 - lda SkStatSimulator - and #%11111110 - bne checkJoyGetKey ; key not pressed, check Joy - .ENDIF - lda kbcode - cmp #@kbcode._none - beq checkJoyGetKey - pha - and #$3f ; CTRL and SHIFT ellimination - cmp #@kbcode._esc ; 28 ; ESC - beq EscPressed - pla - jmp getkeyend -EscPressed - pla - mvy #$80 escFlag - 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 -;-------------------------------------------------- - lda #128-KeyRepeatSpeed ; tricky - sec - sbc FirstKeypressDelay ; tricky 2 :) - sta pressTimer -StillWait - bit pressTimer - bmi KeyAutoReleased - lda STICK0 - and #$0f - cmp #$0f - bne StillWait - lda STRIG0 - beq StillWait - .IF TARGET = 800 - lda SKSTAT - cmp #$ff - bne StillWait - lda CONSOL - and #%00000110 ; Select and Option only - cmp #%00000110 - bne StillWait - .ELIF TARGET = 5200 - lda SkStatSimulator - and #%11111110 - beq StillWait - .ENDIF -KeyReleased - mva #FirstKeySpeed FirstKeypressDelay - rts -KeyAutoReleased ; autorepeat - mva #0 FirstKeypressDelay - rts -.endp -;-------------------------------------------------- -.proc IsKeyPressed -; result: A=0 - yes , A>0 - no -;-------------------------------------------------- - lda SKSTAT - and #%00000100 - beq @+ - lda #1 -@ and STRIG0 - rts -.endp -;-------------------------------------------------- -.proc DemoModeOrKey -; Waits for the key pressed if at least one human is playing. -; Otherwise, waits 3 seconds (demo mode). -;-------------------------------------------------- - ;check demo mode - ldx numberOfPlayers - dex -checkForHuman ; if all in skillTable other than 0 then switch to DEMO MODE - lda skillTable,x - beq peopleAreHere - dex - bpl checkForHuman - ; no people, just wait a bit - ldy #75 - jmp PauseYFrames - ; rts -peopleAreHere - jmp getkey ; jsr:rts -.endp ;-------------------------------------------------- MakeDarkScreen @@ -614,55 +437,6 @@ MakeDarkScreen rts .endp -;-------------------------------------------------- -.proc CheckStartKey -;-------------------------------------------------- - lda CONSOL ; turbo mode - and #%00000001 ; START KEY - rts -.endp -;-------------------------------------------------- -.proc CheckExitKeys -;-------------------------------------------------- -; Checks keyboard and sets appropriate flags for exit procedures -; If START+OPTION is pressed - exit to GameOver screen -; If 'O' key is pressed - displays "Are you sure?" and - exit to GameOver screen -; If 'Esc' key is pressed - displays "Are you sure?" and - exit to Menu screen -; Just setting the right flags!!! - - ; Select and Option - lda CONSOL - and #%00000101 ; Start + Option - beq QuitToGameover - lda SKSTAT - cmp #$ff - jeq nokeys - cmp #$f7 ; SHIFT - jeq nokeys - - lda kbcode - and #%10111111 ; SHIFT elimination - - cmp #@kbcode._O ; $08 ; O - bne CheckEsc - jsr AreYouSure - bit escFlag - bpl nokeys - ;---O pressed-quit game to game over screen--- -QuitToGameover - mva #$C0 escFlag ; bits 7 and 6 set - rts -CheckEsc - cmp #@kbcode._esc ; 28 ; ESC - bne nokeys -DisplayAreYouSure - jsr AreYouSure - ;---esc pressed-quit game--- -nokeys - bit escFlag - rts -; -.endp ;-------------------------------------------------- .proc ShellDelay ;-------------------------------------------------- @@ -718,6 +492,8 @@ noingame bne @- rts .endp +;-------------------------------------------------- + icl 'Atari/inputs.asm' ;-------------------------------------------------- icl 'Atari/interrupts.asm' ;---------------------------------------------- diff --git a/scorch.xex b/scorch.xex index 5e0355d..8b87228 100644 Binary files a/scorch.xex and b/scorch.xex differ diff --git a/scorchC64.asm b/scorchC64.asm index a9089f2..1127a75 100644 --- a/scorchC64.asm +++ b/scorchC64.asm @@ -246,73 +246,6 @@ StartAfterSplash rts .endp -;-------------------------------------------------- -.proc GetKey -; waits for pressing a key and returns pressed value in A -; when [ESC] is pressed, escFlag is set -; result: A=keycode -;-------------------------------------------------- - jsr WaitForKeyRelease - jsr GetKeyFast - ldy #0 - sty escFlag - rts -.endp - -;-------------------------------------------------- -.proc GetKeyFast -; returns pressed value in A - no wait for press -; when [ESC] is pressed, escFlag is set -; result: A=keycode -;-------------------------------------------------- - lda #$ff - rts -.endp - -;-------------------------------------------------- -.proc getkeynowait -;-------------------------------------------------- - jsr WaitForKeyRelease - lda kbcode - and #$3f ;CTRL and SHIFT ellimination - rts -.endp - -;-------------------------------------------------- -.proc WaitForKeyRelease -;-------------------------------------------------- -StillWait - rts -.endp -;-------------------------------------------------- -.proc IsKeyPressed -; result: A=0 - yes , A>0 - no -;-------------------------------------------------- - lda #1 - rts -.endp -;-------------------------------------------------- -.proc DemoModeOrKey -; Waits for the key pressed if at least one human is playing. -; Otherwise, waits 3 seconds (demo mode). -;-------------------------------------------------- - ;check demo mode - ldx numberOfPlayers - dex -checkForHuman ; if all in skillTable other than 0 then switch to DEMO MODE - lda skillTable,x - beq peopleAreHere - dex - bpl checkForHuman - ; no people, just wait a bit - ;pause 150 - ldy #75 - jmp PauseYFrames - ; rts -peopleAreHere - jmp getkey ; jsr:rts -.endp - ;-------------------------------------------------- MakeDarkScreen ;-------------------------------------------------- @@ -338,24 +271,6 @@ MakeDarkScreen rts .endp -;-------------------------------------------------- -.proc CheckStartKey -;-------------------------------------------------- - lda #%00000001 ; START KEY not pressed - rts -.endp -;-------------------------------------------------- -.proc CheckExitKeys -;-------------------------------------------------- -; Checks keyboard and sets appropriate flags for exit procedures -; If START+OPTION is pressed - exit to GameOver screen -; If 'O' key is pressed - displays "Are you sure?" and - exit to GameOver screen -; If 'Esc' key is pressed - displays "Are you sure?" and - exit to Menu screen -; Just setting the right flags!!! - - rts -; -.endp ;-------------------------------------------------- .proc ShellDelay ldy flyDelay @@ -382,6 +297,8 @@ noShellDelay .proc CopyFromRom rts .endp +;-------------------------------------------------- + icl 'C64/inputs.asm' ;-------------------------------------------------- icl 'C64/interrupts.asm' ;---------------------------------------------- diff --git a/scorchC64.prg b/scorchC64.prg index 1d4d099..d98ed4e 100644 Binary files a/scorchC64.prg and b/scorchC64.prg differ