Jump to content
IGNORED

Problem with USR in ataribasic (Atari800)


Recommended Posts

Goodday everyone,

 

I'm having a problem with a USR(ADR()) command in Ataribasic. It keeps crashing in the Atari800 emulator (windows 8.1 64bit host). I'm totally unknown with assembly, so I have no idea why it crashes.

I think it tries to allocate free memory at the address of variable ST and up.

 

 

The listing (from the book dr. Wacko's Guido to creating games) contains the following first lines, of which it keeps crashing on line 50. Any help or direction in which to search is much appreciated:)

crash.png

 

 

It crashes to the following screen:

report.png

 

Link to comment
Share on other sites

I think you forgot to replace the placeholder text inside of M$ with the specified machine code data. The CPU appears to have crashed executing the "r" of "Insert". You need to find the character equivalents of the data on page 75 and put it inside of M$.

Wow... I completely missed that, I deserve a slap for not doing the plain reading that's sometimes required. Thanks a lot for your help!:)

  • Like 1
Link to comment
Share on other sites

I hadn't seen that book before, but I read it, and then I downloaded Myrtle the Turtle from AtariMania.

 

Wow, I could not get Myrtle to lay an Egg. Seemed like a fun concept, but it's not really clear what the author meant by 'safely at her nest'

 

I can transport to the nest, but the turtle immediately dies.

Link to comment
Share on other sites

I think you forgot to replace the placeholder text inside of M$ with the specified machine code data. The CPU appears to have crashed executing the "r" of "Insert". You need to find the character equivalents of the data on page 75 and put it inside of M$.

Briliant, I bet if I had typed it in in 1985 when I first got my Atari, I would have fallen into the very same trap.

Link to comment
Share on other sites

  • 1 year later...

Hi, there Friends!

 

Please help me.

 

This code works like a charm in Basic (it was intended for it),

but I can not force to work it in DOS environment.

; keyjoy.mae
; By Ted Stockwell,
; modified by Patrick Bass

;---------------------------
; Equates
SETVBV  =   $e45c  ;set vector.
SYSVBV  =   $e45f  ;do vblank.
STICK0  =   $0278  ;stick shadow.
CH      =   $02fc

;---------------------------
; Constants
start   =   $0110
vbmode  =   6
speed   =   $00     ;repeat speed.
cur.up  =   142     ;cursor values.
cur.dn  =   143
cur.lt  =   134
cur.rt  =   135
total = end-start

;---------------------------
        .or start

; To activate, point the vblank vector to our routine.
install
        pla ; I've deleted it!!!
        ldy # <vbi
        ldx # >vbi
        lda #vbmode
        jsr SETVBV
        rts 

;------------------------
; Now every vertical blank sends us here first.
vbi
        dec count   ; bump down counter.
        bne done    ; branch out if timer still in use.
        lda speed   ; else refresh counting
        sta count   ; delay counter.
;
        lda STICK0  ; get stick val
        eor #$0f    ; invert it.
        beq done    ; if 0, no press.
;
        ldx #$ff    ; otherwise reset key selector.
mloop
        inx         ; point to next key selection.
        lsr a       ; check for bit.
        bcc mloop   ; branch if no bit available.
        lda keys,x  ; else grab key
        sta CH      ; store in shadow
done
        jmp SYSVBV  ;do rest of vertical blank.

;-----------------------------
keys    .by cur.up,cur.dn
        .by cur.lt,cur.rt
count   .by 5
end     .en 

Needed 30 seconds to some motion actualised and then all stallls again.

 

(Yes, I deleted pla stanza needed in BASIC...)

Link to comment
Share on other sites

Hi there, FJC.

Thank you for early reply!

 

I have still no chance to run it.

Seems to be a simple program but it is not working in DOS.

I even can't imagine what is the difference in DOS/BASIC...

 

May be I need to look at BASIC part...

ez

Link to comment
Share on other sites

It is resetting the "count" delay to whatever is stored in the location labelled "speed" which is memory address $00.

 

What value is there? If it happens to be 0, then "count" is being initialized to 0, and your delay loop will decrement that to $FF, and then it won't make it back to 0 for another 255 frames .

Link to comment
Share on other sites

Hi there, Ken!

 

Really this code is Ted Stockwell's BASIC routine from ANTIC magazine.

http://www.atarimagazines.com/v5n1/joystickcursor.html

 

It's fully working even being placed to stack area.

 

The most amazing is that it's even working after exiting from BASIC to DOS!!!

(I understand that this fact is the result of algorythm!)

 

But standalone assembly part is still absolutely unworkable!

:(

Link to comment
Share on other sites

Hi there,

 

I agree that having the code reside in page 6 is safe but this code was placed so high on the stack originally that I find it hard to believe it was getting overwritten. What is it...48 bytes?

 

Your issue maybe ZP location $00 and how it works in AtariBASIC vs. DOS. To verify or test, add your own variable that gets updated in VBLANK and use it instead.

  • Like 1
Link to comment
Share on other sites

What it's this magic location ZP$00?

 

 

As far as Mapping The Atari goes location $00 is mostly unused.

 

I think the code intends to reference this to get the frame counter speed set by other code (i.e. to allow a BASIC program to change the behavior of this routine.) So, setup for this should initialize $00 to a non-zero value.

  • Like 1
Link to comment
Share on other sites

Finally had a chance to look more closely at this and the answer has been staring us in the face for some time. SPEED is a constant and should not be zero. The delay counter is being reset to the value of location $00 instead of the desired delay value. This works:

 

; keyjoy.mae
; By Ted Stockwell,
; modified by Patrick Bass

;---------------------------
; Equates
SETVBV  =   $e45c  ;set vector.
SYSVBV  =   $e45f  ;do vblank.
STICK0  =   $0278  ;stick shadow.
CH      =   $02fc

;---------------------------
; Constants
start   =   $0110
vbmode  =   6
speed   =   $05     ;repeat speed.
cur.up  =   142     ;cursor values.
cur.dn  =   143
cur.lt  =   134
cur.rt  =   135
total = end-start

;---------------------------
        .or start

; To activate, point the vblank vector to our routine.
install
;        pla ; I've deleted it!!!
        ldy # <vbi
        ldx # >vbi
        lda #vbmode
        jsr SETVBV
        rts 

;------------------------
; Now every vertical blank sends us here first.
vbi
        dec count   ; bump down counter.
        bne done    ; branch out if timer still in use.
        lda #speed   ; else refresh counting
        sta count   ; delay counter.

        lda STICK0  ; get stick val
        eor #$0f    ; invert it.
        beq done    ; if 0, no press.

        ldx #$ff    ; otherwise reset key selector.
mloop
        inx         ; point to next key selection.
        lsr @       ; check for bit.
        bcc mloop   ; branch if no bit available.
        lda keys,x  ; else grab key
        sta CH      ; store in shadow
done
        jmp SYSVBV  ;do rest of vertical blank.

;-----------------------------
keys    .by cur.up,cur.dn
        .by cur.lt,cur.rt
count   .by 5
end     .en 
Edit: Ken got there first. :) Edited by flashjazzcat
Link to comment
Share on other sites

Hi there FJC!

 

You are absolutely right!

 

And just to convince you that I'm not a simple IDIOT ( :? Who knows...) ...

 

Please take a look at this screenshot. It's a disassembly of working BASIC program.

 

Do you see any OCTOTORP (sharp) under arrow?

...

Me too!

 

By the way It's a clear example of different treating of zero in BASIC and Assembly...

BASIC uses $00 but in Assembly it stalls cursor for about 30sec, then it moves again.

 

Best wishes, Friend!

post-20208-0-98974100-1502589358_thumb.png

Link to comment
Share on other sites

It's puzzling. I only see a single write ($FF) to location $00 here using a stock XL/XE OS and no writes at all by BASIC, so this would at least explain the very lengthy delay (five seconds or so) between polling of the joystick. Try to see what value $00 contains when the code is working for you under BASIC.

 

EDIT: does the BASIC setup program not simply POKE some value to $00 first?

 

EDIT2: yes, it does, at line 90 (POKE 0,2).

 

Mystery solved. :)

Edited by flashjazzcat
  • Like 1
Link to comment
Share on other sites

Hello friends.

Very interesting!

 

To ricortes.

At first, while decrementing by 1, 0 become 255 and this garantees very long delay between moving cursor.

As you can see FJC said that BASIC initialises $0 in 2 (still fast for me...) I use 4.

ez

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...