What are some things that can cause FastCopy to crash? It’s been happening in my program and I have no idea why.

Also gbuf is defined as plotsscreen

FastCopy code:

Code:
;-----> Copy the gbuf to the screen (fast)
;Input: nothing
;Output: graph buffer is copied to the screen
fastCopy:
 di
 ld a,$80
 out ($10),a
 ld hl,gbuf-12-(-(12*64)+1)
 ld a,$20
 ld c,a
 inc hl
 dec hl
fastCopyAgain:
 ld b,64
 inc c
 ld de,-(12*64)+1
 out ($10),a
 add hl,de
 ld de,10
fastCopyLoop:
 add hl,de
 inc hl
 inc hl
 inc de
 ld a,(hl)
 out ($11),a
 dec de
 djnz fastCopyLoop
 ld a,c
 cp $2B+1
 jr nz,fastCopyAgain
 ret
You are going to have to provide more context. What calculator? How are you calling this function? Etc.
Assuming you're running that code on a monochrome calc (TI-83 Plus (SE)/TI-84 Plus (SE)), there's nothing in that code that could cause a crash. It might show the results of a crash, but not cause one outright. Check some other piece of your code.

If the display is just glitchy and has been that way in many games, try using this program to fix some timing problems in the LCD.

If you're trying to use this on a color calculator, that's your problem. You'll need a routine specific for those.
To expand slightly on Iambian's answer, the CE uses memory-mapped ports, and will crash if you try to out or in directly to/from to the ports. And the 12 and 64 in that code represent the width (in bytes) and the height (in pixels) of the monochroke calcs' screens.

Of course, if you are on a monochrome calculator, this'll be slightly harder to solve.
KermMartian wrote:
To expand slightly on Iambian's answer, the CE uses memory-mapped ports, and will crash if you try to out or in directly to/from to the ports. And the 12 and 64 in that code represent the width (in bytes) and the height (in pixels) of the monochroke calcs' screens.

Of course, if you are on a monochrome calculator, this'll be slightly harder to solve.


Unfortunately I’m using the TI-84 Plus. To expand more, there’s this problem goes away when I comment out some code that isn’t even run (I used a debugger, this section is never executed).

It’s all very bizzare. Would it be helpful if I posted the whole program? It’s about 350 lines, but I can highlight important sections.
Yes, definitely post your code. Based on that, it sounds like you have another section of code overwriting some of your code.
Here is the program. It's Tetris, but so far you can only move left and right and soft drop.
https://pastebin.com/fJeR8xcJ

It works as is, but if you uncomment lines 61-86, the program crashes. I tested it on both wabbitemu and my actual TI-84 Plus. Compiled with SPASM.
The putSprite routine that you are using doesn't perform clipping, so early on it tries to draw sprites with a y-coordinate of -1, for example. Since this is represented as 255, the putSprite routine tries to draw to the 255th row of the graph buffer, which starts at 0x9F34. Meanwhile, assembly programs run from 0x9D95. So the drawing is overwriting data at about 415 bytes into your program. Your program without the comments is 453 bytes and with the comments it is 408 bytes, so commenting the code was pretty much masking the problem Razz

What you'll need to do is make sure the sprites don't go off-screen and/or add some basic clipping code. I put the following at the top of putSprite and it works, but it isn't ideal:

Code:

  cp 96        ;Check the x coordinate. This also takes care of negatives, since -1 is 255, and 255>=96.
  ret nc
  ld h,a
  ld a,l
  cp 64-3     ;Your sprites have a height of three
  ret nc
  ld a,h


EDIT: accidentally counted the 9 bytes of code I added in.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement