Author Topic: TI-84+ Incompatability Problems  (Read 19612 times)

0 Members and 1 Guest are viewing this topic.

SirCmpwn

  • Guest
TI-84+ Incompatability Problems
« on: January 12, 2011, 04:56:02 pm »
Hello,
I'm having some issues with KnightOS.  As of right now, it runs fine on the TI-83+ (SE).  However, on the TI-84+ (SE), it crashes.  I believe this to be caused by improper USB interrupt handling.  KnightOS runs without incident if interrupts are turned on, but as soon as interrupts (and multitasking) are turned on, it will crash.  Here is my USB interrupt code:
Code: [Select]
HandleUSBEvents:
ld a, (ModelID)
cp 2 ; Models 2 and up have USB.
jp c, ResumeInterrupt ; Leave if we don't have the hardware (also tested with NC)
in a, (55h) ; Read USB status
bit 0, a
jr z, UnknownUSBEvent
bit 2, a
jr z, USBLineInterrupt
bit 4, a
jp z, USBProtocolInterrupt
jp ResumeInterrupt

UnknownUSBEvent:
xor a
out (5Bh), a ; Unknown event, WikiTI claims you should zero port 5B to acknowledge
jp ResumeInterrupt

USBLineInterrupt:
in a, (56h)
ld c, a
cpl ; xor 0FFh
ld b, a
in a, (57h)
ld d, a
and b
out (57h), a
ld a, d
out (57h), a ; Ack the interrupt without doing anything special
jp ResumeInterrupt

USBProtocolInterrupt:
in a, (86h)
ld c, a
in a, (84h)
ld b, a
in a, (85h)
in a, (83h)
in a, (82h) ; Just ack and leave, and hope that it doesn't get angry

jp ResumeInterrupt

However, if you don't notice anything wrong with this, it may not be the problem.  Also suspect is the code that sets up the memory mappings on boot:
Code: [Select]
    ld a, 1    ; Set flash page 1 in bank 1.
    out (6), a
    in a, (2)    ;get calc version
    rlca ;Roll bit 7 into carry.
    ld a, 41h ; Set ram page 1 in bank 2.
    jr nc, LowerModel ; C vs NC?
HigherModel:
    out (5),a
    ld a,81h
    out (7),a
    jr Return
LowerModel:
    out (6), a
    out (7),a
Return:
    ret
I'd put my money on USB interrupts, but that's just me.  You are now looking at the only model-dependent code in the whole OS, so this is pretty much where the problem has to lie.  Is there any hardware I may not have initialized properly, or something I may have left out that is required on the TI-84+ (SE)?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: TI-84+ Incompatability Problems
« Reply #1 on: January 12, 2011, 05:05:54 pm »
Could it be that you are putting RAM page 1 into both $8000-$BFFF and $C000-$FFFF? You'd probably want to put RAM page 0 in $C000-$FFFF to have the same mapping as TI-83+
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #2 on: January 12, 2011, 05:07:33 pm »
Ah, that could present an issue.  I want an executable page in both, though, is that possible?  Compatibility with calculators missing RAM is vital.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: TI-84+ Incompatability Problems
« Reply #3 on: January 12, 2011, 05:08:38 pm »
Paging the single extra RAM page in as page 3 rather than page 2 would allow you to execute stuff on it. :)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: TI-84+ Incompatability Problems
« Reply #4 on: January 12, 2011, 05:09:02 pm »
Yeah, you can put an odd-numbered page in (usually people use 3, but that's due to Omnicalc using pages 4-7, which you don't have to worry about for KOS)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #5 on: January 12, 2011, 05:09:10 pm »
I'm sorry, but I have some trouble with these ports.  Could someone amend the code above to do that?  Thanks!

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: TI-84+ Incompatability Problems
« Reply #6 on: January 12, 2011, 05:11:00 pm »
If I understand correctly you just need to ld a with $83 rather than $81
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #7 on: January 12, 2011, 05:11:40 pm »
Alright, I'll give it a shot.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: TI-84+ Incompatability Problems
« Reply #8 on: January 12, 2011, 05:11:44 pm »
No, that's the $8000-$BFFF region. What you need to do is output 3 to port 5 instead of $40

Edit:
Instead of $41, I meant >_>
« Last Edit: January 12, 2011, 05:12:11 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #9 on: January 12, 2011, 05:13:04 pm »
On which model?

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: TI-84+ Incompatability Problems
« Reply #10 on: January 12, 2011, 05:14:24 pm »
For the "higher models"
However, you made an optimization of reusing a which means you'll have to ld a another time
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #11 on: January 12, 2011, 05:14:45 pm »
Right, I did.  I'm about to test it.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: TI-84+ Incompatability Problems
« Reply #12 on: January 12, 2011, 05:15:25 pm »
Good luck Sir! Hope it works! :D
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

SirCmpwn

  • Guest
Re: TI-84+ Incompatability Problems
« Reply #13 on: January 12, 2011, 05:15:54 pm »
Me too.  I've been trying to fix this issue for weeks now.
EDIT
I tried it to no avail.  The new code:
Code: [Select]
; Initializes the kfs driver
FSInit:
    ld a, 1    ; Set flash page 1 in bank 1.
    out (6), a
    in a, (2)    ;get calc version
    rlca ;Roll bit 7 into carry.
    ld a, 41h ; Set ram page 1 in bank 2.
    jr nc, LowerModel ; C vs NC?
HigherModel:
ld a, 3
    out (5),a
    ld a,81h
    out (7),a
    jr Return
LowerModel:
    out (6), a
    out (7),a
Return:
    ret

It still doesn't work :( Another strange behavior is that when it turns off, it doesn't come back.  It just says "waiting, please install OS now."

EDIT: I found the problem.  It was pretty stupid.  You notice that the second group of code on my first post appears to be called?  It is.  You probably shouldn't muck about with memory while the stack needs preserving.  It runs fine on all hardware now.
« Last Edit: January 12, 2011, 06:17:50 pm by SirCmpwn »

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: TI-84+ Incompatability Problems
« Reply #14 on: January 12, 2011, 06:58:40 pm »
For the record, this part of the code doesn't make sense:
Code: [Select]
ld a, (ModelID)
cp 2 ; Models 2 and up have USB.
jp c, ResumeInterrupt ; Leave if we don't have the hardware (also tested with NC)
This code doesn't make sense in my brain. Say the ModelID is 4. cp 2 would set the carry flag, right? So jp c would jump back for all the models with USB and try and run on those without it.

For that protocol interrupt, if it wants to send you some data over the control pipe, it might not like you ignoring it.  For now, I think you might be able to just stall the ports and that will prevent it from connecting at all, but it should keep the driver working.