Arjen Schumacher Posted May 18, 2016 Share Posted May 18, 2016 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:) It crashes to the following screen: Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted May 18, 2016 Share Posted May 18, 2016 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$. 2 Quote Link to comment Share on other sites More sharing options...
Arjen Schumacher Posted May 18, 2016 Author Share Posted May 18, 2016 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! 1 Quote Link to comment Share on other sites More sharing options...
Dmitry Posted May 19, 2016 Share Posted May 19, 2016 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. Quote Link to comment Share on other sites More sharing options...
+JAC! Posted May 19, 2016 Share Posted May 19, 2016 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. Quote Link to comment Share on other sites More sharing options...
Dmitry Posted May 20, 2016 Share Posted May 20, 2016 Oh I can lay an egg now, I was using altirra basic, which apparently runs Myrtle way too fast. That game makes little sense at hyperspeed If it's not clear...the book eventually culminates in a real video game - Myrtle the Turtle. Quote Link to comment Share on other sites More sharing options...
576XE Posted August 10, 2017 Share Posted August 10, 2017 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...) Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted August 10, 2017 Share Posted August 10, 2017 It's sitting in the stack space, and I guess the stack is wiping out the end of the code when DOS is present. Better assemble it to page 6 or similar (start = $0600). 1 Quote Link to comment Share on other sites More sharing options...
576XE Posted August 11, 2017 Share Posted August 11, 2017 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 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted August 11, 2017 Share Posted August 11, 2017 (edited) Wild guess, but all the extra initialisation when DOS is present may result in a deeper stack of return addresses by the time BASIC executes USR. But it should be moved out of the stack space: change START = $0100 to START = $0600. Edited August 11, 2017 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
576XE Posted August 11, 2017 Share Posted August 11, 2017 Today I've compiled it in user area on 6-th page. I've just forget to say it. Strange behaviour. I can not realize it. Yes, cursor moves in right direction but then freezed for a minute and may move again ... Quote Link to comment Share on other sites More sharing options...
kenjennings Posted August 12, 2017 Share Posted August 12, 2017 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 . Quote Link to comment Share on other sites More sharing options...
576XE Posted August 12, 2017 Share Posted August 12, 2017 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! Quote Link to comment Share on other sites More sharing options...
DEBRO Posted August 12, 2017 Share Posted August 12, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted August 12, 2017 Share Posted August 12, 2017 You're right about the stack... I was way off there. 1 Quote Link to comment Share on other sites More sharing options...
576XE Posted August 12, 2017 Share Posted August 12, 2017 What it's this magic location ZP$00? Really I've tried $80 - no chance! It's concerned CH sell and it's VBI interconnections... IMHO Quote Link to comment Share on other sites More sharing options...
kenjennings Posted August 12, 2017 Share Posted August 12, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted August 12, 2017 Share Posted August 12, 2017 (edited) 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 August 12, 2017 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
576XE Posted August 13, 2017 Share Posted August 13, 2017 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! Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted August 13, 2017 Share Posted August 13, 2017 (edited) 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 August 13, 2017 by flashjazzcat 1 Quote Link to comment Share on other sites More sharing options...
ricortes Posted August 13, 2017 Share Posted August 13, 2017 Haven't had my coffee yet so still groggy. What happens if you change that LDA $0 to LDA #$0 ? Quote Link to comment Share on other sites More sharing options...
576XE Posted August 13, 2017 Share Posted August 13, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.