I work a lot with virtual tables and accessing the function table is very easy. So you don't have to pay attention to the processor type and the index always starts with zero.
The ASM effort is not greater. You don't need to call PeekI because the address is taken directly from the table.
Offtopic
For example, when using gadgets with constants with an enumeration start with zero. This way you can call the event procedure directly with a virtual table.
For this purpose, the event procedures are stored in the DataSection and called up in the gadget event.
Update Example
Code: Select all
;-TOP
Enumeration Windows
#Main
EndEnumeration
Enumeration Gadgets
#Button_Start
#Button_Stop
#Button_End
EndEnumeration
Enumeration Status
#MainStatusBar
EndEnumeration
Prototype MyPrototypeInvoke()
Structure MyEventInvoke
Invoke.MyPrototypeInvoke[0]
EndStructure
Global *vTableMyEventGadget.MyEventInvoke = ?vTableMyEventGadget
Procedure MyEventGadget()
Protected Gadget = EventGadget()
If Gadget >= 0 And Gadget <= #Button_End
*vTableMyEventGadget\Invoke[Gadget]()
EndIf
EndProcedure
BindEvent(#PB_Event_Gadget, @MyEventGadget())
Procedure Main()
#MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 500, 150, "Window - Virtuell Table Example" , #MainStyle)
ButtonGadget(#Button_Start, 10, 10, 120, 25, "Start")
ButtonGadget(#Button_Stop, 140, 10, 120, 25, "Stop")
ButtonGadget(#Button_End, 270, 10, 120, 25, "End")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
EndProcedure : Main()
End
Procedure Event_Button_Start()
Select EventType()
Case #PB_EventType_LeftClick
Debug "Button Start"
EndSelect
EndProcedure
Procedure Event_Button_Stop()
Select EventType()
Case #PB_EventType_LeftClick
Debug "Button Stop"
EndSelect
EndProcedure
Procedure Event_Button_End()
Select EventType()
Case #PB_EventType_LeftClick
Debug "Button End"
EndSelect
EndProcedure
DataSection
vTableMyEventGadget: ; Same order as enumeration
Data.i @Event_Button_Start()
Data.i @Event_Button_Stop()
Data.i @Event_Button_End()
EndDataSection
[/size]