Login
Back to forumReply to this topicGo to last reply

Posted By

malco​ntent
on 2014-08-02
00:21:12
 Some programming help. Crash on CHROUT, maybe?

Every so often I get a weird crash on a routine that has been working fine. There seems to be no way to create the crash that I can find, so it is very tricky to catch in action. What happens when I trace the program is that I see the processor goes to the kernal jump table, finds zeros there, and then jumps to $0000 where it jams. I've had this happen on vice and yape, though it seems to happen more often on vice, maybe it's me.

I have an IRQ going that is pretty simple:

sei
lda irq_lo
sta $314
etc
...
lda #$2
sta $ff0a
lda #$ff
sta $ff0b
cli

In the IRQ i read the joystick ($ff08) Then to acknowledge the IRQ I store $ff in $ff09

I'm using a lot of zp locations, but don't know if that matters. from the Kernal I really only use CHROUT, and PLOT.

Posted By

SVS
on 2014-08-02
02:55:03
 Re: Some programming help. Crash on CHROUT, maybe?

To read the joystick #1, you have first to write over bit 2 of $FF08, then read whole $ff08 to obtain the result (row). The column is available from $FD30 routine).

The jump to $0000 seems to be caused by a missing ROM selection. Have you set ROM read (sta $FF3E) before to return to standard OS?

Posted By

Csabo
on 2014-08-02
10:12:48
 Re: Some programming help. Crash on CHROUT, maybe?

To acknowledge the IRQ, you must both read and write to $FF09. The most common way is to do LDA $FF09 / STA $FF09 (the value itself doesn't matter), or with one instruction as INC $FF09 (or equivalent). I think that might be the issue.

Otherwise, you should probably post the full code, or at least a working partial code which you've seen crash.

Posted By

malco​ntent
on 2014-08-02
22:46:46
 Re: Some programming help. Crash on CHROUT, maybe?

Thanks for your responses. I will change the IRQ ack, and see if it helps. My joystick routine is IIRC straight from the programmers reference guide:

ldx #$fd
- stx $ff08
lda $ff08
stx $ff08
cmp $ff08
bne -
sta joy

Posted By

Csabo
on 2014-08-03
14:13:46
 Re: Some programming help. Crash on CHROUT, maybe?

That part certainly shouldn't crash. If you're still seeing crashes please post the full/partial code (see above).

Posted By

malco​ntent
on 2014-08-05
17:25:29
 Re: Some programming help. Crash on CHROUT, maybe?

I think I might have solved it. It still crashed after fixing the IRQ, but I was writing into $fb, which on c64 (it's ported code) is for the user, but in the PRG it says "Number of rom bank enabled". Also was using $fe, which ("Temp storage for cursor line") might have been used by CHROUT. It might not have solved the problem, but the crash is so rare that I've thought I've solved it before.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024