WIP: more keyboard shenanigans

This commit is contained in:
2022-10-03 22:54:20 -04:00
parent f3b9092777
commit 6425431496
10 changed files with 243 additions and 74 deletions
+16 -2
View File
@@ -525,8 +525,22 @@ weaponsOfDeath ; weapons used in tank death animations
dta 1,2,3,7,17,18,19,20,21,22,23,24,25,26,27 dta 1,2,3,7,17,18,19,20,21,22,23,24,25,26,27
weaponsOfDeathEnd weaponsOfDeathEnd
joyToKeyTable joyToKeyTable
; .by 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15 .by $ff ;00
.by $ff,$ff,$ff,$ff,$ff,$ff,$ff,$07,$ff,$ff,$ff,$06,$ff,$0f,$0e,$ff .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
;----------------------------------- ;-----------------------------------
keycodes ;tables for converting KeyCode to Screen Code (38 -1 characters) keycodes ;tables for converting KeyCode to Screen Code (38 -1 characters)
+1 -1
View File
@@ -102,7 +102,7 @@
sta :1+1 sta :1+1
.endm .endm
;------------------------------------- ;-------------------------------------
.macro randomize .macro randomizer
;usage: randomize floor ceiling ;usage: randomize floor ceiling
;returns (in A) a random .byte between "floor" and "ceiling" ;returns (in A) a random .byte between "floor" and "ceiling"
.if :2 < :1 .if :2 < :1
+20
View File
@@ -249,3 +249,23 @@ scr32 = @dmactl(narrow|dma|players|missiles|lineX1)
mode10 = %10000000 mode10 = %10000000
mode11 = %11000000 mode11 = %11000000
.ende .ende
/*
; commented out to be replaced by the application specific A800 --> 5200 keypad translation
.enum @kbcode
_0
_1
_2
_3
_4
_5
_6
_7
_8
_9
_asterisk = $0a
_hash = $0b
_start = $0c
_pause = $0d
_reset = $0e
.ende
*/
+68
View File
@@ -652,3 +652,71 @@ scr32 = @dmactl(narrow|dma|players|missiles|lineX1)
mode10 = %10000000 mode10 = %10000000
mode11 = %11000000 mode11 = %11000000
.ende .ende
; ---------------------------------------------------------------------------
; KBCODEs
; ---------------------------------------------------------------------------
.enum @kbcode
_none = 255
_esc = 28
_1 = 31
_2 = 30
_3 = 26
_4 = 24
_5 = 29
_6 = 27
_7 = 51
_8 = 53
_9 = 48
_0 = 50
_lt = 54
_gt = 55
_del = 52
_tab = 44
_Q = 47
_W = 46
_E = 42
_R = 40
_T = 45
_Y = 43
_U = 11
_I = 13
_O = 8
_P = 10
_min = 14
_up = 14 ; cursor function
_eq = 15
_down = 15 ; cursor function
_ret = 12
_A = 63
_S = 62
_D = 58
_F = 56
_G = 61
_H = 57
_J = 1
_K = 5
_L = 0
_semicolon = 2
_plus = 6
_left = 6 ; cursor function
_asterisk = 7
_right = 7 ; cursor function
_caps = 60
_Z = 23
_X = 22
_C = 18
_V = 16
_B = 21
_N = 36
_M = 37
_comma = 32
_dot = 34
_slash = 38
_atari = 39
_help = 17
_F1 = 3
_F2 = 4
_F3 = 19
_F4 = 20
_space = 33
.ende
+1 -1
View File
@@ -101,7 +101,7 @@
sta :1+1 sta :1+1
.endm .endm
;------------------------------------- ;-------------------------------------
.macro randomize .macro randomizer
;usage: randomize floor ceiling ;usage: randomize floor ceiling
;returns (in A) a random .byte between "floor" and "ceiling" ;returns (in A) a random .byte between "floor" and "ceiling"
.if :2 < :1 .if :2 < :1
+93 -26
View File
@@ -7,6 +7,8 @@
;--------------------------------------------------- ;---------------------------------------------------
.def TARGET = 800 ;5200 ; or 800 .def TARGET = 800 ;5200 ; or 800
;atari800 -5200 -cart ${outputFilePath} -cart-type 4
;atari800 -run ${outputFilePath}
;--------------------------------------------------- ;---------------------------------------------------
OPT r+ ; saves 12 bytes :O OPT r+ ; saves 12 bytes :O
@@ -133,6 +135,41 @@
OPT h-f+ OPT h-f+
icl 'lib/5200SYS.ASM' icl 'lib/5200SYS.ASM'
icl 'lib/5200MACRO.ASM' icl 'lib/5200MACRO.ASM'
.enum @kbcode
/*
_0
_1
_2
_3
_4
_5
_6
_7
_8
_9
_asterisk = $0a
_hash = $0b
_start = $0c
_pause = $0d
_reset = $0e
*/
_space = $00
_Y = $01
_up = $02
_O = $03
_left = $04
_tab = $05
_right = $06
_A = $07
_down = $08
_I = $09
_esc = $0a
_ret = $0b
_M = $0d
_S = $0e
_del = $0e ; not used in 5200
.ende
.ELSE .ELSE
icl 'lib/ATARISYS.ASM' icl 'lib/ATARISYS.ASM'
icl 'lib/MACRO.ASM' icl 'lib/MACRO.ASM'
@@ -577,7 +614,7 @@ RoboTanks
jsr DisplayStatus ; to make visible AI selected defensive (and offensive :) ) jsr DisplayStatus ; to make visible AI selected defensive (and offensive :) )
jsr MoveBarrelToNewPosition jsr MoveBarrelToNewPosition
lda kbcode lda kbcode
cmp #28 ; ESC cmp #@kbcode._esc ; 28 ; ESC
bne @+ bne @+
jsr AreYouSure jsr AreYouSure
@ lda escFlag @ lda escFlag
@@ -1556,7 +1593,7 @@ SetRandomWalls
lda kbcode lda kbcode
and #$3f ;CTRL and SHIFT ellimination and #$3f ;CTRL and SHIFT ellimination
cmp #28 ; ESC cmp #@kbcode._esc ; 28 ; ESC
bne getkeyend bne getkeyend
mvx #$80 escFlag mvx #$80 escFlag
bne getkeyend bne getkeyend
@@ -1577,7 +1614,7 @@ notpressedJoyGetKey
;fire ;fire
lda STRIG0 lda STRIG0
bne @- bne @-
lda #$0c ;Return key lda #@kbcode._ret ;Return key
getkeyend getkeyend
mvx #sfx_keyclick sfx_effect mvx #sfx_keyclick sfx_effect
@@ -1638,13 +1675,12 @@ checkForHuman ; if all in skillTable other than 0 then switch to DEMO MODE
;pause 150 ;pause 150
ldy #75 ldy #75
jsr PauseYFrames jsr PauseYFrames
jmp noKey rts
peopleAreHere peopleAreHere
jsr getkey jmp getkey ; jsr:rts
noKey
rts
.endp .endp
MakeDarkScreen MakeDarkScreen
mva #0 dmactls ; dark screen mva #0 dmactls ; dark screen
sta dmactl sta dmactl
@@ -1652,13 +1688,12 @@ MakeDarkScreen
.proc WaitOneFrame .proc WaitOneFrame
lda CONSOL lda CONSOL
and #%00000101 ; Start + Option and #%00000101 ; Start + Option
bne @+ sne:mva #$40 escFlag
mva #$40 escFlag and #%00000001 ; START KEY
@ and #%00000001 ; START KEY seq:wait
beq @+ rts
wait
@ rts
.endp .endp
.proc PauseYFrames .proc PauseYFrames
; Y - number of frames to wait (divided by 2) ; Y - number of frames to wait (divided by 2)
; pauses for maximally 510 frames (255 * 2) ; pauses for maximally 510 frames (255 * 2)
@@ -1708,19 +1743,51 @@ noingame
bne @- bne @-
rts rts
.endp .endp
;;-------------------------------------------------- ;--------------------------------------------------
;.proc Randomizer .macro randomize floor ceiling
;;-------------------------------------------------- ;--------------------------------------------------
; ;usage: randomize floor ceiling ;usage: randomize floor ceiling
; ;returns (in A) a random .byte between "floor" and "ceiling" ;returns (in A) a random .byte between "floor" and "ceiling"
;?rand jsr _randomizator
; lda random .byte :floor
; cmp #:1 ;floor .byte :ceiling
; bcc ?rand .endm
; cmp #:2+1 ;ceiling
; bcs ?rand .proc _randomizator
; rts ; private function that accompanies `randomize` macro
;.endp ; trashes: magic, temp, Y
pla
sta magic
pla
sta magic+1
ldy #1 ; add 1 to the value got from the stack to point to the input parameters
lda (magic),y
sta temp
iny
lda (magic),y
sta temp+1
?rand
lda random
cmp temp ;floor
bcc ?rand
cmp temp+1 ;ceiling
bcs ?rand
tay ; save the result
; point the PC to a byte after the parameters
clc
lda magic
adc #2 ; length of the parameters in bytes
sta magic
lda magic+1
adc #0
pha
lda magic
pha
tya ; retrieve the result
rts
.endp
;---------------------------------------------- ;----------------------------------------------
icl 'weapons.asm' icl 'weapons.asm'
;---------------------------------------------- ;----------------------------------------------
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+24 -24
View File
@@ -68,7 +68,7 @@ OptionsMainLoop
bit escFlag bit escFlag
spl:rts spl:rts
cmp #$f ;cursor down cmp #@kbcode._down ; $f ;cursor down
bne OptionsNoDown bne OptionsNoDown
inc:lda OptionsY inc:lda OptionsY
cmp #maxoptions cmp #maxoptions
@@ -77,7 +77,7 @@ OptionsMainLoop
jmp OptionsMainLoop jmp OptionsMainLoop
OptionsNoDown OptionsNoDown
cmp #$e ;cursor up cmp #@kbcode._up ; $e ;cursor up
bne OptionsNoUp bne OptionsNoUp
dec OptionsY dec OptionsY
bpl OptionsMainLoop bpl OptionsMainLoop
@@ -85,7 +85,7 @@ OptionsNoDown
jmp OptionsMainLoop jmp OptionsMainLoop
OptionsNoUp OptionsNoUp
cmp #$6 ;cursor left cmp #@kbcode._left ; $6 ;cursor left
bne OptionsNoLeft bne OptionsNoLeft
ldx OptionsY ldx OptionsY
dec OptionsTable,X dec OptionsTable,X
@@ -95,19 +95,19 @@ OptionsNoUp
jmp OptionsMainLoop jmp OptionsMainLoop
OptionsNoLeft OptionsNoLeft
cmp #$7 ;cursor right cmp #@kbcode._right ; $7 ;cursor right
bne OptionsNoRight bne OptionsNoRight
ldx OptionsY ldx OptionsY
inc OptionsTable,X inc OptionsTable,X
lda OptionsTable,X lda OptionsTable,X
cmp #5 cmp #5 ; number of columns in options
bne OptionsMainLoop bne OptionsMainLoop
dec OptionsTable,X dec OptionsTable,X
jmp OptionsMainLoop jmp OptionsMainLoop
OptionsNoRight OptionsNoRight
cmp #$c ;Return key cmp #@kbcode._ret ; $c ;Return key
bne OptionsNoReturn bne OptionsNoReturn
jmp OptionsFinished jmp OptionsFinished
OptionsNoReturn OptionsNoReturn
@@ -398,19 +398,19 @@ ChoosingItemForPurchase
jsr getkey jsr getkey
bit escFlag bit escFlag
spl:jmp WaitForKeyRelease ; like jsr ... : rts spl:jmp WaitForKeyRelease ; like jsr ... : rts
cmp #$2c ; Tab cmp #@kbcode._esc ; $2c ; Tab
jeq ListChange jeq ListChange
cmp #$06 ; cursor left cmp #@kbcode._left ; $06 ; cursor left
jeq ListChange jeq ListChange
cmp #$0c ; Return cmp #@kbcode._ret ; $0c ; Return
sne:rts sne:rts
cmp #$e cmp #@kbcode._up ; $e
beq PurchaseKeyUp beq PurchaseKeyUp
cmp #$f cmp #@kbcode._down ; $f
beq PurchaseKeyDown beq PurchaseKeyDown
cmp #$21 ; Space cmp #@kbcode._space ; $21 ; Space
jeq PurchaseWeaponNow jeq PurchaseWeaponNow
cmp #$07 ; cursor right cmp #@kbcode._right ; $07 ; cursor right
jeq PurchaseWeaponNow jeq PurchaseWeaponNow
bne ChoosingItemForPurchase bne ChoosingItemForPurchase
@@ -1137,20 +1137,20 @@ YesLetter
@ stx PositionInName ; if not, we store @ stx PositionInName ; if not, we store
jmp CheckKeys jmp CheckKeys
CheckFurtherX01 ; here we check Tab, Return and Del CheckFurtherX01 ; here we check Tab, Return and Del
cmp #$0c ; Return cmp #@kbcode._ret ; $0c ; Return
jeq EndOfNick jeq EndOfNick
cmp #$2c ; Tab cmp #@kbcode._tab ; $2c ; Tab
beq ChangeOfLevelUp beq ChangeOfLevelUp
cmp #$7 ;cursor right cmp #@kbcode._right ; $7 ;cursor right
beq ChangeOfLevelUp beq ChangeOfLevelUp
cmp #$6 ;cursor left cmp #@kbcode._left ; $6 ;cursor left
beq ChangeOfLevelDown beq ChangeOfLevelDown
cmp #$f ;cursor down cmp #@kbcode._down ; $f ;cursor down
beq ChangeOfLevel3Up beq ChangeOfLevel3Up
cmp #$e ;cursor up cmp #@kbcode._up ; $e ;cursor up
beq ChangeOfLevel3Down beq ChangeOfLevel3Down
cmp #$34 ; Backspace (del) cmp #@kbcode._del ; $34 ; Backspace (del)
bne CheckKeys bne CheckKeys
; handling backing one char ; handling backing one char
ldx PositionInName ldx PositionInName
@@ -1334,7 +1334,7 @@ JoyNotCentered
bne NoRight bne NoRight
; joy right ; joy right
cpy #7 cpy #7
beq GoToMainLoop ; jast character beq GoToMainLoop ; the last character
iny iny
bne GoToMainLoop bne GoToMainLoop
NoRight NoRight
@@ -1353,7 +1353,7 @@ NoLeft
; joy up ; joy up
cpx #(keycodesEnd-keycodes-1) cpx #(keycodesEnd-keycodes-1)
bne @+ bne @+
ldx #$00 ; set to first character index (loop) ldx #$00 ; set to the first character index (loop)
beq CharAndMainLoop beq CharAndMainLoop
@ inx @ inx
bne CharAndMainLoop bne CharAndMainLoop
@@ -1363,7 +1363,7 @@ NoUp
; joy down ; joy down
dex dex
bpl CharAndMainLoop bpl CharAndMainLoop
ldx #(keycodesEnd-keycodes-1) ; set to last character index (loop) ldx #(keycodesEnd-keycodes-1) ; set to the last character index (loop)
CharAndMainLoop CharAndMainLoop
lda scrcodes,x lda scrcodes,x
sta NameAdr,y sta NameAdr,y
@@ -1767,7 +1767,7 @@ EndOfTypeLine4x4
jsr GetKey jsr GetKey
cmp #$2b ; "Y" cmp #@kbcode._Y ; $2b ; "Y"
bne @+ bne @+
mva #$80 escFlag mva #$80 escFlag
bne skip01 bne skip01
+20 -20
View File
@@ -1126,7 +1126,7 @@ notpressed
lda kbcode lda kbcode
and #%10111111 ; SHIFT elimination and #%10111111 ; SHIFT elimination
cmp #$08 ; O cmp #@kbcode._O ; $08 ; O
bne @+ bne @+
jsr AreYouSure jsr AreYouSure
bit escFlag bit escFlag
@@ -1136,7 +1136,7 @@ QuitToGameover
mva #$40 escFlag mva #$40 escFlag
rts rts
@ @
cmp #28 ; ESC cmp #@kbcode._esc ; 28 ; ESC
bne @+ bne @+
jsr AreYouSure jsr AreYouSure
bit escFlag bit escFlag
@@ -1144,7 +1144,7 @@ QuitToGameover
;---esc pressed-quit game--- ;---esc pressed-quit game---
rts rts
@ @
cmp #$3f ; A cmp #@kbcode._A ; $3f ; A
bne @+ bne @+
callActivation callActivation
; Hide all tanks - after inventory they may have other shapes ; Hide all tanks - after inventory they may have other shapes
@@ -1153,7 +1153,7 @@ callActivation
jmp afterInventory jmp afterInventory
@ @
cmp #$0d ; I cmp #@kbcode._I ; $0d ; I
bne @+ bne @+
callInventory callInventory
; Hide all tanks - after inventory they may have other shapes ; Hide all tanks - after inventory they may have other shapes
@@ -1172,30 +1172,30 @@ afterInventory
jsr WaitForKeyRelease jsr WaitForKeyRelease
jmp BeforeFire jmp BeforeFire
@ @
cmp #$8e cmp #$80|@kbcode._up
jeq CTRLPressedUp jeq CTRLPressedUp
cmp #$8f cmp #$80|@kbcode._down
jeq CTRLPressedDown jeq CTRLPressedDown
cmp #$ac cmp #$80|@kbcode._tab
jeq CTRLPressedTAB jeq CTRLPressedTAB
and #$3f ;CTRL and SHIFT ellimination and #$3f ;CTRL and SHIFT ellimination
jumpFromStick jumpFromStick
cmp #$e cmp #@kbcode._up ; $e
jeq pressedUp jeq pressedUp
cmp #$f cmp #@kbcode._down ; $f
jeq pressedDown jeq pressedDown
cmp #$6 cmp #@kbcode._left ; $6
jeq pressedLeft jeq pressedLeft
cmp #$7 cmp #@kbcode._right ; $7
jeq pressedRight jeq pressedRight
cmp #$21 cmp #@kbcode._space ; $21
jeq pressedSpace jeq pressedSpace
cmp #$2c cmp #@kbcode._tab ; $2c
jeq pressedTAB jeq pressedTAB
cmp #$25 ; M cmp #@kbcode._M ; $25 ; M
jeq pressedM jeq pressedM
cmp #$3e ; S cmp #@kbcode._S ; $3e ; S
jeq pressedS jeq pressedS
jmp notpressed jmp notpressed
checkJoy checkJoy
@@ -1516,7 +1516,7 @@ ShotUnderGround
;xtraj=xtraj+vx - without Wind ;xtraj=xtraj+vx - without Wind
;vx=vx+Wind (Wind is a small fraction) ;vx=vx+Wind (Wind is a small fraction)
;plot xtraj,ytraj - there is clearing in plot ;plot xtraj,ytraj - there is clearing in plot
;goto begin ;goto begin-
@@ -2548,7 +2548,7 @@ notpressed
lda kbcode lda kbcode
and #%00111111 ; CTRL and SHIFT elimination and #%00111111 ; CTRL and SHIFT elimination
cmp #28 ; ESC cmp #@kbcode._esc ; 28 ; ESC
bne @+ bne @+
jsr AreYouSure jsr AreYouSure
bit escFlag bit escFlag
@@ -2557,11 +2557,11 @@ notpressed
rts rts
@ @
jumpFromStick jumpFromStick
cmp #$6 cmp #@kbcode._left ; $6
jeq pressedLeft jeq pressedLeft
cmp #$7 cmp #@kbcode._right ; $7
jeq pressedRight jeq pressedRight
cmp #$21 cmp #@kbcode._space ; $21
jeq pressedSpace jeq pressedSpace
jmp notpressed jmp notpressed
checkJoy checkJoy