A83: finally ...


[Prev][Next][Index][Thread]

A83: finally ...





Hi
again
Remember me... I while ago I was trying to make an input routine that read more than one key and in different groups ...... after a lot of copying from other people (credits ...... )  I have finally made it .... 

Here it is 2nd Alpha + Arrows simultaneousely ....

in a simple well organised form

.nolist
#define equ .equ
#define EQU .equ
#define end .end
#define END .end

#DEFINE key    8270h

#include "tokens.inc"
#include "ti83asm.inc"

.list
.org $9327

 SET textwrite, (IY+sgrflags)
 call _GRBUFCLR
 jp GetkeyLoop
	
prep:
 ld hl,0101h
 ld (pencol), hl
 ret

Put:
 call _vputs
 call _grbufcpy_v
 ret


GetkeyLoop:
 call _GRBUFCLR
 xor a
 ld (key),a
 ld hl,key

 ld a, 0FFh   ;Reset Keyport
 out (1), a

 ld a, 0FDh   ;Enable Key Group with 'Clear' in it.
 out (1), a
 in a, (1)
 cp 191
 jp z,Done

 ld a, 0FEh   ;Enable Key Group with the Arrows in it.
 out (1), a
 in a, (1)

;(((((((((((((((((((((((((((((((((((((((((((((((((
;how it works ...
;I use hl to store my buttons that are pressed
;the 0 byte is the left arrow key (l = 00000001 means left only)
; and so on the other arrows 1 to 3
; 7 and 6th bit are for 2nd and Alpha... I use a word because lateron I will need more buttons
;If I want to make it faster I should use only the l reg. Am I right ??????????
;I owe credit for some of this code to somebody from this list but I forgot their name ... thanks anyway
;(((((((((((((((((((((((((((((((((((((((((((((((((

chk_down:
 cp %11111110   ;Check for Down.
 jr nz,chk_up
 set 1,(hl)

chk_up:
 cp %11110111   ;Check for Up.
 jr nz,chk_left
 set 3,(hl)

chk_left:
 cp %11111101   ;Check for Left.
 jr nz,chk_right
 set 0,(hl)

chk_right:
 cp %11111011   ;Check for Right.
 jr nz,chk_down_left
 set 2,(hl)

chk_down_left:
 cp %11111100   ;Check for Down AND Left.
 jr nz,chk_down_right
 set 1,(hl)
 set 0,(hl)

chk_down_right:
 cp %11111010   ;Check for Down AND Right.
 jr nz,chk_up_left
 set 1,(hl)
 set 2,(hl)

chk_up_left:
 cp %11110101   ;Check for Up AND Left.
 jr nz,chk_up_right
 set 3,(hl)
 set 0,(hl)

chk_up_right:
 cp %11110011   ;Check for Up AND Right.
 jr nz,chk_k2nd
 set 3,(hl)
 set 2,(hl)

chk_k2nd:
 ld a, 0FFh   ;Reset Keyport
 out (1), a
 ld a, 0bfh
 out (1), a
 in a, (1)
 cp 223
 jr nz,chk_Alpha
 set 7,(hl)

chk_Alpha:
 ld a, 0FFh   ;Reset Keyport
 out (1), a
 ld a,0dfh
 out (1), a
 in a, (1)
 cp 127
 jr nz,donetmp
 set 6,(hl)
 
donetmp:
 call which_key_combination
 jp GetkeyLoop

;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;_______________
; final
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

which_key_combination:
	ld hl,(key)
	ld a,l
	cp 10000000b
	jp z,k2nd
	cp 01000000b
	jp z,Alpha
	cp 11000000b
	jp z,k2nd_Alpha

;((((((((((((((((((((((((((((((((((((((down)))))))))))))))))))))))))))))))))
	cp 00000010b
	jp z,Down
	cp 00000011b
	jp z,Down_Left
	cp 00000110b
	jp z,Down_Right
	cp 10000010b
	jp z,Down_k2nd
	cp 01000010b
	jp z,Down_Alpha
	cp 11000010b
	jp z,Down_k2nd_Alpha

	cp 10000011b
	jp z,Down_Left_k2nd
	cp 10000110b
	jp z,Down_Right_k2nd
	cp 01000011b
	jp z,Down_Left_Alpha
	cp 01000110b
	jp z,Down_Right_Alpha
	
	cp 11000011b
	jp z,Down_Left_k2nd_Alpha
	cp 11000110b
	jp z,Down_Right_k2nd_Alpha

;((((((((((((((((((((((((((((((((((((((((((((((up))))))))))))))))))))))))))))))))))))
	cp 00001000b
	jp z,Up
	cp 00001001b
	jp z,Up_Left
	cp 00001100b
	jp z,Up_Right
	cp 10001000b
	jp z,Up_k2nd
	cp 01001000b
	jp z,Up_Alpha
	cp 11001000b
	jp z,Up_k2nd_Alpha

	cp 10001001b
	jp z,Up_Left_k2nd
	cp 10001100b
	jp z,Up_Right_k2nd
	cp 01001001b
	jp z,Up_Left_Alpha
	cp 01001100b
	jp z,Up_Right_Alpha
	
	cp 11001001b
	jp z,Up_Left_k2nd_Alpha
	cp 11001100b
	jp z,Up_Right_k2nd_Alpha
;(((((((((((((((((((((((((((((((((((((((((((((left))))))))))))))))))))))))))
	cp 00000001b
	jp z,Left
	cp 11000001b
	jp z,Left_k2nd_Alpha
	cp 01000001b
	jp z,Left_Alpha
	cp 10000001b
	jp z,Left_k2nd

;((((((((((((((((((((((((((((((((((((((((((((right))))))))))))))))))))))))))
	cp 00000100b
	jp z,Right
	cp 11000100b
	jp z,Right_k2nd_Alpha
	cp 01000100b
	jp z,Right_Alpha
	cp 10000100b
	jp z,Right_k2nd

	ret



k2nd_Alpha:
	call prep
	ld hl,k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	ret

Down:
	call prep
	ld hl,Down_Pressed
	call put
	call put_all_off
	call put_arrow_down
        ret
Up:
	call prep
	ld hl,Up_Pressed
	call put
	call put_all_off
	call put_arrow_up
        ret
Left:
	call prep
	ld hl,Left_Pressed
	call put
	call put_all_off
	call put_arrow_left
        ret
Right:
	call prep
	ld hl,Right_Pressed
	call put
	call put_all_off
	call put_arrow_right
        ret
k2nd:
	call prep
        ld hl,k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
        ret
Alpha:
	call prep
	ld hl,Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
        ret

Down_Left:
	call prep
	ld hl,Down_Left_Pressed
	call put
	call put_all_off
	call put_arrow_left
	call put_arrow_down
        ret
Down_Right:
	call prep
	ld hl,Down_Right_Pressed
	call put
	call put_all_off
	call put_arrow_right
	call put_arrow_down
        ret
Down_k2nd:
	call prep
        ld hl,Down_k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_arrow_down
        ret
Left_k2nd:
	call prep
        ld hl,Left_k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_arrow_left
        ret
Right_k2nd:
	call prep
        ld hl,Right_k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_arrow_right
        ret
Down_Alpha:
	call prep
	ld hl,Down_Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
	call put_arrow_down
        ret
Left_Alpha:
	call prep
	ld hl,Left_Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
	call put_arrow_left
        ret
Right_Alpha:
	call prep
	ld hl,Right_Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
	call put_arrow_right
        ret

Down_Left_k2nd:
	call prep
        ld hl,Down_Left_k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_arrow_down
	call put_arrow_left
        ret
Down_Right_k2nd:
	call prep
        ld hl,Down_Right_k2nd_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_arrow_down
	call put_arrow_right
        ret
Down_Left_Alpha:
	call prep
	ld hl,Down_Left_Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
	call put_arrow_down
	call put_arrow_left
	call put
        ret
Down_Right_Alpha:
	call prep
	ld hl,Down_Right_Alpha_Pressed
	call put
	call put_all_off
	call put_button4_on
	call put_arrow_down
	call put_arrow_right
        ret
Left_k2nd_Alpha:
	call prep
        ld hl,Left_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_left
        ret

Right_k2nd_Alpha:
	call prep
        ld hl,Right_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_right
        ret
Down_k2nd_Alpha:
	call prep
        ld hl,Down_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_down
        ret

Down_Left_k2nd_Alpha:
	call prep
        ld hl,Down_Left_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_left
	call put_arrow_down
        ret
Down_Right_k2nd_Alpha:
	call prep
        ld hl,Down_Right_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_right
	call put_arrow_down
        ret



Up_Left_k2nd_Alpha:
	call prep
        ld hl,Up_Left_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_left
	call put_arrow_up
        ret
Up_Right_k2nd_Alpha:
	call prep
        ld hl,Up_Right_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_button1_on
	call put_button4_on
	call put_arrow_right
	call put_arrow_up
        ret
Up_Left:
	call prep
	ld hl,Up_Left_Pressed
	call put
	call put_all_off
	call put_arrow_left
	call put_arrow_up
        ret
Up_Right:
	call prep
	ld hl,Up_Right_Pressed
	call put
	call put_all_off
	call put_arrow_right
	call put_arrow_up
        ret
Up_k2nd:
	call prep
        ld hl,Up_k2nd_Pressed
	call put
	call put_all_off
	call put_arrow_up
	call put_button1_on
        ret
Up_Alpha:
	call prep
	ld hl,Up_Alpha_Pressed
	call put
	call put_all_off
	call put_arrow_up
	call put_button4_on
        ret
Up_k2nd_Alpha:
	call prep
        ld hl,Up_k2nd_Alpha_Pressed
	call put
	call put_all_off
	call put_arrow_up
	call put_button1_on
	call put_button4_on
        ret
Up_Left_k2nd:
	call prep
        ld hl,Up_Left_k2nd_Pressed
	call put
	call put_all_off
	call put_arrow_left
	call put_arrow_up
	call put_button1_on
        ret
Up_Left_Alpha:
	call prep
	ld hl,Up_Left_Alpha_Pressed
	call put
	call put_all_off
	call put_arrow_left
	call put_arrow_up
	call put_button4_on
        ret
Up_Right_k2nd:
	call prep
        ld hl,Up_Right_k2nd_Pressed
	call put
	call put_all_off
	call put_arrow_right
	call put_arrow_up
	call put_button1_on
        ret
Up_Right_Alpha:
	call prep
	ld hl,Up_Right_Alpha_Pressed
	call put
	call put_all_off
	call put_arrow_right
	call put_arrow_up
	call put_button4_on
        ret










;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;button dRAW
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


put_all_off:
	ld a,20
	ld e,a
	ld a,10
	ld bc,button_off
	call SPRXOR
	ld a,30
	ld e,a
	ld a,10
	ld bc,button_off
	call SPRXOR
	ld a,20
	ld e,a
	ld a,20
	ld bc,button_off
	call SPRXOR
	ld a,30
	ld e,a
	ld a,20
	ld bc,button_off
	call SPRXOR
	ld a,20
	ld e,a
	ld a,30
	ld bc,button_off
	call SPRXOR
	ld a,30
	ld e,a
	ld a,30
	ld bc,button_off
	call SPRXOR
	call _grbufcpy_v
	ret

put_button1_on:
	ld a,20
	ld e,a
	ld a,10
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_button4_on:
	ld a,30
	ld e,a
	ld a,10
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_button2_on:
	ld a,20
	ld e,a
	ld a,20
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_button5_on:
	ld a,30
	ld e,a
	ld a,20
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_button3_on:
	ld a,20
	ld e,a
	ld a,30
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_button6_on:
	ld a,30
	ld e,a
	ld a,30
	ld bc,button_on
	call SPRXOR
	call _grbufcpy_v
	ret

put_arrow_up:
	ld a,15
	ld e,a
	ld a,45
	ld bc,arrow_up
	call SPRXOR
	call _grbufcpy_v
	ret



put_arrow_down:
	ld a,25
	ld e,a
	ld a,45
	ld bc,arrow_down
	call SPRXOR
	call _grbufcpy_v
	ret

put_arrow_left:
	ld a,20
	ld e,a
	ld a,40
	ld bc,arrow_left
	call SPRXOR
	call _grbufcpy_v
	ret

put_arrow_right:
	ld a,20
	ld e,a
	ld a,50
	ld bc,arrow_right
	call SPRXOR
	call _grbufcpy_v
	ret



;strings;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;simple
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Down_Pressed:
	.db "Down Pressed",0
Up_Pressed:
	.db "Up Pressed",0
Left_Pressed:
	.db "Left Pressed",0
Right_Pressed:
	.db "Right Pressed",0
k2nd_Pressed:
        .db "k2nd Pressed",0
Alpha_Pressed:
	.db "Alpha Pressed ",0

;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;double
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Down_Left_Pressed:
	.db "Down Left Pressed ",0
Down_Right_Pressed:
	.db "Down Right Pressed ",0
Down_k2nd_Pressed:
        .db "Down k2nd Pressed ",0
Left_k2nd_Pressed:
        .db "Left k2nd Pressd ",0
Right_k2nd_Pressed:
        .db "Right k2nd Pressed ",0
Down_Alpha_Pressed:
	.db "Down Alpha Pressed ",0
Left_Alpha_Pressed:
	.db "Left Alpha Pressd ",0
Right_Alpha_Pressed:
	.db "Right Alpha Pressed ",0
k2nd_Alpha_Pressed:
	.db "2nd and Alpha ... yo",0

;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;triple
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Down_Left_k2nd_Pressed:
        .db "Down Left k2nd Pressed ",0
Down_Right_k2nd_Pressed:
        .db "Down Right k2nd Pressed ",0
Down_Left_Alpha_Pressed:
	.db "Down Left Alpha Pressed ",0
Down_Right_Alpha_Pressed:
	.db "Down Right Alpha Pressed ",0

Left_k2nd_Alpha_Pressed:
        .db "Left k2nd Alpha Pressed ",0
Right_k2nd_Alpha_Pressed:
        .db "Right k2nd Alpha Pressed ",0
Down_k2nd_Alpha_Pressed:
        .db "Down k2nd Alpha Pressed ",0


;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
;quadruple
;HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Down_Left_k2nd_Alpha_Pressed:
        .db "Down Left k2nd Alpha Pressed ",0
Down_Right_k2nd_Alpha_Pressed:
        .db "Down Right k2nd Alpha Pressed ",0


;new

Up_Left_k2nd_Alpha_Pressed:
        .db "Up Left k2nd Alpha Pressed",0
Up_Right_k2nd_Alpha_Pressed:
        .db "Up Right k2nd Alpha Pressed",0
Up_Left_Pressed:
	.db "Up Left Pressed",0
Up_Right_Pressed:
	.db "Up Right Pressed",0
Up_k2nd_Pressed:
        .db "Up k2nd Pressed",0
Up_Alpha_Pressed:
	.db "Up Alpha Pressed",0
Up_k2nd_Alpha_Pressed:
        .db "Up k2nd Alpha Pressed",0
Up_Left_k2nd_Pressed:
        .db "Up Left k2nd Pressed",0
Up_Left_Alpha_Pressed:
	.db "Up Left Alpha Pressed",0
Up_Right_k2nd_Pressed:
        .db "Up Right k2nd Pressed",0
Up_Right_Alpha_Pressed:
	.db "Up Right Alpha Pressed",0


;END-NEW


; SPRXOR       by you know who
; Xor 8x8 sprite þ a=x, e=y, bc=sprite address
SPRXOR:

        push    bc              ; Save sprite address

;====   Calculate the address in graphbuf   ====

        ld      hl,0            ; Do y*12
        ld      d,0
        add     hl,de
        add     hl,de
        add     hl,de

        add     hl,hl
        add     hl,hl

        ld      d,0             ; Do x/8
        ld      e,a
        srl     e
        srl     e
        srl     e
        add     hl,de

        ld      de,8e29h
        add     hl,de           ; Add address to graphbuf

        ld      b,00000111b     ; Get the remainder of x/8
        and     b
        cp      0               ; Is this sprite aligned to 8*n,y?
        jp      z,ALIGN


;====   Non aligned sprite blit starts here   ====

        pop     ix              ; ix->sprite
        ld      d,a             ; d=how many bits to shift each line

        ld      e,8             ; Line loop
LILOP:  ld      b,(ix+0)        ; Get sprite data

        ld      c,0             ; Shift loop
        push    de
SHLOP:  srl     b
        rr      c
        dec     d
        jp      nz,SHLOP
        pop     de

        ld      a,b             ; Write line to graphbuf
        or     (hl)
        ld      (hl),a

        inc     hl
        ld      a,c
        or     (hl)
        ld      (hl),a

        ld      bc,11           ; Calculate next line address
        add     hl,bc
        inc     ix              ; Inc spritepointer

        dec     e
        jp      nz,LILOP        ; Next line

        jp      DONE1


;====   Aligned sprite blit starts here   ====

ALIGN:                          ; Blit an aligned sprite to graphbuf
        pop     de              ; de->sprite

        ld      b,8
ALOP1:  ld      a,(de)
        or     (hl)
        ld      (hl),a
        inc     de
        push    bc
        ld      bc,12
        add     hl,bc
        pop     bc
        djnz    ALOP1

DONE1:
        ret
; SPRXOR 

; Z80 Sprite83  movax 



button_on:
        .db %00000000
        .db %00111100
        .db %01111110
        .db %01111110
        .db %01111110
        .db %01111110
        .db %00111100
        .db %00000000

button_off:
        .db %00000000
        .db %00111100
        .db %01000010
        .db %01000010
        .db %01000010
        .db %01000010
        .db %00111100
        .db %00000000

arrow_up:
        .db %00010000
        .db %00111000
        .db %01111100
        .db %11111110
        .db %00111000
        .db %00111000
        .db %00111000
        .db %00000000

arrow_down:
        .db %00000000
        .db %00011100
        .db %00011100
        .db %00011100
        .db %01111111
        .db %00111110
        .db %00011100
        .db %00001000

arrow_left:
        .db %00000000
        .db %00010000
        .db %00110000
        .db %01111110
        .db %11111110
        .db %01111110
        .db %00110000
        .db %00010000
arrow_right:
        .db %00000000
        .db %00001000
        .db %00001100
        .db %01111110
        .db %01111111
        .db %01111110
        .db %00001100
        .db %00001000

Done:
 RES textwrite, (IY+sgrflags)
 call _GRBUFCLR
 call _clrLCDFull
 ret


.end
END

Now... is there something I can do to make it faster smaller ?
Comments ?
I have included the 83p file aswell.
Well I thauth you people would like to see it .....

homonerdicus





()()()()()()()()()()()()()()()()    ()()()()()() 
() www.homonerdicus.cjb.net  ()    ()visit me() 
()()()()()()()()()()()()()()()    ()()()()()() 


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: