Re: LF: More trouble...


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

Re: LF: More trouble...




Kevin T. Huber writes:
  > A bunch of stuff in reply to Jake Robb

If you want to actually print the numeric code for the pressed key, you'll
have to use sprintf or some other number printing routine.  The attached
listing is a repost, but it's got an example call to sprintf.  The nice
thing about sprintf versus hexlib is that you can print in decimal, octal,
or hex.  Note that I didn't use any macros just to simplify things for
demonstration.

A good logical way for a keycode printer to work is to have a last_key
variable.  You initialize it to some impossible value like 65535, then
after you call idle_loop you compare d0 to last_key.  If they're the same,
you exit, otherwise print the value, store d0 in last_key and loop again.
This way you can print all of the keycodes (without special casing escape
for example).  The keycodes are in the TI-92 manual so you should be able
to verify that they're correct.

-Kevin
khuber@mr.net

; ex.asm
; print 1-50
; no rights reserved - kth
        @program        prog_code,prog_name
prog_code:
	jsr	flib[clr_scr]

        move.w  #1,-(a7)               ;#1 is 8x8 font
        jsr     romlib[set_font]
        lea     2(a7),a7

        move.w #1,x                    ; x=1
startloop:

        move.l #$4440,a1               ; start of LCD mem (aka LCD_MEM)
        move.l #$4440,a2
        add.l  #30*8,a2                ; 8 lines down
        move.w #(((121-8)*30)/2)-1,d0  ; copy first 121 lines up
startcopy:
        move.w (a2),(a1)               ; copy a word (16 bits)
        add.l #2,a1                    
        add.l #2,a2
        dbra.w d0,startcopy            ; if d0 > 0,decrement & goto startcopy

        move.l #$4440+112*30,a1        ;112 lines down
        move.w #(15*8)-1,d0            ;8 rows
starterase:
        move.w #0,(a1)                 ;clear
        add.l #2,a1
        dbra d0,starterase

        move.w x,-(a7)           ; push argument 1
        pea  numfmt(PC)          ; format string
        pea  numtemp(PC)         ; output buffer
        jsr romlib[sprintf]
        lea 10(a7),a7

        move.w          #0001,-(a7)             ; color
        pea             numtemp(PC)             ; Variable of string to print
        move.w          #112,-(a7)              ;   y
        move.w          #0,-(a7)                ;   x
        jsr             romlib[puttext]         ; ROM call to puttext
        lea             10(a7),a7               ; restore the stack pointer

        jsr flib[idle_loop]                     ; wait for key


        add.w #1,x                              ; x=x+1
        cmp #50,x                              
        ble startloop                           ; while x<=50 loop
        rts

;*****************************************************
prog_name:
        dc.b    "example loop in ML",0

x       dc.w    0
numfmt  dc.b    "%d",0
numtemp dc.b    "    ",0          ;big enough for 9999
;*************** End of Fargo program ****************

	reloc_open
        add_library     romlib
        add_library     flib
	reloc_close
	end



References: