First steps in ASM, but I (probably) need some guidance

Page 7/7
1 | 2 | 3 | 4 | 5 | 6 |

Par hit9918

Prophet (2866)

Portrait de hit9918

09-06-2012, 10:13

I found this in my sources

inkey:
call 0x9c
jp z,nokey
call 0x9f
ret
nokey:
ld a,0
ret

Par erwinmusik

Master (140)

Portrait de erwinmusik

09-06-2012, 20:29

OK, I will try this tomorrow.
Today I have learn about HALT and put a seconds counter in my code
I code it strictly in the structure hit9918 suggest, this is the part after set Page 0 to BIOS:

; now view the BIOS
	
 	EI 		  ;let interrupts pass
 			  ;get some keypress
	LD	A,(KEYS+8)	  ;space pressed?
	bit	0,A
	JP	Z,BACK
	CALL	KILBUF		; Flush Keyboardbuffer
	HALT
	LD	A,(CLOCKC)              ; the clockcounter
	INC	A
	LD	(CLOCKC),A
	CP	50		; second full?
	CALL	Z,SECINC	                 ; if then goto Second Increment
 	DI
	CALL	SETSFG 		;set music slot
; now view the SFG

 	JP mainloop

is this the right way?
In the mainloop I have a CALL to a subroutine wich shows the seconds on the screen
mainloop:

 	;all my stuff in music slot view including vram printing
	CALL	SHOWCLOCK

It works and for now it shows only the characters incremented every second, real seconds and minutes follows tomorrow
Back to Basic with Space KEy works too
Flush KEybuffer CALL - if I pressed a lot of other keys before Space, all the others are swown when back in BASIC
I think thats a good idea, isn´t it?

Par hit9918

Prophet (2866)

Portrait de hit9918

10-06-2012, 17:57

With inkey, can forget that keyboard buffer.
Except you keep keys pressed like playing piano, and keyrepeat kicks in.

Is keyrepeat speed always the same amount of interrupts?
Then every key event could set a counter for that key.
And every frame you decrement the counters of all keys.
And once a counter reached 0, you got a "key is no more pressed" case.

I heard ugly things about some MSXes having odd keyboard map, so going at the hardware is trouble.
But if you want to just hack your machine, asking the key matrix is easier.

Page 7/7
1 | 2 | 3 | 4 | 5 | 6 |