Welcome, Guest. Please login or register.

Author Topic: AmiBlitz (Blitz Basic) "Type not found" error  (Read 3094 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Doobrey

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 1876
    • Show all replies
    • http://www.doobreynet.co.uk
Re: AmiBlitz (Blitz Basic) "Type not found" error
« on: May 24, 2006, 07:28:05 PM »
Gah... looks like somethings wrong with the way blitz calls the two misc.resource functions :-(
 They were only added for completeness, and don't stop you from banging the hardware.
This is really all you need for testing your relay

NEWTYPE .byte
b.b
End NEWTYPE

*PPort_Dir.byte = $BFE301
*PPort_Bits.byte = $BFE101

*PPort_Dir\b= %11111111 ; set all bits direction to output
*PPort_Bits\b=%01010101 ; set the output of each pin
End

On schedule, and suing
 

Offline Doobrey

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 1876
    • Show all replies
    • http://www.doobreynet.co.uk
Re: AmiBlitz (Blitz Basic) "Type not found" error
« Reply #1 on: May 24, 2006, 07:52:27 PM »
Yup, it's a bug in the way Blitz calls the resource.
I just cobbled together 2 funcs that call it directly and it doesn't crash.

Code: [Select]

Function.l AllocMiscResource{unit.l,name.l}
 SHARED MiscBase.l
 GetReg d0,unit
 GetReg a1,name
 GetReg a6,MiscBase
 JSR -6(a6)
 AsmExit
End Function

Statement FreeMiscResource{unit.l}
 SHARED MiscBase.l
  GetReg d0,unit
  GetReg a6,MiscBase
  JSR -12(a6)
End Statement

 ;-- No more stupid Poking/peeking...
 NEWTYPE .byte
  b.b
 End NEWTYPE

 MiscBase.l=0
 
 *PPort_Dir.byte=$bfe301
 *PPort_Bits.byte=$bfe101
                                                                                                                                                                                                                                                         

 MiscBase.l=OpenResource_("misc.resource")
 If MiscBase

  If AllocMiscResource{#MR_PARALLELPORT,"MyAppName"}=0

    *PPort_Dir\b= %11111111   ; set all bits to output
    *PPort_Bits\b=%01010101


    FreeMiscResource {#MR_PARALLELPORT}

  Else
    NPrint "Crap!"
  EndIf

 EndIf

End


On schedule, and suing
 

Offline Doobrey

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 1876
    • Show all replies
    • http://www.doobreynet.co.uk
Re: AmiBlitz (Blitz Basic) "Type not found" error
« Reply #2 on: May 24, 2006, 09:18:50 PM »
Bin$(number) converts from an integar to string showing the binary representation.
Str$(number) converts from integar to string.
bit$=Right$(Bin$(*PPort_Bits\b),8) should give you the lower 8 bits...assuming you're trying to read the current state of the relays.
If you're using the relays the other way around to input into the Amiga, then you'll need to set each direction bit to 0  (*PPort_Dir\b=%xxxxxxxx) before reading the bits

As for the other way around, I dunno if blitz has a function to do it..been a while since I did anything with it.
 I'll have a look and see what I can find, but I'm a bit preoccupied with Remus at the moment.... it might not live to see v1.0  :madashell:

BTW, why's this page soooooo wide?
On schedule, and suing