Re: LF: More trouble...


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

Re: LF: More trouble...



I think you're passing the wrong parameters to putchar.

If you look at romlib.fn, you see:

; putchar(int ch, int x, int y, int color, int what1, int what2, int what3)

Fargo uses a C calling convention which means that you push the
arguments on the stack from right to left, 
i.e. what3,what2,what1,color,y,x,ch

you are pushing
what3,what2,what1,font,x,y,ch

So, you're mixing up x and y and pushing a font style instead of a color.

One thing you should do is experiment with using macros.  if you
add a line after @program like:
        include         macros.h

you can go
        SetFont         #4
        WriteChar       #0,#0,#1,d0

instead of everything between loop and the jsr to putchar since all the
macro does is take your arguments and expand them out to a form like you
had anyway -- but it saves you a lot of typing and you don't have to worry
about the stack.

Also, you have some labels that aren't used like prog_data.  Someone on the
list said that you can run out of labels if you use too many so I would
just put a comment in those places instead like ;program data.

The "BRA LOOP" line will always branch, so there is no way for the program
to exit.  You will have to check the value in d0 to see if a key was
pressed.

The following two lines will loop until escape is pressed:
        cmp.w #$108,d0    ;esc?
        bne loop

I know assembly must seem like it isn't worth the effort, but once you
figure out how to create macros to simplify things and get used to the
libraries it gets a lot easier.

good luck,
-Kevin
khuber@mr.net

The changes I'm thinking of look something like this, but I'm in Linux
so I can't test it right now.  I hope this helps:


        @program prog_code,prog_name
        include         macros.h
; *=changed from before        
prog_code:
        SetFont #4
        JSR     flib[clr_scr]       ; clear screen
        JSR     flib[idle_loop]     ; wait for key 
LOOP:                               ; label         
        WriteChar #0,#0,#1,D0
        JSR     flib[idle_loop]     ; wait for key
        cmp.w   #$108,d0            ; esc?
        beq     LOOP                ; no - goto label LOOP
Exit:                               ; yes, esc was pressed so exit
        RTS                         ; end of prog

prog_name:                          ; declare string for comment line
        DC.B    "Key Code Generator",0

prog_data:
        reloc_open                  ; include libraries flib and romlib
        add_library  romlib
        add_library  flib
        reloc_close

 END                                ; see?  it really is there!


Follow-Ups: References: