Jump to content


Photo

Free space and code optimisation in "JSW"


  • Please log in to reply
252 replies to this topic

#251 Norman Sword

Norman Sword

    Advanced Member

  • Member
  • PipPipPip
  • 187 posts

Posted 21 November 2018 - 12:09 PM

This is a re-use of the same algorithm. This time it translates a key press into a key value. Could be used for high score input which uses the keyboard to type in a name and not the easy scroll letters to get an input. The big wastage is the translate table. The purpose of typing this is only to show a quick re purposing of a routine. (Of note I have seen far worse than this)
.
.
key_input:
LD HL,TABLE-1

LD BC,#FEFE

 

keyloop1:

IN A,( C )

LD E,5

keyloop2:

INC HL

RRCA

JR NC,key_pressed

DEC E

JR NZ,keyloop2

RLC B

JR NC,keyloop1
JR C,keyloop1   << corrected

JR key_input

 

 

key_pressed:

LD A,(HL)                 ;the key value from the keyboard

.

.

TABLE  db   0,"ZXCVASDFGQWERT1234509876POIUY",13,"IJKL ",1,MNB"
TABLE db    0,"ZXCVASDFGQWERT1234509876POIUY",13,"LKJH ",1,"MNB"  <<hopefully corrected
 

 

shift translates as 0, symbol shift as 1, enter as 13

 

Edited to correct the errors from my quick transcribe. 


Edited by Norman Sword, 21 November 2018 - 01:02 PM.

  • IRF likes this

#252 IRF

IRF

    Advanced Member

  • Contributor
  • 4,037 posts

Posted 21 November 2018 - 12:33 PM

"JR NC,keyloop1" should read "JR C,keyloop1"?

 

This entry: "IJKL ", should be "LKJH ", (with the Space character at the end, before the symbol shift entry)?



#253 Norman Sword

Norman Sword

    Advanced Member

  • Member
  • PipPipPip
  • 187 posts

Posted 21 November 2018 - 12:51 PM

Very surprised it did not contain far more errors. 

I will edit but leave the errors obvious.

 


  • IRF likes this




1 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


    Bing (1)