From 9589abfda7e69b7fd93ce50c311b9bd83c5c13e7 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 16 Feb 2019 17:29:39 -0500 Subject: [PATCH] debugger - add toolcall and GS/OS call recognition to the disassembler. --- src/CMakeLists.txt | 4 + src/assets/GSOS.text | 120 ++++ src/assets/Tools.text | 1460 +++++++++++++++++++++++++++++++++++++++ src/debug_shell.re2c | 326 ++++++--- src/debug_template.re2c | 160 ++++- 5 files changed, 1962 insertions(+), 108 deletions(-) create mode 100644 src/assets/GSOS.text create mode 100644 src/assets/Tools.text diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6cf91e..8b7eb6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,6 +140,8 @@ add_executable(GSplus WIN32 MACOSX_BUNDLE $<$:win32.rc> $<$:assets/gsp_icon.icns> $<$:assets/GSBug.Templates> + $<$:assets/Tools.text> + $<$:assets/GSOS.text> $<$:fix_mac_menu.m> ) @@ -152,6 +154,8 @@ SET_SOURCE_FILES_PROPERTIES( SET_SOURCE_FILES_PROPERTIES( assets/GSBug.Templates + assets/Tools.text + assets/GSOS.text PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) diff --git a/src/assets/GSOS.text b/src/assets/GSOS.text new file mode 100644 index 0000000..894d3d6 --- /dev/null +++ b/src/assets/GSOS.text @@ -0,0 +1,120 @@ +; ProDOS 16 Calls. +0001 CREATE +0002 DESTROY +0004 CHANGE_PATH +0005 SET_FILE_INFO +0006 GET_FILE_INFO +0008 VOLUME +0009 SET_PREFIX +000A GET_PREFIX +000B CLEAR_BACKUP_BIT +0010 OPEN +0011 NEWLINE +0012 READ +0013 WRITE +0014 CLOSE +0015 FLUSH +0016 SET_MARK +0017 GET_MARK +0018 SET_EOF +0019 GET_EOF +001A SET_LEVEL +001B GET_LEVEL +001C GET_DIR_ENTRY +0020 GET_DEV_NUM +0021 GET_LAST_DEV +0022 READ_BLOCK +0023 WRITE_BLOCK +0024 FORMAT +0025 ERASE_DISK +0027 GET_NAME +0028 GET_BOOT_VOL +0029 QUIT +002A GET_VERSION +002C D_INFO +0031 ALLOC_INTERRUPT +0032 DEALLOCATE_INTERRUPT +; ORCA/Shell calls. +0101 Get_LInfo +0102 Set_LInfo +0103 Get_Lang +0104 Set_Lang +0105 Error +0106 Set_Variable +0107 Version +0108 Read_Indexed +0109 Init_Wildcard +010A Next_Wildcard +010B Read_Variable +010C ChangeVector +010D Execute +010E FastFile +010F Direction +0110 Redirect +0113 Stop +0114 ExpandDevices +0115 UnsetVariable +0116 Export +0117 PopVariables +0118 PushVariables +0119 SetStopFlag +011A ConsoleOut +011B SetIODevices +011C GetIODevices +011D GetCommand +; GS/OS Calls. +2001 Create +2002 Destroy +2003 OSShutdown +2004 ChangePath +2005 SetFileInfo +2006 GetFileInfo +2007 JudgeName +2008 Volume +2009 SetPrefix +200A GetPrefix +200B ClearBackup +200C SetSysPrefs +200D Null +200E ExpandPath +200F GetSysPrefs +2010 Open +2011 NewLine +2012 Read +2013 Write +2014 Close +2015 Flush +2016 SetMark +2017 GetMark +2018 SetEOF +2019 GetEOF +201A SetLevel +201B GetLevel +201C GetDirEntry +201D BeginSession +201E EndSession +201F SessionStatus +2020 GetDevNumber +2024 Format +2025 EraseDisk +2026 ResetCache +2027 GetName +2028 GetBootvol +2029 Quit +202A GetVersion +202B GetFSTInfo +202C DInfo +202D DStatus +202E DControl +202F DRead +2030 DWrite +2031 BindInt +2032 UnbindInt +2033 FSTSpecific +2034 AddNotifyProc +2035 DelNotifyProc +2036 DRename +2037 GetStdRefNum +2038 GetRefNum +2039 GetRefInfo +203A SetStdRefNum diff --git a/src/assets/Tools.text b/src/assets/Tools.text new file mode 100644 index 0000000..892bed2 --- /dev/null +++ b/src/assets/Tools.text @@ -0,0 +1,1460 @@ +; === System Tools === +; === tool locator === +0101 TLBootInit +0201 TLStartUp +0301 TLShutDown +0401 TLVersion +0501 TLReset +0601 TLStatus +0901 GetTSPtr +0A01 SetTSPtr +0B01 GetFuncPtr +0C01 GetWAP +0D01 SetWAP +0E01 LoadTools +0F01 LoadOneTool +1001 UnloadOneTool +1101 TLMountVolume +1201 TLTextMountVolume +1301 SaveTextState +1401 RestoreTextState +1501 MessageCenter +1601 SetDefaultTPT +1701 MessageByName +1801 StartUpTools +1901 ShutDownTools +1A01 GetMsgHandle +1B01 AcceptRequests +1C01 SendRequest +; === memory manager === +0102 MMBootInit +0202 MMStartUp +0302 MMShutDown +0402 MMVersion +0502 MMReset +0602 MMStatus +0902 NewHandle +0A02 ReAllocHandle +0B02 RestoreHandle +0C02 AddToOOMQueue +0D02 RemoveFromOOMQueue +1002 DisposeHandle +1102 DisposeAll +1202 PurgeHandle +1302 PurgeAll +1802 GetHandleSize +1902 SetHandleSize +1A02 FindHandle +1B02 FreeMem +1C02 MaxBlock +1D02 TotalMem +1E02 CheckHandle +1F02 CompactMem +2002 HLock +2102 HLockAll +2202 HUnlock +2302 HUnlockAll +2402 SetPurge +2502 SetPurgeAll +2802 PtrToHand +2902 HandToPtr +2A02 HandToHand +2B02 BlockMove +2F02 RealFreeMem +3002 SetHandleID +; === misc tools === +0103 MTBootInit +0203 MTStartUp +0303 MTShutDown +0403 MTVersion +0503 MTReset +0603 MTStatus +0903 WriteBRam +0A03 ReadBRam +0B03 WriteBParam +0C03 ReadBParam +0D03 ReadTimeHex +0E03 WriteTimeHex +0F03 ReadAsciiTime +1003 SetVector +1103 GetVector +1203 SetHeartBeat +1303 DelHeartBeat +1403 ClrHeartBeat +1503 SysFailMgr +1603 GetAddr +1703 ReadMouse +1803 InitMouse +1903 SetMouse +1A03 HomeMouse +1B03 ClearMouse +1C03 ClampMouse +1D03 GetMouseClamp +1E03 PosMouse +1F03 ServeMouse +2003 GetNewID +2103 DeleteID +2203 StatusID +2303 IntSource +2403 FWEntry +2503 GetTick +2603 PackBytes +2703 UnPackBytes +2803 Munger +2903 GetIRQEnable +2A03 SetAbsClamp +2B03 GetAbsClamp +2C03 SysBeep +2E03 AddToQueue +2F03 DeleteFromQueue +3003 SetInterruptState +3103 GetInterruptState +3203 GetIntStateRecSize +3303 ReadMouse2 +3403 GetCodeResConverter +3503 GetROMResource +3603 ReleaseROMResource +3703 ConvSeconds +3803 SysBeep2 +3903 VersionString +3A03 WaitUntil +3B03 StringToText +3C03 ShowBootInfo +3D03 ScanDevices +3E03 AlertMessage +3F03 DoSysPrefs +; === QuickDraw II === +0104 QDBootInit +0204 QDStartUp +0304 QDShutDown +0404 QDVersion +0504 QDReset +0604 QDStatus +0904 GetAddress +0A04 GrafOn +0B04 GrafOff +0C04 GetStandardSCB +0D04 InitColorTable +0E04 SetColorTable +0F04 GetColorTable +1004 SetColorEntry +1104 GetColorEntry +1204 SetSCB +1304 GetSCB +1404 SetAllSCBs +1504 ClearScreen +1604 SetMasterSCB +1704 GetMasterSCB +1804 OpenPort +1904 InitPort +1A04 ClosePort +1B04 SetPort +1C04 GetPort +1D04 SetPortLoc +1E04 GetPortLoc +1F04 SetPortRect +2004 GetPortRect +2104 SetPortSize +2204 MovePortTo +2304 SetOrigin +2404 SetClip +2504 GetClip +2604 ClipRect +2704 HidePen +2804 ShowPen +2904 GetPen +2A04 SetPenState +2B04 GetPenState +2C04 SetPenSize +2D04 GetPenSize +2E04 SetPenMode +2F04 GetPenMode +3004 SetPenPat +3104 GetPenPat +3204 SetPenMask +3304 GetPenMask +3404 SetBackPat +3504 GetBackPat +3604 PenNormal +3704 SetSolidPenPat +3804 SetSolidBackPat +3904 SolidPattern +3A04 MoveTo +3B04 Move +3C04 LineTo +3D04 Line +3E04 SetPicSave +3F04 GetPicSave +4004 SetRgnSave +4104 GetRgnSave +4204 SetPolySave +4304 GetPolySave +4404 SetGrafProcs +4504 GetGrafProcs +4604 SetUserField +4704 GetUserField +4804 SetSysField +4904 GetSysField +4A04 SetRect +4B04 OffsetRect +4C04 InsetRect +4D04 SectRect +4E04 UnionRect +4F04 PtInRect +5004 Pt2Rect +5104 EqualRect +5204 NotEmptyRect +5304 FrameRect +5404 PaintRect +5504 EraseRect +5604 InvertRect +5704 FillRect +5804 FrameOval +5904 PaintOval +5A04 EraseOval +5B04 InvertOval +5C04 FillOval +5D04 FrameRRect +5E04 PaintRRect +5F04 EraseRRect +6004 InvertRRect +6104 FillRRect +6204 FrameArc +6304 PaintArc +6404 EraseArc +6504 InvertArc +6604 FillArc +6704 NewRgn +6804 DisposeRgn +6904 CopyRgn +6A04 SetEmptyRgn +6B04 SetRectRgn +6C04 RectRgn +6D04 OpenRgn +6E04 CloseRgn +6F04 OffsetRgn +7004 InsetRgn +7104 SectRgn +7204 UnionRgn +7304 DiffRgn +7404 XorRgn +7504 PtInRgn +7604 RectInRgn +7704 EqualRgn +7804 EmptyRgn +7904 FrameRgn +7A04 PaintRgn +7B04 EraseRgn +7C04 InvertRgn +7D04 FillRgn +7E04 ScrollRect +7F04 PaintPixels +8004 AddPt +8104 SubPt +8204 SetPt +8304 EqualPt +8404 LocalToGlobal +8504 GlobalToLocal +8604 Random +8704 SetRandSeed +8804 GetPixel +8904 ScalePt +8A04 MapPt +8B04 MapRect +8C04 MapRgn +8D04 SetStdProcs +8E04 SetCursor +8F04 GetCursorAdr +9004 HideCursor +9104 ShowCursor +9204 ObscureCursor +9304 SetMouseLoc ??? +9404 SetFont +9504 GetFont +9604 GetFontInfo +9704 GetFontGlobals +9804 SetFontFlags +9904 GetFontFlags +9A04 SetTextFace +9B04 GetTextFace +9C04 SetTextMode +9D04 GetTextMode +9E04 SetSpaceExtra +9F04 GetSpaceExtra +A004 SetForeColor +A104 GetForeColor +A204 SetBackColor +A304 GetBackColor +A404 DrawChar +A504 DrawString +A604 DrawCString +A704 DrawText +A804 CharWidth +A904 StringWidth +AA04 CStringWidth +AB04 TextWidth +AC04 CharBounds +AD04 StringBounds +AE04 CStringBounds +AF04 TextBounds +B004 SetArcRot +B104 GetArcRot +B204 SetSysFont +B304 GetSysFont +B404 SetVisRgn +B504 GetVisRgn +B604 SetIntUse +B704 OpenPicture +B804 PicComment +B904 ClosePicture +BA04 DrawPicture +BB04 KillPicture +BC04 FramePoly +BD04 PaintPoly +BE04 ErasePoly +BF04 InvertPoly +C004 FillPoly +C104 OpenPoly +C204 ClosePoly +C304 KillPoly +C404 OffsetPoly +C504 MapPoly +C604 SetClipHandle +C704 GetClipHandle +C804 SetVisHandle +C904 GetVisHandle +CA04 InitCursor +CB04 SetBufDims +CC04 ForceBufDims +CD04 SaveBufDims +CE04 RestoreBufDims +CF04 GetFGSize +D004 SetFontID +D104 GetFontID +D204 SetTextSize +D304 GetTextSize +D404 SetCharExtra +D504 GetCharExtra +D604 PPToPort +D704 InflateTextBuffer +D804 GetRomFont +D904 GetFontLore +DA04 Get640Colors +DB04 Set640Color +; === desk manager === +0105 DeskBootInit +0205 DeskStartUp +0305 DeskShutDown +0405 DeskVersion +0505 DeskReset +0605 DeskStatus +0905 SaveScrn +0A05 RestScrn +0B05 SaveAll +0C05 RestAll +0E05 InstallNDA +0F05 InstallCDA +1105 ChooseCDA +1305 SetDAStrPtr +1405 GetDAStrPtr +1505 OpenNDA +1605 CloseNDA +1705 SystemClick +1805 SystemEdit +1905 SystemTask +1A05 SystemEvent +1B05 GetNumNDAs +1C05 CloseNDAbyWinPtr +1D05 CloseAllNDAs +1E05 FixAppleMenu +1F05 AddToRunQ +2005 RemoveFromRunQ +2105 RemoveCDA +2205 RemoveNDA +2305 GetDeskAccInfo +2405 CallDeskAcc +2505 GetDeskGlobal +; === event manager === +0106 EMBootInit +0206 EMStartUp +0306 EMShutDown +0406 EMVersion +0506 EMReset +0606 EMStatus +0906 DoWindows +0A06 GetNextEvent +0B06 EventAvail +0C06 GetMouse +0D06 Button +0E06 StillDown +0F06 WaitMouseUp +1006 TickCount +1106 GetDblTime +1206 GetCaretTime +1306 SetSwitch +1406 PostEvent +1506 FlushEvents +1606 GetOSEvent +1706 OSEventAvail +1806 SetEventMask +1906 FakeMouse +1A06 SetAutoKeyLimit +1B06 GetKeyTranslation +1C06 SetKeyTranslation +; === scheduler === +0107 SchBootInit +0207 SchStartUp +0307 SchShutDown +0407 SchVersion +0507 SchReset +0607 SchStatus +0907 SchAddTask +0A07 SchFlush +; === sound manager === +0108 SoundBootInit +0208 SoundStartUp +0308 SoundShutDown +0408 SoundVersion +0508 SoundReset +0608 SoundToolStatus +0908 WriteRamBlock +0A08 ReadRamBlock +0B08 GetTableAddress +0C08 GetSoundVolume +0D08 SetSoundVolume +0E08 FFStartSound +0F08 FFStopSound +1008 FFSoundStatus +1108 FFGeneratorStatus +1208 SetSoundMIRQV +1308 SetUserSoundIRQV +1408 FFSoundDoneStatus +1508 FFSetUpSound +1608 FFStartPlaying +1708 SetDocReg +1808 ReadDocReg +; === desktop bus === +0109 ADBBootInit +0209 ADBStartUp +0309 ADBShutDown +0409 ADBVersion +0509 ADBReset +0609 ADBStatus +0909 SendInfo +0A09 ReadKeyMicroData +0B09 ReadKeyMicroMemory +;0C09 [resynch--don't call] +0D09 AsyncADBReceive +0E09 SyncADBReceive +0F09 AbsOn +1009 AbsOff +1109 RdAbs +1209 SetAbsScale +1309 GetAbsScale +1409 SRQPoll +1509 SRQRemove +1609 ClearSRQTable +;FF09 [OBSOLETE: Use 09FF] +; === SANE === +010A SANEBootInit +020A SANEStartUp +030A SANEShutDown +040A SANEVersion +050A SANEReset +060A SANEStatus +090A FPNum +0A0A DecStrNum +0B0A ElemNum +;FF0A [OBSOLETE: USE $0AFF] +; === integer math === +010B IMBootInit +020B IMStartUp +030B IMShutDown +040B IMVersion +050B IMReset +060B IMStatus +090B Multiply +0A0B SDivide +0B0B UDivide +0C0B LongMul +0D0B LongDivide +0E0B FixRatio +0F0B FixMul +100B FracMul +110B FixDiv +120B FracDiv +130B FixRound +140B FracSqrt +150B FracCos +160B FracSin +170B FixATan2 +180B HiWord +190B LoWord +1A0B Long2Fix +1B0B Fix2Long +1C0B Fix2Frac +1D0B Frac2Fix +1E0B Fix2X +1F0B Frac2X +200B X2Fix +210B X2Frac +220B Int2Hex +230B Long2Hex +240B Hex2Int +250B Hex2Long +260B Int2Dec +270B Long2Dec +280B Dec2Int +290B Dec2Long +2A0B HexIt +; === text tools === +010C TextBootInit +020C TextStartUp +030C TextShutDown +040C TextVersion +050C TextReset +060C TextStatus +090C SetInGlobals +0A0C SetOutGlobals +0B0C SetErrGlobals +0C0C GetInGlobals +0D0C GetOutGlobals +0E0C GetErrGlobals +0F0C SetInputDevice +100C SetOutputDevice +110C SetErrorDevice +120C GetInputDevice +130C GetOutputDevice +140C GetErrorDevice +150C InitTextDev +160C CtlTextDev +170C StatusTextDev +180C WriteChar +190C ErrWriteChar +1A0C WriteLine +1B0C ErrWriteLine +1C0C WriteString +1D0C ErrWriteString +1E0C TextWriteBlock +1F0C ErrWriteBlock +200C WriteCString +210C ErrWriteCString +220C ReadChar +230C TextReadBlock +240C ReadLine +; === window manager === +010E WindBootInit +020E WindStartUp +030E WindShutDown +040E WindVersion +050E WindReset +060E WindStatus +090E NewWindow +0A0E CheckUpdate +0B0E CloseWindow +0C0E Desktop +0D0E SetWTitle +0E0E GetWTitle +0F0E SetFrameColor +100E GetFrameColor +110E SelectWindow +120E HideWindow +130E ShowWindow +140E SendBehind +150E FrontWindow +160E SetInfoDraw +170E FindWindow +180E TrackGoAway +190E MoveWindow +1A0E DragWindow +1B0E GrowWindow +1C0E SizeWindow +1D0E TaskMaster +1E0E BeginUpdate +1F0E EndUpdate +200E GetWMgrPort +210E PinRect +220E HiliteWindow +230E ShowHide +240E BringToFront +250E WindNewRes +260E TrackZoom +270E ZoomWindow +280E SetWRefCon +290E GetWRefCon +2A0E GetNextWindow +2B0E GetWKind +2C0E GetWFrame +2D0E SetWFrame +2E0E GetStructRgn +2F0E GetContentRgn +300E GetUpdateRgn +310E GetDefProc +320E SetDefProc +330E GetWControls +340E SetOriginMask +350E GetInfoRefCon +360E SetInfoRefCon +370E GetZoomRect +380E SetZoomRect +390E RefreshDesktop +3A0E InvalRect +3B0E InvalRgn +3C0E ValidRect +3D0E ValidRgn +3E0E GetContentOrigin +3F0E SetContentOrigin +400E GetDataSize +410E SetDataSize +420E GetMaxGrow +430E SetMaxGrow +440E GetScroll +450E SetScroll +460E GetPage +470E SetPage +480E GetContentDraw +490E SetContentDraw +4A0E GetInfoDraw +4B0E SetSysWindow +4C0E GetSysWFlag +4D0E StartDrawing +4E0E SetWindowIcons +4F0E GetRectInfo +500E StartInfoDrawing +510E EndInfoDrawing +520E GetFirstWindow +530E WindDragRect +540E GetDragRectPtr +550E DrawInfoBar +560E WindowGlobal +570E SetContentOrigin2 +580E GetWindowMgrGlobals +590E AlertWindow +5A0E StartFrameDrawing +5B0E EndFrameDrawing +5C0E ResizeWindow +5D0E TaskMasterContent +5E0E TaskMasterKey +5F0E TaskMasterDA +600E CompileText +610E NewWindow2 +620E ErrorWindow +630E GetAuxWindInfo +640E DoModalWindow +650E MWGetCtlPart +660E MWSetMenuProc +670E MWStdDrawProc +680E MWSetUpEditMenu +690E FindCursorCtl +6A0E ResizeInfoBar +6B0E HandleDiskInsert +6C0E UpdateWindow +; === menu manager === +010F MenuBootInit +020F MenuStartUp +030F MenuShutDown +040F MenuVersion +050F MenuReset +060F MenuStatus +090F MenuKey +0A0F GetMenuBar +0B0F MenuRefresh +0C0F FlashMenuBar +0D0F InsertMenu +0E0F DeleteMenu +0F0F InsertMItem +100F DeleteMItem +110F GetSysBar +120F SetSysBar +130F FixMenuBar +140F CountMItems +150F NewMenuBar +160F GetMHandle +170F SetBarColors +180F GetBarColors +190F SetMTitleStart +1A0F GetMTitleStart +1B0F GetMenuMgrPort +1C0F CalcMenuSize +1D0F SetMTitleWidth +1E0F GetMTitleWidth +1F0F SetMenuFlag +200F GetMenuFlag +210F SetMenuTitle +220F GetMenuTitle +230F MenuGlobal +240F SetMItem +250F GetMItem +260F SetMItemFlag +270F GetMItemFlag +280F SetMItemBlink +290F MenuNewRes +2A0F DrawMenuBar +2B0F MenuSelect +2C0F HiliteMenu +2D0F NewMenu +2E0F DisposeMenu +2F0F InitPalette +300F EnableMItem +310F DisableMItem +320F CheckMItem +330F SetMItemMark +340F GetMItemMark +350F SetMItemStyle +360F GetMItemStyle +370F SetMenuID +380F SetMItemID +390F SetMenuBar +3A0F SetMItemName +3B0F GetPopUpDefProc +3C0F PopUpMenuSelect +3D0F DrawPopUp +3E0F NewMenu2 +3F0F InsertMItem2 +400F SetMenuTitle2 +410F SetMItem2 +420F SetMItemName2 +430F NewMenuBar2 +450F HideMenuBar +460F ShowMenuBar +470F SetMItemIcon +480F GetMItemIcon +490F SetMItemStruct +4A0F GetMItemStruct +4B0F RemoveMItemStruct +4C0F GetMItemFlag2 +4D0F SetMItemFlag2 +4F0F GetMItemBlink +500F InsertPathMItems +; === control manager === +0110 CtlBootInit +0210 CtlStartUp +0310 CtlShutDown +0410 CtlVersion +0510 CtlReset +0610 CtlStatus +0910 NewControl +0A10 DisposeControl +0B10 KillControls +0C10 SetCtlTitle +0D10 GetCtlTitle +0E10 HideControl +0F10 ShowControl +1010 DrawControls +1110 HiliteControl +1210 CtlNewRes +1310 FindControl +1410 TestControl +1510 TrackControl +1610 MoveControl +1710 DragControl +1810 SetCtlIcons +1910 SetCtlValue +1A10 GetCtlValue +1B10 SetCtlParams +1C10 GetCtlParams +1D10 DragRect +1E10 GrowSize +1F10 GetCtlDpage +2010 SetCtlAction +2110 GetCtlAction +2210 SetCtlRefCon +2310 GetCtlRefCon +2410 EraseControl +2510 DrawOneCtl +2610 FindTargetCtl +2710 MakeNextCtlTarget +2810 MakeThisCtlTarget +2910 SendEventToCtl +2A10 GetCtlID +2B10 SetCtlID +2C10 CallCtlDefProc +2D10 NotifyCtls +2E10 GetCtlMoreFlags +2F10 SetCtlMoreFlags +3010 GetCtlHandleFromID +3110 NewControl2 +3210 CMLoadResource +3310 CMReleaseResource +3410 SetCtlParamPtr +3510 GetCtlParamPtr +3710 InvalCtls +;3810 [reserved] +3910 FindRadioButton +3A10 SetLETextByID +3B10 GetLETextByID +3C10 SetCtlValueByID +3D10 GetCtlValueByID +3E10 InvalOneCtlByID +3F10 HiliteCtlByID +; === loader === +0111 LoaderBootInit +0211 LoaderStartUp +0311 LoaderShutDown +0411 LoaderVersion +0511 LoaderReset +0611 LoaderStatus +0911 InitialLoad +0A11 Restart +0B11 LoadSegNum +0C11 UnloadSegNum +0D11 LoadSegName +0E11 UnloadSeg +0F11 GetLoadSegInfo +1011 GetUserID +1111 LGetPathname +1211 UserShutDown +1311 RenamePathname +2011 InitialLoad2 +2111 GetUserID2 +2211 LGetPathname2 +; === QuickDraw Aux === +0112 QDAuxBootInit +0212 QDAuxStartUp +0312 QDAuxShutDown +0412 QDAuxVersion +0512 QDAuxReset +0612 QDAuxStatus +0912 CopyPixels +0A12 WaitCursor +0B12 DrawIcon +0C12 SpecialRect +0D12 SeedFill +0E12 CalcMask +0F12 GetSysIcon +1012 PixelMap2Rgn +1312 IBeamCursor +1412 WhooshRect +1512 DrawStringWidth +1612 UseColorTable +1712 RestoreColorTable +; === print manager === +0113 PMBootInit +0213 PMStartUp +0313 PMShutDown +0413 PMVersion +0513 PMReset +0613 PMStatus +0913 PrDefault +0A13 PrValidate +0B13 PrStlDialog +0C13 PrJobDialog +0D13 PrPixelMap +0E13 PrOpenDoc +0F13 PrCloseDoc +1013 PrOpenPage +1113 PrClosePage +1213 PrPicFile +1313 PrControl +1413 PrError +1513 PrSetError +1613 PrChoosePrinter +1813 PrGetPrinterSpecs +1913 PrDevPrChanged +1A13 PrDevStartup +1B13 PrDevShutDown +1C13 PrDevOpen +1D13 PrDevRead +1E13 PrDevWrite +1F13 PrDevClose +2013 PrDevStatus +2113 PrDevAsyncRead +2213 PrDevWriteBackground +2313 PrDriverVer +2413 PrPortVer +2513 PrGetZoneName +2813 PrGetPrinterDvrName +2913 PrGetPortDvrName +2A13 PrGetUserName +2B13 PrGetNetworkName +3013 PrDevIsItSafe +3113 GetZoneList +3213 GetMyZone +3313 GetPrinterList +3413 PMUnloadDriver +3513 PMLoadDriver +3613 PrGetDocName +3713 PrSetDocName +3813 PrGetPgOrientation +; === line edit === +0114 LEBootInit +0214 LEStartUp +0314 LEShutDown +0414 LEVersion +0514 LEReset +0614 LEStatus +0914 LENew +0A14 LEDispose +0B14 LESetText +0C14 LEIdle +0D14 LEClick +0E14 LESetSelect +0F14 LEActivate +1014 LEDeactivate +1114 LEKey +1214 LECut +1314 LECopy +1414 LEPaste +1514 LEDelete +1614 LEInsert +1714 LEUpdate +1814 LETextBox +1914 LEFromScrap +1A14 LEToScrap +1B14 LEScrapHandle +1C14 LEGetScrapLen +1D14 LESetScrapLen +1E14 LESetHilite +1F14 LESetCaret +2014 LETextBox2 +2114 LESetJust +2214 LEGetTextHand +2314 LEGetTextLen +2414 GetLEDefProc +2514 LEClassifyKey +; === dialog manager === +0115 DialogBootInit +0215 DialogStartUp +0315 DialogShutDown +0415 DialogVersion +0515 DialogReset +0615 DialogStatus +0915 ErrorSound +0A15 NewModalDialog +0B15 NewModelessDialog +0C15 CloseDialog +0D15 NewDItem +0E15 RemoveDItem +0F15 ModalDialog +1015 IsDialogEvent +1115 DialogSelect +1215 DlgCut +1315 DlgCopy +1415 DlgPaste +1515 DlgDelete +1615 DrawDialog +1715 Alert +1815 StopAlert +1915 NoteAlert +1A15 CautionAlert +1B15 ParamText +1C15 SetDAFont +1E15 GetControlDItem +1F15 GetIText +2015 SetIText +2115 SelectIText +2215 HideDItem +2315 ShowDItem +2415 FindDItem +2515 UpdateDialog +2615 GetDItemType +2715 SetDItemType +2815 GetDItemBox +2915 SetDItemBox +2A15 GetFirstDItem +2B15 GetNextDItem +2C15 ModalDialog2 +2E15 GetDItemValue +2F15 SetDItemValue +3215 GetNewModalDialog +3315 GetNewDItem +3415 GetAlertStage +3515 ResetAlertStage +3615 DefaultFilter +3715 GetDefButton +3815 SetDefButton +3915 DisableDItem +3A15 EnableDItem +; === scrap manager === +0116 ScrapBootInit +0216 ScrapStartUp +0316 ScrapShutDown +0416 ScrapVersion +0516 ScrapReset +0616 ScrapStatus +0916 UnloadScrap +0A16 LoadScrap +0B16 ZeroScrap +0C16 PutScrap +0D16 GetScrap +0E16 GetScrapHandle +0F16 GetScrapSize +1016 GetScrapPath +1116 SetScrapPath +1216 GetScrapCount +1316 GetScrapState +1416 GetIndScrap +1516 ShowClipboard +; === standard file === +0117 SFBootInit +0217 SFStartUp +0317 SFShutDown +0417 SFVersion +0517 SFReset +0617 SFStatus +0917 SFGetFile +0A17 SFPutFile +0B17 SFPGetFile +0C17 SFPPutFile +0D17 SFAllCaps +0E17 SFGetFile2 +0F17 SFPutFile2 +1017 SFPGetFile2 +1117 SFPPutFile2 +1217 SFShowInvisible +1317 SFReScan +1417 SFMultiGet2 +1517 SFPMultiGet2 +; === note synthesizer === +0119 NSBootInit +0219 NSStartUp +0319 NSShutDown +0419 NSVersion +0519 NSReset +0619 NSStatus +0919 AllocGen +0A19 DeallocGen +0B19 NoteOn +0C19 NoteOff +0D19 AllNotesOff +0E19 NSSetUpdateRate +0F19 NSSetUserUpdateRtn +; === note sequencer === +011A SeqBootInit +021A SeqStartUp +031A SeqShutDown +041A SeqVersion +051A SeqReset +061A SeqStatus +091A SetIncr +0A1A ClearIncr +0B1A GetTimer +0C1A GetLoc +0D1A SeqAllNotesOff +0E1A SetTrkInfo +0F1A StartSeq +101A StepSeq +111A StopSeq +121A SetInstTable +131A StartInts +141A StopInts +151A StartSeqRel +; === font manager === +011B FMBootInit +021B FMStartUp +031B FMShutDown +041B FMVersion +051B FMReset +061B FMStatus +091B CountFamilies +0A1B FindFamily +0B1B GetFamInfo +0C1B GetFamNum +0D1B AddFamily +0E1B InstallFont +0F1B SetPurgeStat +101B CountFonts +111B FindFontStats +121B LoadFont +131B LoadSysFont +141B AddFontVar +151B FixFontMenu +161B ChooseFont +171B ItemID2FamNum +181B FMSetSysFont +191B FMGetSysFID +1A1B FMGetCurFID +1B1B FamNum2ItemID +1C1B InstallWithStats +; === List Manager === +011C ListBootInit +021C ListStartUp +031C ListShutDown +041C ListVersion +051C ListReset +061C ListStatus +091C CreateList +0A1C SortList +0B1C NextMember +0C1C DrawMember +0D1C SelectMember +0E1C GetListDefProc +0F1C ResetMember +101C NewList +111C DrawMember2 +121C NextMember2 +131C ResetMember2 +141C SelectMember2 +151C SortList2 +161C NewList2 +171C ListKey +181C CompareStrings +; === Audio Compression/Expansion === +011D ACEBootInit +021D ACEStartUp +031D ACEShutDown +041D ACEVersion +051D ACEReset +061D ACEStatus +071D ACEInfo +091D ACECompress +0A1D ACEExpand +0B1D ACECompBegin +0C1D ACEExpBegin +0D1D GetACEExpState +0E1D SetACEExpState +; === Resource Manager === +011E ResourceBootInit +021E ResourceStartUp +031E ResourceShutDown +041E ResourceVersion +051E ResourceReset +061E ResourceStatus +091E CreateResourceFile +0A1E OpenResourceFile +0B1E CloseResourceFile +0C1E AddResource +0D1E UpdateResourcefile +0E1E LoadResource +0F1E RemoveResource +101E MarkResourceChange +111E SetCurResourceFile +121E GetCurResourceFile +131E SetCurResourceApp +141E GetCurResourceApp +151E HomeResourceFile +161E WriteResource +171E ReleaseResource +181E DetachResource +191E UniqueResourceID +1A1E SetResourceID +1B1E GetResourceAttr +1C1E SetResourceAttr +1D1E GetResourceSize +1E1E MatchResourceHandle +1F1E GetOpenFileRefNum +201E CountTypes +211E GetIndType +221E CountResources +231E GetIndResource +241E SetResourceLoad +251E SetResourceFileDepth +261E GetMapHandle +271E LoadAbsResource +281E ResourceConverter +291E LoadResource2 +2A1E RMFindNamedResource +2B1E RMGetResourceName +2C1E RMLoadNamedResource +2D1E RMSetResourceName +2E1E OpenResourceFileByID +2F1E CompactResourceFile +; === MIDI === +0120 MidiBootInit +0220 MidiStartUp +0320 MidiShutDown +0420 MidiVersion +0520 MidiReset +0620 MidiStatus +0920 MidiControl +0A20 MidiDevice +0B20 MidiClock +0C20 MidiInfo +0D20 MidiReadPacket +0E20 MidiWritePacket +; === Video Overlay === +0121 VDBootInit +0221 VDStartUp +0321 VDShutDown +0421 VDVersion +0521 VDReset +0621 VDStatus +0921 VDInStatus +0A21 VDInSetStd +0B21 VDInGetStd +0C21 VDInConvAdj +0D21 VDKeyControl +0E21 VDKeyStatus +0F21 VDKeySetKCol +1021 VDKeyGetKRCol +1121 VDKeyGetKGCol +1221 VDKeyGetKBCol +1321 VDKeySetKDiss +1421 VDKeyGetKDiss +1521 VDKeySetNKDiss +1621 VDKeyGetNKDiss +1721 VDOutSetStd +1821 VDOutGetStd +1921 VDOutControl +1A21 VDOutStatus +1B21 VDGetFeatures +1C21 VDInControl +1D21 VDGGControl +1E21 VDGGStatus +; === Text Edit === +0122 TEBootInit +0222 TEStartUp +0322 TEShutDown +0422 TEVersion +0522 TEReset +0622 TEStatus +0922 TENew +0A22 TEKill +0B22 TESetText +0C22 TEGetText +0D22 TEGetTextInfo +0E22 TEIdle +0F22 TEActivate +1022 TEDeactivate +1122 TEClick +1222 TEUpdate +1322 TEPaintText +1422 TEKey +;1522 [not supported] +1622 TECut +1722 TECopy +1822 TEPaste +1922 TEClear +1A22 TEInsert +1B22 TEReplace +1C22 TEGetSelection +1D22 TESetSelection +1E22 TEGetSelectionStyle +1F22 TEStyleChange +2022 TEOffsetToPoint +2122 TEPointToOffset +2222 TEGetDefProc +2322 TEGetRuler +2422 TESetRuler +2522 TEScroll +2622 TEGetInternalProc +2722 TEGetLastError +2822 TECompactRecord +; === MIDI Synth === +0123 MSBootInit +0223 MSStartUp +0323 MSShutDown +0423 MSVersion +0523 MSReset +0623 MSStatus +0923 SetBasicChannel +0A23 SetMIDIMode +0B23 PlayNote +0C23 StopNote +0D23 KillAllNotes +0E23 SetRecTrack +0F23 SetPlayTrack +1023 TrackToChannel +1123 Locate +1223 SetVelComp +1323 SetMIDIPort +1423 SetInstrument +1523 SeqPlayer +1623 SetTempo +1723 SetCallBack +1823 SysExOut +1923 SetBeat +1A23 MIDIMessage +1B23 LocateEnd +1C23 Merge +1D23 DeleteTrack +1E23 SetMetro +1F23 GetMSData +2023 ConvertToTime +2123 ConvertToMeasure +2223 MSSuspend +2323 MSResume +2423 SetTuningTable +2523 GetTuningTable +2623 SetTrackOut +2723 InitMIDIDriver +2823 RemoveMIDIDriver +; === Media Controller === +0126 MCBootInit +0226 MCStartUp +0326 MCShutDown +0426 MCVersion +0526 MCReset +0626 MCStatus +0926 MCGetErrorMsg +0A26 MCLoadDriver +0B26 MCUnLoadDriver +0C26 MCTimeToBin +0D26 MCBinToTime +0E26 MCGetTrackTitle +0F26 MCSetTrackTitle +1026 MCGetProgram +1126 MCSetProgram +1226 MCGetDiscTitle +1326 MCSetDiscTitle +1426 MCDStartUp +1526 MCDShutDown +1626 MCGetFeatures +1726 MCPlay +1826 MCPause +1926 MCSendRawData +1A26 MCGetStatus +1B26 MCControl +1C26 MCScan +1D26 MCGetSpeeds +1E26 MCSpeed +1F26 MCStopAt +2026 MCJog +2126 MCSearchTo +2226 MCSearchDone +2326 MCSearchWait +2426 MCGetPosition +2526 MCSetAudio +2626 MCGetTimes +2726 MCGetDiscTOC +2826 MCGetDiscID +2926 MCGetNoTracks +2A26 MCRecord +2B26 MCStop +2C26 MCWaitRawData +2D26 MCGetName +2E26 MCSetVolume +; === Marinetti === +0136 TCPIPBootInit +0236 TCPIPStartUp +0336 TCPIPShutDown +0436 TCPIPVersion +0536 TCPIPReset +0636 TCPIPStatus +0836 TCPIPLongVersion +0936 TCPIPGetConnectStatus +0A36 TCPIPGetErrorTable +0B36 TCPIPGetReconnectStatus +0C36 TCPIPReconnect +0D36 TCPIPConvertIPToHex +0E36 TCPIPConvertIPToASCII +0F36 TCPIPGetMyIPAddress +1036 TCPIPGetConnectMethod +1136 TCPIPSetConnectMethod +1236 TCPIPConnect +1336 TCPIPDisconnect +1436 TCPIPGetMTU +1536 TCPIPValidateIPCString +1636 TCPIPGetConnectData +1736 TCPIPSetConnectData +1836 TCPIPGetDisconnectData +1936 TCPIPSetDisconnectData +1A36 TCPIPLoadPreferences +1B36 TCPIPSavePreferences +1C36 TCPIPGetDNS +1D36 TCPIPSetDNS +1E36 TCPIPGetTuningTable +1F36 TCPIPSetTuningTable +2036 TCPIPCancelDNR +2136 TCPIPDNRNameToIP +2236 TCPIPPoll +2336 TCPIPLogin +2436 TCPIPLogout +2536 TCPIPSendICMP +2636 TCPIPSendUDP +2736 TCPIPGetDatagramCount +2836 TCPIPGetNextDatagram +2936 TCPIPGetLoginCount +2A36 TCPIPSendICMPEcho +2B36 TCPIPReceiveICMPEcho +2C36 TCPIPOpenTCP +2D36 TCPIPWriteTCP +2E36 TCPIPReadTCP +2F36 TCPIPCloseTCP +3036 TCPIPAbortTCP +3136 TCPIPStatusTCP +3236 TCPIPGetSourcePort +3336 TCPIPGetTOS +3436 TCPIPSetTOS +3536 TCPIPGetTTL +3636 TCPIPSetTTL +3736 TCPIPSetSourcePort +3836 TCPIPSetMyIPAddress +3936 TCPIPGetDP +3A36 TCPIPGetDebugHex +3B36 TCPIPDebugHex +3C36 TCPIPGetDebugTCP +3D36 TCPIPDebugTCP +3E36 TCPIPGetUserRecord +3F36 TCPIPConvertIPCToHex +4036 TCPIPSendIPDatagram +4136 TCPIPConvertIPToClass +4236 TCPIPGetConnectMsgFlag +4336 TCPIPSetConnectMsgFlag +4436 TCPIPGetUsername +4536 TCPIPSetUsername +4636 TCPIPGetPassword +4736 TCPIPSetPassword +4836 TCPIPValidateIPString +4936 TCPIPGetUserStatistic +4A36 TCPIPGetLinkVariables +4B36 TCPIPEditLinkConfig +4C36 TCPIPGetModuleNames +4D36 TCPIPRebuildModuleList +4E36 TCPIPListenTCP +4F36 TCPIPAcceptTCP +5036 TCPIPSetNewDestination +5136 TCPIPGetHostName +5236 TCPIPSetHostName +5336 TCPIPStatusUDP +5436 TCPIPGetLinkLayer +5536 TCPIPPtrToPtr +5636 TCPIPPtrToPtrNeg +5736 TCPIPGetAuthMessage +5836 TCPIPConvertIPToCASCII +5936 TCPIPMangleDomainName +5A36 TCPIPGetAliveFlag +5B36 TCPIPSetAliveFlag +5C36 TCPIPGetAliveMinutes +5D36 TCPIPSetAliveMinutes +5E36 TCPIPReadLineTCP +5F36 TCPIPGetBootConnectFlag +6036 TCPIPSetBootConnectFlag +6136 TCPIPSetUDPDispatch +6236 TCPIPGetDestination +6336 TCPIPGetUserEventTrigger +6436 TCPIPSetUserEventTrigger +6536 TCPIPGetSysEventTrigger +6636 TCPIPSetSysEventTrigger +6736 TCPIPGetDNRTimeouts +6836 TCPIPSetDNRTimeouts +; === Male Voice === +0132 MaleBootInit +0232 MaleStartUp +0332 MaleShutDown +0432 MaleVersion +0532 MaleReset +0632 MaleStatus +0932 MaleSpeak +; === Female Voice === +0133 FemaleBootInit +0233 FemaleStartUp +0333 FemaleShutDown +0433 FemaleVersion +0533 FemaleReset +0633 FemaleStatus +0933 FemaleSpeak +; === TML Speech Toolkit parser === +0134 SpeechBootInit +0234 SpeechStartUp +0334 SpeechShutDown +0434 SpeechVersion +0534 SpeechReset +0634 SpeechStatus +0934 Parse +0A34 DictInsert +0B34 DictDelete +0C34 DictDump +0D34 SetSayGlobals +0E34 DictInit +0F34 Say +1034 Activate... +; === GSBug === +04FF DebugVersion +06FF DebugStatus +09FF DebugStr +0AFF SetMileStone +0BFF DebugSetHook +0CFF DebugGetInfo +0DFF DebugControl +0EFF DebugQuery \ No newline at end of file diff --git a/src/debug_shell.re2c b/src/debug_shell.re2c index 4cf6a28..d760a45 100644 --- a/src/debug_shell.re2c +++ b/src/debug_shell.re2c @@ -44,8 +44,10 @@ static word32 g_prev_stack_bank = 0; static int g_templates_loaded = 0; -extern void debug_load_template(const char *path); +extern void debug_load_templates(const char *path); extern word32 debug_apply_template(word32 address, const char *name); +extern void debug_load_tools(const char *path, unsigned vector); +extern const char *debug_tool_name(unsigned, unsigned vector); #if defined(__APPLE__) #include @@ -267,42 +269,90 @@ word32 do_stack(word32 address, unsigned bank) { } -word32 do_list(word32 address, int *psr_ptr, int lines) { +struct disasm_cookie { + unsigned psr; + unsigned x; +}; +static int is_jsl_e10000(word32 address) { + return get_memory_c(address, 0) == 0x22 && + get_memory24_c(address + 1, 0) == 0xe10000; +} + +static int is_jsl_e10008(word32 address) { + return get_memory_c(address, 0) == 0x22 && + get_memory24_c(address + 1, 0) == 0xe10008; +} +static int is_jsl_e100a8(word32 address) { + return get_memory_c(address, 0) == 0x22 && + get_memory24_c(address + 1, 0) == 0xe100a8; +} + + +static int is_jsl_e100b0(word32 address) { + return get_memory_c(address, 0) == 0x22 && + get_memory24_c(address + 1, 0) == 0xe100b0; +} + +static int is_jsr_bf00(word32 address) { + return get_memory_c(address, 0) == 0x20 && + get_memory16_c(address + 1, 0) == 0xbf00; +} + +static int g_disasm_psr; + +word32 do_list(word32 address, int lines) { + + unsigned char buffer2[32]; char buffer[32]; - int psr = *psr_ptr; + + const char *opcode_string; + unsigned opcode; unsigned dtype; unsigned operand; + word32 pc; int i; int args; + int n; while (lines--) { + + int bsize = 0; pc = address; opcode = get_memory_c(address++, 0); dtype = disasm_types[opcode]; args = dtype >> 8; + buffer2[bsize++] = opcode; + opcode_string = disasm_opcodes[opcode]; + switch (args) { case 4: - args = psr & 0x20 ? 1 : 2; + args = g_disasm_psr & 0x20 ? 1 : 2; break; case 5: - args = psr & 0x10 ? 1 : 2; + args = g_disasm_psr & 0x10 ? 1 : 2; break; } operand = 0; switch(args) { case 1: operand = get_memory_c(address, 0); + buffer2[bsize++] = operand; break; case 2: operand = get_memory16_c(address, 0); + buffer2[bsize++] = operand; + buffer2[bsize++] = operand >> 8; break; case 3: operand = get_memory24_c(address, 0); + buffer2[bsize++] = operand; + buffer2[bsize++] = operand >> 8; + buffer2[bsize++] = operand >> 16; break; } address += args; @@ -319,91 +369,141 @@ word32 do_list(word32 address, int *psr_ptr, int lines) { sprintf(buffer, "$%04x,y", operand); break; - case ABSIND: - sprintf(buffer,"($%04x)",operand ); - break; - case ABSXIND: - sprintf(buffer,"($%04x,x)",operand ); - break; - case IMPLY: - break; - case ACCUM: - break; - case IMMED: - sprintf(buffer,"#$%0*x",args * 2, operand); - break; - case JUST8: - sprintf(buffer,"$%02x",operand); - break; - case DLOC: - sprintf(buffer,"$%02x",operand); - break; - case DLOCX: - sprintf(buffer,"$%02x,x",operand); - break; - case DLOCY: - sprintf(buffer,"$%02x,y",operand); - break; - case ABSLONG: - sprintf(buffer,"$%06x",operand); - break; - case ABSLONGX: - sprintf(buffer,"$%06x,x",operand); - break; - case DLOCIND: - sprintf(buffer,"($%02x)",operand); - break; - case DLOCINDY: - sprintf(buffer,"($%02x),y",operand); - break; - case DLOCXIND: - sprintf(buffer,"($%02x,x)",operand); - break; - case DLOCBRAK: - sprintf(buffer,"[$%02x]",operand); - break; - case DLOCBRAKY: - sprintf(buffer,"[$%02x],y",operand); - break; - case DISP8: - sprintf(buffer,"$%04x", - (address+(int8_t)operand) & 0xffff); - break; - case DISP8S: - sprintf(buffer,"$%02x,s",operand); - break; - case DISP8SINDY: - sprintf(buffer,"($%02x,s),y",operand); - break; - case DISP16: - sprintf(buffer,"$%04x", - (address+(int16_t)(operand)) & 0xffff); - break; - case MVPMVN: - sprintf(buffer,"$%02x,$%02x",operand & 0xff,operand >> 8); - break; - case SEPVAL: - psr |= operand; - sprintf(buffer,"#$%02x",operand); - break; - case REPVAL: - psr &= ~operand; - sprintf(buffer,"#$%02x",operand); - break; + case ABSIND: + sprintf(buffer,"($%04x)",operand ); + break; + case ABSXIND: + sprintf(buffer,"($%04x,x)",operand ); + break; + case IMPLY: + break; + case ACCUM: + break; + case IMMED: + sprintf(buffer,"#$%0*x",args * 2, operand); + break; + case JUST8: + sprintf(buffer,"$%02x",operand); + break; + case DLOC: + sprintf(buffer,"$%02x",operand); + break; + case DLOCX: + sprintf(buffer,"$%02x,x",operand); + break; + case DLOCY: + sprintf(buffer,"$%02x,y",operand); + break; + case ABSLONG: + sprintf(buffer,"$%06x",operand); + break; + case ABSLONGX: + sprintf(buffer,"$%06x,x",operand); + break; + case DLOCIND: + sprintf(buffer,"($%02x)",operand); + break; + case DLOCINDY: + sprintf(buffer,"($%02x),y",operand); + break; + case DLOCXIND: + sprintf(buffer,"($%02x,x)",operand); + break; + case DLOCBRAK: + sprintf(buffer,"[$%02x]",operand); + break; + case DLOCBRAKY: + sprintf(buffer,"[$%02x],y",operand); + break; + case DISP8: + sprintf(buffer,"$%04x", + (address+(int8_t)operand) & 0xffff); + break; + case DISP8S: + sprintf(buffer,"$%02x,s",operand); + break; + case DISP8SINDY: + sprintf(buffer,"($%02x,s),y",operand); + break; + case DISP16: + sprintf(buffer,"$%04x", + (address+(int16_t)(operand)) & 0xffff); + break; + case MVPMVN: + sprintf(buffer,"$%02x,$%02x",operand & 0xff,operand >> 8); + break; + case SEPVAL: + case REPVAL: + sprintf(buffer,"#$%02x",operand); + break; } - printf("%02x/%04x: %s %-10s", - pc >> 16, pc & 0xffff, - disasm_opcodes[opcode], buffer); + /* todo -- special case for ldx #xxxx, jsl $e10000 */ + /* todo -- special case for GS/OS calls */ + /* todo -- special case for P8 MLI calls */ - printf("%02x", opcode); - for(i = 0 ; i < args; ++i) { - printf(" %02x", operand & 0xff); - operand >>= 8; + switch (opcode) { + case 0xe2: /* sep */ + g_disasm_psr|= operand; + break; + case 0xc2: /* rep */ + g_disasm_psr &= ~operand; + break; + case 0xfb: /* xce */ + g_disasm_psr |= 0x0130; + break; + case 0xa2: /* ldx # */ + if (is_jsl_e10000(address)) { + /* tool call ... */ + const char *name = debug_tool_name(operand, 0xe10000); + if (name) { + opcode_string = name; + buffer[0] = 0; + for (i = 0; i < 4; ++i) { + buffer2[bsize++] = get_memory_c(address++, 0); + } + } + } + break; + case 0xae: /* ldx ... */ + case 0xbe: + case 0xa6: + case 0xb6: + case 0xfa: /* plx */ + case 0xaa: /* tax */ + case 0xba: /* tsx */ + case 0xbb: /* tyx */ + case 0xca: /* dex */ + case 0xe8: /* inx */ + break; + case 0x22: /* jsl */ + if (operand == 0xe100a8) { + /* inline GS/OS call? */ + unsigned num = get_memory16_c(address, 0); + const char *name = debug_tool_name(num, operand); + if (name) { + opcode_string = name; + unsigned parms = get_memory24_c(address + 2, 0); + sprintf(buffer, "$%06x", parms); + + for (i = 0; i < 6; ++i) { + buffer2[bsize++] = get_memory_c(address++, 0); + } + } + } + break; + } + + n = printf("%02x/%04x: %s %s", + pc >> 16, pc & 0xffff, + opcode_string, buffer); + for(; n < 40; ++n) putchar(' '); + + for(i = 0; i < bsize; ++i) { + printf(" %02x", buffer2[i]); } fputc('\n', stdout); } - *psr_ptr = psr; return address; } @@ -729,24 +829,26 @@ void delete_bp(int type, word32 addr) { static void do_help(void) { fputs( - " * Print registers\n" - " reg=value Assign register (a,x,y,etc)\n" - " reset Reset computer\n" - " quit exit debugger\n" - " s single step\n" - " g go\n" - " bp List PC breakpoints\n" - " mp List memory breakpoints\n" + " * Print registers\n" + " reg=value Assign register (a,x,y,etc)\n" + " reset Reset computer\n" + " quit Exit debugger\n" + " s Single step\n" + " g Go\n" + " bp List PC breakpoints\n" + " mp List memory breakpoints\n" "\n" - " [address];l List\n" - " [address];h Hexdump\n" - " [address];bp Set PC breakpoint\n" - " [address];bp- Remove PC breakpoint\n" - " [address];mp Set memory breakpoint\n" - " [address];mp- Remove memory breakpoint\n" + " [address];l List\n" + " [address];h Hexdump\n" + " [address];bp Set PC breakpoint\n" + " [address];bp- Remove PC breakpoint\n" + " [address];mp Set memory breakpoint\n" + " [address];mp- Remove memory breakpoint\n" + " [address]\\temp name Display template\n" "\n" "\n" - "Address = 12/3456, 123456, or 1234\n", + "Address = 12/3456, 123456, or 1234\n" + "Register = %%a, %%x, %%y, %%pc, etc\n", stdout); } @@ -757,8 +859,8 @@ static int parse_command(const char *cp) { /* TODO: - pc++ EOL -> skip current instruction ! -> mini assembler mode. + require 2 successive ^Ds to exit */ const char *YYCURSOR = cp; @@ -946,8 +1048,7 @@ command: } (";l" | "l") eol { - int psr = engine.psr; - g_prev_address = do_list(addr, &psr, 20); + g_prev_address = do_list(addr, 20); return 0; } ";h" eol { @@ -1027,15 +1128,25 @@ int debug_shell(int code) { int c; char *cp; - int psr = engine.psr; - if (!g_templates_loaded) { char *path; g_templates_loaded = 1; path = get_resource_path("GSBug.Templates"); - debug_load_template(path); - free(path); + if (path) { + debug_load_templates(path); + free(path); + } + path = get_resource_path("Tools.text"); + if (path) { + debug_load_tools(path, 0xe10000); + free(path); + } + path = get_resource_path("GSOS.text"); + if (path) { + debug_load_tools(path, 0xe100a8); + free(path); + } } @@ -1061,11 +1172,12 @@ int debug_shell(int code) { /* halt_printf */ } - do_list(engine.kpc, &psr, 1); g_prev_stack_address = engine.stack; g_prev_stack_bank = engine.kpc & 0xff0000; g_prev_address = engine.kpc; + g_disasm_psr = engine.psr; + do_list(engine.kpc, 1); for(;;) { cp = x_readline("> "); diff --git a/src/debug_template.re2c b/src/debug_template.re2c index f0fac3b..14e3f5a 100644 --- a/src/debug_template.re2c +++ b/src/debug_template.re2c @@ -16,6 +16,7 @@ re2c:yyfill:enable = 0; eol = "\x00"; ws = [ \t\r\n]; + x = [0-9a-fA-F]; */ @@ -142,7 +143,7 @@ next: } -void debug_load_template(const char *path) { +void debug_load_templates(const char *path) { FILE *f; char buffer[1024]; int ok; @@ -312,3 +313,160 @@ word32 debug_apply_template(word32 address, const char *name) { fputc('\n', stdout); return address; } + +/* nifty list */ +/* + * format: + * fffx ... header comments + * xxxx name ; p8 mli calls + * * + * xxxx name ; p16/gsos calls + * * + * xxxx name ; tool calls + * * + * xxxx name ; user tool calls + * * + * xxxx name ; e1 vectors + * * + * xxxx name ; e0 vectors + * * + * xxxx name ; softswitch/f8 rom + * * + * xxxx name ; 01 vectors + * * + * xxxx name ; nifty list service calls + * * + * xxxx name ; resource types + * * + * xxxx name ; error codes + * * + * xxxx name ; HC IIgs callbacks + * * + * xxxx name ; request codes + * * + * + */ + +struct tool { + char *name; + unsigned number; + unsigned vector; +}; + +struct tool *tools = NULL; +int tool_count = 0; +int tool_alloc = 0; + +static void add_tool(struct tool *t) { + if (tool_count == tool_alloc) { + size_t size = (tool_alloc + 1024) * sizeof(struct tool); + void *tmp = realloc(tools, size); + if (!tmp) return; + tools = tmp; + tool_alloc += 1024; + } + tools[tool_count++] = *t; +} + +static word32 to_hex(const char *iter, const char *end) { + word32 rv = 0; + while(iter != end) { + char c = *iter++; + rv <<= 4; + if (isdigit(c)) rv |= c - '0'; + else rv |= (c | 0x20) - 'a' + 10; + } + return rv; +} + +static int tool_compare(const void *a, const void *b) { + const struct tool *aa = a; + const struct tool *bb = b; + + int rv = (int)aa->vector - (int)bb->vector; + if (rv == 0) + rv = (int)aa->number - (int)bb->number; + return rv; +} + +/* +static int tool_search(const void *a, const void *b) { + const struct tool *aa = a; + const struct tool *bb = b; + + int rv = (int)aa->vector - (int)bb->vector + if (rv == 0) + rv = (int)aa->number - (int)bb->number; + return rv; +} +*/ + +void debug_load_tools(const char *path, unsigned vector) { + + FILE *f; + char buffer[1024]; + unsigned line = 0; + const char *YYMARKER = NULL; + const char *YYCTXMARKER = NULL; + + + f = fopen(path, "r"); + if (!f) { + fprintf(stderr, "Unable to load %s: %s\n", path, strerror(errno)); + return; + } + for (line = 1;;++line) { + const char *start; + const char *end; + struct tool tool = { 0, 0, vector }; + + const char *cp = fgets(buffer, sizeof(buffer), f); + if (!cp) break; + + start = cp; + /*!re2c + [\r\n\x00] { continue; } + ";" { continue; } + * { + fprintf(stderr, "%s:%d: Bad line: %s", path, line, buffer); + continue; + } + x{4} / ws { goto ok; } + */ +ok: + end = cp; + tool.number = to_hex(start, end); + while (isspace(*cp)) ++cp; + + start = cp; + for(;;) { + /*!re2c + "" / (eol | ws) { break; } + * { continue; } + */ + } + end = cp; + if (end > start) { + int l = end - start; + + /* add a leading _ */ + tool.name = malloc(l + 2); + tool.name[0] = '_'; + strncpy(tool.name + 1, start, l); + tool.name[l + 2] = 0; + add_tool(&tool); + } + + + } + + qsort(tools, tool_count, sizeof(struct tool), tool_compare); + fclose(f); +} + +const char *debug_tool_name(unsigned number, unsigned vector) { + struct tool tmp = { 0, number, vector }; + struct tool *t = bsearch(&tmp, tools, tool_count, sizeof(struct tool), tool_compare); + if (t) return t->name; + return NULL; +} \ No newline at end of file