a quick and dirty asm hack for buttons

Rob Miller (rmiller@bsm.biochemistry.ucl.ac.uk)
Mon, 12 Jun 1995 13:52:11 GMT

posted this to comp.os.geos in response to an info
requexst from someone, thought I may as well put it
up here too even though I expect there's much overlap.....

Subject: Re: Zoomer and Geos
Newsgroups: comp.os.geos

barrym (barrym@starbase.neosoft.com) wrote:

: I'm slowly realizing that the Zoomer users are really into hacking. I'm a

Yep, and here's some code I hacked up to just display button (a,b,arrows)
presses. I *know* this is not the right way to program mr. Z, but I don't
have the SDK, a cd-rom drive, or a >= 386 pc with me these days.

Enjoy, and it's just a hack so don't complain about where I could
have coded better :-). Anybody figures out how to do screen display
stuff at this pathetic asm hacker level, do let me know. Yes, it would
only work on the Zoomer ROM revision currently in my possession, but
you knew it was orphaned and not to be upgraded when you bought it at
CostCo for cheap anyway.

No, I don't know what all the interrupts do, and I'm not going to say
where I started from to get this working. Let's just say I do not
copyright the brilliant source code below in any way, nor do I accept
any liability whatsoever for whatever may happen as a result of your
looking at and/or using it. Wrote this for tasm, the assembler that
came with the last version of Borland C++ (2.0 ?) that would work on my
8086 dos 3.3 palmtop (which is why my friend gave it to me :-).

Big apologies to Geos/Zoomer pros and other software *engineers*, I know
you put a lot of excellent work into developing a nice object oriented,
_engineered_ system, but the starting barrier is just a little high for
me these days as I see it. Seems like the SDK might contain basic info
and addresses that would be useful to me along these lines, but haven't
gotten there yet. I've ordered IZL, perhaps that will satisfy for a
while....

Also apologies if I messed anything up adding what I hoped were
additional helpful comments, think it should be ok.

rob.

.MODEL small
.8086
.STACK 100h

a_offs EQU 'a'-0ah

.DATA
rlabl DB 'al = ','$'
finlin DB ' ',13,10,'$'
finmsg DB 'finishing',13,10,'$'

mychar DW 0
oldchar DW 0
oldad1 DW 0
oldad2 DW 0

.CODE
jmp start ;;;; the following are just support
;;;; routines, skip down to the program part

;;; dax dump AX to screen
dax: push ds
push cx
push ax

mov ax,@data ; get local_data base addr
mov ds,ax ; into ds
mov ah,9h
mov dx,OFFSET rlabl ; the opening line
int 21h ; put

mov cx,4h ; 4 digits
nlp:
pop dx ; retrieve the input
push dx ; but save it
push cx ; save digit loop counter
mov ax,cx ; prep for mul
dec ax ; digit-1
shl ax,1h ; 4 bits per char * digit-1
shl ax,1h
mov cx,ax
shr dx,cl ; current digit in dl
pop cx ; loop / digit counter back
and dl,000fh ; only low four bits go out
cmp dl,0ah ; check for char result
jl nm ; if not, move on
add dl,a_offs ; digit->ascii_char conversion
jmp doit
nm: add dl,'0' ; digit->ascii_digit conversion
doit: mov ah,02h
int 21h ; display
loop nlp

mov dx,OFFSET finlin ; crlf etc.
mov ah,9h
int 21h
pop ax
pop cx
pop ds
ret ; all safe, all done

doint1:
mov ax,5001h
mov bh,00h
int 16h
mov [oldchar],bx ; int 16 return val in bl
ret

doint2:
mov ax,5003h
mov bh,00h
int 16h
mov [oldad1],dx ; int 16 return val in cx,dx
mov [oldad2],cx
ret

;; have a keypress, put it where main loop can find it
myhndlr:
or al,al
je mhfin
push ds
push dx
mov dx,@data
mov ds,dx
mov [mychar],ax
pop dx
pop ds
mhfin: retf

;; set up myhandlr to be called on a key press
doint3:
mov ax,5003h
mov bh,01
mov dx,cs
mov cx,OFFSET myhndlr
int 16h
ret ; apparently no return value

doint4:
mov ax,5001h
mov bh,01h
mov bl,01h
int 16h
ret ; apparently no return value

myint:
mov ah,07
int 21h
ret

;;;;
;;;; main program starts here
;;;;

start: mov dx,@data ; base or our data space
mov ds,dx ; into ds

call doint1 ; apparently these set things up
call doint2 ; for what we are about to do
call doint3
call doint4

mov ax,0
mov [mychar],ax
mov cx,25 ;; do 25 key presses, then finish
dlp: mov ax,[mychar]
or ax,ax
je dlp
call dax
mov ax,0
mov [mychar],ax
loop dlp

;; make everything nice and go back to wherever we were before
fin:
stc
push dx
pushf
mov dx,[oldad1]
mov cx,[oldad2]
mov bh,01
mov ax,5003h
int 16h
popf
pop dx

mov dx,OFFSET finmsg
mov ah,09
int 21h

mov al,0
mov ah,4ch
int 21h

END

-- 
-------------------------------------------------------
Rob Miller, Ph.D.  

Biomolecular Structure and Modelling Unit (BSM), Department of Biochemistry and Molecular Biology, University College / Gower Street / London WC1E 6BT. United Kingdom.

Tel: +44 171419 3896 Fax: +44 171380 7193

Internet: rmiller@bsm.bioc.ucl.ac.uk http://www.biochem.ucl.ac.uk/~rmiller -------------------------------------------------------